/* ==========================================================================
   PocketPPC — main.css
   One stylesheet. The whole token system lives in :root.
   Sections:
     1. Fonts
     2. Tokens (color, type, space, layout)
     3. Reset & base elements
     4. Layout primitives (article grid, breakout)
     5. Site chrome (header, nav, footer, theme toggle)
     6. Components (series card, carryover, series nav, pullquote, callout,
        TOC, term chip, era rail)
     7. Utilities
   ========================================================================== */

/* 1. FONTS ================================================================= */

/* Newsreader and IBM Plex Sans latin subsets are variable across 400–600,
   so one file per family covers both weights we use. Plex Mono is static. */

@font-face {
  font-family: "Newsreader";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("/assets/fonts/newsreader-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+2074,
    U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Newsreader";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/newsreader-italic-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+2074,
    U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("/assets/fonts/ibm-plex-sans-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+2074,
    U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/ibm-plex-mono-400-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+2074,
    U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/assets/fonts/ibm-plex-mono-600-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+2074,
    U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* 2. TOKENS =============================================================== */

:root {
  /* --- Palette: raw values (do not use directly outside this block) --- */
  --papaya-whip: #ffefd3;
  --prussian-blue: #001b2e;
  --charcoal-blue: #294c60;
  --pale-slate: #adb6c4;
  --peach-glow: #ffc49b;
  --surface-cream: #f2e5cc; /* Papaya Whip mixed ~6% toward Charcoal Blue */
  --surface-blue: #123243; /* Charcoal Blue, desaturated */

  /* --- Semantic color roles: LIGHT MODE (default) --- */
  --color-bg: var(--papaya-whip);
  --color-text: var(--prussian-blue);
  --color-text-secondary: var(--charcoal-blue);
  --color-border: var(--pale-slate);
  --color-surface: var(--surface-cream);
  --color-accent: var(--peach-glow);

  /* Peach Glow is a SHAPE color in light mode, a TEXT color in dark mode.
     These two tokens encode that asymmetry so components don't have to. */
  --color-link: var(--prussian-blue);
  --color-link-underline: var(--peach-glow);
  --color-accent-text: var(--charcoal-blue); /* when accent-adjacent text is needed */
  --color-number: var(--prussian-blue); /* series numerals sit on a peach block */
  --color-number-bg: var(--peach-glow);

  --focus-ring: var(--peach-glow);
  --selection-bg: var(--peach-glow);
  --selection-text: var(--prussian-blue);

  /* --- Type --- */
  --font-serif: "Newsreader", Georgia, "Times New Roman", serif;
  --font-sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto,
    sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas,
    monospace;

  /* 1.25 ratio, fluid. Body 17–19px. */
  --text-xs: clamp(0.8125rem, 0.79rem + 0.11vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.85rem + 0.13vw, 0.9375rem);
  --text-base: clamp(1.0625rem, 1rem + 0.3vw, 1.1875rem);
  --text-h3: clamp(1.25rem, 1.19rem + 0.3vw, 1.375rem);
  --text-h2: clamp(1.5rem, 1.38rem + 0.6vw, 1.75rem);
  --text-h1: clamp(2rem, 1.6rem + 2vw, 2.625rem);
  --text-display: clamp(2.5rem, 1.9rem + 3vw, 3.5rem);

  --leading-body: 1.65;
  --leading-tight: 1.2;
  --leading-snug: 1.35;
  --para-gap: 1.4em;

  /* --- Space (4 / 8 / 12 / 16 / 24 / 32 / 48 / 64 / 96) --- */
  --s-4: 0.25rem;
  --s-8: 0.5rem;
  --s-12: 0.75rem;
  --s-16: 1rem;
  --s-24: 1.5rem;
  --s-32: 2rem;
  --s-48: 3rem;
  --s-64: 4rem;
  --s-96: 6rem;

  /* --- Layout --- */
  --measure: 68ch;
  --content-width: 42rem;
  --wide-width: 68rem;
  --header-height: 3.5rem;

  --radius: 2px;
  --rule: 1px solid var(--color-border);
  --transition: 120ms ease;
}

/* --- DARK MODE --- */
/* Applied when the user's system prefers dark AND they haven't forced light. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: var(--prussian-blue);
    --color-text: var(--papaya-whip);
    --color-text-secondary: var(--pale-slate);
    --color-border: var(--charcoal-blue);
    --color-surface: var(--surface-blue);
    --color-accent: var(--peach-glow);

    --color-link: var(--peach-glow);
    --color-link-underline: var(--peach-glow);
    --color-accent-text: var(--peach-glow);
    --color-number: var(--prussian-blue);
    --color-number-bg: var(--peach-glow);

    --selection-bg: var(--peach-glow);
    --selection-text: var(--prussian-blue);
  }
}

/* Explicit override always wins in both directions. */
:root[data-theme="dark"] {
  --color-bg: var(--prussian-blue);
  --color-text: var(--papaya-whip);
  --color-text-secondary: var(--pale-slate);
  --color-border: var(--charcoal-blue);
  --color-surface: var(--surface-blue);
  --color-accent: var(--peach-glow);

  --color-link: var(--peach-glow);
  --color-link-underline: var(--peach-glow);
  --color-accent-text: var(--peach-glow);
  --color-number: var(--prussian-blue);
  --color-number-bg: var(--peach-glow);

  --selection-bg: var(--peach-glow);
  --selection-text: var(--prussian-blue);
}

/* 3. RESET & BASE ======================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + var(--s-24));
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-serif);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

::selection {
  background: var(--selection-bg);
  color: var(--selection-text);
}

img,
picture,
svg {
  display: block;
  max-width: 100%;
  height: auto;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-sans);
  font-weight: 600;
  line-height: var(--leading-tight);
  letter-spacing: -0.011em;
  text-wrap: balance;
}

h1 {
  font-size: var(--text-h1);
}
h2 {
  font-size: var(--text-h2);
}
h3 {
  font-size: var(--text-h3);
}

p,
ul,
ol,
blockquote,
figure,
pre,
table {
  margin-block: 0;
}

a {
  color: var(--color-link);
  text-decoration: underline;
  text-decoration-color: var(--color-link-underline);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.18em;
  transition: text-decoration-color var(--transition), color var(--transition);
}

a:hover {
  text-decoration-color: var(--color-link);
}

:root[data-theme="dark"] a:hover,
.dark a:hover {
  text-decoration-color: var(--color-accent);
}

strong,
b {
  font-weight: 600;
}

em,
i {
  font-style: italic;
}

code,
kbd,
samp {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

pre {
  font-family: var(--font-mono);
  background: var(--color-surface);
  border: var(--rule);
  border-radius: var(--radius);
  padding: var(--s-16);
  overflow-x: auto;
  font-size: var(--text-sm);
  line-height: 1.6;
}

hr {
  border: 0;
  border-top: var(--rule);
  margin-block: var(--s-48);
}

/* Focus: a dark hairline + a thick peach ring. Peach alone is too low
   contrast on cream, so it never stands alone as the focus indicator. */
:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 1px;
  box-shadow: 0 0 0 1px var(--color-text);
}

/* 4. LAYOUT PRIMITIVES =================================================== */

/* The article grid: named columns let pull quotes, glossary blocks and
   images break out to a wider column with no wrapper divs. Direct children
   land in [content]; add .breakout for [wide] or .full-bleed for edge-to-edge. */
.prose {
  display: grid;
  grid-template-columns:
    [full-start] minmax(var(--s-16), 1fr)
    [content-start] min(100% - var(--s-32), var(--content-width))
    [content-end] minmax(var(--s-16), 1fr)
    [full-end];
}

.prose > * {
  grid-column: content;
  min-width: 0;
}

/* Breakout: widen to the right only, so it never collides with the
   sticky TOC that lives in the left gutter on desktop. */
.prose > .breakout {
  grid-column: content-start / full-end;
  width: min(100%, 50rem);
  justify-self: start;
}

.prose > .full-bleed {
  grid-column: full;
}

/* Vertical rhythm inside prose */
.prose > * + * {
  margin-top: var(--para-gap);
}

.prose > .toc + * {
  margin-top: 0;
}

.prose > h2 {
  margin-top: var(--s-48);
  max-width: var(--measure);
}

.prose > h3 {
  margin-top: var(--s-32);
}

.prose > p,
.prose > ul,
.prose > ol {
  max-width: var(--measure);
}

.prose > ul,
.prose > ol {
  padding-left: 1.4em;
}

.prose li + li {
  margin-top: 0.5em;
}

.prose li::marker {
  color: var(--color-text-secondary);
}

/* --- Data table in article body --- */
.prose > figure.table {
  overflow-x: auto;
  margin-block: var(--s-32);
}
.prose table {
  border-collapse: collapse;
  width: 100%;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  line-height: 1.4;
}
.prose caption {
  caption-side: top;
  text-align: left;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-secondary);
  padding-bottom: var(--s-12);
}
.prose th,
.prose td {
  text-align: left;
  padding: var(--s-8) var(--s-16) var(--s-8) 0;
  border-bottom: var(--rule);
  vertical-align: top;
}
.prose thead th {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-secondary);
  border-bottom: 2px solid var(--color-border);
  white-space: nowrap;
}
.prose tbody tr:last-child td {
  border-bottom: 0;
}

