/* ==========================================================================
   Deckscene design tokens
   Product UI tokens (--*) and deck/slide tokens (--deck-*) are separate:
   the studio chrome follows the viewer's theme, a deck follows its template.
   Fonts: Inter Tight (display) + Inter (UI, tabular numbers) from Google Fonts.
   ========================================================================== */

:root {
  color-scheme: light;

  /* ---- Color: neutrals (light) ---- */
  --bg: #f7f7f4;
  --surface: #ffffff;
  --surface-2: #f0f0ec;
  --surface-3: #e7e7e1;
  --border: #dedcd5;
  --border-strong: #c6c4bb;
  --text: #15171c;
  --text-2: #464b57;
  --text-3: #5f6472;          /* 5.3:1 on --bg */
  --overlay: rgba(21, 23, 28, 0.48);

  /* ---- Color: accent & status ---- */
  --accent: #2b54d9;          /* 5.9:1 on white */
  --accent-hover: #2246bb;
  --accent-ink: #ffffff;
  --accent-soft: #e8edfc;
  --accent-soft-ink: #1d3a9e;
  --success: #17724a;
  --success-soft: #e3f3ea;
  --warning: #8f5200;
  --warning-soft: #fbf0dc;
  --danger: #b8322b;
  --danger-soft: #fbe7e5;
  --focus: #2b54d9;

  /* ---- Color: data (chart series, order matters) ---- */
  --data-1: #2b54d9;
  --data-2: #0f8f7c;
  --data-3: #d9772b;
  --data-4: #8a57d1;
  --data-5: #8d95a5;
  --data-grid: #e4e3dd;
  --data-axis: #6a6f7c;

  /* ---- Typography ---- */
  --font-display: "Inter Tight", "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --font-ui: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  /* Type scale (1.25 minor third-ish, clamped for display) */
  --text-xs: 0.75rem;     /* 12 — captions, badges */
  --text-sm: 0.8125rem;   /* 13 — dense UI, panel labels */
  --text-md: 0.9375rem;   /* 15 — UI body */
  --text-lg: 1.0625rem;   /* 17 — marketing body */
  --text-xl: 1.25rem;     /* 20 — card titles */
  --text-2xl: 1.5rem;     /* 24 — section sub-heads */
  --text-3xl: clamp(1.75rem, 1.2rem + 1.8vw, 2.5rem);   /* 28–40 — section titles */
  --text-4xl: clamp(2.25rem, 1.3rem + 3.6vw, 4rem);     /* 36–64 — hero */

  --leading-tight: 1.1;
  --leading-snug: 1.3;
  --leading-body: 1.55;
  --tracking-display: -0.022em;
  --tracking-caps: 0.06em;
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  /* ---- Space (4px base) ---- */
  --space-1: 4px;
  --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;
  --space-20: 80px;
  --space-24: 96px;
  --gutter: clamp(16px, 4vw, 40px);
  --content-max: 1200px;

  /* ---- Radius ---- */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 999px;

  /* ---- Shadow / elevation ---- */
  --shadow-1: 0 1px 2px rgba(21, 23, 28, 0.06), 0 0 0 1px rgba(21, 23, 28, 0.04);
  --shadow-2: 0 4px 12px rgba(21, 23, 28, 0.08), 0 1px 3px rgba(21, 23, 28, 0.06);
  --shadow-3: 0 18px 48px rgba(21, 23, 28, 0.16), 0 4px 12px rgba(21, 23, 28, 0.08);
  --ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--focus);

  /* ---- Sizes ---- */
  --control-h: 40px;        /* min touch target */
  --control-h-sm: 32px;     /* dense desktop-only controls, padded hit area */
  --header-h: 64px;

  /* ---- Motion ---- */
  --dur-instant: 80ms;      /* press, toggle */
  --dur-fast: 160ms;        /* hover, focus, small UI */
  --dur-base: 240ms;        /* panels, menus, tabs */
  --dur-slow: 420ms;        /* dialog, step change */
  --dur-chart: 900ms;       /* chart series enter */
  --dur-count: 1200ms;      /* KPI counter */
  --dur-slide: 600ms;       /* slide transition */
  --stagger: 60ms;          /* between bars / points */

  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --ease-enter: cubic-bezier(0.05, 0.7, 0.1, 1);
  --ease-exit: cubic-bezier(0.3, 0, 0.8, 0.15);
  --ease-data: cubic-bezier(0.22, 1, 0.36, 1);   /* ease-out-quint: values settle, never overshoot */
  --ease-linear: linear;

  /* ---- Deck (slide) defaults: template "Ledger" ---- */
  --deck-bg: #ffffff;
  --deck-surface: #f4f5f8;
  --deck-text: #14161b;
  --deck-text-2: #545a68;
  --deck-accent: #2b54d9;
  --deck-grid: #e6e7ec;
  --deck-font: "Inter Tight", "Inter", Arial, sans-serif;
}

