/* ==========================================================================
   Design tokens. The only place colours and scales are defined.
   Dark is the default theme; [data-theme] switches a subtree, so the style
   guide can show both themes side by side.
   ========================================================================== */

:root {
  /* Typography ----------------------------------------------------------- */
  --font-sans: "Inter Variable", "Inter", ui-sans-serif, system-ui, -apple-system,
    "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono Variable", "JetBrains Mono", ui-monospace, SFMono-Regular,
    Menlo, Consolas, monospace;

  --text-2xs: 0.6875rem;  /* 11 */
  --text-xs: 0.75rem;     /* 12 */
  --text-sm: 0.8125rem;   /* 13 */
  --text-md: 0.875rem;    /* 14 — body */
  --text-lg: 1rem;        /* 16 */
  --text-xl: 1.125rem;    /* 18 */
  --text-2xl: 1.375rem;   /* 22 */
  --text-3xl: 1.75rem;    /* 28 */
  --text-4xl: 2.25rem;    /* 36 */

  --leading-tight: 1.2;
  --leading-snug: 1.35;
  --leading: 1.5;

  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  --tracking-tight: -0.015em;
  --tracking-caps: 0.06em;

  /* Spacing: a 4 px scale ------------------------------------------------ */
  --space-0-5: 2px;
  --space-1: 4px;
  --space-1-5: 6px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Radius --------------------------------------------------------------- */
  --radius-xs: 3px;
  --radius-sm: 5px;
  --radius-md: 7px;
  --radius-lg: 10px;
  --radius-xl: 14px;
  --radius-full: 9999px;

  /* Motion: nothing longer than 150 ms ----------------------------------- */
  --duration-fast: 90ms;
  --duration: 150ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  /* Brand mark ----------------------------------------------------------- */
  --brand-from: #5b9bff;
  --brand-to: #1d4ed8;

  /* Layout --------------------------------------------------------------- */
  --topbar-height: 56px;
  --sidebar-width: 260px;
  --content-max: 1600px;
  --control-height-sm: 28px;
  --control-height: 34px;
  --control-height-lg: 40px;

  /* Layers --------------------------------------------------------------- */
  --z-sticky: 10;
  --z-topbar: 50;
  --z-dropdown: 60;
  --z-drawer: 70;
  --z-modal: 80;
  --z-toast: 90;
  --z-tooltip: 100;
}

