/* ---------------------------------------------------------------------------
   Design tokens — the single source of truth for every color, size and motion
   value in the design system. Components never use raw values; they read these.

   Kept in sync with Erudite (erudite/frontend/src/index.css):
   - Color tokens use the same shadcn-style names and, by default, Erudite's values
     (pink brand). A product changes its brand hue by loading a theme from
     themes/ after this file (e.g. themes/indigo.css) — never by editing components.
   - Scale tokens use Tailwind v4 theme names (--spacing, --text-*, --font-weight-*,
     --leading-*, --tracking-*, --radius-*, --shadow-*, --ease-*), so a value here
     maps 1:1 to the utility class Erudite uses: `padding: calc(var(--spacing) * 4)`
     is `p-4`, `font-size: var(--text-control)` is `text-[13px]`.

   Neutrals are true grays; there is one brand hue. Actions are neutral (near
   black); the brand marks what is active, selected or in progress. Surfaces are
   separated by 1px hairlines first; shadows are kept for overlays. Type is Geist
   and Geist Mono, with Instrument Serif italic as a display accent only.

   Dark mode is class-driven: <html class="dark"> is set before first paint by an
   inline script in the layout (see ui.js for the toggle).
--------------------------------------------------------------------------- */

/* --- Colors (light) — same names and values as Erudite ------------------------ */

:root {
  color-scheme: light;

  --background: #fafafa;
  --foreground: #0a0a0a;
  --card: #ffffff;
  --card-foreground: #0a0a0a;
  --popover: #ffffff;
  --popover-foreground: #0a0a0a;
  --muted: #f4f4f5;
  --muted-foreground: #65656d; /* ≥ 4.5:1 on --muted, --card and active nav rows */
  --secondary: #f4f4f5;
  --secondary-foreground: #18181b;
  --border: #ebebeb; /* hairlines around surfaces (≈ black 7%) */
  --line: #f0f0f0; /* dividers inside a surface: card header bands, table heads */
  --line-soft: #f4f4f5; /* row dividers */
  --border-strong: #d4d4d8; /* dashed "placeholder" outlines */
  --input: #e0e0e0; /* controls: inputs, outline buttons */
  --ring: #ec38bc;

  /* Actions are neutral; the brand marks what is active, selected or in progress. */
  --primary: #0a0a0a;
  --primary-foreground: #ffffff;
  --brand: #ec38bc; /* fills and indicators (≥ 3:1 on --card) */
  --brand-ink: #b81b8f; /* brand text (≥ 4.5:1 on --card and --accent) */
  --brand-foreground: #ffffff; /* text on a --brand fill */
  --accent: #fdeff9; /* soft brand tint for active / highlighted surfaces */
  --accent-foreground: #b81b8f;

  --destructive: #c43333; /* ≥ 4.5:1 on --danger-soft and --card */
  --destructive-foreground: #ffffff;
  --success: #137a3a;
  --success-soft: #e9f6ee;
  --warning: #a35c00;
  --warning-soft: #fdf4e3;
  --info: #1c5cab;
  --info-soft: #eaf2fc;
  --danger-soft: #fcecec;

  --sidebar: #fafafa;
  --sidebar-foreground: #3f3f46;
  --sidebar-border: #ebebeb;
  --overlay: rgb(0 0 0 / 0.4); /* dialog and drawer backdrops (Erudite: bg-black/40) */

  /* Charts (categorical order is fixed — never cycle) */
  --chart-1: #ec38bc; /* brand */
  --chart-2: #eb6834; /* orange */
  --chart-3: #1baf7a; /* aqua */
  --chart-4: #eda100; /* yellow */
  --chart-5: #2a78d6; /* blue */
  --chart-6: #008300; /* green */
  --chart-7: #4a3aa7; /* violet */
  --chart-8: #e34948; /* red */
  --chart-grid: #efefef;
  --chart-axis: #c8c8cc;
  --chart-muted: #8a8a90;
  /* Sequential single-hue ramp on the brand (100 → 700): even OKLCH lightness steps,
     so it stays monotonic (and CVD-safe). Labels on 600+ use --background ink. */
  --seq-100: #ffe2f2;
  --seq-200: #fec0e4;
  --seq-300: #fa9fd7;
  --seq-400: #f27dc8;
  --seq-500: #e55cb8;
  --seq-600: #c43c9a;
  --seq-700: #a72e82;
  /* Ordinal progress (completed → in progress → not started). In bars "not started" is
     the empty --muted track; this swatch is for legends. */
  --progress-complete: #ec38bc;
  --progress-partial: #f9c4e6;
  --progress-none: #e4e4e7;
  /* Status (reserved; always paired with icon + label) */
  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;

  /* Logo mark: a brand gradient on a near-black tile (same in both modes). */
  --logo-tile: #111113;
  --logo-stop-1: #2c1527;
  --logo-stop-2: #a72e82;
  --logo-stop-3: #ec38bc;
  --logo-stop-4: #ffe2f2;
}

