/* ═══════════════════════════════════════════════════════════════
   Sentinel Design Tokens
   Source: docs/DESIGN_BRIEF.md §6
   Three theme scopes: dark (default), light, terminal (Bloomberg amber)
   ═══════════════════════════════════════════════════════════════ */

/* ─── Dark theme (Obsidian-teal) ─── */
.theme-dark {
  --bg-0: #0A0B0D;
  --bg-1: #1A1B20;
  --bg-2: #1F2028;
  --bg-3: #282A33;

  --fg-primary: #F4F5F7;
  --fg-secondary: #C5CAD1;
  --fg-tertiary: #8A93A0;
  --fg-muted: #5B6472;
  --fg-disabled: #3A3F48;

  --border-subtle: #242730;
  --border-strong: #2E3340;
  --border-focus: #2DD4BF;

  --accent: #2DD4BF;
  --accent-hover: #5EEAD4;
  --accent-press: #14B8A6;
  --focus-ring: #2DD4BF;

  --positive: #2FBF71;
  --positive-muted: #1E6B44;
  --positive-bg: #102B1E;
  --negative: #F05A5A;
  --negative-muted: #7A2A2A;
  --negative-bg: #2B1215;
  --warning: #E8A33D;
  --warning-bg: #2A1F0E;
  --info: #5AA8F0;
  --info-bg: #0E1F2E;
  --neutral: #8A93A0;

  --overlay: rgba(6, 7, 9, 0.78);

  /* Finance-specific tokens */
  --fin-gain: #2FBF71;
  --fin-loss: #F05A5A;
  --fin-neutral: #8A93A0;

  /* Surface system */
  --surface-card-shadow:
    rgba(14, 63, 126, 0.04) 0px 0px 0px 1px,
    rgba(42, 51, 69, 0.04) 0px 1px 1px -0.5px,
    rgba(42, 51, 70, 0.04) 0px 3px 3px -1.5px,
    rgba(42, 51, 70, 0.04) 0px 6px 6px -3px,
    rgba(14, 63, 126, 0.04) 0px 12px 12px -6px,
    rgba(14, 63, 126, 0.04) 0px 24px 24px -12px;
  --glow-accent: 0 0 20px -4px rgba(45, 212, 191, 0.12), 0 0 40px -8px rgba(45, 212, 191, 0.06);
  --glow-accent-sm: 0 0 12px -2px rgba(45, 212, 191, 0.08);

  /* Chart palette — Okabe-Ito, dark-tuned, colour-blind safe */
  --chart-cat-1: #56B4E9;
  --chart-cat-2: #E69F00;
  --chart-cat-3: #009E73;
  --chart-cat-4: #F0E442;
  --chart-cat-5: #0072B2;
  --chart-cat-6: #D55E00;
  --chart-cat-7: #CC79A7;
  --chart-cat-8: #BBBBBB;

  /* Sequential (dark-mode) */
  --chart-seq-1: #0D1E3A;
  --chart-seq-2: #163B66;
  --chart-seq-3: #1D5A8E;
  --chart-seq-4: #2F7FB8;
  --chart-seq-5: #56A3D1;
  --chart-seq-6: #8AC5E0;
  --chart-seq-7: #C2E0EC;
  --chart-seq-8: #F5FAF9;

  /* Diverging (RdBu 11-step) — dark-neutral midpoint, NOT bg-matching */
  --chart-div-1: #053061;
  --chart-div-2: #2166AC;
  --chart-div-3: #4393C3;
  --chart-div-4: #92C5DE;
  --chart-div-5: #D1E5F0;
  --chart-div-6: #3A3F48;
  --chart-div-7: #FDDBC7;
  --chart-div-8: #F4A582;
  --chart-div-9: #D6604D;
  --chart-div-10: #B2182B;
  --chart-div-11: #67001F;

  /* Chart grid and axes */
  --chart-axis-line: rgba(255, 255, 255, 0.14);
  --chart-axis-tick: rgba(255, 255, 255, 0.22);
  --chart-grid-major: rgba(255, 255, 255, 0.06);
  --chart-grid-minor: rgba(255, 255, 255, 0.03);
  --chart-axis-label: #8A93A0;
  --chart-zero-line: rgba(255, 255, 255, 0.32);
  --chart-crosshair: rgba(255, 255, 255, 0.48);
}

