/* snsnegi.com — design tokens + base styles.
   Doctrine: consistent as a rule, differentiate for emphasis (see _research design doc).
   Zero JS, system fonts, <50KB budget. */

:root {
  --ink: #1a1a1a;
  --paper: #ffffff;
  --muted: #6b6b6b;
  --accent: #1a4f9c;      /* deep blue — links only */
  --rule: #e2e2e2;
  --measure: 65ch;        /* banner column */
  --measure-wide: 76ch;   /* content column — banner stays narrower */
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.75rem;
  --space: 1.5rem;
  /* Pinned-banner height: name + slot + headings row + padding. Sticky offsets
     (lineage map, anchor scroll margins) hang off this. Re-measure if the banner grows. */
  --banner-h: 9.2rem;
}

/* Default is LIGHT regardless of OS preference; dark only via the ◐ toggle. */

/* Manual override (◐ toggle) — wins over the OS preference. */
:root[data-theme="dark"] {
  --ink: #d9d9d9;
  --paper: #121212;
  --muted: #8f8f8f;
  --accent: #7aa7e0;
  --rule: #2c2c2c;
}
:root[data-theme="light"] {
  --ink: #1a1a1a;
  --paper: #ffffff;
  --muted: #6b6b6b;
  --accent: #1a4f9c;
  --rule: #e2e2e2;
}

/* No rubber-band overscroll: the elastic bounce at page ends drags the fixed banner with it. */
html { overscroll-behavior-y: none; }

body { position: relative; }

/* Site banner: a fixed overlay — never scrolls, on any view. The box is full-bleed
   (paper background, invisible seams) so its rule runs long and it eats any content
   scrolling under it; the banner's text stays in the narrow measure via .banner-inner. */
header.banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  background: var(--paper);
}
/* The rule: content-column length, not full-bleed — the box above it stays invisible. */
header.banner::after {
  content: "";
  display: block;
  width: 100%;
  max-width: var(--measure-wide);
  margin: 0 auto;
  border-bottom: 1px solid var(--rule);
}
.banner-inner {
  position: relative;
  max-width: var(--measure);
  margin: 0 auto;
  padding: var(--space) var(--space) var(--space);
}

/* Sits at the right end of the name row, pinned with the banner. */
#theme-toggle {
  position: absolute;
  top: calc(var(--space) + 0.45rem);
  right: var(--space);
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
#theme-toggle:hover { color: var(--accent); }

* { box-sizing: border-box; }

body {
  margin: 0 auto;
  /* Top padding = the fixed banner's height; content starts below the overlay. */
  padding: var(--banner-h) var(--space) var(--space);
  max-width: var(--measure-wide);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: var(--step-0);
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  /* Sticky footer: short views pin the footer to the viewport bottom — no bounce between views. */
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  width: 100%;
}

main { flex: 1; padding-top: var(--space); }

/* Blog-post head: sits below the banner, scrolls with the content. */
.post-head .post-title {
  font-size: var(--step-2);
  line-height: 1.2;
  margin: 0.15rem 0 var(--space);
}

h1 {
  font-size: var(--step-2);
  line-height: 1.2;
  margin: 0 0 0.25rem;
}

h2 {
  font-size: var(--step-1);
  margin: 0 0 var(--space);
}

p { margin: 0 0 1rem; }

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: var(--space) 0;
}

header .tagline {
  color: var(--muted);
  margin: 0;
}