/* A centered single-column wrapper for non-article pages */
.wrap {
  width: 100%;
  max-width: var(--content-width);
  margin-inline: auto;
  padding-inline: var(--s-16);
}

.wrap--wide {
  max-width: var(--wide-width);
}

main {
  flex: 1 0 auto;
  padding-block: var(--s-48) var(--s-96);
}

/* 5. SITE CHROME ======================================================== */

.skip-link {
  position: absolute;
  left: var(--s-8);
  top: var(--s-8);
  z-index: 100;
  background: var(--color-bg);
  color: var(--color-text);
  padding: var(--s-8) var(--s-12);
  border: 2px solid var(--color-accent);
  border-radius: var(--radius);
  transform: translateY(-150%);
  transition: transform var(--transition);
}
.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--color-bg);
  border-bottom: 1px solid transparent;
  transition: border-color var(--transition);
}

.site-header.is-scrolled {
  border-bottom-color: var(--color-border);
}

.site-header__inner {
  max-width: var(--wide-width);
  margin-inline: auto;
  padding: var(--s-12) var(--s-16);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-16);
  min-height: var(--header-height);
}

.wordmark {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: calc(var(--text-sm) * 1.5);
  letter-spacing: 0.02em;
  color: var(--color-text);
  text-decoration: none;
  white-space: nowrap;
  position: relative;
  display: inline-flex;
  align-items: center;
  line-height: 1;
}
.wordmark:hover {
  color: var(--color-text);
}
/* Left-to-right underline wipe on hover / keyboard focus */
.wordmark::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -0.18em;
  height: 2px;
  background: var(--color-accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 240ms ease;
}
.wordmark:hover::after,
.wordmark:focus-visible::after {
  transform: scaleX(1);
}
.wordmark .dot {
  color: var(--color-accent);
}
:root:not([data-theme="dark"]) .wordmark .dot {
  /* peach text on cream fails contrast; give the mark a filled block instead */
  background: var(--color-accent);
  color: var(--color-bg);
  padding: 0 0.25em;
  border-radius: 1px;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: clamp(var(--s-12), 2vw, var(--s-24));
}

