/* tokens.css — Central design tokens.
 * All colors, spacing and typography live here as CSS custom properties.
 * No component may hardcode values — always reference a token. */

:root {
  color-scheme: light;

  /* Colors */
  --color-primary: #1a2e4a;
  --color-primary-light: #243d63;
  --color-accent: #4a9eba;
  --color-accent-hover: #3a8aaa;
  /* RGB channels of the brand accent, for rgba() tints that need an
   * alpha. Defined once here (not per theme) so accent tints render
   * identically in light and dark, matching the previous hardcoded
   * rgba(74, 158, 186, …) values. */
  --color-accent-rgb: 74, 158, 186;
  --color-bg: #f5f7fa;
  --color-bg-alt: #ffffff;
  --color-text: #1a1a2e;
  --color-text-muted: #6b7280;
  --color-border: #e2e8f0;
  /* Card borders — a touch stronger than --color-border so cards read
   * as clearly defined without feeling heavy. */
  --color-card-border: #cdd6e1;
  /* Opaque header background once scrolled — see .op-header.is-scrolled.
   * Must be fully opaque so the fixed header reliably masks the section
   * behind it; a translucent value let the dark hero bleed through during
   * anchor jumps. */
  --glass-bg: #ffffff;

  /* Typography */
  --font-family: 'DM Sans', system-ui, sans-serif;
  --font-family-display: 'DM Serif Display', Georgia, serif;
  --font-size-base: 1rem;
  --font-size-sm: 0.875rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 2rem;
  --font-size-hero: clamp(2rem, 5vw, 3.5rem);

  /* Spacing scale */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-24: 6rem;

  /* Layout */
  --container-max: 1200px;
  --container-padding: var(--space-6);
  --border-radius: 0.5rem;
  --border-radius-lg: 1rem;
  --header-height: 64px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.10);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);

  /* Transitions */
  --transition: 200ms ease;
  --transition-slow: 400ms ease;
}

/* Dark palette.
 *
 * Applied in two cases:
 *
 * 1. data-theme="dark" — set explicitly by theme.js when the user
 *    picks Dark, or via the inline flash-prevention script when the
 *    user is in "system" mode and the OS prefers dark.
 *
 * 2. :root:not([data-theme]) inside prefers-color-scheme: dark — pure
 *    CSS fallback when JavaScript is disabled or blocked. The inline
 *    script normally sets data-theme before first paint, so this
 *    branch only runs in the JS-disabled edge case. Without it the
 *    site would force light mode on every no-JS visitor regardless of
 *    OS preference. */
[data-theme="dark"] {
  color-scheme: dark;

  --color-primary: #c5d5e8;
  --color-primary-light: #8fa8c8;
  --color-accent: #5cb8d6;
  --color-accent-hover: #7acce6;
  --color-bg: #0f1724;
  --color-bg-alt: #162032;
  --color-text: #e2e8f0;
  --color-text-muted: #94a3b8;
  --color-border: #2a3a52;
  --color-card-border: rgba(255, 255, 255, 0.14);
  --glass-bg: #0f1724;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;

    --color-primary: #c5d5e8;
    --color-primary-light: #8fa8c8;
    --color-accent: #5cb8d6;
    --color-accent-hover: #7acce6;
    --color-bg: #0f1724;
    --color-bg-alt: #162032;
    --color-text: #e2e8f0;
    --color-text-muted: #94a3b8;
    --color-border: #2a3a52;
    --color-card-border: rgba(255, 255, 255, 0.14);
    --glass-bg: #0f1724;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
  }
}
