/* =============================================================
   base.css — Design tokens, reset, typography, layout primitives.
   Loaded on every page before components.css.
   ============================================================= */

/* ---------- 1. Design tokens ---------- */
:root {
  /* Brand palette (brief §1.6) */
  --ink: #0e0f0c;            /* deep green-black */
  --ink-90: #15170f;
  --ink-80: #1f2117;
  --ink-70: #2a2d22;
  --ink-60: #3a3d30;
  --ink-50: #585c4b;
  --ink-40: #7e8373;
  --ink-30: #a8ac9c;
  --ink-20: #c9ccbe;
  --ink-10: #e4e6db;

  --cream: #f4f1ea;          /* warm cream ink */
  --cream-soft: #ece8de;
  --cream-warm: #f8f5ec;

  --ember: #e87a2d;          /* burnt-orange accent — for large text, buttons, decoration */
  --ember-soft: #f19e5e;
  --ember-deep: #b35a15;
  --ember-text: #9a4510;     /* small-text accent that meets AA (≥4.5:1) on --cream */
  --ember-tint: rgba(232,122,45,0.12);

  --pine: #3d5a3a;
  --snow: #fafbf8;
  --danger: #a62828;
  --success: #2f6b3a;

  /* Surfaces */
  --surface: var(--cream);
  --surface-inverse: var(--ink);
  --surface-raised: #ffffff;
  --surface-sunken: var(--cream-soft);
  --border-soft: rgba(14,15,12,0.10);
  --border-strong: rgba(14,15,12,0.22);

  /* Type */
  --font-display: "Fraunces", "Georgia", "Cambria", serif;
  --font-sans: "Inter Tight", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  /* Type scale (fluid clamp) */
  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-base: 1rem;
  --fs-md: 1.125rem;
  --fs-lg: 1.25rem;
  --fs-xl: 1.5rem;
  --fs-2xl: clamp(1.5rem, 2.4vw, 2rem);
  --fs-3xl: clamp(2rem, 3.5vw, 2.75rem);
  --fs-4xl: clamp(2.5rem, 5vw, 3.75rem);
  --fs-hero: clamp(2.75rem, 7vw, 5.5rem);

  /* Spacing */
  --sp-0: 0;
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.25rem;
  --sp-6: 1.5rem;
  --sp-8: 2rem;
  --sp-10: 2.5rem;
  --sp-12: 3rem;
  --sp-16: 4rem;
  --sp-20: 5rem;
  --sp-24: 6rem;

  /* Radii */
  --r-sm: 6px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 28px;
  --r-pill: 999px;

  /* Shadow */
  --shadow-sm: 0 1px 2px rgba(14,15,12,0.06);
  --shadow-md: 0 4px 16px rgba(14,15,12,0.08), 0 1px 2px rgba(14,15,12,0.06);
  --shadow-lg: 0 12px 48px rgba(14,15,12,0.18);

  /* Motion */
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --fast: 160ms;
  --med: 280ms;
  --slow: 480ms;

  /* Layout */
  --maxw-content: 72rem;
  --maxw-prose: 40rem;
  --maxw-narrow: 56rem;

  /* Z */
  --z-nav: 40;
  --z-bottom-sheet: 50;
  --z-modal: 60;
  --z-toast: 70;

  color-scheme: light;
}

/* ---------- 2. Modern reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html:focus-within { scroll-behavior: smooth; }
body, h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd, ul, ol { margin: 0; }
ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }
img, picture, video, canvas, svg { display: block; max-width: 100%; }
input, button, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
table { border-collapse: collapse; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { padding: 0; }
summary::-webkit-details-marker { display: none; }

/* ---------- 3. Body + typography base ---------- */
body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.6;
  color: var(--ink);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.015em;
  color: var(--ink);
}
h1 { font-size: var(--fs-hero); }
h2 { font-size: var(--fs-4xl); }
h3 { font-size: var(--fs-2xl); }
h4 { font-size: var(--fs-xl); font-weight: 500; }

em, i {
  font-style: italic;
  color: var(--ember-text);
}

p { max-width: var(--maxw-prose); }

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color var(--fast) var(--ease);
}
a:hover { color: var(--ember); }

/* Visible focus for keyboard users only */
:where(a, button, input, select, textarea, [tabindex], [role="button"]):focus-visible {
  outline: 2px solid var(--ember);
  outline-offset: 3px;
  border-radius: 3px;
}

::selection { background: var(--ember); color: var(--cream); }

/* Skip link */
.skip-link {
  position: absolute;
  left: 1rem;
  top: 1rem;
  padding: 0.625rem 1rem;
  background: var(--ink);
  color: var(--cream);
  border-radius: var(--r-sm);
  transform: translateY(-140%);
  transition: transform var(--fast) var(--ease);
  z-index: 100;
  font-weight: 500;
}
.skip-link:focus-visible { transform: translateY(0); }

/* ---------- 4. Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- 5. Layout primitives ---------- */
.container {
  width: 100%;
  max-width: var(--maxw-content);
  margin-inline: auto;
  padding-inline: 1.25rem;
}
@media (min-width: 720px) {
  .container { padding-inline: 2rem; }
}
@media (min-width: 1080px) {
  .container { padding-inline: 2.5rem; }
}

.container-narrow {
  width: 100%;
  max-width: var(--maxw-narrow);
  margin-inline: auto;
  padding-inline: 1.25rem;
}
@media (min-width: 720px) {
  .container-narrow { padding-inline: 2rem; }
}

.section { padding-block: var(--sp-20); }
.section--sm { padding-block: var(--sp-12); }
.section--lg { padding-block: var(--sp-24); }
@media (max-width: 640px) {
  .section { padding-block: var(--sp-16); }
  .section--lg { padding-block: var(--sp-20); }
}

.stack > * + * { margin-top: var(--sp-4); }
.stack-lg > * + * { margin-top: var(--sp-8); }
.stack-xl > * + * { margin-top: var(--sp-12); }

.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;
}

/* ---------- 6. Theme variants ---------- */
.theme-dark {
  --surface: var(--ink);
  --surface-raised: var(--ink-90);
  --surface-sunken: var(--ink-80);
  --border-soft: rgba(244,241,234,0.10);
  --border-strong: rgba(244,241,234,0.22);
  background: var(--ink);
  color: var(--cream);
}
.theme-dark h1, .theme-dark h2, .theme-dark h3, .theme-dark h4 { color: var(--cream); }

.theme-cream {
  background: var(--cream);
}

/* Utility colors used across pages */
.text-ember { color: var(--ember); }
.text-dim { color: var(--ink-50); }
.text-cream { color: var(--cream); }

/* Prose container for long copy */
.prose {
  max-width: var(--maxw-prose);
  font-size: var(--fs-md);
  line-height: 1.75;
  color: var(--ink-70);
}
.prose p + p { margin-top: 1em; }
.prose h2 { font-size: var(--fs-2xl); margin-top: 2em; }
.prose h3 { font-size: var(--fs-xl); margin-top: 1.75em; }
.prose ul, .prose ol { padding-left: 1.25em; margin-block: 0.75em; }
.prose li + li { margin-top: 0.35em; }
.prose a { text-decoration: underline; color: var(--ember-text); }

/* Tag / eyebrow label */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-sans);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ember-text);
}
.eyebrow::before {
  content: "";
  width: 20px;
  height: 1px;
  background: currentColor;
}
.eyebrow--no-rule::before { display: none; }

/* Divider */
.rule {
  border: 0;
  height: 1px;
  background: var(--border-soft);
  margin-block: var(--sp-8);
}
