/* ==========================================================================
   Design System Tokens — Cherry Arbor Design
   ========================================================================== */

/* --- Light Mode (cream paper) --- */
:root {
  /* Ink hierarchy — graphite on paper */
  --ink: #2a2a28;
  --ink-secondary: #5c5a54;
  --ink-tertiary: #8a8780;
  --ink-muted: #b0ada6;

  /* Paper surfaces — cream, not white */
  --paper: #f5f2eb;
  --paper-raised: #faf8f3;
  --paper-inset: #edeae2;

  /* Rules — graph paper grid lines */
  --rule: rgba(90, 85, 75, 0.12);
  --rule-emphasis: rgba(90, 85, 75, 0.25);

  /* Accent — engineering graph paper teal */
  --grid-teal: hsl(165, 45%, 38%);
  --grid-teal-bg: hsla(165, 45%, 38%, 0.1);
  --grid-teal-hover: hsl(165, 45%, 32%);

  /* Semantic */
  --mark-success: hsl(150, 40%, 38%);
  --mark-warning: hsl(38, 60%, 48%);
  --mark-error: hsl(4, 50%, 48%);

  /* 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-12: 3rem;

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;

  /* Legacy aliases */
  --text-color: var(--ink);
  --text-muted: var(--ink-secondary);
  --bg-color: var(--paper);
  --nav-bg: var(--paper-raised);
  --border-color: var(--rule-emphasis);
  --accent-color: var(--grid-teal);
  --accent-hover: var(--grid-teal-hover);
}

/* --- Dark Mode (slate/chalkboard) — system preference --- */
@media (prefers-color-scheme: dark) {
  :root:not(.light) {
    --ink: #e2dfd8;
    --ink-secondary: #a8a49c;
    --ink-tertiary: #706d66;
    --ink-muted: #4a4843;

    --paper: #1e1e1c;
    --paper-raised: #26261f;
    --paper-inset: #18181a;

    --rule: rgba(200, 195, 185, 0.10);
    --rule-emphasis: rgba(200, 195, 185, 0.20);

    --grid-teal: hsl(165, 45%, 48%);
    --grid-teal-bg: hsla(165, 45%, 48%, 0.1);
    --grid-teal-hover: hsl(165, 45%, 55%);

    --mark-success: hsl(150, 40%, 48%);
    --mark-warning: hsl(38, 55%, 52%);
    --mark-error: hsl(4, 45%, 55%);
  }
}

/* --- Dark Mode (manual toggle) --- */
:root.dark {
  --ink: #e2dfd8;
  --ink-secondary: #a8a49c;
  --ink-tertiary: #706d66;
  --ink-muted: #4a4843;

  --paper: #1e1e1c;
  --paper-raised: #26261f;
  --paper-inset: #18181a;

  --rule: rgba(200, 195, 185, 0.10);
  --rule-emphasis: rgba(200, 195, 185, 0.20);

  --grid-teal: hsl(165, 45%, 48%);
  --grid-teal-hover: hsl(165, 45%, 55%);

  --mark-success: hsl(150, 40%, 48%);
  --mark-warning: hsl(38, 55%, 52%);
  --mark-error: hsl(4, 45%, 55%);
}

/* ==========================================================================
   Reset and Base Styles
   ========================================================================== */

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

html {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  line-height: 1.65;
}

body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
}

/* ==========================================================================
   Typography
   ========================================================================== */

h1, h2, h3, h4, h5, h6 {
  margin-top: 0;
  line-height: 1.3;
  font-weight: 600;
  letter-spacing: -0.01em;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

p {
  margin-top: 0;
}

a {
  color: var(--grid-teal);
}

a:hover {
  color: var(--grid-teal-hover);
}
