/* CryptoGraph design tokens v2 — "Graphite Cobalt" (docs/DESIGN_SYSTEM.md).
   Two brand colours: graphite surfaces + cobalt accent. Long / short / liquidation are
   semantic colours, never decoration. Every theme keeps the same token names, so
   components never hard-code colours. Contrast is verified by tools/contrast_check.py. */

/* ---------- theme-independent scale ---------- */
:root {
  /* fonts: Inter for UI, JetBrains Mono with tabular figures for every number */
  --sans: "Inter", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", Consolas, ui-monospace, monospace;
  --display: "Inter", "Segoe UI", system-ui, sans-serif;

  /* type scale (px) */
  --fs-2xs: 11px;
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 14px;
  --fs-lg: 16px;
  --fs-xl: 20px;
  --fs-2xl: 28px;

  /* 4/8 spacing grid */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;
  --s8: 64px;

  /* radii: controls, cards, sheets, pills */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-pill: 999px;

  /* control heights */
  --h-xs: 24px;
  --h-sm: 28px;
  --h-md: 32px;
  --h-lg: 40px;

  /* motion: 120–200 ms, one easing curve */
  --backdrop: #03050999;
  --shadow-inset: 0 1px 0 #0000003D;
  /* watchlist tag dots: categorical, same in every theme */
  --tag-red: #E35D6A; --tag-orange: #E0913C; --tag-yellow: #D4B02C;
  --tag-green: #3EA072; --tag-blue: #4A7FD4; --tag-purple: #8B6CC4; --tag-pink: #D46BA3;
  --dur-fast: 120ms;
  --dur: 160ms;
  --dur-slow: 200ms;
  --ease: cubic-bezier(.2, .7, .2, 1);

  /* layering */
  --z-popover: 40;
  --z-dialog: 60;
  --z-toast: 80;

  /* terminal layout */
  --left: 268px;
  --right: 320px;
  --bottom: 240px;
  --side: var(--right);
  --topbar-h: 48px;
  --tools-h: 40px;
  --draw-w: 48px;
  --motion: var(--dur);
}

/* ---------- Graphite Cobalt (default) ---------- */
:root, [data-theme="graphite"] {
  color-scheme: dark;
  --bg: #07090D;
  --panel: #0D1016;
  --panel2: #131720;
  --surface3: #1A1F29;
  --chart-bg: #0A0D12;
  --border: #1E232D;
  --border-strong: #2A303C;
  --rule: #161A22;
  --text: #E6EAF0;
  --muted: #8B93A1;
  --soft: #7D8696;
  --accent: #3D6BFF;
  --accent-hover: #5A82FF;
  --accent-fill: #3461F0;
  --accent-soft: #3D6BFF24;
  --btn-fg: #FFFFFF;
  --green: #2EBD85;
  --red: #F6465D;
  --warning: #F5A524;
  --long: var(--green);
  --short: var(--red);
  --liq: var(--warning);
  --neutral: var(--muted);
  --on-long: #04130C;
  --on-short: #1A0306;
  --long-soft: #2EBD851F;
  --short-soft: #F6465D1F;
  --warning-soft: #F5A5241F;
  --orange: var(--warning);
  --yellow: var(--warning);
  --ai: #7C9BFF;
  --ai-text: #A9BCFF;
  --ai-dim: #7C9BFF1F;
  --disabled: #3A414D;
  --hover: #151A23;
  --selected: #16213D;
  --grid-line: #11151C;
  --focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
  --shadow-1: 0 8px 24px #0000007A, 0 1px 0 #FFFFFF08 inset;
  --shadow-2: 0 24px 64px #000000A8, 0 1px 0 #FFFFFF0A inset;
}

/* ---------- Low-Glare: dimmer, warmer, no animation ---------- */
[data-theme="low-glare"] {
  color-scheme: dark;
  --bg: #0A0B0E;
  --panel: #0F1115;
  --panel2: #14171C;
  --surface3: #1A1E24;
  --chart-bg: #0C0E12;
  --border: #1F232A;
  --border-strong: #2A2F37;
  --rule: #171A1F;
  --text: #CDD2DA;
  --muted: #8A919C;
  --soft: #7E8796;
  --accent: #5B7BD6;
  --accent-hover: #6E8BDD;
  --accent-fill: #4A68C4;
  --accent-soft: #5B7BD624;
  --btn-fg: #FFFFFF;
  --green: #3E9C78;
  --red: #D0646B;
  --warning: #C9923A;
  --long: var(--green);
  --short: var(--red);
  --liq: var(--warning);
  --neutral: var(--muted);
  --on-long: #04130C;
  --on-short: #1A0306;
  --long-soft: #3E9C781F;
  --short-soft: #D0646B1F;
  --warning-soft: #C9923A1F;
  --orange: var(--warning);
  --yellow: var(--warning);
  --ai: #8DA3E0;
  --ai-text: #9DB0E8;
  --ai-dim: #8DA3E01F;
  --disabled: #3A3F48;
  --hover: #16191F;
  --selected: #1A2235;
  --grid-line: #121418;
  --focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
  --shadow-1: 0 8px 24px #00000080;
  --shadow-2: 0 24px 64px #000000AA;
  --motion: 0s;
}

