/* dashboard/theme.css — The Market Formula design tokens + base.
   Loaded first on every page, then brand.css (shared chrome), then the page's
   own <style>.

   The palette, type and theme model are copied from The Racing Formula
   (tipping-monster-stats public/css/style.css) so the two sites read as one
   family. Light is the default, exactly as on theracingformula.com; dark is
   [data-theme="dark"]. The <head> boot script always sets data-theme to
   "light" or "dark" explicitly, so a page may target either.

   Brand colours (MASTER kit): Midnight Navy #071C3C, Formula Green #00A66A,
   Victory Gold #D4A640, Graph Slate #17304F, Silver Mist #E8EDF4.
   Formula Green (3.15:1) and Victory Gold (2.25:1) fail AA on white, so small
   text on a light ground uses the darkened same-hue values (#007345, #8A6410),
   as TRF does. Use the tokens below, never a raw hex, in page CSS.

   Legacy names (--orange, --yellow, --blue, --card, --text-dim …) are kept
   as aliases so older rules keep resolving; prefer the semantic names. */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/Inter.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('/fonts/JetBrainsMono.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* Headline face: one weight, one style, one width. Uppercase display only —
   never data-bearing text (horse names, prices). */
@font-face {
  font-family: 'Noto Sans Display';
  font-style: italic;
  font-weight: 600;
  font-stretch: 62.5%;
  font-display: swap;
  src: url('/fonts/NotoSansDisplayXCond.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light;

  /* ── Brand (theme-independent) ── */
  --brand-navy: #071c3c;
  --brand-green: #00a66a;
  --brand-gold: #d4a640;
  --brand-slate: #17304f;
  --brand-mist: #e8edf4;
  /* Brand ramp steps (theme-independent, the same values the theme tokens
     below use): data-viz segments with fixed text colours on top. */
  --brand-steel: #47607f;
  --brand-deep: #24456b;
  --brand-fog: #a9bbd1;
  --brand-gold-light: #f0cf8a;
  --brand-green-light: #7fe0b4;

  /* ── Surfaces ── */
  --bg: #f7f9fc;              /* page */
  --bg-deep: #e8edf4;         /* footer, wells */
  --surface: #ffffff;         /* cards, panels */
  --surface-raised: #ffffff;  /* popovers, sticky bars */
  --surface-hover: #eef2f8;   /* row / card hover fill */
  --surface-active: #e6f6ef;  /* selected row */
  --input-bg: #f1f4f9;

  /* ── Lines ── */
  --border: #e8edf4;          /* hairlines, table rules */
  --border-subtle: #d3dce8;   /* card outlines */
  --border-strong: #a9bbd1;   /* hover / focus-adjacent outlines */

  /* ── Text ── */
  --text-strong: #000000;     /* headings, key figures */
  --text: #071c3c;            /* body */
  --text-dim: #47607f;        /* secondary */
  --text-muted: #5b6b7f;      /* labels, captions (5.3:1 on white) */

  /* ── Interactive / brand accent ── */
  --accent: #007345;          /* links, active nav, focus */
  --accent-fill: #007345;     /* primary button background */
  --on-accent: #ffffff;       /* text on --accent-fill */
  --accent-dim: #e6f6ef;      /* tinted fill behind accent text */
  --accent-border: rgba(0, 115, 69, 0.35);

  /* ── Semantic ── */
  --green: #007345;           /* win, positive P&L, price shortening */
  --green-dim: #e6f6ef;
  --green-border: rgba(0, 115, 69, 0.35);
  --red: #c5242b;             /* loss, negative P&L, errors */
  --red-dim: #fde8e9;
  --red-border: #f0c0c2;
  --gold: #8a6410;            /* highlights: steam size, money flow, best-of */
  --gold-dim: #fbf2de;
  --gold-border: #f0cf8a;
  --drift: #24456b;           /* drifters, price lengthening */
  --drift-dim: #e8edf4;
  --drift-border: #c3d0e0;
  --vip: #7a5810;             /* VIP tier label (gold family, darker) */
  --estimate: #7656b5;        /* projected SP: an estimate, not a traded price */
  --backdrop: rgba(0, 27, 55, 0.67); /* behind modal dialogs */

  /* ── Type ── */
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --font-headline: 'Noto Sans Display', 'Inter', system-ui, sans-serif;
  --num: var(--font-mono);

  /* ── Shape ── */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-card: 0 1px 2px rgba(11, 13, 18, 0.04), 0 1px 3px rgba(11, 13, 18, 0.06);
  --shadow-hover: 0 2px 6px rgba(11, 13, 18, 0.08), 0 4px 12px rgba(11, 13, 18, 0.06);
  --shadow-pop: 0 12px 32px rgba(7, 28, 60, 0.16);

  --header-bg: rgba(255, 255, 255, 0.95);
  --header-border: #e8edf4;

  /* ── Legacy aliases (pre-rebrand names still used in page CSS) ── */
  --card: var(--surface);
  --card-solid: var(--surface);
  --card-border: var(--border-subtle);
  --card-hover: var(--border-strong);
  --orange: var(--gold);
  --orange-dim: var(--gold-dim);
  --yellow: var(--gold);
  --blue: var(--drift);
  --glow-orange: none;
}

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

  --bg: #000000;
  --bg-deep: #071c3c;
  --surface: #071c3c;
  --surface-raised: #17304f;
  --surface-hover: #1d3a5c;
  --surface-active: #072418;
  --input-bg: rgba(255, 255, 255, 0.06);

  --border: #17304f;
  --border-subtle: #24456b;
  --border-strong: #47607f;

  --text-strong: #ffffff;
  --text: #e8edf4;
  --text-dim: #a9bbd1;
  --text-muted: #8fa3bc;

  --accent: #00a66a;
  --accent-fill: #00a66a;
  --on-accent: #071c3c;
  --accent-dim: #072418;
  --accent-border: rgba(0, 166, 106, 0.45);

  --green: #00a66a;
  --green-dim: #072418;
  --green-border: rgba(0, 166, 106, 0.45);
  --red: #f85149;
  --red-dim: #3d1214;
  --red-border: rgba(248, 81, 73, 0.45);
  --gold: #d4a640;
  --gold-dim: #2e2408;
  --gold-border: rgba(212, 166, 64, 0.45);
  --drift: #a9bbd1;
  --drift-dim: rgba(23, 48, 79, 0.55);
  --drift-border: rgba(169, 187, 209, 0.4);
  --vip: #f0cf8a;
  --estimate: #c6a8ff;

  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-pop: 0 12px 32px rgba(0, 0, 0, 0.55);

  --header-bg: rgba(7, 28, 60, 0.92);
  --header-border: rgba(255, 255, 255, 0.06);
}

/* ── Base ── */
*, *::before, *::after { box-sizing: border-box; }
html {
  overflow-x: clip; /* root-level safety net: never allow horizontal page scroll */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.55;
  overflow-x: clip; /* safety net: never allow horizontal page scroll */
  -webkit-font-smoothing: antialiased;
  accent-color: var(--accent);
}
a { color: var(--accent); }
::selection { background: rgba(0, 166, 106, 0.22); }
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