.site-nav a {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-decoration: none;
  color: var(--color-text-secondary);
  padding-block: var(--s-4);
}
.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--color-text);
}
.site-nav a[aria-current="page"] {
  box-shadow: inset 0 -2px 0 var(--color-accent);
}

.theme-toggle {
  font: inherit;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  background: transparent;
  color: var(--color-text-secondary);
  border: var(--rule);
  border-radius: var(--radius);
  padding: var(--s-4) var(--s-8);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  transition: color var(--transition), border-color var(--transition);
}
.theme-toggle:hover {
  color: var(--color-text);
  border-color: var(--color-text-secondary);
}
.theme-toggle__icon {
  width: 1em;
  height: 1em;
}
/* show the icon for the theme you'd switch TO */
.theme-toggle .icon-dark {
  display: none;
}
:root[data-theme="dark"] .theme-toggle .icon-dark,
.dark .theme-toggle .icon-dark {
  display: block;
}
:root[data-theme="dark"] .theme-toggle .icon-light,
.dark .theme-toggle .icon-light {
  display: none;
}

/* Narrow screens: wordmark + toggle on one row, nav spread across the next. */
/* Narrow screens: wordmark + toggle on one row, nav on the next (left-aligned). */
@media (max-width: 30rem) {
  .site-header__inner {
    flex-wrap: wrap;
    row-gap: var(--s-8);
    padding-block: var(--s-8);
    min-height: 0;
  }
  .wordmark {
    order: 1;
  }
  .theme-toggle {
    order: 2;
  }
  .site-nav {
    order: 3;
    width: 100%;
    justify-content: flex-start;
    gap: var(--s-24);
  }
}

