/* ==========================================================================
   tokens.css - the only file that may hold raw colours, px sizes and curves.
   Everything else reads these custom properties. See "Design system" in CLAUDE.md.

   Breakpoints (used in @media rules only; CSS cannot read a variable there):
     sm 640px   md 768px   lg 1024px   xl 1280px      (mobile-first, min-width)
   ========================================================================== */

:root {
  /* ---------- colour: light (default) ---------- */
  color-scheme: light;
  --bg: #FFFFFF;            /* page */
  --surface: #FFFFFF;       /* cards, tiles, sheet */
  --surface-2: #F4F8FC;     /* nav tray, table heads, code wells */
  --line: #DDE6EF;          /* hairlines */
  --grid-line: #E8EFF7;     /* decorative graph-paper lines */
  --ink: #14171C;
  --muted: #5B6472;
  --brand: #A8D3F5;         /* primary button fill, swatches */
  --brand-hover: #93C8F2;
  --brand-line: #A8D3F5;    /* emphasised borders, dot textures */
  --on-brand: #14171C;      /* text on --brand */
  --accent: #3C82DE;        /* links, marks, focus */
  --accent-soft: #E4F1FC;   /* highlighted cells, icon buttons */
  --accent-faint: #F1F8FE;  /* quiet tinted panels */
  --logo: #5FA3E6;          /* ASCII intro settled colour */
  --danger: #B3261E;
  --glass: rgba(255, 255, 255, 0.72);
  --card-edge: #FFFFFF;
  --shadow-tint: rgba(60, 130, 222, 0.35);
  --mask-on: #000000;       /* alpha mask source, never painted */

  /* ---------- trace colours: the meaning of a colour on the grid, in a demo or on a canvas ---------- */
  --trace-precedent: #3A6FF0;     /* a cell that feeds the focus */
  --trace-dependent: #FD5108;     /* a cell the focus feeds */
  --trace-input: #1F4FD1;         /* hard-coded input, the blue convention */
  --trace-contributes: #2F9E44;   /* rows that actually carry a SUMIFS / lookup */
  --trace-target: #217346;        /* the selected cell, Excel green */
  --trace-edit: var(--trace-dependent);  /* caret and the cell being typed in */
  --trace-error: #E5484D;
  --trace-warn: #C8791F;
  --trace-ok: #217346;
  --trace-flash: rgba(253, 81, 8, 0.55);  /* one-frame flash on a changed cell */
  --trace-error-soft: #FDECEC;
  --trace-warn-soft: #FBF0E2;
  --trace-ok-soft: #E3F1E8;
  --heat-1: #F2B25C;              /* impact ramp, nearest to farthest */
  --heat-2: #F7CD8E;
  --heat-3: #FADFB8;
  --heat-4: #FDEEDB;
  /* argument palette: arg 1..7 of a formula, in order */
  --arg-1: #3A6FF0;
  --arg-2: #E5484D;
  --arg-3: #9B78D0;
  --arg-4: #2F9E44;
  --arg-5: #C8791F;
  --arg-6: #0F8B8D;
  --arg-7: #B0483E;

  /* ---------- canvas surface: the mock Excel a demo draws on ---------- */
  --canvas-bg: #F4F5F7;
  --canvas-cell: #FFFFFF;
  --canvas-header: #F3F3F3;
  --canvas-grid: #E2E2E2;
  --canvas-ink: #17191D;
  --canvas-text: #333941;
  --canvas-muted: #6B7380;
  --canvas-formula-bar: #F7F8FA;
  --canvas-pill: rgba(255, 255, 255, 0.95);
  --canvas-row-hi: #EAF0FE;
  --canvas-border: #CBD1D9;
  --canvas-key: #FFFFFF;
  --canvas-key-down: #E4EAF6;
  --canvas-key-line: #C3CAD6;
  --canvas-panel: #FFFFFF;
  --canvas-panel-line: #E7E9EC;
  --canvas-panel-hi: #F2F3F5;
  --canvas-sleep: #9AA2AD;        /* an untaken branch */
  --canvas-gold: #B8862F;
  --canvas-fog: rgba(244, 245, 247, 0.9);
  --canvas-cursor: #FFFFFF;
  --canvas-cursor-edge: #000000;

  /* ---------- fonts (one Google Fonts link per page loads all of them) ---------- */
  --font-display: "Schibsted Grotesk", "Segoe UI", system-ui, sans-serif;  /* headings, stat numbers */
  --font-sans: "Hanken Grotesk", "Segoe UI", system-ui, sans-serif;        /* body */
  --font-mono: "IBM Plex Mono", "Cascadia Mono", Consolas, ui-monospace, monospace;
  --font-wordmark: "Tektur", "Segoe UI", sans-serif;                       /* GXLSHOUSE only */
  --font-intro-logo: "Tektur", "Segoe UI", sans-serif;                     /* index.html ASCII intro, kept as-is */
  --font-intro-dots: "Geist Mono", ui-monospace, monospace;

  /* ---------- spacing: 4px base ---------- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 28px;
  --space-8: 32px;
  --space-9: 40px;
  --space-10: 48px;
  --space-11: 56px;
  --space-12: 64px;
  --space-14: 80px;

  /* ---------- type scale ---------- */
  --text-2xs: 11px;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-md: 14px;
  --text-base: 15px;        /* body */
  --text-lg: 16px;
  --text-xl: 17px;          /* h3 */
  --text-2xl: 20px;
  --text-3xl: clamp(23px, 2.3vw, 30px);   /* h2 */
  --text-4xl: clamp(34px, 4.2vw, 56px);   /* h1 */
  --text-stat: clamp(38px, 4vw, 52px);    /* big numerals */
  --text-quote: clamp(16px, 1.5vw, 19px);
  --lh-none: 1;
  --lh-display: 0.98;       /* h1 */
  --lh-tight: 1.05;         /* h2 */
  --lh-snug: 1.3;
  --lh-copy: 1.4;
  --lh-body: 1.55;
  --tracking-display: -0.035em;
  --tracking-heading: -0.025em;
  --tracking-title: -0.01em;
  --tracking-caps: 0.06em;
  --tracking-wide: 0.1em;
  --tracking-eyebrow: 0.14em;
  --measure-lede: 34em;
  --measure-copy: 36em;
  --measure-faq: 40em;

  /* ---------- shape ---------- */
  --hairline: 1px;
  --stroke: 2px;
  --radius-sm: 0;           /* the site is square; one knob if that changes */
  --radius-pill: 0;         /* square too: one look, no rounded pills (DESIGN-SYSTEM.md) */
  --shadow-card: inset 0 var(--hairline) 0 var(--card-edge), 0 18px 40px -24px var(--shadow-tint);

  /* ---------- sizes ---------- */
  --size-icon-btn: 36px;
  --size-icon: 18px;
  --size-swatch: 12px;
  --size-bullet: 10px;
  --size-check: 16px;
  --size-dot-grid: 7px;
  --size-graph-paper: 28px;
  --size-row-head: 36px;
  --size-cmd-pad-end: 84px;
  --table-min: 760px;
  --ill-ratio: 240 / 150;

  /* ---------- motion ---------- */
  --dur-fast: 150ms;
  --dur-base: 220ms;
  --dur-slow: 260ms;
  --dur-reveal: 700ms;
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ease: ease;

  /* ---------- layout ---------- */
  --container: 1440px;      /* content width; the gutter sits outside it (1180 felt cramped on wide screens, Sam 2026-10-24) */
  --gutter: 16px;           /* side gutter, 16px minimum on phones */
  --grid-gap: 16px;
  --section-y-tight: 40px;
  --section-y: 56px;
  --section-y-loose: 80px;
  --z-header: 20;
  --z-intro: 100;
}