/* Dark theme (default) ---------------------------------------------------- */
:root,
[data-theme="dark"] {
  color-scheme: dark;

  --bg: #090d14;
  --surface-1: #0f141d;
  --surface-2: #151b26;
  --surface-3: #1c2431;
  --surface-inset: #0b1018;
  --surface-overlay: #131a25;

  --border-subtle: #18202c;
  --border: #222c3a;
  --border-strong: #324055;
  --border-control: #5a687e;

  --text: #e8edf4;
  --text-secondary: #a3aebf;
  --text-tertiary: #7f8b9d;
  --text-disabled: #4e5a6b;

  --accent: #3b82f6;
  --accent-strong: #2563eb;
  --accent-strong-hover: #3474f0;
  --accent-text: #6ea8ff;
  --accent-soft: rgb(59 130 246 / 0.14);
  --accent-soft-strong: rgb(59 130 246 / 0.24);
  --on-accent: #ffffff;

  --up: #2ebd85;
  --up-soft: rgb(46 189 133 / 0.13);
  --down: #f6555f;
  --down-soft: rgb(246 85 95 / 0.13);
  --flat: #8e9aac;

  --success: #34c27a;
  --success-soft: rgb(52 194 122 / 0.13);
  --warning: #f0b440;
  --warning-soft: rgb(240 180 64 / 0.13);
  --danger: #f6555f;
  --danger-soft: rgb(246 85 95 / 0.13);
  --danger-strong: #d93340;
  --info: #4ea8f7;
  --info-soft: rgb(78 168 247 / 0.13);

  /* Data series, in fixed order (validated for colour-vision deficiency on
     this surface; see docs/build/06). Overlays on price charts skip green and
     red, which belong to up and down. */
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
  --heat-mid: #283140;          /* a heatmap's "no change" */
  --corr-pos: #3987e5;
  --corr-neg: #d95926;

  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px rgb(59 130 246 / 0.7);
  --backdrop: rgb(3 6 11 / 0.66);
  --skeleton-base: #19212d;
  --skeleton-shine: #222c3b;

  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow-md: 0 6px 16px -4px rgb(0 0 0 / 0.5), 0 2px 4px rgb(0 0 0 / 0.3);
  --shadow-lg: 0 24px 48px -12px rgb(0 0 0 / 0.65), 0 4px 12px rgb(0 0 0 / 0.35);
  --highlight-top: inset 0 1px 0 rgb(255 255 255 / 0.04);
}

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

  --bg: #f3f5f8;
  --surface-1: #ffffff;
  --surface-2: #f6f8fb;
  --surface-3: #ebeff5;
  --surface-inset: #ffffff;
  --surface-overlay: #ffffff;

  --border-subtle: #edf0f4;
  --border: #dde3ea;
  --border-strong: #c3cdd9;
  --border-control: #7f8ca0;

  --text: #0d1625;
  --text-secondary: #46536a;
  --text-tertiary: #5f6b80;
  --text-disabled: #a7b0be;

  --accent: #2563eb;
  --accent-strong: #2563eb;
  --accent-strong-hover: #1d4fd6;
  --accent-text: #1d55d6;
  --accent-soft: rgb(37 99 235 / 0.09);
  --accent-soft-strong: rgb(37 99 235 / 0.16);
  --on-accent: #ffffff;

  --up: #057349;
  --up-soft: rgb(5 115 73 / 0.09);
  --down: #c22433;
  --down-soft: rgb(194 36 51 / 0.08);
  --flat: #5f6b80;

  --success: #0a7343;
  --success-soft: rgb(15 126 74 / 0.09);
  --warning: #9a5b00;
  --warning-soft: rgb(214 140 20 / 0.12);
  --danger: #c22433;
  --danger-soft: rgb(194 36 51 / 0.08);
  --danger-strong: #c42434;
  --info: #1964b8;
  --info-soft: rgb(29 111 196 / 0.09);

  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #6250d6;
  --series-8: #e34948;
  --heat-mid: #e3e7ee;
  --corr-pos: #2a78d6;
  --corr-neg: #eb6834;

  --focus-ring: 0 0 0 2px var(--surface-1), 0 0 0 4px rgb(37 99 235 / 0.55);
  --backdrop: rgb(15 23 42 / 0.4);
  --skeleton-base: #e9edf3;
  --skeleton-shine: #f4f6f9;

  --shadow-sm: 0 1px 2px rgb(16 24 40 / 0.06);
  --shadow-md: 0 6px 16px -4px rgb(16 24 40 / 0.1), 0 2px 4px rgb(16 24 40 / 0.05);
  --shadow-lg: 0 24px 48px -12px rgb(16 24 40 / 0.22), 0 4px 12px rgb(16 24 40 / 0.06);
  --highlight-top: none;
}

/* Colour-blind-safe market colours: blue for up, orange for down ---------- */
:root[data-updown="cb"],
[data-updown="cb"] [data-theme="dark"] {
  --up: #4ea8f7;
  --up-soft: rgb(78 168 247 / 0.14);
  --down: #f5a524;
  --down-soft: rgb(245 165 36 / 0.14);
}

:root[data-updown="cb"][data-theme="light"],
[data-updown="cb"] [data-theme="light"] {
  --up: #1d63c4;
  --up-soft: rgb(29 99 196 / 0.09);
  --down: #a85200;
  --down-soft: rgb(168 82 0 / 0.1);
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --duration-fast: 0ms;
    --duration: 0ms;
  }
}