.site-footer {
  flex-shrink: 0;
  border-top: var(--rule);
  background: var(--color-bg);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
}
.site-footer__inner {
  max-width: var(--wide-width);
  margin-inline: auto;
  padding: var(--s-32) var(--s-16);
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-16) var(--s-32);
  align-items: baseline;
  justify-content: space-between;
}
.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-16) var(--s-24);
}
.site-footer a {
  color: var(--color-text-secondary);
  text-decoration: none;
}
.site-footer a:hover {
  color: var(--color-text);
  text-decoration: underline;
  text-decoration-color: var(--color-link-underline);
}
.site-footer__meta {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
}

/* 6. COMPONENTS ======================================================== */

/* --- Article header (history) --- */
.article-head {
  max-width: var(--content-width);
  margin-inline: auto;
  margin-bottom: var(--s-48);
}
.series-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  gap: var(--s-12);
  margin-bottom: var(--s-16);
}
.series-label .num {
  background: var(--color-number-bg);
  color: var(--color-number);
  font-weight: 600;
  padding: 0.15em 0.5em;
  border-radius: 1px;
  letter-spacing: 0.05em;
}
.article-head h1 {
  font-size: var(--text-h1);
  max-width: 20ch;
}
.article-head .dek {
  font-size: var(--text-h3);
  line-height: var(--leading-snug);
  color: var(--color-text-secondary);
  margin-top: var(--s-16);
  max-width: 46ch;
  font-style: italic;
}
.article-meta {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  margin-top: var(--s-24);
  padding-top: var(--s-16);
  border-top: var(--rule);
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-8) var(--s-16);
}

/* --- Table of contents --- */
.toc {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  border: var(--rule);
  border-radius: var(--radius);
  padding: var(--s-16) var(--s-16) var(--s-12);
  background: var(--color-surface);
  margin-bottom: var(--s-32);
}
.toc > summary {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-secondary);
  cursor: pointer;
  list-style: none;
}
.toc > summary::-webkit-details-marker {
  display: none;
}
.toc > summary::after {
  content: " +";
}
.toc[open] > summary::after {
  content: " –";
}
.toc ol {
  list-style: none;
  padding: 0;
  margin: var(--s-12) 0 0;
  counter-reset: toc;
}
.toc li {
  counter-increment: toc;
  line-height: 1.4;
}
.toc li + li {
  margin-top: var(--s-8);
}
.toc a {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 0.6em;
  padding-left: 0.7em;
  text-decoration: none;
  color: var(--color-text-secondary);
}
.toc a::before {
  content: counter(toc, decimal-leading-zero);
  flex: none;
  font-family: var(--font-mono);
  font-size: 0.85em;
  color: var(--color-text-secondary);
}
.toc a:hover,
.toc a.is-active {
  color: var(--color-text);
}
.toc a.is-active::before {
  color: var(--color-text);
}
/* "you are here" bar, flush to the left edge of the item */
.toc a.is-active::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0.15em;
  bottom: 0.15em;
  width: 2px;
  border-radius: 1px;
  background: var(--color-accent);
}

/* On mobile the TOC is a normal collapsible block in the content column.
   On desktop it moves into the left gutter of the prose grid and sticks. */
.prose > .toc {
  grid-column: content;
}