@media (min-width: 768px) {
  :root {
    --gutter: 24px;
    --grid-gap: 24px;
  }
}

/* ---------- colour: dark (follows the system unless the user chose light) ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0A0F1A;
    --surface: #0F1626;
    --surface-2: #131C30;
    --line: #22304A;
    --grid-line: #16223A;
    --ink: #E8EEF7;
    --muted: #98A5BA;
    --brand: #A8D3F5;
    --brand-hover: #C2E1FA;
    --brand-line: #2C5A8F;
    --on-brand: #0A0F1A;
    --accent: #6AA8F5;
    --accent-soft: #16294A;
    --accent-faint: #0F1D36;
    --logo: #6AA8F5;
    --danger: #F2877F;
    --glass: rgba(15, 22, 38, 0.72);
    --card-edge: rgba(255, 255, 255, 0.06);
    --shadow-tint: rgba(0, 0, 0, 0.6);
    --trace-precedent: #5B8CFF;
    --trace-dependent: #FF7A3D;
    --trace-input: #8FB3FF;
    --trace-contributes: #3FD28A;
    --trace-target: #21A366;
    --trace-error: #FF5F6D;
    --trace-warn: #FFB547;
    --trace-ok: #4EC98A;
    --trace-flash: rgba(255, 122, 61, 0.35);   /* lighter on dark so a flash never smothers the cell */
    --trace-error-soft: #3A1F22;
    --trace-warn-soft: #33281A;
    --trace-ok-soft: #16301F;
    --heat-1: #9A6A2A;
    --heat-2: #7A5626;
    --heat-3: #5A4222;
    --heat-4: #3F311D;
    --arg-1: #5B8CFF;
    --arg-2: #FF5F6D;
    --arg-3: #C08BFF;
    --arg-4: #3FD28A;
    --arg-5: #FFB547;
    --arg-6: #36C9D1;
    --arg-7: #FF7A3D;
    --canvas-bg: #0C111B;
    --canvas-cell: #121A27;
    --canvas-header: #0F1622;
    --canvas-grid: #1E2736;
    --canvas-ink: #EEF2F8;
    --canvas-text: #B8C1CF;
    --canvas-muted: #6F7A8C;
    --canvas-formula-bar: #0E1420;
    --canvas-pill: rgba(10, 14, 22, 0.95);
    --canvas-row-hi: #22314A;
    --canvas-border: #2F3D56;
    --canvas-key: #1A2335;
    --canvas-key-down: #2A3A58;
    --canvas-key-line: #3A4A66;
    --canvas-panel: #0F1520;
    --canvas-panel-line: #222C3B;
    --canvas-panel-hi: #18233A;
    --canvas-sleep: #5A6475;
    --canvas-gold: #D9A84E;
    --canvas-fog: rgba(205, 214, 228, 0.85);
  }
}