/* ─── Light theme ─── */
.theme-light {
  --bg-0: #FFFFFF;
  --bg-1: #F7F8FA;
  --bg-2: #F0F2F5;
  --bg-3: #E6E9EE;

  --fg-primary: #0B0C0E;
  --fg-secondary: #3A3F48;
  --fg-tertiary: #5B6472;
  --fg-muted: #8A93A0;
  --fg-disabled: #C0C5CD;

  --border-subtle: #E6E9EE;
  --border-strong: #CDD2DA;
  --border-focus: #0D9488;

  --accent: #0D9488;
  --accent-hover: #14B8A6;
  --accent-press: #0F766E;
  --focus-ring: #0D9488;

  --positive: #117A3D;
  --positive-muted: #BFE3CC;
  --positive-bg: #E8F6EE;
  --negative: #C8322E;
  --negative-muted: #F2C2C0;
  --negative-bg: #FBECEB;
  --warning: #B2740A;
  --warning-bg: #FBF1DC;
  --info: #0F5499;
  --info-bg: #E4EEF8;
  --neutral: #5B6472;

  --overlay: rgba(11, 12, 14, 0.48);

  --chart-cat-1: #56B4E9;
  --chart-cat-2: #E69F00;
  --chart-cat-3: #009E73;
  --chart-cat-4: #F0E442;
  --chart-cat-5: #0072B2;
  --chart-cat-6: #D55E00;
  --chart-cat-7: #CC79A7;
  --chart-cat-8: #BBBBBB;

  --chart-seq-1: #FFFFE5;
  --chart-seq-2: #FFF7BC;
  --chart-seq-3: #FEE391;
  --chart-seq-4: #FEC44F;
  --chart-seq-5: #FE9929;
  --chart-seq-6: #EC7014;
  --chart-seq-7: #CC4C02;
  --chart-seq-8: #8C2D04;

  --chart-div-1: #053061;
  --chart-div-2: #2166AC;
  --chart-div-3: #4393C3;
  --chart-div-4: #92C5DE;
  --chart-div-5: #D1E5F0;
  --chart-div-6: #F7F7F7;
  --chart-div-7: #FDDBC7;
  --chart-div-8: #F4A582;
  --chart-div-9: #D6604D;
  --chart-div-10: #B2182B;
  --chart-div-11: #67001F;

  --chart-axis-line: rgba(0, 0, 0, 0.14);
  --chart-axis-tick: rgba(0, 0, 0, 0.22);
  --chart-grid-major: rgba(0, 0, 0, 0.06);
  --chart-grid-minor: rgba(0, 0, 0, 0.03);
  --chart-axis-label: #5B6472;
  --chart-zero-line: rgba(0, 0, 0, 0.32);
  --chart-crosshair: rgba(0, 0, 0, 0.48);
}

/* ─── Terminal theme (Bloomberg amber on pure black) ─── */
.theme-terminal {
  --bg-0: #000000;
  --bg-1: #0A0A0A;
  --bg-2: #141414;
  --bg-3: #1E1E1E;

  --fg-primary: #F4F5F7;
  --fg-secondary: #C5CAD1;
  --fg-tertiary: #8A93A0;
  --fg-muted: #5B6472;
  --fg-disabled: #3A3F48;

  --border-subtle: #1E1E1E;
  --border-strong: #2A2A2A;
  --border-focus: #FFA028;

  --accent: #FFA028;
  --accent-hover: #FFB14D;
  --accent-press: #E88A15;
  --focus-ring: #FFA028;

  --positive: #2FBF71;
  --positive-muted: #1E6B44;
  --positive-bg: #0A1F10;
  --negative: #FF433D;
  --negative-muted: #7A2020;
  --negative-bg: #2B0A0A;
  --warning: #E8A33D;
  --warning-bg: #2A1F0E;
  --info: #5AA8F0;
  --info-bg: #0A1A2E;
  --neutral: #8A93A0;

  --overlay: rgba(0, 0, 0, 0.80);

  --chart-cat-1: #56B4E9;
  --chart-cat-2: #FFA028;
  --chart-cat-3: #009E73;
  --chart-cat-4: #F0E442;
  --chart-cat-5: #0072B2;
  --chart-cat-6: #D55E00;
  --chart-cat-7: #CC79A7;
  --chart-cat-8: #BBBBBB;

  --chart-axis-line: rgba(255, 255, 255, 0.14);
  --chart-axis-tick: rgba(255, 255, 255, 0.22);
  --chart-grid-major: rgba(255, 255, 255, 0.06);
  --chart-grid-minor: rgba(255, 255, 255, 0.03);
  --chart-axis-label: #8A93A0;
  --chart-zero-line: rgba(255, 255, 255, 0.32);
  --chart-crosshair: rgba(255, 255, 255, 0.48);
}