@media (min-width: 85rem) {
  .prose > .toc {
    grid-column: full-start / content-start;
    justify-self: end;
    grid-row: 1 / span 999;
    align-self: start;
    position: sticky;
    top: calc(var(--header-height) + var(--s-24));
    width: 10.5rem;
    margin: 0 var(--s-16) 0 0;
    background: transparent;
    border: 0;
    border-left: var(--rule);
    border-radius: 0;
    padding: 0 0 0 var(--s-16);
  }
  .prose > .toc > summary {
    pointer-events: none;
  }
  .prose > .toc[open] > summary::after,
  .prose > .toc > summary::after {
    content: "";
  }
}

/* --- Carryover glossary block (the signature component) --- */
.carryover {
  border-left: 3px solid var(--color-accent);
  background: var(--color-surface);
  padding: var(--s-24) var(--s-24) var(--s-24) var(--s-24);
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-top: var(--s-48);
}
.carryover__label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-secondary);
}
.carryover__intro {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-top: var(--s-8);
  max-width: 50ch;
}
.carryover dl {
  margin-top: var(--s-24);
  display: grid;
  gap: var(--s-24);
}
.carryover .term-row {
  display: grid;
  gap: var(--s-4);
}
.carryover dt {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--color-text);
}
.carryover dt .era {
  font-weight: 400;
  color: var(--color-text-secondary);
}
.carryover dd {
  margin: 0;
  font-size: var(--text-sm);
  line-height: 1.55;
}
.carryover .modern {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  display: block;
  margin-top: var(--s-4);
}
.carryover .modern::before {
  content: "→ ";
  color: var(--color-accent-text);
  font-weight: 600;
}

/* --- Series navigation --- */
.series-nav {
  margin-top: var(--s-64);
  border-top: var(--rule);
  padding-top: var(--s-24);
}
.series-nav__position {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-secondary);
  text-align: center;
}
.series-dots {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--s-8);
  margin: var(--s-16) 0 var(--s-24);
  padding: 0;
  list-style: none;
}
.series-dots li {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--color-border);
}
/* override the .prose li + li vertical rhythm that would stagger the dots */
.series-dots li + li {
  margin-top: 0;
}
.series-dots li.is-current {
  background: var(--color-accent);
  border-color: var(--color-accent);
}
.series-nav__links {
  display: flex;
  justify-content: space-between;
  gap: var(--s-16);
  font-family: var(--font-sans);
}
.series-nav__links a {
  text-decoration: none;
  max-width: 20ch;
}
.series-nav__links .dir {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-secondary);
}
.series-nav__links .next {
  text-align: right;
  margin-left: auto;
}
.series-nav__links [aria-disabled="true"] {
  opacity: 0.5;
}
.series-nav__links [aria-disabled="true"] .title {
  color: var(--color-text-secondary);
}
.series-nav__links a:hover .title {
  text-decoration: underline;
  text-decoration-color: var(--color-link-underline);
}

/* --- Notes (standalone posts, no series chrome) --- */
.note-kicker {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-secondary);
  margin-bottom: var(--s-12);
}
.note-foot {
  margin-top: var(--s-64);
  border-top: var(--rule);
  padding-top: var(--s-24);
  font-family: var(--font-sans);
}
.note-foot a {
  font-weight: 600;
  text-decoration: none;
}
.note-foot a:hover {
  text-decoration: underline;
  text-decoration-color: var(--color-link-underline);
}

/* --- Pull quote --- */
.pullquote {
  font-family: var(--font-serif);
  font-size: clamp(1.4rem, 1.1rem + 1.4vw, 1.9rem);
  line-height: 1.35;
  color: var(--color-text-secondary);
  border-top: var(--rule);
  border-bottom: var(--rule);
  padding-block: var(--s-24);
  margin-block: var(--s-48);
}
.pullquote cite {
  display: block;
  margin-top: var(--s-12);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-style: normal;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-secondary);
}

/* --- Display formula (Ad Rank = Bid × CTR) --- */
.formula {
  font-family: var(--font-mono);
  font-size: clamp(1.05rem, 0.95rem + 0.7vw, 1.375rem);
  text-align: center;
  color: var(--color-text);
  border-top: var(--rule);
  border-bottom: var(--rule);
  padding-block: var(--s-24);
  margin-block: var(--s-32);
  letter-spacing: 0.01em;
}
.formula b {
  color: var(--color-accent-text);
  font-weight: 600;
}

