/* Trio design tokens (docs/JARLAY_UI_SPEC.md section 4).
 *
 * Dark is the default. Light is defined twice on purpose:
 *   1. [data-theme="light"]  - an explicit choice (also usable on any element to
 *      scope a light island, as the styleguide does)
 *   2. @media (prefers-color-scheme: light) :root:not([data-theme]) - no explicit
 *      choice, so follow the operating system.
 * Keep both light blocks identical (scripts/contrast check enforces it).
 *
 * Palette: Orchid (docs/trio_brand_research_2026-11-03.md s.3), flat: no glow or gradient. Derived: --surface-3,
 * --border*, --ink-3, --accent-hover, soft tints. --good/--bad: graded won/lost only, with an icon.
 */

/* ---------- dark (default) ---------- */
:root,
[data-theme="dark"] {
  color-scheme: dark;

  --bg: #120E1A;
  --surface: #1B1626;
  --surface-2: #251E33;
  --surface-3: #302744;
  --border: #2E2640;          /* hairlines, decorative */
  --border-strong: #7A7090;   /* control edges, 3:1 */
  --ink: #F3EFF8;
  --ink-2: #A9A1BA;
  --ink-3: #9A92AC;
  --accent: #D777C9;
  --accent-hover: #E595D9;
  --accent-ink: #1A0A17;
  --accent-soft: rgba(215, 119, 201, 0.14);
  --good: #58C4B4;
  --warn: #b78606;
  --bad: #F0836B;
  --info: #498ee1;
  --good-soft: rgba(88, 196, 180, 0.16);
  --warn-soft: rgba(183, 134, 6, 0.2);
  --bad-soft: rgba(240, 131, 107, 0.16);
  --info-soft: rgba(73, 142, 225, 0.18);
  --neutral-soft: rgba(169, 161, 186, 0.12);
  --overlay: rgba(8, 5, 12, 0.64);
  --hover-wash: rgba(255, 255, 255, 0.03);
  --highlight: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  /* brand/bucket placeholders: swap here and in img/logo.svg only */
  --brand-1: #D777C9;
  --brand-2: #8E7CF0;
  --brand-3: #F0B8E6;
  --bucket-steady: #74B7E8;
  --bucket-balanced: #E2BC4F;
  --bucket-swing: #F29A5B;

  /* chart: categorical, set order, never cycled (validated adjacent, dark) */
  --s1: #18a992;
  --s2: #336abd;
  --s3: #b3377d;
  --s4: #b78800;
  --s5: #977ae7;
  --s6: #d77205;
  --s-other: #8994ab;
  /* chart: sequential, one hue, magnitude low -> high (brighter = more) */
  --seq-1: #036056;
  --seq-2: #0e8073;
  --seq-3: #05a291;
  --seq-4: #15c5b1;
  --seq-5: #4ee6d1;
  /* chart: diverging blue <- gray -> amber, "2" is the stronger step */
  --div-neg-2: #5194e6;
  --div-neg-1: #2669b7;
  --div-mid: #3b4558;
  --div-pos-1: #856308;
  --div-pos-2: #b98a00;
  /* chart chrome */
  --grid: #1c2638;
  --axis: #36435b;
}

