/* BestProps design tokens. Owned by L0. v2.0 (2026-10-04) adds the Glass + Engineering drawing tokens
   (ground, drafting grid, ink, draft lines, indigo, glass, grain); see the "v2" blocks below.
   Dark is primary. Light is blueprint on paper: navy ink and indigo lines on a pale paper ground.
   Themes apply to html[data-theme] and to any nested element with data-theme,
   so a panel can render in the other theme (used by the styleguide parity section).
   Theme rule: a stored choice wins, else the OS prefers-color-scheme, else dark (head.html init script and the no-JS fallback below agree). */

:root,
[data-theme="dark"] {
  color-scheme: dark;

  /* Surfaces */
  --bg: #05060B;                /* v2: same as --ground */
  --bg-elev: #0A0B12;          /* page bands, sunken wells */
  --surface: #0D0F18;          /* cards */
  --raised: #141726;           /* hover, menus, popovers */
  --overlay: #181B2C;          /* drawers, palette */
  --line: #22263A;
  --line-strong: #30354F;
  --line-soft: rgba(255, 255, 255, 0.05);

  /* Text */
  --text: #EEF0F7;
  --text-2: #C4C7D8;
  --muted: #9095AE;
  --faint: #858AA3;            /* 5.0:1 or better on every dark surface */
  --caution-ink: var(--caution); --profit-ink: var(--profit); --info-ink: var(--info);  /* small-text ink for tags */

  /* Brand */
  --brand: #4F48FF;
  --brand-hover: #5F59FF;
  --brand-press: #4039EE;
  --brand-soft: #8A85FF;       /* links, arcs, accents on dark */
  --brand-ink: #FFFFFF;        /* text on brand fills */
  --brand-tint: rgba(79, 72, 255, 0.14);
  --brand-tint-2: rgba(138, 133, 255, 0.22);
  --brand-glow: rgba(79, 72, 255, 0.45);

  /* Signals */
  --profit: #2EE59D;
  --profit-tint: rgba(46, 229, 157, 0.12);
  --caution: #FFC24B;
  --caution-tint: rgba(255, 194, 75, 0.12);
  --breach: #FF5C72;
  --breach-tint: rgba(255, 92, 114, 0.12);
  --info: #6FB6FF;
  --info-tint: rgba(111, 182, 255, 0.12);
  --deal: #FFF029;
  --deal-ink: #14140A;

  /* Effects */
  --edge: inset 0 1px 0 rgba(255, 255, 255, 0.05);   /* inner glow edge on dark cards */
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 8px 24px -8px rgba(0, 0, 0, 0.6), 0 2px 6px rgba(0, 0, 0, 0.35);
  --shadow-3: 0 24px 64px -16px rgba(0, 0, 0, 0.75), 0 4px 16px rgba(0, 0, 0, 0.4);
  --scrim: rgba(3, 4, 8, 0.66);
  --focus: #9A95FF;
  --zebra: rgba(255, 255, 255, 0.018);
  --skeleton-a: #141726;
  --skeleton-b: #1C2033;
  --mono-tile-l1: 46%;
  --mono-tile-l2: 30%;
  --grid-line: rgba(255, 255, 255, 0.035);

  /* v2: Glass + Engineering drawing */
  --ground: #05060B;                              /* page ground under the drafting grid */
  --grid-fine: rgba(140, 150, 255, 0.035);        /* every 8 px */
  --grid-major: rgba(140, 150, 255, 0.075);       /* every 40 px */
  --ink: #F2F3FA;                                 /* headings and figures */
  --ink-2: #B9BDD3;                               /* body */
  --ink-3: #8F94AE;                               /* labels, 5:1 or better on the ground */
  --draft: rgba(255, 255, 255, 0.5);              /* drafting lines, dimension lines */
  --draft-2: rgba(255, 255, 255, 0.2);            /* extension and construction lines, rules */
  --indigo: #7C76FF;                              /* leader lines, value arcs, reference numbers */
  --indigo-ink: #A9A5FF;                          /* indigo for small text on dark */
  --indigo-deep: #4F48FF;                         /* fills, primary button, floor lines */
  --amber: #FFC24B;                               /* second marker (formula draft) */
  --glass: linear-gradient(160deg, rgba(30, 34, 62, 0.55), rgba(10, 12, 24, 0.62) 55%, rgba(8, 9, 18, 0.7));
  --glass-solid: #0B0D19;                         /* opaque base under glass for menus and overlays */
  --glass-edge: rgba(150, 160, 255, 0.16);
  --glass-hi: rgba(255, 255, 255, 0.10);          /* 1 px top-left inner highlight */
  --glass-spec: rgba(255, 255, 255, 0.06);        /* top-left specular wash */
  --glass-glow: 0 0 0 1px rgba(124, 118, 255, 0.55), 0 0 32px -6px rgba(79, 72, 255, 0.55);
  --glass-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.8);
  --eq-line: #DCDDFF;                             /* equity path in diagrams */
  --grain: 0.06;                                  /* film grain opacity */
}