/* --- Worked equation line(s) — for math-heavy notes --- */
.eq {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.7;
  white-space: nowrap;
  overflow-x: auto;
  background: var(--color-surface);
  border-left: 3px solid var(--color-accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: var(--s-12) var(--s-16);
}
.eq b {
  font-weight: 600;
  color: var(--color-accent-text);
}
.prose > p + .eq,
.prose > .eq + .eq {
  margin-top: var(--s-8);
}
.prose > p + figure.table {
  margin-top: var(--s-12);
}

/* --- "The Bid" — the key stat each history part turns on --- */
.keystat {
  border-left: 3px solid var(--color-accent);
  padding-left: var(--s-24);
  margin-block: var(--s-32);
}
.keystat__label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-secondary);
}
.keystat__value {
  display: block;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: clamp(1.6rem, 1.2rem + 2vw, 2.5rem);
  line-height: 1.15;
  margin-top: var(--s-8);
}
.keystat__note {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-top: var(--s-12);
  max-width: 52ch;
}

/* --- Callout / aside --- */
.callout {
  background: var(--color-surface);
  border: var(--rule);
  border-radius: var(--radius);
  padding: var(--s-24);
  font-size: var(--text-sm);
  line-height: 1.6;
}
.callout__label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-secondary);
  display: block;
  margin-bottom: var(--s-8);
}
.callout > * + * {
  margin-top: var(--s-12);
}

/* --- Inline term chip --- */
.term {
  text-decoration: underline dotted var(--color-link-underline);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.18em;
  color: inherit;
  cursor: help;
}
.term[data-def] {
  position: relative;
}
.term__tip {
  position: absolute;
  left: 0;
  bottom: calc(100% + 0.5em);
  width: max-content;
  max-width: 22rem;
  background: var(--color-text);
  color: var(--color-bg);
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  line-height: 1.45;
  padding: var(--s-8) var(--s-12);
  border-radius: var(--radius);
  box-shadow: 0 2px 12px rgb(0 0 0 / 0.18);
  z-index: 20;
}

/* --- Series card (used on indexes; here for the template) --- */
.series-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--s-16) var(--s-24);
  align-items: start;
  padding: var(--s-24) 0;
  border-top: var(--rule);
  text-decoration: none;
  color: inherit;
}
.series-card:last-child {
  border-bottom: var(--rule);
}
.series-card__num {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: var(--text-h3);
  background: var(--color-number-bg);
  color: var(--color-number);
  padding: 0.1em 0.4em;
  border-radius: 1px;
  align-self: start;
  min-width: 2.4em;
  text-align: center;
}
.series-card > span:last-child {
  display: block;
}
.series-card__title {
  display: block;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: var(--text-h3);
  line-height: var(--leading-snug);
}
.series-card:hover .series-card__title {
  text-decoration: underline;
  text-decoration-color: var(--color-link-underline);
  text-decoration-thickness: 2px;
}
.series-card__era {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  margin-top: var(--s-4);
}
.series-card__dek {
  display: block;
  margin-top: var(--s-8);
  font-family: var(--font-serif);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  max-width: 60ch;
}

/* --- Heading anchor (copy-link-to-heading) --- */
.heading-anchor {
  position: absolute;
  margin-left: 0.35em;
  opacity: 0;
  text-decoration: none;
  color: var(--color-text-secondary);
  font-family: var(--font-mono);
  font-size: 0.75em;
  transition: opacity var(--transition);
}
.prose h2,
.prose h3 {
  position: relative;
}
.prose h2:hover .heading-anchor,
.prose h3:hover .heading-anchor,
.heading-anchor:focus {
  opacity: 1;
}

/* --- Home --- */
.hero {
  padding-block: var(--s-48) var(--s-32);
}
.hero h1 {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: var(--text-display);
  letter-spacing: -0.02em;
  line-height: 1.05;
}
.hero p {
  margin-top: var(--s-16);
  font-size: var(--text-h3);
  color: var(--color-text-secondary);
  max-width: 44ch;
  line-height: var(--leading-snug);
}

