/* Design tokens. Code references these custom properties only; never
   hard-code a color, font, size, spacing step, or radius anywhere else.
   The world: a night mist you write into. Cool slate fog, one lit sheet of
   paper, and no warm color except the light of the letter leaving (fire,
   lantern). DESIGN.md records the system.
   Dark (night mist) is the default; light (morning mist) is below. */
:root {
  color-scheme: dark;

  /* The mist. --mist is the ground; the fog blooms over it never get
     lighter than --mist-high, so text contrast is checked against both. */
  --night: #1d262e;
  --mist: #24303a;
  --mist-high: #34424e;
  --fog: #aabecc; /* the drifting blooms, used at low alpha */

  /* Text on the mist. --text: 11.3:1 on --mist, 8.65:1 on --mist-high.
     --text-soft: 7.2:1 and 5.5:1 (WCAG AA either way). */
  --text: #e6ecef;
  --text-soft: #b3c0c8;
  --hairline: #3d4b57; /* quiet dividers, never the only cue */
  --edge: #6d7e8a; /* control edges: 3.2:1 on --mist (WCAG 1.4.11) */
  --cursor: #8a9aa6; /* the tools' pointer ring: shows on the paper and the mist */
  --veil: rgb(230 236 239 / 0.07); /* a raised or chosen row, over the mist */

  /* The one strong action: a frost-white pill with night text (12.9:1). */
  --accent: #e6ecef;
  --accent-ink: #1d262e;

  /* The sheet: cool white paper, never cream. */
  --paper: #eef1f2;
  --ink: #1f2a33; /* 12.9:1 on --paper */
  --ink-soft: #56626c; /* 5.5:1 on --paper: placeholders and notes */
  --line: #c9d1d6; /* underlines on the paper, and torn edges */
  --shadow: 0 2px 6px rgb(8 12 16 / 0.35), 0 24px 60px rgb(8 12 16 / 0.45);
  --tray-shadow: 0 4px 12px rgb(8 12 16 / 0.4);

  /* System fonts only, nothing downloaded (CLAUDE.md). Headings are the UI
     face at a light weight: thin, like something seen through fog. */
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-letter: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --weight-display: 300;
  --weight-strong: 600;

  --text-xs: 0.8125rem;
  --text-sm: 0.875rem;
  --text-md: 1rem;
  --text-lg: 1.25rem;
  --text-xl: 1.5rem;
  --text-display: clamp(1.75rem, 1.2rem + 2.2vw, 2.5rem);
  --tracking-display: -0.015em;
  --tracking-mark: 0.08em;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 16px;
  --space-4: 24px;
  --space-5: 40px;
  --space-6: 64px;

  --radius: 8px;
  --radius-lg: 16px;
  --radius-pill: 999px;
  --control-h: 44px; /* comfortable thumb height for buttons and segments */
  --column: 600px; /* the sheet's width, and the column everything sits in */

  /* Motion. Exponential ease-out; the fog drifts slowly enough to miss. */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-calm: cubic-bezier(0.37, 0, 0.63, 1); /* sine in-out: even, unhurried fades */
  --fog-drift: 90s;
  --fog-close: 2.4s; /* stillness: the mist thickens where the letter was */

  /* Read it once: letter fade-in, and how long "Let it go" waits before
     brightening. Guesses to tune by feel. */
  --read-fade: 1.2s;
  --read-pause: 3s;
  /* Stillness: how long before "Write another" brightens. A guess. */
  --stillness-pause: 6s; /* after the ending has fully arrived (about 4.4s) */
  /* The ending's calm arrival (2026-10-21, by request): the scene fades
     out, then the ending comes in a piece at a time. Guesses to tune. */
  --leave-fade: 1.2s; /* the release screen, once its scene is over */
  --still-fade: 2s; /* each piece of the ending fading in */
  --still-step: 0.8s; /* between the pieces: backdrop, heading, line, button */
  /* Smallest tap or click target (WCAG 2.5.8, AA). */
  --target-min: 24px;
  /* Release screen: room for Mute, the hint, and "Let it go" around the
     stage, so the whole page and the button fit on a short laptop screen.
     The stage never gets narrower than --release-min. */
  --release-chrome: 196px;
  /* Read it once: room for Back, the heading and the buttons, so "Let it
     go" is on screen without scrolling. */
  --read-chrome: 280px;
  --release-min: 300px;
  --scenic-max: 1200px; /* the widest a scenic send-off opens */

  /* The letter page, in PAGE units (js/page.js). Unitless on purpose:
     CSS scales them to the paper's width, and letter.js can read them too. */
  --page-width: 600;
  --page-height: 800;
  --page-margin: 48;
  --letter-size-1: 16;
  --letter-size-2: 20;
  --letter-size-3: 24;
  /* Smallest letter text in CSS px, for small screens where the scaled page
     would make it hard to read. Each size step above Small adds
     --letter-min-step px per PAGE unit: 16, 18, 20 px on a phone. */
  --letter-min: 16;
  --letter-min-step: 0.5;
  --letter-line: 1.5;
  /* Rich letters: one indent step, and the room a list marker takes, in em
     of the letter size. letter.js reads the same numbers. */
  --letter-indent: 1.5;
  --letter-list-gutter: 1.6;

  /* Handwriting ink (Stroke.ink, Stroke.size in docs/contracts.md).
     Sizes are pen diameters in PAGE units. */
  /* Ruled paper. Light enough that the grid counts it as paper, not ink
     (grid.js: ink is darker than 0.6 luminance). */
  --rule: #c8d4dc;
  --ink-black: #1f2a33;
  --ink-blue: #2c3e66;
  --ink-sepia: #704214;
  --ink-size-1: 3;
  --ink-size-2: 5;
  --ink-size-3: 8;

  /* Burn (B3): the color ramp a cell passes through, plus char, scorch, and
     smoke. Hotter first. The fire is the world's only warmth. */
  --fire-hot: #ffe28c;
  --fire-bright: #ffa834;
  --fire-mid: #e45618;
  --fire-low: #6e1e0a;
  --char: #1a1614;
  --scorch: #6e3a18;
  --smoke: #5c6670;

  /* Paper boat (C1): a misty lake at night. Sky, water from far to near,
     wave lines, fold lines. */
  --sky: #2b3842;
  --water-far: #34434f;
  --water-near: #24303a;
  --wave: #5f7381;
  --fold: #a9b4bb;
  /* Lantern: night fog, and the warm light inside the paper */
  --dusk-high: #1b242c;
  --dusk-low: #2b3842;
  --dusk-ground: #24303a;
  --lantern-glow: #ffb35c;
  --lantern-light: #ffd9a0;
  /* Shredder */
  --shredder: #3a4650;
  --shredder-mouth: #0e1418;

  /* Stillness (C2): pale ash drifting into the mist after a burn. */
  --ash: #9aa6ae;
}