/* --- Colors (dark) -------------------------------------------------------------- */

.dark {
  color-scheme: dark;

  --background: #0a0a0a;
  --foreground: #ededed;
  --card: #111111;
  --card-foreground: #ededed;
  --popover: #141414;
  --popover-foreground: #ededed;
  --muted: #1a1a1a;
  --muted-foreground: #a1a1aa;
  --secondary: #1c1c1c;
  --secondary-foreground: #ededed;
  --border: #232323;
  --line: #1d1d1d;
  --line-soft: #1a1a1a;
  --border-strong: #3a3a3d;
  --input: #2e2e2e;
  --ring: #ec38bc;

  --primary: #fafafa;
  --primary-foreground: #0a0a0a;
  --brand: #ec38bc;
  --brand-ink: #ec38bc; /* ≥ 4.5:1 on --background, --card and --accent */
  --brand-foreground: #ffffff;
  --accent: #2c1527; /* opaque, so brand ink stays ≥ 4.5:1 on it over any surface */
  --accent-foreground: #ec38bc;

  --destructive: #ef5b5b;
  --destructive-foreground: #0a0a0a;
  --success: #3ccf72;
  --success-soft: #0f2418;
  --warning: #f0b43c;
  --warning-soft: #261d0e;
  --info: #6da7ec;
  --info-soft: #0f1f33;
  --danger-soft: #2c1314;

  --sidebar: #0a0a0a;
  --sidebar-foreground: #c4c4cc;
  --sidebar-border: #232323;
  --overlay: rgb(0 0 0 / 0.6);

  --chart-1: #ec38bc;
  --chart-2: #d95926;
  --chart-3: #199e70;
  --chart-4: #c98500;
  --chart-5: #3987e5;
  --chart-6: #008300;
  --chart-7: #9085e9;
  --chart-8: #e66767;
  --chart-grid: #222222;
  --chart-axis: #3a3a3d;
  --chart-muted: #8c8c94;
  --seq-100: #451e37;
  --seq-200: #5e244b;
  --seq-300: #79295f;
  --seq-400: #8f2f70;
  --seq-500: #a23a80;
  --seq-600: #db5ab0;
  --seq-700: #f392ce;
  --progress-complete: #ec38bc;
  --progress-partial: #a23a80;
  --progress-none: #3a3a3d;

  --shadow-lg: 0 12px 32px -8px rgb(0 0 0 / 0.5), 0 4px 8px -4px rgb(0 0 0 / 0.3);
  --shadow-xl: 0 24px 48px -12px rgb(0 0 0 / 0.6);
}

/* --- Scales — Tailwind v4 theme names, Erudite's values (same in both modes) ---- */

