/* base.css — Design tokens, reset, typography, dark mode, focus styles */

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

/* ===== DESIGN TOKENS ===== */
:root {
  /* Brand colors */
  --red: #DC143C;
  --red-light: #e8365a;
  --red-dark: #b91133;
  --navy: #1B2A4A;
  --navy-light: #2a3d63;

  /* Semantic colors */
  --green: #28a745;
  --green-light: #34c759;
  --orange: #f0ad4e;
  --orange-light: #f5c06d;
  --blue: #3b82f6;
  --purple: #8b5cf6;
  --pink: #ec4899;
  --teal: #14b8a6;
  --amber: #f59e0b;
  --indigo: #6366f1;
  --slate: #64748b;

  /* Feedback */
  --success: #28a745;
  --error: #dc3545;
  --warning: #f0ad4e;
  --info: #3b82f6;

  /* Light mode */
  --bg: #f5f5f5;
  --bg-alt: #eef1f5;
  --card-bg: #ffffff;
  --text: #1a1a2e;
  --text-secondary: #555;
  --text-muted: #888;
  --border: #e0e0e0;
  --input-bg: #ffffff;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-hover: 0 6px 24px rgba(0,0,0,0.12);
  --overlay: rgba(0,0,0,0.5);

  /* Typography */
  --font: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Consolas', 'Monaco', monospace;

  /* Spacing scale (4px base) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;

  /* Border radius */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* Transitions */
  --ease: 0.25s ease;

  /* Layout */
  --nav-height: 56px;
  --max-width: 1200px;
  --content-width: 800px;
}

/* ===== DARK MODE ===== */
[data-theme="dark"] {
  --bg: #0d1117;
  --bg-alt: #161b22;
  --card-bg: #161b22;
  --text: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --border: #30363d;
  --input-bg: #21262d;
  --shadow: 0 2px 12px rgba(0,0,0,0.3);
  --shadow-hover: 0 6px 24px rgba(0,0,0,0.5);
  --overlay: rgba(0,0,0,0.7);
}

/* ===== BASE STYLES ===== */
html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-height) + 16px);
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-top: var(--nav-height);
  transition: background var(--ease), color var(--ease);
}

/* ===== TYPOGRAPHY SCALE ===== */
h1 { font-size: 2rem; font-weight: 700; line-height: 1.2; color: var(--text); }
h2 { font-size: 1.5rem; font-weight: 700; line-height: 1.3; color: var(--text); }
h3 { font-size: 1.25rem; font-weight: 600; line-height: 1.4; color: var(--text); }
h4 { font-size: 1.1rem; font-weight: 600; line-height: 1.4; color: var(--text); }
h5 { font-size: 1rem; font-weight: 600; line-height: 1.5; color: var(--text); }

p { margin-bottom: var(--sp-4); color: var(--text-secondary); }

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

/* ===== FOCUS STYLES ===== */
:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

[data-theme="dark"] :focus-visible {
  outline-color: #58a6ff;
}

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* ===== SKIP LINK ===== */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--sp-4);
  background: var(--navy);
  color: #fff;
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-sm);
  z-index: 10000;
  font-size: 0.875rem;
  transition: top 0.2s;
}
.skip-link:focus {
  top: var(--sp-2);
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== UTILITIES ===== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--sp-6);
}

.container--narrow {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 var(--sp-6);
}

.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-1 { margin-top: var(--sp-1); }
.mt-2 { margin-top: var(--sp-2); }
.mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }
.mt-8 { margin-top: var(--sp-8); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-6 { margin-bottom: var(--sp-6); }
.mb-8 { margin-bottom: var(--sp-8); }

/* ===== RESPONSIVE BASE ===== */
@media (max-width: 1024px) {
  :root {
    --sp-6: 20px;
  }
}

@media (max-width: 768px) {
  h1 { font-size: 1.6rem; }
  h2 { font-size: 1.3rem; }
  h3 { font-size: 1.1rem; }
  body { padding-top: var(--nav-height); }
}

@media (max-width: 480px) {
  h1 { font-size: 1.4rem; }
  h2 { font-size: 1.15rem; }
  :root {
    --sp-6: 16px;
  }
}