/* ---------- High Contrast ---------- */
[data-theme="high-contrast"] {
  color-scheme: dark;
  --bg: #000000;
  --panel: #05070A;
  --panel2: #0D1117;
  --surface3: #141A22;
  --chart-bg: #000000;
  --border: #5B6474;
  --border-strong: #8A93A3;
  --rule: #3A4250;
  --text: #FFFFFF;
  --muted: #C5CBD6;
  --soft: #8A93A3;
  --accent: #7C9BFF;
  --accent-hover: #9DB3FF;
  --accent-fill: #7C9BFF;
  --accent-soft: #7C9BFF33;
  --btn-fg: #000000;
  --green: #3DDC97;
  --red: #FF6B7D;
  --warning: #FFC046;
  --long: var(--green);
  --short: var(--red);
  --liq: var(--warning);
  --neutral: var(--muted);
  --on-long: #000000;
  --on-short: #000000;
  --long-soft: #3DDC9729;
  --short-soft: #FF6B7D29;
  --warning-soft: #FFC04629;
  --orange: var(--warning);
  --yellow: var(--warning);
  --ai: #A9BCFF;
  --ai-text: #C3D0FF;
  --ai-dim: #A9BCFF29;
  --disabled: #8A93A3;
  --hover: #1C2430;
  --selected: #1E3A5F;
  --grid-line: #2A3542;
  --focus: 0 0 0 2px #000000, 0 0 0 4px #FFFFFF;
  --shadow-1: 0 0 0 1px var(--border-strong);
  --shadow-2: 0 0 0 1px var(--border-strong);
}

/* ---------- Light Pro (day work) ---------- */
[data-theme="light-pro"] {
  color-scheme: light;
  --bg: #F6F7FA;
  --panel: #FFFFFF;
  --panel2: #EEF0F5;
  --surface3: #FFFFFF;
  --chart-bg: #FFFFFF;
  --border: #D5D9E2;
  --border-strong: #B9BFCC;
  --rule: #E6E9EF;
  --text: #0A0D14;
  --muted: #5B6170;
  --soft: #5F6675;
  --accent: #2A55F0;
  --accent-hover: #1F44D0;
  --accent-fill: #2A55F0;
  --accent-soft: #2A55F01A;
  --btn-fg: #FFFFFF;
  --green: #0A7F56;
  --red: #D42A44;
  --warning: #B45309;
  --long: var(--green);
  --short: var(--red);
  --liq: var(--warning);
  --neutral: var(--muted);
  --on-long: #FFFFFF;
  --on-short: #FFFFFF;
  --long-soft: #0A7F561A;
  --short-soft: #D42A441A;
  --warning-soft: #B453091A;
  --orange: var(--warning);
  --yellow: var(--warning);
  --ai: #2A55F0;
  --ai-text: #2A55F0;
  --ai-dim: #2A55F01A;
  --disabled: #B9BFCC;
  --hover: #EEF1F6;
  --selected: #E5ECFE;
  --grid-line: #EEF0F5;
  --focus: 0 0 0 2px #FFFFFF, 0 0 0 4px var(--accent);
  --shadow-1: 0 8px 24px #0A0D1414, 0 1px 2px #0A0D140F;
  --shadow-2: 0 24px 64px #0A0D1424, 0 2px 6px #0A0D1414;
}

/* ---------- motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  :root { --dur-fast: 0s; --dur: 0s; --dur-slow: 0s; --motion: 0s; }
}
[data-theme="low-glare"] *, [data-theme="low-glare"] *::before, [data-theme="low-glare"] *::after {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}

/* ---------- legacy badges (kept for existing markup; new code uses .badge from components.css) ---------- */
.badge-ai, .badge-beta, .badge-warn {
  display: inline-flex; align-items: center; gap: 4px;
  border-radius: var(--r-pill); padding: 1px 8px;
  font-size: var(--fs-2xs); font-weight: 500; line-height: 1.4; border: 1px solid;
}
.badge-ai { background: var(--ai-dim); border-color: var(--ai); color: var(--ai-text); }
.badge-beta { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.badge-warn { background: var(--warning-soft); border-color: var(--warning); color: var(--warning); }