/* ---- Dark theme: system preference unless user forced light ---- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e1014;
    --surface: #15181e;
    --surface-2: #1b1f27;
    --surface-3: #232833;
    --border: #2a2f3a;
    --border-strong: #3a4150;
    --text: #eceef2;
    --text-2: #b0b6c3;
    --text-3: #8f96a5;
    --overlay: rgba(0, 0, 0, 0.6);
    --accent: #7d9bff;
    --accent-hover: #99b0ff;
    --accent-ink: #0b0d12;
    --accent-soft: #1c2645;
    --accent-soft-ink: #b9c8ff;
    --success: #4cc38a;
    --success-soft: #12291f;
    --warning: #e0a84a;
    --warning-soft: #2b2112;
    --danger: #ff7b72;
    --danger-soft: #34161a;
    --focus: #99b0ff;
    --data-1: #7d9bff;
    --data-2: #3cc7b0;
    --data-3: #f0a05e;
    --data-4: #b48cf0;
    --data-5: #8d95a5;
    --data-grid: #2a2f3a;
    --data-axis: #9aa1b0;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.04);
    --shadow-2: 0 6px 16px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.04);
    --shadow-3: 0 24px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.06);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1014;
  --surface: #15181e;
  --surface-2: #1b1f27;
  --surface-3: #232833;
  --border: #2a2f3a;
  --border-strong: #3a4150;
  --text: #eceef2;
  --text-2: #b0b6c3;
  --text-3: #8f96a5;
  --overlay: rgba(0, 0, 0, 0.6);
  --accent: #7d9bff;
  --accent-hover: #99b0ff;
  --accent-ink: #0b0d12;
  --accent-soft: #1c2645;
  --accent-soft-ink: #b9c8ff;
  --success: #4cc38a;
  --success-soft: #12291f;
  --warning: #e0a84a;
  --warning-soft: #2b2112;
  --danger: #ff7b72;
  --danger-soft: #34161a;
  --focus: #99b0ff;
  --data-1: #7d9bff;
  --data-2: #3cc7b0;
  --data-3: #f0a05e;
  --data-4: #b48cf0;
  --data-5: #8d95a5;
  --data-grid: #2a2f3a;
  --data-axis: #9aa1b0;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.04);
  --shadow-2: 0 6px 16px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.04);
  --shadow-3: 0 24px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.06);
}

/* ---- Deck templates (independent of UI theme) ---- */
[data-template="ledger"] {
  --deck-bg: #ffffff; --deck-surface: #f4f5f8; --deck-text: #14161b; --deck-text-2: #545a68;
  --deck-grid: #e6e7ec; --deck-font: "Inter Tight", "Inter", Arial, sans-serif;
}
[data-template="night"] {
  --deck-bg: #11141b; --deck-surface: #1a1f2a; --deck-text: #f1f3f7; --deck-text-2: #a3abbb;
  --deck-grid: #283041; --deck-font: "Inter Tight", "Inter", Arial, sans-serif;
}
[data-template="paper"] {
  --deck-bg: #f6f1e7; --deck-surface: #ece5d6; --deck-text: #231f1a; --deck-text-2: #6a6152;
  --deck-grid: #ddd4c3; --deck-font: "Inter", Arial, sans-serif;
}

/* ---- Reduced motion: collapse durations; components also check in JS ---- */
@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-fast: 1ms; --dur-base: 1ms; --dur-slow: 1ms;
    --dur-chart: 1ms; --dur-count: 1ms; --dur-slide: 1ms; --stagger: 0ms;
  }
}