[data-theme="light"] {
  color-scheme: light;

  --bg: #F3F5FB;                /* v2: paper, same as --ground */
  --bg-elev: #ECEFF8;
  --surface: #FFFFFF;
  --raised: #F3F4F9;
  --overlay: #FFFFFF;
  --line: #E3E4EE;
  --line-strong: #CDD0DF;
  --line-soft: rgba(14, 16, 32, 0.05);

  --text: #0E1020;
  --text-2: #2C3048;
  --muted: #5B6078;
  --faint: #60667F;            /* 4.9:1 or better on every light surface */
  --caution-ink: #7A4D00; --profit-ink: #065F42; --info-ink: #175A9E;  /* 6:1 or better on their tints */

  --brand: #342DF1;
  --brand-hover: #2A23E0;
  --brand-press: #221CC4;
  --brand-soft: #342DF1;
  --brand-ink: #FFFFFF;
  --brand-tint: rgba(52, 45, 241, 0.08);
  --brand-tint-2: rgba(52, 45, 241, 0.14);
  --brand-glow: rgba(52, 45, 241, 0.25);

  --profit: #067253;
  --profit-tint: rgba(10, 138, 92, 0.09);
  --caution: #8A5A00;
  --caution-tint: rgba(214, 150, 20, 0.12);
  --breach: #B81D37;
  --breach-tint: rgba(204, 39, 64, 0.08);
  --info: #1F6FC5;
  --info-tint: rgba(31, 111, 197, 0.08);
  --deal: #FFF029;
  --deal-ink: #14140A;

  --edge: inset 0 0 0 rgba(0, 0, 0, 0);
  --shadow-1: 0 1px 2px rgba(16, 18, 40, 0.06);
  --shadow-2: 0 1px 2px rgba(16, 18, 40, 0.05), 0 8px 24px -10px rgba(16, 18, 40, 0.14);
  --shadow-3: 0 2px 6px rgba(16, 18, 40, 0.06), 0 28px 64px -20px rgba(16, 18, 40, 0.28);
  --scrim: rgba(14, 16, 32, 0.38);
  --focus: #342DF1;
  --zebra: rgba(14, 16, 32, 0.022);
  --skeleton-a: #ECEDF3;
  --skeleton-b: #F6F6FA;
  --mono-tile-l1: 50%;
  --mono-tile-l2: 38%;
  --grid-line: rgba(14, 16, 32, 0.05);

  /* v2: blueprint on paper */
  --ground: #F3F5FB;
  --grid-fine: rgba(40, 52, 160, 0.05);
  --grid-major: rgba(40, 52, 160, 0.1);
  --ink: #0B1033;
  --ink-2: #2A3060;
  --ink-3: #4F567D;
  --draft: rgba(18, 26, 90, 0.62);
  --draft-2: rgba(18, 26, 90, 0.24);
  --indigo: #3C35E0;
  --indigo-ink: #3C35E0;
  --indigo-deep: #3C35E0;
  --amber: #8A5A00;
  --glass: linear-gradient(160deg, rgba(255, 255, 255, 0.86), rgba(246, 247, 253, 0.74));
  --glass-solid: #FFFFFF;
  --glass-edge: rgba(40, 52, 160, 0.16);
  --glass-hi: rgba(255, 255, 255, 0.9);
  --glass-spec: rgba(255, 255, 255, 0.7);
  --glass-glow: 0 0 0 1px rgba(60, 53, 224, 0.5), 0 10px 30px -12px rgba(60, 53, 224, 0.35);
  --glass-shadow: 0 24px 50px -32px rgba(20, 28, 90, 0.35);
  --eq-line: #1B2160;
  --grain: 0.03;
}

