/**
 * tokens.css: Mould Detect design tokens. Single source of truth,
 * generated from /design.md v1.0. Edit design.md first, then this file.
 *
 * Theme model (per design.md §2.3, §5.1):
 *   - Bare :root holds the full LIGHT palette.
 *   - Dark redefines colour tokens only, twice: media-query (system default,
 *     guarded so a manual light choice wins) and [data-theme="dark"]
 *     (manual choice wins in both directions).
 *   - [data-daypart] applies small surface-temperature drifts. Accent,
 *     status and chart colours never change with daypart.
 */

:root {
  /* ---- surfaces & ink (light / bone) ---- */
  --surface-0: #f6f4ec;
  --surface-1: #efece0;
  --surface-2: #e5e1d2;
  --ink-0: #152018;
  --ink-1: #3d4a40;
  --ink-2: #6b7769;
  --accent: #3e7a2e;
  --accent-ink: #f6f4ec;
  --accent-deep: #1e4d33;
  --line: #d6d2c0;

  /* ---- status / risk (data only; labels mandatory) ---- */
  --risk-low: #3e7a2e;
  --risk-watch: #c0921f;
  --risk-high: #a04a1e;
  --risk-severe: #8a2a1b;

  /* ---- type ---- */
  --font-display: "Libre Baskerville", "Iowan Old Style", Georgia, serif;
  --font-body: "Schibsted Grotesk", -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", monospace;

  --text-display: clamp(2.75rem, 1.2rem + 6.5vw, 6rem);
  --text-h2: clamp(2rem, 1.2rem + 3vw, 3.5rem);
  --text-h3: clamp(1.35rem, 1.1rem + 1vw, 1.75rem);
  --text-stat: clamp(2.5rem, 1.5rem + 4vw, 4.5rem);
  --text-body-lg: clamp(1.075rem, 1rem + 0.4vw, 1.25rem);
  --text-body: 1rem;
  --text-small: 0.875rem;
  --text-mono: 0.8125rem;

  --leading-tight: 1.12;   /* Libre Baskerville needs more air than Fraunces did */
  --leading-body: 1.65;
  --track-mono: 0.08em;
  --track-display: -0.01em;

  /* ---- space, grid, shape ---- */
  --sp-1: 0.25rem; --sp-2: 0.5rem; --sp-3: 1rem; --sp-4: 1.5rem;
  --sp-5: 2.5rem; --sp-6: 4rem; --sp-7: 6rem; --sp-8: 9rem;
  --section-pad: clamp(4rem, 10vh, 9rem);
  --page-max: 1240px;
  --gutter: clamp(1rem, 2.5vw, 2rem);
  --page-margin: clamp(1.25rem, 5vw, 4rem);
  --r-1: 6px; --r-2: 12px; --r-3: 24px;
  --shadow-1: 0 24px 60px -24px rgb(21 32 24 / 0.28);

  /* ---- motion ---- */
  --dur-fast: 180ms;
  --dur-base: 420ms;
  --dur-slow: 900ms;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-grow: cubic-bezier(0.34, 1.2, 0.4, 1);

  /* ---- hero organism (shader reads these via JS) ---- */
  --organism-base: 246, 244, 236;   /* rgb triplet of surface-0 */
  --organism-growth: 62, 122, 46;   /* rgb triplet of accent    */

  color-scheme: light;
}

/* ---- dark (system preference; a manual light choice wins) ---- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --surface-0: #0f1712;
    --surface-1: #16211a;
    --surface-2: #1d2b22;
    --ink-0: #edebe0;
    --ink-1: #a8b3a6;
    --ink-2: #71806f;
    --accent: #8fcb5b;
    --accent-ink: #0f1712;
    --accent-deep: #2e5b3d;
    --line: #26332a;
    --risk-low: #66a63f;
    --risk-watch: #c4a63c;
    --risk-high: #c4713a;
    --risk-severe: #b23a2e;
    --shadow-1: 0 24px 60px -24px rgb(0 0 0 / 0.55);
    --organism-base: 15, 23, 18;
    --organism-growth: 143, 203, 91;
    color-scheme: dark;
  }
}

/* ---- dark (manual choice; wins over system) ---- */
:root[data-theme="dark"] {
  --surface-0: #0f1712;
  --surface-1: #16211a;
  --surface-2: #1d2b22;
  --ink-0: #edebe0;
  --ink-1: #a8b3a6;
  --ink-2: #71806f;
  --accent: #8fcb5b;
  --accent-ink: #0f1712;
  --accent-deep: #2e5b3d;
  --line: #26332a;
  --risk-low: #66a63f;
  --risk-watch: #c4a63c;
  --risk-high: #c4713a;
  --risk-severe: #b23a2e;
  --shadow-1: 0 24px 60px -24px rgb(0 0 0 / 0.55);
  --organism-base: 15, 23, 18;
  --organism-growth: 143, 203, 91;
  color-scheme: dark;
}

/* ---- circadian drift (surfaces only; subtle by design, §5.1) ----
   Light drifts are guarded to the explicit light theme: the JS (head script
   + environment.js) always stamps data-theme, and an unguarded drift after
   the dark block would clobber dark surfaces at dusk (same specificity,
   later in file). No-JS visitors get no daypart attribute, so no drift. */
:root[data-daypart="dawn"][data-theme="light"] { --surface-0: #f3f4ee; --surface-1: #ebede2; }
:root[data-daypart="dusk"][data-theme="light"] { --surface-0: #f7f3e7; --surface-1: #f0ebdb; }
:root[data-daypart="dawn"][data-theme="dark"],
:root[data-daypart="night"][data-theme="dark"] { --surface-0: #0d1511; }