/* ---------- colour: dark, chosen explicitly with the toggle ---------- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0A0F1A;
  --surface: #0F1626;
  --surface-2: #131C30;
  --line: #22304A;
  --grid-line: #16223A;
  --ink: #E8EEF7;
  --muted: #98A5BA;
  --brand: #A8D3F5;
  --brand-hover: #C2E1FA;
  --brand-line: #2C5A8F;
  --on-brand: #0A0F1A;
  --accent: #6AA8F5;
  --accent-soft: #16294A;
  --accent-faint: #0F1D36;
  --logo: #6AA8F5;
  --danger: #F2877F;
  --glass: rgba(15, 22, 38, 0.72);
  --card-edge: rgba(255, 255, 255, 0.06);
  --shadow-tint: rgba(0, 0, 0, 0.6);
  --trace-precedent: #5B8CFF;
  --trace-dependent: #FF7A3D;
  --trace-input: #8FB3FF;
  --trace-contributes: #3FD28A;
  --trace-target: #21A366;
  --trace-error: #FF5F6D;
  --trace-warn: #FFB547;
  --trace-ok: #4EC98A;
  --trace-flash: rgba(255, 122, 61, 0.35);
  --trace-error-soft: #3A1F22;
  --trace-warn-soft: #33281A;
  --trace-ok-soft: #16301F;
  --heat-1: #9A6A2A;
  --heat-2: #7A5626;
  --heat-3: #5A4222;
  --heat-4: #3F311D;
  --arg-1: #5B8CFF;
  --arg-2: #FF5F6D;
  --arg-3: #C08BFF;
  --arg-4: #3FD28A;
  --arg-5: #FFB547;
  --arg-6: #36C9D1;
  --arg-7: #FF7A3D;
  --canvas-bg: #0C111B;
  --canvas-cell: #121A27;
  --canvas-header: #0F1622;
  --canvas-grid: #1E2736;
  --canvas-ink: #EEF2F8;
  --canvas-text: #B8C1CF;
  --canvas-muted: #6F7A8C;
  --canvas-formula-bar: #0E1420;
  --canvas-pill: rgba(10, 14, 22, 0.95);
  --canvas-row-hi: #22314A;
  --canvas-border: #2F3D56;
  --canvas-key: #1A2335;
  --canvas-key-down: #2A3A58;
  --canvas-key-line: #3A4A66;
  --canvas-panel: #0F1520;
  --canvas-panel-line: #222C3B;
  --canvas-panel-hi: #18233A;
  --canvas-sleep: #5A6475;
  --canvas-gold: #D9A84E;
  --canvas-fog: rgba(205, 214, 228, 0.85);
}
