/* Design tokens — spec §15.2, visual direction A, "The Intruding System".
 *
 * A dark ink-and-parchment novel with an alien game interface pasted over it. Nine colours,
 * two families, and nothing else: every surface, glow and hairline on the reader is one of
 * the nine or a `color-mix` of one with the ground. That is the whole point of the
 * direction — the System's acid is the only thing on the page that was not printed, so the
 * moment a fourth accent appears the clash stops meaning anything.
 *
 * Season 1 is dark only (§15.2: "light theme is deliberately not offered"), so there is no
 * media query here and no second palette to keep in step.
 */

:root {
  color-scheme: dark;

  /* --- the nine (§15.2) ------------------------------------------------------------- */
  --ink: #0e0d0b; /* the ground */
  --ink-2: #11100d; /* strips: ticker, sheet, anything laid over the ground */
  --parchment: #e9dfc9; /* prose */
  --parchment-dim: #bdb08f; /* the inner voice, and anything the narrator half-says */
  --rule: #26221a; /* hairlines */
  --muted: #978d72; /* quiet labels; one step up from #8d8369 (2026-10-08, TYPE): 5.9:1 on the ground */
  --acid: #c7ff3a; /* System chrome */
  --cyan: #3ee0ff; /* party, and anything a viewer caused */
  --blood: #ff5a5a; /* death, and the live dot */
  --fray: #e3a23c; /* a fight with monsters (R98): ochre, 9:1 on the ground; blood stays death and crawlers against crawlers */
  --flood: #5ea6ff; /* the flood (R98, DR2-WEB): water, 7:1 on the ground, never the red of a fight or a death; cyan stays the party's */

  /* --- surfaces derived from the nine ------------------------------------------------ */
  /* Mixed rather than picked, so the ground stays one colour with the lights turned down. */
  --ink-deep: color-mix(in srgb, var(--ink) 82%, #000); /* under the ticker */
  --rule-soft: color-mix(in srgb, var(--rule) 70%, var(--ink)); /* dashed row separators */
  /* Edges only, and named for it: at 3.2:1 on the ground it is a rule, never text. */
  --rule-strong: color-mix(in srgb, var(--rule) 55%, var(--parchment-dim));
  --band-ground: color-mix(in srgb, var(--parchment-dim) 30%, var(--ink-2)); /* a plate that stays under a fight's: the map's stairs band */
  /* The dimmest thing allowed to carry a word. Mixed at 80% (2026-10-08, TYPE: it was 70%, 4.9:1 on
   * the ground but 4.0:1 on a row tinted with 6% parchment — `.blow--own`, a name in it, a miss —
   * which is a ground it is judged on). 80% is 6.1:1 on the ground, 5.65 on the raised surface and
   * about 5.0 on that tint, and still under `--parchment-dim` (9:1) and `--parchment` (14:1), so
   * muted still reads as muted. A test holds it there. */
  --parchment-faint: color-mix(in srgb, var(--parchment-dim) 80%, var(--ink));

  /* The rule under every text link at rest (SR2-VISUAL, M6, L5): 4.3:1 on the ground and 4.0 on the raised
   * surface — it was 2.3:1, under the 3:1 a non-text mark needs, and a phone has no hover to say "link".
   * An edge, never text. A card host's dotted rule (`hover.css`) is its own mark. */
  --link-rest: color-mix(in srgb, var(--parchment) 50%, var(--ink));

  /* The third surface (the reader rebuild, 2026-09-25): the stage and the cards sit one step
   * above the panels, the panels one above the ground. Mixed at 97% because that is as far
   * as it lifts while `--parchment-faint`, the dimmest word, still reads AA on it (4.55:1). */
  --surface-raised: color-mix(in srgb, var(--ink-2) 97%, var(--parchment));

  /* The colour a System box is intruding in. Set per kind in blocks/system.css; every
   * border, label, inner outline and glow on the box reads it, so a kind is one declaration. */
  --kind: var(--acid);
  --kind-tint: color-mix(in srgb, var(--kind) 6%, transparent);
  --kind-edge: color-mix(in srgb, var(--kind) 22%, transparent);
  --kind-glow: color-mix(in srgb, var(--kind) 12%, transparent);

  /* A crawler's name followed down the page (`name_tint.js`, #31): the marker wash behind every mention
   * of the crawler under the pointer, and its edge. A violet nothing else on the site wears (acid is the
   * System and level and XP, cyan the party, blood death, ochre a fight with monsters): the olive the wash
   * made of acid read as a lime level (DR-PAGES, the designer of MBW4-s7). Parchment on the wash is 10:1,
   * and a tinted name is always parchment. */
  --mention: #b79bff;
  --name-tint: color-mix(in srgb, var(--mention) 22%, transparent);
  --name-tint-edge: color-mix(in srgb, var(--mention) 60%, transparent);

  /* --- type (§15.2) ------------------------------------------------------------------ */
  --font-prose: "Newsreader", "Newsreader Fallback", Georgia, "Times New Roman", serif;
  --font-system: "IBM Plex Mono", "IBM Plex Mono Fallback", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* The reading column. Everything else on the page is chrome around this number. */
  --measure: 62ch;
  /* The feed's measure on the rebuilt pages. Running text keeps it; a wide page fills with
   * columns beside it, never with longer lines (LAYOUT, 2026-10-08). */
  --measure-feed: 40rem;
  /* A one-line note or headline in the chrome (the break's, the crawl's): never past 72 characters, which the page pass reads as 76-80 against a face that has not landed. */
  --measure-note: 72ch;
  --rail-width: 20rem;

  /* One frame for every page (LAYOUT, #11): the masthead's own width, and the content inside it.
   * `--shell-max` is the masthead, the strip, `<main>` and the footer, centred past it;
   * `--page-max` is what is left of it between the gutters — where the wordmark's left edge is
   * every page's left edge. A page container is at most `--page-max` and never sets a width of
   * its own; a page that wants two columns divides this one. */
  --shell-max: 96rem;
  --page-max: calc(var(--shell-max) - 2 * var(--gutter));
  /* The space between a page's reading column and the companion column beside it. The reading
   * column keeps its measure on the left; the companion takes everything else, so this is the
   * only space between the two (LAYOUT2, #13). */
  --page-gap: var(--space-6);

  /* The scale (the reader rebuild, 2026-09-25): a floor, two fixed steps above it, and four
   * that grow with the viewport. Titles are big, prose is comfortable, and nothing on any
   * page computes under `--text-12` — `test_gallery.py` holds every sheet to it. */
  --text-12: 0.75rem;
  --text-14: 0.875rem;
  --text-16: 1rem;
  --text-prose: clamp(1.0625rem, 0.98rem + 0.35vw, 1.25rem);
  --text-lead: clamp(1.25rem, 1.1rem + 0.5vw, 1.5rem);
  --text-h2: clamp(1.5rem, 1.2rem + 1.2vw, 2.125rem);
  --text-h1: clamp(2rem, 1.3rem + 2.8vw, 3.5rem);

  --leading-prose: 1.62;
  --leading-chrome: 1.45;

  /* Tracking: three steps where there were eleven literals — tight for display titles, label
   * for a word set apart, caps for serif section labels and the nav (0.14em before 2026-10-08,
   * TYPE: the design review asked for 0.12 on 12 px caps). */
  --track-tight: -0.01em;
  --track-label: 0.08em;
  --track-caps: 0.12em;
  --tracking-wordmark: 0.24em;

  /* --- rhythm ------------------------------------------------------------------------ */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2.25rem;
  --space-7: 3.5rem;

  /* The pinned masthead's height (STICKYHEAD, #4): what stays on screen, so where everything else that
   * sticks starts. A token set per width in CSS (below), never measured by a script; below 768 it is
   * the bar's height (the wordmark and the menu), from 768 the whole row's. `--stick-top` is where a
   * sticky column sticks (a gap under the masthead) and `--stick-room` is the screen it has there. */
  --masthead-h: 2.75rem;
  --stick-top: calc(var(--masthead-h) + var(--space-4));
  --stick-room: calc(100vh - var(--masthead-h) - 2 * var(--space-4));
  /* ...and what a sticky column cannot ride into at the page's end: the page's bottom padding and the
   * footer under it (one line, 46 px measured at 1600), less the gap the room already leaves. A column
   * whose box is taller than the room less this is pushed up by its page's end: the cam's rail rose
   * 87 px with 400 px of nothing under it (the owner, 2026-10-23, #34). */
  --pagefoot-h: 3.25rem;
  --foot-room: calc(var(--space-7) + var(--pagefoot-h) - var(--space-4));

  /* The feed's turns (TURNHEAD, 2026-10-15): the space before a turn, which is at least
   * twice the gap between a turn's own lines (`--space-3`, or the section gap `--space-5` where a turn's
   * items are boxes: two section gaps and a breath, 52 px, MB75-PAGES); and where a turn's head sticks,
   * which is the masthead's foot (STICKYHEAD: the masthead stays, so the head clears it). */
  --turn-gap: calc(2 * var(--space-5) + var(--space-1));
  --turn-head-top: var(--masthead-h);
  /* ...and how tall that head is: a 14 px line, 8 px over and under, and its rule (2 px on /live), so a link
   * a keyboard scrolls to is brought clear of it (`common.css`, SR2-VISUAL M32). */
  --turn-head-h: calc(var(--text-14) * var(--leading-chrome) + 2 * var(--space-2) + 2px);

  /* A capped pane — a sticky column that scrolls inside its own box, a list capped at a height —
   * fades its cut instead of slicing a line (designer, V1). The pane only sets
   * `padding-bottom: var(--pane-fade-band)` where it is capped: the band is empty padding, so a pane
   * that fits, or is scrolled to its end, has nothing under the cut. The fade itself is the mark's,
   * not the pane's (I3-WEB, the designer: a roster faded with nothing hidden): `pane_cue.js` marks a
   * pane `data-more` only while rows lie under its cut, and `layout.css` masks what is marked. */
  --pane-fade-band: var(--space-7);
  /* The fade of a pane that has more under it (`[data-more]`, `layout.css`): gone a step before the cap
   * and a hair above the cue's own top (`--pane-cue-gap`: a faded line reaching the bar's edge read as
   * printed under "more below", the designer's landing/live-1440), and the strip under that is opaque, so the
   * cue's bar is read whole. */
  --pane-cue-h: 1.5rem;
  --pane-cue-gap: var(--space-2);
  --pane-fade-cue: linear-gradient(
    to bottom,
    #000 calc(100% - var(--space-7)),
    transparent calc(100% - var(--pane-cue-h) - var(--pane-cue-gap)),
    transparent calc(100% - var(--pane-cue-h)),
    #000 calc(100% - var(--pane-cue-h))
  );
  --gutter: clamp(0.875rem, 0.4rem + 2vw, 1.75rem);

  /* A thumb's worth (WCAG 2.2's 2.5.8; Task S4, 2026-09-27): the least a control a phone taps
   * is, 24 CSS px. What a word lacks of it: a name in a line of text is its font's box, about
   * an em tall (`--tap-lift`), and a hover host is a line box of its own and its dotted rule
   * (`--tap-lift-line`). Resolved on the element that uses them — an em and a line are its own. */
  --tap: 1.5rem;
  --tap-lift: max(0px, calc(var(--tap) - 1em));
  --tap-lift-line: max(0px, calc(var(--tap) - 1lh - 1px));

  /* --- motion (§15.4) ---------------------------------------------------------------- */
  --duration-fast: 120ms;
  --duration-normal: 320ms;
  --duration-glow: 1200ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* The pinned masthead's height, per width (STICKYHEAD, #4). Below 1024 it is the bar's one row; from
 * 1024 the whole row — 12 px over and under a 22 px nav link, with a hair to spare — and from 1280 to
 * 1439 a break's line is a second row of the same header (from 1440 it stands in the row), which is
 * `:has` so it follows `masthead.js` unhiding the line without a script of its own. The dynamic
 * viewport where the browser has one, so a phone's address bar does not leave the column short. */
@media (min-width: 64em) {
  :root {
    --masthead-h: 3.125rem;
  }
}

@media (min-width: 80em) and (max-width: 89.99em) {
  :root:has(.masthead-episode:not([hidden])) {
    --masthead-h: 5rem;
  }
}

@supports (height: 100dvh) {
  :root {
    --stick-room: calc(100dvh - var(--masthead-h) - 2 * var(--space-4));
  }
}

/* Motion is a garnish here: it says "this line just arrived", and a reader who has asked
 * for stillness is told the same thing by the line being there. Zeroed at the token, so
 * every transition and animation in the stack goes instant at once (§15.4). */
@media (prefers-reduced-motion: reduce) {
  :root {
    --duration-fast: 0ms;
    --duration-normal: 0ms;
    --duration-glow: 0ms;
  }
}

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

/* Deliberately NOT `scroll-behavior: smooth`. It reads well on an anchor and is wrong
 * everywhere else here: `scroll-behavior` also governs every scroll a script makes of the
 * page without naming a behaviour, and the reader's own scrolls are the ones that hold a
 * reader's place while a page changes above them (`feed.js`, `steady.js`) — held by an
 * animation, the line being read is seen to move. Motion on this page belongs to the block
 * that just arrived, not to the page. */
html {
  scroll-behavior: auto;
}

body {
  margin: 0;
  /* Painted explicitly: a transparent body borrows whatever ground is behind the page. */
  background: var(--ink);
  color: var(--parchment);
  font-family: var(--font-prose);
  font-size: var(--text-prose);
  line-height: var(--leading-prose);
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}