:root {
  --font-sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --font-serif: "Instrument Serif", Georgia, serif;

  /* Spacing: every gap, padding, margin and size is a multiple of this unit,
     written calc(var(--spacing) * n) — the same n as Erudite's p-n / gap-n / h-n. */
  --spacing: 0.25rem; /* 4px */

  /* Type scale. Tailwind's steps plus the fixed sizes Erudite uses as arbitrary values. */
  --text-3xs: 0.625rem; /* 10 — Erudite text-[10px]: counters inside chips */
  --text-2xs: 0.6875rem; /* 11 — Erudite text-[11px]: label-caps, meta */
  --text-xs: 0.75rem; /* 12 */
  --text-control: 0.8125rem; /* 13 — Erudite text-[13px]: controls, table cells, menus */
  --text-sm: 0.875rem; /* 14 — body */
  --text-md: 0.9375rem; /* 15 — Erudite text-[15px]: large buttons, reading text */
  --text-base: 1rem; /* 16 */
  --text-lead: 1.0625rem; /* 17 — Erudite text-[17px]: dialog and section titles */
  --text-lg: 1.125rem; /* 18 */
  --text-xl: 1.25rem; /* 20 */
  --text-2xl: 1.5rem; /* 24 */
  --text-3xl: 1.875rem; /* 30 */
  /* Named roles: size / line height / tracking / weight travel together. */
  --text-display: clamp(2.75rem, 7vw, 5.25rem); /* 44 → 84 */
  --text-display--line-height: 1.02;
  --text-display--letter-spacing: -0.035em;
  --text-display--font-weight: 500;
  --text-display-sm: clamp(2.25rem, 5.4vw, 3.75rem); /* 36 → 60, closing calls to action */
  --text-display-sm--line-height: 1.03;
  --text-display-sm--letter-spacing: -0.035em;
  --text-display-sm--font-weight: 500;
  --text-section: clamp(2rem, 4.4vw, 3rem); /* 32 → 48, landing section titles */
  --text-section--line-height: 1.05;
  --text-section--letter-spacing: -0.03em;
  --text-section--font-weight: 500;
  --text-page-title: 2rem; /* 32 */
  --text-page-title--line-height: 1.1;
  --text-page-title--letter-spacing: -0.035em;
  --text-page-title--font-weight: 500;
  --text-metric: 1.75rem; /* 28, tabular */
  --text-metric--line-height: 1;
  --text-metric--letter-spacing: -0.03em;
  --text-metric--font-weight: 500;
  --text-card-title: 0.9375rem; /* 15 */
  --text-card-title--line-height: 1.35;
  --text-card-title--letter-spacing: -0.01em;
  --text-card-title--font-weight: 600;

  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  --leading-none: 1;
  --leading-tight: 1.25;
  --leading-snug: 1.35;
  --leading-normal: 1.5;
  --leading-relaxed: 1.6;
  --leading-loose: 1.7; /* reading text */

  --tracking-tighter: -0.035em; /* display and page titles */
  --tracking-tight: -0.03em; /* metrics, section titles */
  --tracking-snug: -0.02em; /* wordmark */
  --tracking-heading: -0.015em; /* dialog and card headings */
  --tracking-subtle: -0.01em; /* card titles, serif accent */
  --tracking-normal: 0;
  --tracking-caps: 0.04em; /* label-caps */

  /* chip 5 · control 8 · large button 10 · card 14 · auth card / frame 16 */
  --radius: 0.625rem;
  --radius-xs: 3px; /* checkmarks and other tiny marks */
  --radius-sm: 5px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 14px;
  --radius-2xl: 16px;
  --radius-full: 9999px;

  /* Elevation is for overlays only. */
  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.06); /* the selected segment of a segmented control */
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.05), 0 1px 2px -1px rgb(0 0 0 / 0.04);
  --shadow-md: 0 4px 12px -2px rgb(0 0 0 / 0.06), 0 2px 4px -2px rgb(0 0 0 / 0.04);
  --shadow-lg: 0 12px 32px -8px rgb(0 0 0 / 0.1), 0 4px 8px -4px rgb(0 0 0 / 0.04);
  --shadow-xl: 0 24px 48px -12px rgb(0 0 0 / 0.18);

  /* Focus: Erudite's focus-visible:ring-[3px] ring-ring/40 (buttons) and ring-ring/15 (fields). */
  --ring-width: 3px;
  --focus-ring: 0 0 0 var(--ring-width) color-mix(in srgb, var(--ring) 40%, transparent);
  --focus-ring-field: 0 0 0 var(--ring-width) color-mix(in srgb, var(--ring) 15%, transparent);
  --focus-ring-invalid: 0 0 0 var(--ring-width) color-mix(in srgb, var(--destructive) 20%, transparent);

  --opacity-disabled: 0.5;

  /* Motion */
  --default-transition-duration: 150ms;
  --duration-slow: 200ms;
  --duration-progress: 500ms;
  --blur-overlay: 2px; /* dialog backdrop (Erudite: backdrop-blur-[2px]) */
  --blur-topbar: 12px; /* translucent sticky top bar */
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);

  /* Stacking order */
  --z-raised: 1;
  --z-sticky: 20; /* top bar, sticky table heads */
  --z-backdrop: 35; /* mobile sidebar backdrop */
  --z-sidebar: 40;
  --z-popover: 50; /* menus, popovers */
  --z-skip-link: 60;

  /* Widths — Tailwind's container scale (max-w-sm … max-w-2xl) */
  --container-sm: 24rem;
  --container-md: 28rem;
  --container-lg: 32rem; /* dialogs */
  --container-xl: 36rem;
  --container-2xl: 42rem;
  --container-3xl: 48rem; /* narrow public pages */
  --container-5xl: 64rem;
  --container-prose: 40rem; /* readable line length on public pages */

  /* Breakpoints (media queries can't read custom properties; use these literal
     values): sm 640px · md 768px · lg 1024px, plus 900px and 1100px for wide grids. */

  /* Layout */
  --sidebar-width: 240px;
  --topbar-height: 60px;
  --content-max: 1240px;
}
