/* ===== base.css — Reset, tokens, typography ===== */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* --- Palette --- */
  --color-bg:       #f8fafc;
  --color-text:     #0f172a;
  --color-text-muted: #64748b;
  --color-primary:  #6366f1;
  --color-primary-hover: #4f46e5;
  --color-primary-soft: rgba(99,102,241,.08);
  --color-secondary: #2563eb;
  --color-border:   #e2e8f0;
  --color-surface:  #ffffff;
  --color-surface-elevated: #ffffff;
  --color-success:  #10b981;
  --color-danger:   #ef4444;
  --color-code-bg:  #f1f5f9;

  /* --- Spacing --- */
  --space-0: .25rem;
  --space-1: .5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2rem;
  --space-5: 3rem;
  --space-6: 4rem;

  /* --- Radius --- */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* --- Shadows --- */
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow:    0 2px 8px rgba(0,0,0,.06), 0 0 1px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,.08), 0 0 1px rgba(0,0,0,.06);
  --shadow-glow: 0 0 20px rgba(99,102,241,.15);

  /* --- Typography --- */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  --line-height: 1.65;
  --line-height-tight: 1.3;

  /* --- Transitions --- */
  --ease: cubic-bezier(.4, 0, .2, 1);
  --duration: 200ms;
  --duration-slow: 350ms;
}

/* ===== Dark Theme ===== */
[data-theme="dark"] {
  --color-bg:       #0c0f1a;
  --color-text:     #e2e8f0;
  --color-text-muted: #94a3b8;
  --color-primary:  #818cf8;
  --color-primary-hover: #a5b4fc;
  --color-primary-soft: rgba(129,140,248,.1);
  --color-border:   #1e293b;
  --color-surface:  #141827;
  --color-surface-elevated: #1a1f36;
  --color-code-bg:  #1e293b;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --shadow:    0 2px 8px rgba(0,0,0,.3), 0 0 1px rgba(0,0,0,.4);
  --shadow-lg: 0 8px 30px rgba(0,0,0,.4), 0 0 1px rgba(0,0,0,.3);
  --shadow-glow: 0 0 25px rgba(129,140,248,.15);
}

/* ===== Base ===== */
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: var(--line-height);
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--duration-slow) var(--ease),
              color var(--duration-slow) var(--ease);
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--duration) var(--ease);
}
a:hover { color: var(--color-primary-hover); }

h1, h2, h3, h4, h5, h6 {
  line-height: var(--line-height-tight);
  font-weight: 700;
  color: var(--color-text);
}
h1 { font-size: clamp(2rem, 5vw, 3rem);    letter-spacing: -.025em; }
h2 { font-size: clamp(1.35rem, 3vw, 1.75rem); letter-spacing: -.015em; }
h3 { font-size: 1.15rem; }

p  { max-width: 65ch; }
code, pre { font-family: var(--font-mono); }

img { max-width: 100%; display: block; }
ul, ol { padding-left: 1.25em; }

/* Focus ring */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Screen-reader only */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* Skip link */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-2);
  background: var(--color-primary);
  color: #fff;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  z-index: 9999;
  font-weight: 600;
  transition: top var(--duration) var(--ease);
}
.skip-link:focus {
  top: var(--space-2);
}

/* Container utility */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-3);
}
