/* LAYER 1 — PRIMITIVES (theme-independent) */

:root {
  /* Spacing scale (8px grid) */
  --space-0: 0;
  --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;
  --space-32: 128px;
  --space-40: 160px;

  /* Radii */
  --radius-none: 0;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Z-index */
  --z-base: 1;
  --z-elevated: 10;
  --z-nav: 50;
  --z-overlay: 90;
  --z-modal: 100;
  --z-toast: 200;

  /* Easing */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Duration */
  --dur-fast: 150ms;
  --dur-base: 250ms;
  --dur-slow: 400ms;
  --dur-slower: 700ms;

  /* Type scale (modular 1.25) */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;
  --text-5xl: 3rem;
  --text-6xl: 3.75rem;
  --text-7xl: 4.5rem;
  --text-8xl: 6rem;
  --text-9xl: 8rem;

  /* Line heights */
  --lh-none: 1;
  --lh-tight: 1.1;
  --lh-snug: 1.25;
  --lh-normal: 1.5;
  --lh-relaxed: 1.625;
  --lh-loose: 2;

  /* Font weights */
  --fw-light: 300;
  --fw-normal: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;
  --fw-black: 900;

  /* Letter spacing */
  --ls-tighter: -0.04em;
  --ls-tight: -0.02em;
  --ls-normal: 0;
  --ls-wide: 0.02em;
  --ls-wider: 0.08em;
  --ls-widest: 0.14em;
  --ls-deco: 0.28em;

  /* Container widths */
  --container-sm: 640px;
  --container-md: 768px;
  --container-lg: 1024px;
  --container-xl: 1280px;
  --container-2xl: 1440px;

  /* Font stacks — theme-independent fallbacks */
  --font-sys-sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-sys-serif: Georgia, Cambria, 'Times New Roman', serif;
  --font-sys-mono: ui-monospace, 'SF Mono', Monaco, Menlo, Consolas, monospace;
}

/* Media queries helper — still needs prefers-color-scheme fallback when no data-theme */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
  }
}

/* Container utilities */
.container {
  width: 100%;
  max-width: var(--container-xl);
  margin: 0 auto;
  padding-inline: var(--space-6);
}

@media (min-width: 768px) {
  .container { padding-inline: var(--space-8); }
}

.container-wide {
  width: 100%;
  max-width: var(--container-2xl);
  margin: 0 auto;
  padding-inline: var(--space-6);
}

@media (min-width: 768px) {
  .container-wide { padding-inline: var(--space-8); }
}

.container-narrow {
  width: 100%;
  max-width: var(--container-md);
  margin: 0 auto;
  padding-inline: var(--space-6);
}

/* Section base */
section {
  padding-block: var(--space-20);
  position: relative;
}

@media (min-width: 768px) {
  section { padding-block: var(--space-32); }
}

section.compact { padding-block: var(--space-16); }