/* The slot: tagline and heading intros share it; ONE fixed line ⇒ no layout jump. */
.slot {
  min-height: 1.6em;
  max-height: 1.6em;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.slot p { margin: 0; }
.slot.intro { font-style: italic; }

a.plain { color: inherit; }

/* Blog takeover of the banner: back icon + title on the name line, subtitle in the slot.
   Title clips to one line so the banner height never changes. */
.banner .post-h1 {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Back arrow floats in the free margin LEFT of the banner's narrow column (content runs wider,
   so that space exists). Sibling of the title, not inside it — the title never moves or clips it. */
.banner .back {
  position: absolute;
  left: -1.6rem;
  top: calc(var(--space) + 0.4rem);
  font-size: 1.2rem;
  line-height: 1.2;
  text-decoration: none;
}
.banner .back:hover { text-decoration: none; opacity: 0.75; }
/* Blog banner: date sits in the tagline slot (where "Data Scientist" lives on home);
   tags take the nav row — same centered layout, dotted underlines, heading tag last in accent. */
.banner .post-tags .ptag {
  color: var(--muted);
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}
.banner .post-tags .ptag:hover { color: var(--accent); }
.banner .post-tags .ptag.head { color: var(--accent); }

nav.tags {
  margin-top: 0.75rem;
  font-size: 0.9rem;
}
nav.tags a { margin-right: 1rem; }

/* Headings row: links truly centered; search is out of the centering math,
   hanging at the row's right edge. Subheadings below stay full-width. */
nav.mainnav {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 0 1rem;
}
nav.mainnav a { margin-right: 0; }

/* Search flows inline at the end of the topic tags (only exists inside a heading). */
.subnav-topics form.search { display: inline; }
.subnav-topics input[type="search"] { font-size: inherit; }
nav.tags a.active {
  font-weight: 600;
  text-decoration: underline;
}

.stream article {
  margin: 0 -0.75rem calc(var(--space) * 0.9);
  padding: 0.45rem 0.75rem;
  border-left: 2px solid transparent;
  border-radius: 3px;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
/* Pinned items rest on a very mild gray wash; hover still wins with the blue. */
.stream article.pinned {
  background: color-mix(in oklab, var(--muted) 8%, var(--paper));
}
.stream article:hover {
  background: color-mix(in oklab, var(--accent) 5%, var(--paper));
  border-left-color: var(--accent);
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.item-head {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
}

.item-date {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.chip {
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 2px;
  padding: 0 0.4rem;
  white-space: nowrap;
}
.chip:hover { text-decoration: none; }

/* Topic chips stay muted; only the primary heading chip carries the accent. */
.chip.topic {
  color: var(--muted);
  border-color: var(--rule);
}
.chip.topic:hover {
  color: var(--accent);
  border-color: var(--accent);
}

h2.item-title {
  font-size: var(--step-0);
  font-weight: 600;
  margin: 0.15rem 0;
}
h2.item-title a { color: inherit; }
h2.item-title a:hover { color: var(--accent); }

/* External-link marker: signals the title leaves the site. */
.ext {
  color: var(--accent);
  font-size: 0.8em;
}

/* Blog-post marker: minimal document icon — the title opens a page here, not an external link. */
.item-title .doc {
  color: var(--accent);
  vertical-align: -1px;
}

/* View toolbar: lives BELOW the rule, only on heading views — part of the content zone.
   One line; topics clip whole-word before the search; search always visible. */
nav.subnav {
  display: flex;
  align-items: baseline;
  max-height: 1.5em;
  margin: 0 0 var(--space);
  font-size: 0.85rem;
  line-height: 1.5;
  overflow: hidden;
}
.subnav-topics {
  flex: 1;
  max-height: 1.5em;
  overflow: hidden;
}
.subnav-topics a { margin-right: 0.8rem; }
nav.subnav form.search { margin-left: 1rem; }
/* Search: invisible at rest — just the word "search" sitting in the corner.
   The underline only exists while it's being used. */
nav.tags input[type="search"] {
  width: 5.5rem;
  border: 0;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  padding: 0;
  -webkit-appearance: none;
  appearance: none;
}
nav.tags input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
nav.tags input[type="search"]::placeholder {
  color: var(--muted);
  font-style: italic;
  opacity: 1;
}
nav.tags input[type="search"]:hover { border-bottom-color: var(--rule); }
nav.tags input[type="search"]:focus {
  outline: none;
  border-bottom-color: var(--accent);
}

nav.tags a.topiclink {
  color: var(--muted);
  font-size: 0.85rem;
}
nav.tags a.topiclink:hover { color: var(--accent); }
nav.tags a.topiclink.active {
  color: var(--ink);
  font-weight: 600;
  text-decoration: underline;
}

.chip.topic { border-style: dashed; }

.pin { color: var(--muted); font-size: 0.8rem; }

.dep {
  color: color-mix(in oklab, var(--muted) 55%, var(--paper));
  font-style: italic;
  font-size: 0.8rem;
}

/* Tags row: ONE line at the bottom of a listing — topics first, heading chip last.
   Server-side math middle-drops overflowing topics (single … marker); CSS clip is the backstop. */
.item-topics {
  display: flex;
  align-items: baseline;
  gap: 0 0.75rem;
  margin-top: 0.2rem;
  font-size: 0.85rem;
  line-height: 1.5;
  max-height: 1.5em;
  white-space: nowrap;
  overflow: hidden;
}
.item-topics .ellip { color: var(--muted); }
/* Heading tag: same dotted-underline treatment as topics, just in accent blue — no box to clip. */
.item-topics a.chip.headchip {
  color: var(--accent);
  border: 0;
  padding: 0;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}
.item-topics .chip {
  border: 0;
  padding: 0;
  color: var(--muted);
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}
.item-topics .chip:hover {
  color: var(--accent);
  text-decoration: underline dotted;
}

.item-summary {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
}
.item-summary p { margin: 0; }

/* "Live …" marker: breathes from muted toward ink — slow, barely there. */
.live-mark { font-style: italic; animation: live-breathe 1.5s ease-in-out infinite; }
@keyframes live-breathe {
  0%, 100% { color: var(--muted); }
  50% { color: var(--ink); }
}
@media (prefers-reduced-motion: reduce) {
  .live-mark { animation: none; }
}

/* mailto links read like the heading tags: accent blue, dotted. */
.item-summary a[href^="mailto:"] {
  color: var(--accent);
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}

.item-meta {
  color: var(--muted);
  font-size: 0.9rem;
}

nav.pagination {
  display: flex;
  gap: 1rem;
  align-items: baseline;
  font-size: 0.9rem;
}

article.body pre {
  overflow-x: auto;
  padding: 0.75rem;
  border: 1px solid var(--rule);
  font-size: 0.85rem;
}

@media (max-width: 480px) {
  /* Headings row wraps to two lines on narrow screens — banner is taller. */
  :root { --step-2: 1.5rem; --banner-h: 10.3rem; }
  body { padding: var(--banner-h) 1rem var(--space); }
  nav.tags a { margin-right: 0.7rem; }
  .banner-inner { padding: var(--space) 1rem var(--space); }
  /* No outer margin on phones — arrow tucks into the padding gutter instead. */
  .banner .back { left: 0; font-size: 1rem; top: calc(var(--space) + 0.35rem); }
  #theme-toggle { right: 1rem; }
}

footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--rule);
  padding-top: var(--space);
  margin-top: var(--space);
}
footer p { margin: 0; }
footer .forge { color: var(--muted); display: inline-flex; }
footer .forge:hover { color: var(--accent); }