/* ---------- light ---------- */
[data-theme="light"] {
  color-scheme: light;

  --bg: #F7F4FA;
  --surface: #FFFFFF;
  --surface-2: #ECE6F3;
  --surface-3: #DDD4E8;
  --border: #D9D0E3;
  --border-strong: #7A708A;
  --ink: #17121F;
  --ink-2: #5A5068;
  --ink-3: #5F5570;
  --accent: #A12E92;
  --accent-hover: #861F79;
  --accent-ink: #FFFFFF;
  --accent-soft: rgba(161, 46, 146, 0.1);
  --good: #0E7468;
  --warn: #996001;
  --bad: #B8432C;
  --info: #0a57a5;
  --good-soft: rgba(14, 116, 104, 0.11);
  --warn-soft: rgba(153, 96, 1, 0.12);
  --bad-soft: rgba(184, 67, 44, 0.09);
  --info-soft: rgba(10, 87, 165, 0.09);
  --neutral-soft: rgba(90, 80, 104, 0.09);
  --overlay: rgba(23, 18, 31, 0.4);
  --hover-wash: rgba(15, 23, 42, 0.035);
  --highlight: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  --brand-1: #A12E92;
  --brand-2: #5B48C8;
  --brand-3: #7A3B70;
  --bucket-steady: #1F6FA8;
  --bucket-balanced: #8A6500;
  --bucket-swing: #B2530E;

  --s1: #30a492;
  --s2: #223fca;
  --s3: #a8004d;
  --s4: #d97706;
  --s5: #7c3aed;
  --s6: #ea580c;
  --s-other: #6b768c;
  --seq-1: #15c5b1;
  --seq-2: #15a796;
  --seq-3: #018b7c;
  --seq-4: #046f63;
  --seq-5: #05544a;
  --div-neg-2: #397bcb;
  --div-neg-1: #6caeff;
  --div-mid: #e3e7ef;
  --div-pos-1: #e1af3b;
  --div-pos-2: #a97f0e;
  --grid: #e6eaf2;
  --axis: #b9c2d3;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;

    --bg: #F7F4FA;
    --surface: #FFFFFF;
    --surface-2: #ECE6F3;
    --surface-3: #DDD4E8;
    --border: #D9D0E3;
    --border-strong: #7A708A;
    --ink: #17121F;
    --ink-2: #5A5068;
    --ink-3: #5F5570;
    --accent: #A12E92;
    --accent-hover: #861F79;
    --accent-ink: #FFFFFF;
    --accent-soft: rgba(161, 46, 146, 0.1);
    --good: #0E7468;
    --warn: #996001;
    --bad: #B8432C;
    --info: #0a57a5;
    --good-soft: rgba(14, 116, 104, 0.11);
    --warn-soft: rgba(153, 96, 1, 0.12);
    --bad-soft: rgba(184, 67, 44, 0.09);
    --info-soft: rgba(10, 87, 165, 0.09);
    --neutral-soft: rgba(90, 80, 104, 0.09);
    --overlay: rgba(23, 18, 31, 0.4);
    --hover-wash: rgba(15, 23, 42, 0.035);
    --highlight: inset 0 1px 0 rgba(255, 255, 255, 0.7);
    --brand-1: #A12E92;
    --brand-2: #5B48C8;
    --brand-3: #7A3B70;
    --bucket-steady: #1F6FA8;
    --bucket-balanced: #8A6500;
    --bucket-swing: #B2530E;

    --s1: #30a492;
    --s2: #223fca;
    --s3: #a8004d;
    --s4: #d97706;
    --s5: #7c3aed;
    --s6: #ea580c;
    --s-other: #6b768c;
    --seq-1: #15c5b1;
    --seq-2: #15a796;
    --seq-3: #018b7c;
    --seq-4: #046f63;
    --seq-5: #05544a;
    --div-neg-2: #397bcb;
    --div-neg-1: #6caeff;
    --div-mid: #e3e7ef;
    --div-pos-1: #e1af3b;
    --div-pos-2: #a97f0e;
    --grid: #e6eaf2;
    --axis: #b9c2d3;
  }
}

/* ---------- theme-independent tokens ---------- */
:root {
  /* type */
  --font-ui: "DM Sans", "Inter", ui-sans-serif, "Segoe UI", Roboto, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-num: "DM Mono", "JetBrains Mono", ui-monospace, "Cascadia Mono", "SF Mono", Consolas, "Liberation Mono", monospace;
  --font-head: "Sora", "DM Sans", ui-sans-serif, system-ui, sans-serif;
  --fs-12: 0.75rem;
  --fs-13: 0.8125rem;   /* table default */
  --fs-14: 0.875rem;
  --fs-16: 1rem;
  --fs-20: 1.25rem;
  --fs-28: 1.75rem;
  --fs-40: 2.5rem;      /* hero number */
  --lh-table: 1.35;
  --lh-prose: 1.5;

  /* 8-px grid (4 px half step) */
  --sp-0: 4px;
  --sp-1: 8px;
  --sp-2: 16px;
  --sp-3: 24px;
  --sp-4: 32px;
  --sp-5: 40px;
  --sp-6: 48px;
  --sp-8: 64px;

  --radius-sm: 4px;
  --radius: 8px;
  --radius-ctl: 6px;
  --radius-pill: 999px;

  /* layout */
  --rail-w: 220px;
  --rail-w-collapsed: 64px;
  --content-max: 1600px;
  --header-h: 48px;
  --strip-h: 32px;
  --bottombar-h: 56px;
  --tap: 44px;

  /* tables (density) */
  --row-h: 36px;
  --row-h-compact: 30px;

  /* motion */
  --dur: 140ms;
  --dur-fast: 120ms;
  --dur-flash: 300ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);

  /* z */
  --z-sticky: 5;
  --z-header: 20;
  --z-overlay: 40;
  --z-drawer: 50;
  --z-palette: 60;
  --z-toast: 70;
  --z-tooltip: 80;
}

/* density modes: set data-density="compact" on <html> (or any container) */
[data-density="compact"] {
  --row-h: var(--row-h-compact);
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --dur: 0.01ms;
    --dur-fast: 0.01ms;
    --dur-flash: 0.01ms;
  }
}
