/* ============================================
   DESIGN SYSTEM — Tokens, Reset, Typography
   ============================================ */

/* --- Tokens --- */
:root {
  /* Colors */
  --color-bg: #ffffff;
  --color-text: #1a1a1a;
  --color-accent: #e63946;
  --color-accent-hover: #c1313d;
  --color-muted: #6b7280;
  --color-border: #e5e7eb;
  --color-surface: #f9fafb;
  --color-code-bg: #f3f4f6;
  --color-checker: #eee;

  /* Status Colors */
  --color-success: #15803d;
  --color-success-bg: #f0fdf4;
  --color-success-border: #bbf7d0;
  --color-error: #b91c1c;
  --color-error-bg: #fef2f2;
  --color-error-border: #fecaca;

  /* Syntax Highlighting */
  --color-syntax-string: #15803d;
  --color-syntax-number: #1d4ed8;
  --color-syntax-boolean: #b45309;
  --color-syntax-null: #9333ea;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-card: 0 2px 12px rgba(230, 57, 70, 0.08);

  /* Typography */
  --font-heading: 'Instrument Serif', Georgia, serif;
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;
  --space-4xl: 6rem;

  /* Layout */
  --max-w-content: 720px;
  --max-w-tool: 1080px;
  --max-w-wide: 1200px;

  /* Font Sizes */
  --text-sm: 0.875rem;
  --text-lg: 1.125rem;

  /* Transitions */
  --transition: 150ms ease;
}

/* --- Dark Theme --- */
[data-theme="dark"] {
  --color-bg: #0f0f0f;
  --color-text: #e5e5e5;
  --color-accent: #ff4d5a;
  --color-accent-hover: #ff6e78;
  --color-muted: #9ca3af;
  --color-border: #2a2a2a;
  --color-surface: #1a1a1a;
  --color-code-bg: #1e1e1e;
  --color-checker: #2a2a2a;

  --color-success: #4ade80;
  --color-success-bg: #052e16;
  --color-success-border: #166534;
  --color-error: #f87171;
  --color-error-bg: #450a0a;
  --color-error-border: #7f1d1d;

  --color-syntax-string: #4ade80;
  --color-syntax-number: #60a5fa;
  --color-syntax-boolean: #fbbf24;
  --color-syntax-null: #c084fc;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-card: 0 2px 12px rgba(230, 57, 70, 0.15);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  color-scheme: light dark;
}

body {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
}

input, button, textarea, select {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

ul, ol {
  list-style: none;
}

/* --- Typography --- */
h1, h2, h3, h4 {
  font-family: var(--font-heading);
  font-weight: 400;
  line-height: 1.2;
}

h1 {
  font-size: 3rem;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 1.75rem;
  letter-spacing: -0.01em;
}

h3 {
  font-size: 1.25rem;
}

h4 {
  font-size: 1.1rem;
}

p {
  margin-bottom: var(--space-md);
}

p:last-child {
  margin-bottom: 0;
}

small, .text-sm {
  font-size: 0.875rem;
}

.text-xs {
  font-size: 0.75rem;
}

.text-muted {
  color: var(--color-muted);
}

.text-accent {
  color: var(--color-accent);
}

code, .mono {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

/* --- Utilities --- */
.container {
  width: 100%;
  max-width: var(--max-w-content);
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

.container--wide {
  max-width: var(--max-w-tool);
}

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

.is-hidden {
  display: none !important;
}

.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-accent);
  color: white;
  font-size: var(--text-sm);
  border-radius: 0 0 6px 6px;
  z-index: 1000;
  transition: top var(--transition);
}

.skip-link:focus {
  top: 0;
}

hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-3xl) 0;
}

/* --- Selection --- */
::selection {
  background-color: var(--color-accent);
  color: white;
}

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

/* --- Responsive --- */
@media (max-width: 768px) {
  h1 { font-size: 2.25rem; }
  h2 { font-size: 1.5rem; }
  hr { margin: var(--space-2xl) 0; }
  .container { padding: 0 var(--space-md); }
}

@media (max-width: 480px) {
  h1 { font-size: 2rem; }
}
