/* Trench OS design tokens. Custom properties only: no selectors that style elements.
   Loaded first (index.html). The plan behind every value is docs/design.md.
   Names don't collide with the legacy variables in base.css / research.css (--bg, --text, --acc,
   --warn, ...); Phase 2 re-points those at these and then removes them. */

:root {
  /* ------------------------------------------------------------ base palette
     Night-field olive graphite, paper ink, manila. Green and red are reserved for
     price direction and danger, so the brand colour is neither. */
  --loam: #171914; /* desktop canvas */
  --dugout: #1e201a; /* window surface */
  --sandbag: #262920; /* raised: panels, inputs, link buttons */
  --parapet: #30342a; /* hover / selected / highest surface */
  --paper: #ece7d8; /* primary ink */
  --manila: #d9bf86; /* accent: yours (thesis, vibe, ticks, selection) and the primary action */

  /* surfaces, by height */
  --surface-0: var(--loam);
  --surface-1: var(--dugout);
  --surface-2: var(--sandbag);
  --surface-3: var(--parapet);
  --surface-panel: #23261f; /* board panels: a half step above the window */
  --surface-sunk: #13140f; /* wells: code, terminal, embeds' frame, media letterbox */

  /* ink (text and icons) */
  --ink-1: var(--paper); /* primary text, numbers that matter */
  --ink-2: #bdb9a9; /* secondary text, panel titles' meta */
  --ink-3: #8d8b7d; /* labels, sources, ages (4.7:1 on --dugout) */
  --ink-4: #64655a; /* disabled, placeholder decoration only */
  --ink-on-accent: #241f12; /* text on a manila fill */

  /* rules (borders, dividers) */
  --rule-1: #2c3027; /* hairlines inside a window */
  --rule-2: #3a3f34; /* control borders, panel outlines */
  --rule-3: #4d5345; /* hover borders, strong dividers */

  /* accent */
  --accent: var(--manila);
  --accent-strong: #ead29d; /* hover on accent fills */
  --accent-wash: rgba(217, 191, 134, 0.13); /* selected rows, ticked steps, active tab underlay */
  --accent-line: rgba(217, 191, 134, 0.45);
  --focus-ring: 0 0 0 2px var(--surface-1), 0 0 0 4px var(--manila);

  /* ------------------------------------------------------------ semantic
     Price direction (charts, % change). Data only: never on buttons or brand. */
  --up: #4fd18b;
  --up-wash: rgba(79, 209, 139, 0.12);
  --down: #f2685c;
  --down-wash: rgba(242, 104, 92, 0.12);

  /* Signals from free checks. Danger is the giga red-flag strip; it always carries the flag icon. */
  --danger: #ff5b57;
  --danger-ink: #ffb8b0; /* text on --danger-wash */
  --danger-wash: rgba(255, 91, 87, 0.14);
  --danger-line: rgba(255, 91, 87, 0.42);
  --caution: #e6bb45;
  --caution-ink: #f3dc9c;
  --caution-wash: rgba(230, 187, 69, 0.12);
  --fine: #93bf8d; /* quiet "no big red flags", checks that passed: muted sage, not price green */
  --fine-wash: rgba(147, 191, 141, 0.1);
  --info: #8fb5e2; /* agent activity, in-sandbox state, neutral notices */
  --info-wash: rgba(143, 181, 226, 0.12);

  /* Vibe: the user's gut call, bad → good. A temperature scale (cold dusk → manila → ember),
     never red→green, so it can't be misread as price or danger. Always paired with its face icon. */
  --vibe-1: #9a8ec0; /* bad: dusk lilac, faceBad */
  --vibe-2: #8d8b7d; /* meh: pencil, faceMeh */
  --vibe-3: #c8c2ae; /* unsure: paper-dim, faceUnsure */
  --vibe-4: #d9bf86; /* good: manila, faceGood */
  --vibe-5: #f5a05a; /* hot: ember, fire */

  /* Charts (native charts and sparklines; embeds keep their own theme) */
  --chart-up: var(--up);
  --chart-down: var(--down);
  --chart-line: var(--paper);
  --chart-area: rgba(236, 231, 216, 0.08);
  --chart-volume: #3f4537;
  --chart-grid: #262a21;
  --chart-axis: var(--ink-3);
  --chart-cross: var(--ink-2);
  --chart-mark: var(--manila); /* user annotations, entry lines, "you were here" */
  /* comparison series, in order (validated against --dugout for 3:1 and mutual distinctness) */
  --series-1: #d9bf86;
  --series-2: #8fb5e2;
  --series-3: #c39bd3;
  --series-4: #93bf8d;
  --series-5: #f5a05a;
  /* angle colours (src/panels/util.ts ANGLE_COLORS, rail .ac-*): first four follow the series */
  --angle-amber: var(--series-1);
  --angle-sky: var(--series-2);
  --angle-violet: var(--series-3);
  --angle-lime: var(--series-4);
  --angle-rose: #e59aa6;
  --angle-teal: #7cc7bf;
  --angle-slate: #9aa3ad;

  /* ------------------------------------------------------------ type
     UI: Atkinson Hyperlegible Next (built to tell 1/l/I and 0/O apart at a glance).
     Voice: Newsreader, only for words the user wrote: thesis, notes, step notes, captions.
     Code: Atkinson Hyperlegible Mono, only for addresses, hashes, commands, terminal. */
  --font-ui: "Atkinson Hyperlegible Next", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-voice: "Newsreader", "Iowan Old Style", Charter, Georgia, serif;
  --font-code: "Atkinson Hyperlegible Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Scale from the classic typographic series (Bringhurst): 11 12 14 16 18 21 24 30 */
  --fs-micro: 11px; /* source + age footers, kbd */
  --fs-meta: 12px; /* labels, chips, tab text, secondary lines */
  --fs-body: 14px; /* default UI text (13px in compact) */
  --fs-lead: 16px; /* panel titles, story paragraph, notes body */
  --fs-title: 18px; /* section headings, coin name in compact header */
  --fs-name: 21px; /* coin name in the case header */
  --fs-thesis: 24px; /* the thesis line, Newsreader */
  --fs-hero: 30px; /* Home's question (sans: serif is reserved for the user's words) */

  --lh-tight: 1.2; /* headings, numbers */
  --lh-ui: 1.45; /* sans UI text */
  --lh-voice: 1.55; /* serif reading text */

  --fw-regular: 400;
  --fw-medium: 520; /* labels that need a touch more weight */
  --fw-strong: 640; /* titles, key numbers */
  --fw-heavy: 760; /* the coin name only */

  --tracking-tight: -0.01em; /* >= 21px */
  --tracking-ui: 0;
  --num: tabular-nums; /* font-variant-numeric for every column of numbers */

  /* ------------------------------------------------------------ space (4px grid) */
  --sp-0h: 2px;
  --sp-1: 4px;
  --sp-1h: 6px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-14: 56px;
  --sp-18: 72px;

  /* ------------------------------------------------------------ radii, by hierarchy
     Bigger containers get rounder corners; nested things get tighter ones. */
  --radius-window: 12px;
  --radius-panel: 10px;
  --radius-media: 8px;
  --radius-control: 7px;
  --radius-inner: 5px; /* kbd, chips inside controls, tick boxes */
  --radius-pill: 999px; /* flags, status, chain chips, tabs' dots */

  /* ------------------------------------------------------------ elevation
     Panels are flat (tone + hairline). Shadows are olive-black, not grey, and only on things that float. */
  --elev-0: none;
  --elev-1: 0 1px 0 rgba(255, 248, 225, 0.03) inset, 0 1px 2px rgba(6, 7, 3, 0.35); /* controls */
  --elev-2: 0 10px 28px -10px rgba(6, 7, 3, 0.7), 0 0 0 1px var(--rule-2); /* menus, popovers, toasts */
  --elev-window: 0 28px 70px -20px rgba(6, 7, 3, 0.8), 0 0 0 1px rgba(255, 248, 225, 0.05);
  --elev-overlay: 0 40px 120px -20px rgba(6, 7, 3, 0.9), 0 0 0 1px var(--rule-3); /* palette, dialogs, lightbox */
  --scrim: rgba(12, 13, 9, 0.62);

  /* ------------------------------------------------------------ icons (paths in src/desktop/dom.ts, 16×16 grid) */
  --icon-sm: 14px; /* inline with 12–14px text */
  --icon-md: 16px; /* buttons, link bar, tabs */
  --icon-lg: 20px; /* section headings, dock, empty states */
  --icon-stroke: 1.5;

  /* ------------------------------------------------------------ motion */
  --dur-1: 90ms; /* press, colour change */
  --dur-2: 160ms; /* menus, toggles, tab switch */
  --dur-3: 240ms; /* window open/close, section collapse */
  --dur-4: 420ms; /* the one orchestrated moment: a case opening */
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-in-out: cubic-bezier(0.45, 0, 0.2, 1);

  /* ------------------------------------------------------------ shell + layout */
  --shell-top-h: 38px;
  --shell-dock-h: 48px;
  --case-tabs-h: 40px;
  --measure: 68ch; /* reading width for story, notes, thesis */
  --board-cols: 12;
  --board-max: 1680px; /* past this, the case board centres instead of stretching */

  /* ------------------------------------------------------------ density: comfortable (default) */
  --row-h: 36px; /* list rows, step rows, table rows */
  --ctl-h: 32px; /* buttons, inputs, link buttons */
  --ctl-h-sm: 26px;
  --pad-panel: var(--sp-4);
  --pad-window: var(--sp-6);
  --gap-board: var(--sp-4);
  --gap-section: var(--sp-10);
  --fs-ui: var(--fs-body);

  color-scheme: dark;
}

/* Compact: same hierarchy, tighter. Set data-density on <html> (global) or on a case root. */
[data-density="compact"] {
  --fs-body: 13px;
  --fs-lead: 14px;
  --fs-name: 18px;
  --fs-thesis: 20px;
  --row-h: 28px;
  --ctl-h: 26px;
  --ctl-h-sm: 22px;
  --pad-panel: var(--sp-3);
  --pad-window: var(--sp-4);
  --gap-board: var(--sp-2);
  --gap-section: var(--sp-6);
  --fs-ui: 13px;
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-1: 0ms;
    --dur-2: 0ms;
    --dur-3: 0ms;
    --dur-4: 0ms;
  }
}