/* ─── Typography tokens ─── */
:root {
  --font-sans: "DM Sans", "Inter", -apple-system, BlinkMacSystemFont,
               "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", "IBM Plex Mono", "Geist Mono",
               ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --font-display: "DM Sans", "Inter", var(--font-sans);
  --font-heading: "Outfit", "DM Sans", var(--font-sans);

  /* Type scale (13px base) */
  --text-2xs-size: 11px;  --text-2xs-lh: 14px;  --text-2xs-weight: 500; --text-2xs-ls: 0.01em;
  --text-xs-size: 12px;   --text-xs-lh: 16px;   --text-xs-weight: 500;  --text-xs-ls: 0.005em;
  --text-sm-size: 13px;   --text-sm-lh: 18px;   --text-sm-weight: 400;  --text-sm-ls: 0;
  --text-base-size: 13px; --text-base-lh: 20px;  --text-base-weight: 400; --text-base-ls: 0;
  --text-md-size: 14px;   --text-md-lh: 22px;   --text-md-weight: 400;  --text-md-ls: 0;
  --text-lg-size: 16px;   --text-lg-lh: 24px;   --text-lg-weight: 500;  --text-lg-ls: -0.005em;
  --text-xl-size: 18px;   --text-xl-lh: 26px;   --text-xl-weight: 600;  --text-xl-ls: -0.01em;
  --text-2xl-size: 22px;  --text-2xl-lh: 28px;  --text-2xl-weight: 600; --text-2xl-ls: -0.015em;
  --text-3xl-size: 28px;  --text-3xl-lh: 34px;  --text-3xl-weight: 600; --text-3xl-ls: -0.02em;
  --text-4xl-size: 36px;  --text-4xl-lh: 42px;  --text-4xl-weight: 700; --text-4xl-ls: -0.025em;

  /* Line heights */
  --lh-dense: 1.2;
  --lh-tight: 1.3;
  --lh-body: 1.5;
  --lh-heading: 1.15;

  /* ─── Spacing (4px base) ─── */
  --space-0: 0;
  --space-0-5: 2px;
  --space-1: 4px;
  --space-1-5: 6px;
  --space-2: 8px;
  --space-2-5: 10px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-20: 80px;
  --space-24: 96px;

  /* ─── Motion ─── */
  --dur-instant: 0ms;
  --dur-fast: 120ms;
  --dur-base: 200ms;
  --dur-slow: 320ms;
  --dur-crawl: 480ms;

  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --ease-enter: cubic-bezier(0, 0, 0.2, 1);
  --ease-exit: cubic-bezier(0.4, 0, 1, 1);
  --ease-emphasized: cubic-bezier(0.2, 0, 0, 1.1);

  /* ─── Layout ─── */
  --max-width-landing: 1440px;
  --max-width-prose: 720px;
  --max-width-feature: 1040px;
  --gutter-landing: 24px;
  --gutter-app: 8px;
  --outer-margin: 32px;

  /* ─── Density modes ─── */
  --row-compact: 24px;
  --row-standard: 32px;
  --row-comfortable: 40px;

  /* ─── Panel radius + elevation ─── */
  --panel-radius-sm: 4px;
  --panel-radius-md: 6px;
  --panel-radius-lg: 10px;
  --panel-radius-xl: 16px;
  --elevation-1: 0 1px 2px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.12);
  --elevation-2: 0 2px 4px rgba(0, 0, 0, 0.10), 0 12px 32px rgba(0, 0, 0, 0.18);

  /* ─── Chrome ─── */
  --topbar-height: 48px;
  --header-height: 64px;
  --tab-bar-height: 44px;
}

/* Terminal theme runs deeper shadow on pure black */
.theme-terminal {
  --elevation-1: 0 1px 2px rgba(0, 0, 0, 0.35), 0 6px 18px rgba(0, 0, 0, 0.45);
  --elevation-2: 0 2px 4px rgba(0, 0, 0, 0.40), 0 16px 40px rgba(0, 0, 0, 0.55);
}

/* Light theme softens elevation to stay below content weight */
.theme-light {
  --elevation-1: 0 1px 1px rgba(10, 12, 16, 0.04), 0 2px 6px rgba(10, 12, 16, 0.06);
  --elevation-2: 0 1px 2px rgba(10, 12, 16, 0.06), 0 6px 18px rgba(10, 12, 16, 0.09);
}

/* ─── Responsive token overrides ─── */

@media (max-width: 640px) {
  :root,
  .theme-dark,
  .theme-light,
  .theme-terminal {
    --outer-margin: 16px;
    --gutter-app: 4px;
    --topbar-height: 44px;
    --space-5: 16px;
    --space-6: 20px;
  }
}

@media (max-width: 480px) {
  :root,
  .theme-dark,
  .theme-light,
  .theme-terminal {
    --outer-margin: 12px;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-fast: 0.01ms;
    --dur-base: 0.01ms;
    --dur-slow: 0.01ms;
    --dur-crawl: 0.01ms;
  }
}