/* Light: a morning mist. The same world by day: pale fog, a white sheet,
   night-slate text and buttons. It follows the device setting unless the
   footer switch picks one (js/theme.js sets data-theme on <html>).
   The two blocks below must stay identical (tests/unit/theme.test.js). */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --night: #f3f6f8;
    --mist: #e2e8ec;
    --mist-high: #f3f6f8;
    --fog: #ffffff;
    --text: #1f2a33; /* 11.8:1 on --mist, 13.5:1 on --mist-high */
    --text-soft: #4a5761; /* 6.0:1 and 6.8:1 */
    --hairline: #c6d0d6;
    --edge: #6d7e8a; /* 3.4:1 on --mist */
    --cursor: #6d7e8a;
    --veil: rgb(31 42 51 / 0.05);
    --accent: #24303a;
    --accent-ink: #f3f6f8; /* 12.4:1 */
    --paper: #fbfcfc;
    --ink-soft: #56626c; /* 6.1:1 on --paper */
    --shadow: 0 2px 6px rgb(31 42 51 / 0.08), 0 20px 50px rgb(31 42 51 / 0.12);
    --tray-shadow: 0 4px 12px rgb(31 42 51 / 0.12);
    --smoke: #8d979f;
    --sky: #d6dee3;
    --water-far: #c5d0d7;
    --water-near: #9eafba;
    --wave: #7d909c;
    --dusk-high: #b5c1c9;
    --dusk-low: #dbe2e6;
    --dusk-ground: #e2e8ec;
    --shredder: #8f9ba4;
    --shredder-mouth: #2a333a;
    --ash: #6f7b84;
  }
}

:root[data-theme="light"] {
  color-scheme: light;
  --night: #f3f6f8;
  --mist: #e2e8ec;
  --mist-high: #f3f6f8;
  --fog: #ffffff;
  --text: #1f2a33; /* 11.8:1 on --mist, 13.5:1 on --mist-high */
  --text-soft: #4a5761; /* 6.0:1 and 6.8:1 */
  --hairline: #c6d0d6;
  --edge: #6d7e8a; /* 3.4:1 on --mist */
  --cursor: #6d7e8a;
  --veil: rgb(31 42 51 / 0.05);
  --accent: #24303a;
  --accent-ink: #f3f6f8; /* 12.4:1 */
  --paper: #fbfcfc;
  --ink-soft: #56626c; /* 6.1:1 on --paper */
  --shadow: 0 2px 6px rgb(31 42 51 / 0.08), 0 20px 50px rgb(31 42 51 / 0.12);
  --tray-shadow: 0 4px 12px rgb(31 42 51 / 0.12);
  --smoke: #8d979f;
  --sky: #d6dee3;
  --water-far: #c5d0d7;
  --water-near: #9eafba;
  --wave: #7d909c;
  --dusk-high: #b5c1c9;
  --dusk-low: #dbe2e6;
  --dusk-ground: #e2e8ec;
  --shredder: #8f9ba4;
  --shredder-mouth: #2a333a;
  --ash: #6f7b84;
}
