/* Design tokens — the single source of truth for color, type, space, shape,
   motion, and layering. Everything else in the app references these variables;
   no component hardcodes a raw color or size. Light is the default; dark is
   applied via [data-theme="dark"] and mirrored to the OS preference. */

:root {
  /* ---- Brand palette (theme-independent seeds) ---- */
  --brand-primary: #5b3df5;
  --brand-primary-strong: #4a2fd6;
  --brand-secondary: #17c3b2;
  --brand-accent: #ff7a59;

  /* ---- Semantic colors (light) ---- */
  --color-bg: #ffffff;
  --color-surface: #f7f7fb;
  --color-surface-2: #eef0f6;
  --color-text: #14141f;
  --color-text-secondary: #3c3c50;
  --color-text-muted: #6b6b80;
  --color-border: #e2e2ec;
  --color-border-strong: #ccccd8;

  --color-brand: var(--brand-primary);
  --color-brand-strong: var(--brand-primary-strong);
  --color-brand-contrast: #ffffff;
  --color-secondary: var(--brand-secondary);
  --color-accent: var(--brand-accent);

  --color-success: #0e9f6e;
  --color-warning: #b4690e;
  --color-error: #d32f2f;
  --color-focus: #5b3df5;

  --color-on-brand: #ffffff;
  --color-link: var(--brand-primary-strong);

  /* ---- Per-product accents ---- */
  --product-zornux: #5b3df5;
  --product-zoijs: #0f9e90;
  --product-zorise: #d9603f;

  /* ---- Section treatments ---- */
  --color-section-alt: #f4f4fa;
  --gradient-brand: linear-gradient(120deg, var(--color-brand), var(--color-secondary));
  --gradient-surface: linear-gradient(
    180deg,
    var(--color-surface),
    color-mix(in srgb, var(--color-brand) 5%, var(--color-surface))
  );

  /* ---- Typography ---- */
  --font-sans:
    "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono:
    "JetBrains Mono", ui-monospace, "SF Mono", "Cascadia Code", "Fira Code", Menlo, Consolas,
    monospace;

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

  /* Fluid heading + body scale */
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.375rem;
  --font-size-2xl: clamp(1.6rem, 1.2rem + 1.6vw, 2rem);
  --font-size-3xl: clamp(2rem, 1.4rem + 2.6vw, 2.75rem);
  --font-size-4xl: clamp(2.5rem, 1.6rem + 4vw, 3.75rem);

  --line-height-tight: 1.15;
  --line-height-snug: 1.3;
  --line-height-normal: 1.6;

  --letter-spacing-tight: -0.02em;
  --letter-spacing-normal: 0;
  --letter-spacing-wide: 0.06em;

  /* ---- Spacing scale (0.25rem base) ---- */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4rem;
  --space-9: 6rem;
  --space-10: 8rem;

  /* ---- Layout ---- */
  --layout-content-width: 72rem;
  --layout-content-width-narrow: 44rem;
  --layout-header-height: 4rem;
  --layout-section-spacing: var(--space-9);
  --layout-gutter: var(--space-5);

  /* ---- Breakpoints (documentation; used in media queries) ---- */
  --breakpoint-sm: 40rem;
  --breakpoint-md: 48rem;
  --breakpoint-lg: 64rem;
  --breakpoint-xl: 80rem;

  /* ---- Shape ---- */
  --radius-sm: 0.375rem;
  --radius-md: 0.625rem;
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;
  --radius-full: 999px;
  --border-width: 1px;
  --border-width-thick: 2px;

  /* ---- Effects ---- */
  --shadow-sm: 0 1px 2px rgba(20, 20, 31, 0.06);
  --shadow-md: 0 4px 16px rgba(20, 20, 31, 0.08);
  --shadow-lg: 0 12px 40px rgba(20, 20, 31, 0.12);
  --shadow-focus: 0 0 0 3px color-mix(in srgb, var(--color-focus) 45%, transparent);

  --transition-fast: 120ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 320ms ease;

  /* ---- Layering ---- */
  --z-base: 0;
  --z-header: 100;
  --z-scrim: 200;
  --z-drawer: 300;
  --z-toast: 400;
  --z-skip-link: 500;
}

/* ---- Dark theme ---- */
:root[data-theme="dark"] {
  --color-bg: #0d0d14;
  --color-surface: #16161f;
  --color-surface-2: #1f1f2b;
  --color-text: #f2f2f7;
  --color-text-secondary: #c7c7d4;
  --color-text-muted: #9494a6;
  --color-border: #2a2a38;
  --color-border-strong: #3a3a4c;

  --brand-primary: #7c66ff;
  --color-brand: #7c66ff;
  --color-brand-strong: #6a52f0;
  --color-link: #a898ff;
  --color-secondary: #2fd6c4;
  --color-accent: #ff8f73;

  --color-success: #34d399;
  --color-warning: #e0a94b;
  --color-error: #f26d6d;
  --color-focus: #a898ff;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.6);

  --product-zornux: #8b6cff;
  --product-zoijs: #2fd6c4;
  --product-zorise: #ff9e73;
  --color-section-alt: #12121b;
}

/* Follow the OS preference when the user has not chosen a theme explicitly.
   The inline script in index.html stamps [data-theme] before paint; this block
   covers first-paint before JS and keeps SSR/no-JS visitors in sync. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #0d0d14;
    --color-surface: #16161f;
    --color-surface-2: #1f1f2b;
    --color-text: #f2f2f7;
    --color-text-secondary: #c7c7d4;
    --color-text-muted: #9494a6;
    --color-border: #2a2a38;
    --color-border-strong: #3a3a4c;
    --color-brand: #7c66ff;
    --color-brand-strong: #6a52f0;
    --color-link: #a898ff;
    --color-focus: #a898ff;
    --product-zornux: #8b6cff;
    --product-zoijs: #2fd6c4;
    --product-zorise: #ff9e73;
    --color-section-alt: #12121b;
  }
}