/* Section header above a card grid */
.home-section {
  margin-top: var(--s-48);
}
.home-section__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-4) var(--s-16);
  padding-bottom: var(--s-12);
  border-bottom: var(--rule);
  margin-bottom: var(--s-24);
}
.home-section__head h2 {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: var(--text-h2);
}
.home-section__head .kicker {
  flex-basis: 100%;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-secondary);
  margin-bottom: var(--s-4);
}
.home-section__head a {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  text-decoration: none;
  white-space: nowrap;
}
.home-section__head a:hover {
  text-decoration: underline;
  text-decoration-color: var(--color-link-underline);
}

/* The article card grid — five across on desktop */
.card-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--s-12);
}
@media (max-width: 66rem) {
  .card-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (max-width: 42rem) {
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 26rem) {
  .card-grid {
    grid-template-columns: 1fr;
  }
  .article-card {
    min-height: 0;
  }
}

.article-card {
  display: flex;
  flex-direction: column;
  gap: var(--s-8);
  padding: var(--s-16) var(--s-16) var(--s-12);
  background: var(--color-surface);
  border: var(--rule);
  border-top: 2px solid var(--color-accent);
  border-radius: 0 0 var(--radius) var(--radius);
  text-decoration: none;
  color: inherit;
  min-height: 6.5rem;
  transition: border-color var(--transition);
}
.article-card:hover {
  border-color: var(--color-text-secondary);
  border-top-color: var(--color-accent);
}
.article-card__num {
  align-self: flex-start;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: var(--text-xs);
  letter-spacing: 0.04em;
  color: var(--color-number);
  background: var(--color-number-bg);
  padding: 0.1em 0.45em;
  border-radius: 1px;
}
.article-card__title {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: var(--text-sm);
  line-height: 1.3;
  color: var(--color-text);
}
.article-card:hover .article-card__title {
  text-decoration: underline;
  text-decoration-color: var(--color-link-underline);
  text-decoration-thickness: 2px;
}
.article-card__note {
  font-family: var(--font-serif);
  font-size: var(--text-xs);
  line-height: 1.4;
  color: var(--color-text-secondary);
}
.article-card__era {
  margin-top: auto;
  padding-top: var(--s-8);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
}

.note-list {
  margin-top: var(--s-48);
  max-width: var(--content-width);
  list-style: none;
  padding: 0;
}
.note-list__heading {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-secondary);
  padding-bottom: var(--s-12);
  border-bottom: var(--rule);
}
.note-list li {
  padding: var(--s-16) 0;
  border-bottom: var(--rule);
}
.note-list a {
  text-decoration: none;
  font-family: var(--font-sans);
  font-weight: 600;
}
.note-list a:hover {
  text-decoration: underline;
  text-decoration-color: var(--color-link-underline);
}
.note-list time {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  margin-bottom: var(--s-4);
}
.note-list .dek {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-top: var(--s-4);
  font-family: var(--font-serif);
}

/* --- History index (light Phase-2 version; era rail comes in Phase 3) --- */
.index-head {
  margin-bottom: var(--s-32);
}
.index-head h1 {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: var(--text-display);
  letter-spacing: -0.02em;
}
.index-head p {
  margin-top: var(--s-16);
  color: var(--color-text-secondary);
  font-size: var(--text-h3);
  max-width: 40ch;
}
.index-head .lede {
  margin-top: var(--s-24);
  max-width: 60ch;
  font-size: var(--text-base);
}

/* Upcoming / unpublished series entries on the history index */
.series-card--upcoming .series-card__num {
  background: var(--color-border);
  color: var(--color-bg);
}
.series-card--upcoming .series-card__title {
  color: var(--color-text-secondary);
}

/* Plain vertical flow for simple pages (about, colophon) */
.flow > * + * {
  margin-top: var(--para-gap);
}
.flow p,
.flow li {
  max-width: var(--measure);
}
.flow h2 {
  margin-top: var(--s-32);
  font-size: var(--text-h2);
}

/* 7. UTILITIES ========================================================= */

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.lede {
  font-size: var(--text-h3);
  line-height: var(--leading-snug);
  color: var(--color-text-secondary);
  max-width: 60ch;
}

[hidden] {
  display: none !important;
}