/* No-JS fallback: follow the OS when no theme attribute was set. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --bg: #F3F5FB; --bg-elev: #ECEFF8; --surface: #FFFFFF; --raised: #F3F4F9; --overlay: #FFFFFF;
    --line: #E3E4EE; --line-strong: #CDD0DF; --line-soft: rgba(14, 16, 32, 0.05);
    --text: #0E1020; --text-2: #2C3048; --muted: #5B6078; --faint: #60667F; --caution-ink: #7A4D00; --profit-ink: #065F42; --info-ink: #175A9E;
    --brand: #342DF1; --brand-hover: #2A23E0; --brand-press: #221CC4; --brand-soft: #342DF1;
    --brand-tint: rgba(52, 45, 241, 0.08); --brand-tint-2: rgba(52, 45, 241, 0.14); --brand-glow: rgba(52, 45, 241, 0.25);
    --profit: #067253; --profit-tint: rgba(10, 138, 92, 0.09); --caution: #8A5A00; --caution-tint: rgba(214, 150, 20, 0.12);
    --breach: #B81D37; --breach-tint: rgba(204, 39, 64, 0.08); --info: #1F6FC5; --info-tint: rgba(31, 111, 197, 0.08);
    --edge: inset 0 0 0 rgba(0, 0, 0, 0); --shadow-1: 0 1px 2px rgba(16, 18, 40, 0.06);
    --shadow-2: 0 1px 2px rgba(16, 18, 40, 0.05), 0 8px 24px -10px rgba(16, 18, 40, 0.14);
    --shadow-3: 0 2px 6px rgba(16, 18, 40, 0.06), 0 28px 64px -20px rgba(16, 18, 40, 0.28);
    --scrim: rgba(14, 16, 32, 0.38); --focus: #342DF1; --zebra: rgba(14, 16, 32, 0.022);
    --skeleton-a: #ECEDF3; --skeleton-b: #F6F6FA; --mono-tile-l1: 50%; --mono-tile-l2: 38%; --grid-line: rgba(14, 16, 32, 0.05);
    --ground: #F3F5FB; --grid-fine: rgba(40, 52, 160, 0.05); --grid-major: rgba(40, 52, 160, 0.1);
    --ink: #0B1033; --ink-2: #2A3060; --ink-3: #4F567D; --draft: rgba(18, 26, 90, 0.62); --draft-2: rgba(18, 26, 90, 0.24);
    --indigo: #3C35E0; --indigo-ink: #3C35E0; --indigo-deep: #3C35E0; --amber: #8A5A00;
    --glass: linear-gradient(160deg, rgba(255, 255, 255, 0.86), rgba(246, 247, 253, 0.74)); --glass-solid: #FFFFFF;
    --glass-edge: rgba(40, 52, 160, 0.16); --glass-hi: rgba(255, 255, 255, 0.9); --glass-spec: rgba(255, 255, 255, 0.7);
    --glass-glow: 0 0 0 1px rgba(60, 53, 224, 0.5), 0 10px 30px -12px rgba(60, 53, 224, 0.35);
    --glass-shadow: 0 24px 50px -32px rgba(20, 28, 90, 0.35); --eq-line: #1B2160; --grain: 0.03;
  }
}

/* Theme-independent tokens */
:root {
  /* Type */
  --font-sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --font-serif: var(--font-sans); /* accent face: was Instrument Serif italic, removed 2026-10-04 */

  /* Fluid type scale (min at 390px, max at 1440px) */
  --fs-2xs: 0.6875rem;                                   /* 11 */
  --fs-xs: 0.75rem;                                      /* 12 */
  --fs-sm: 0.8125rem;                                    /* 13 */
  --fs-base: 0.9375rem;                                  /* 15 */
  --fs-md: clamp(1rem, 0.96rem + 0.15vw, 1.0625rem);     /* 16 to 17 */
  --fs-lg: clamp(1.125rem, 1.06rem + 0.25vw, 1.25rem);   /* 18 to 20 */
  --fs-xl: clamp(1.3125rem, 1.18rem + 0.55vw, 1.625rem); /* 21 to 26 */
  --fs-2xl: clamp(1.625rem, 1.4rem + 0.95vw, 2.25rem);   /* 26 to 36 */
  --fs-3xl: clamp(2rem, 1.62rem + 1.6vw, 3.125rem);      /* 32 to 50 */
  --fs-display: clamp(2.5rem, 1.9rem + 2.6vw, 4.5rem);   /* 40 to 72 */

  --lh-tight: 1.06;
  --lh-snug: 1.22;
  --lh-body: 1.6;

  --track-display: -0.035em;
  --track-tight: -0.022em;
  --track-caps: 0.08em;

  /* Spacing (4px base) */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px; --s-5: 20px;
  --s-6: 24px; --s-7: 32px; --s-8: 40px; --s-9: 56px; --s-10: 72px; --s-11: 96px; --s-12: 128px;
  --section-y: clamp(64px, 5vw + 40px, 120px);
  --gutter: clamp(16px, 3.4vw, 40px);
  --container: 1240px;
  --container-narrow: 760px;
  --container-wide: 1400px;
  --header-h: 60px;               /* v2: slimmer header */
  --container-sheet: 1440px;      /* v2: drafting sheet width (home and review frames) */

  /* Shape */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 10px;
  --r-card: 14px;
  --r-lg: 18px;
  --r-xl: 24px;
  --r-pill: 999px;

  /* Motion */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --t-fast: 150ms;
  --t-base: 220ms;
  --t-slow: 300ms;
  --t-draw: 1400ms;               /* v2: line draw-in */
  --ease-draw: cubic-bezier(0.65, 0, 0.35, 1);

  /* v2 type scale (frames): display 42 to 76, h2 32 to 60, h3 22 to 28 */
  --fs-v2-display: clamp(2.625rem, 1.9rem + 3vw, 4.75rem);
  --fs-v2-h1: clamp(2.375rem, 1.8rem + 2.4vw, 4rem);
  --fs-v2-h2: clamp(2rem, 1.4rem + 2.5vw, 3.75rem);
  --fs-v2-h3: clamp(1.375rem, 1.2rem + 0.6vw, 1.75rem);
  --fs-v2-lede: clamp(1rem, 0.94rem + 0.3vw, 1.1875rem);
  --track-v2: -0.04em;

  /* Layers */
  --z-header: 50;
  --z-tray: 60;
  --z-drawer: 80;
  --z-palette: 90;
  --z-toast: 100;
}
