/* ==========================================================================
   Base: reset, design tokens, typography, theme (light/dark)
   ========================================================================== */

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

:root {
  /* ---- Type ---- */
  --font-display: 'Bricolage Grotesque', 'Archivo', -apple-system, sans-serif;
  --font-body: 'Archivo', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --fs-xs: 0.8125rem;
  --fs-sm: 0.9375rem;
  --fs-base: 1rem;
  --fs-md: 1.1875rem;
  --fs-lg: 1.5rem;
  --fs-xl: 2rem;
  --fs-2xl: clamp(2rem, 1.6rem + 2vw, 2.75rem);
  --fs-3xl: clamp(2.5rem, 1.9rem + 3vw, 3.75rem);
  --fs-hero: clamp(2.75rem, 2rem + 4.2vw, 4.75rem);

  /* ---- Spacing (8px rhythm) ---- */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.5rem;
  --sp-6: 2rem;
  --sp-8: 3rem;
  --sp-10: 4rem;
  --sp-12: 6rem;
  --sp-16: 8rem;

  /* ---- Radius ---- */
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 22px;
  --r-xl: 30px;
  --r-pill: 999px;

  /* ---- Motion ---- */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast: 150ms;
  --dur-base: 250ms;
  --dur-slow: 400ms;

  /* ---- Z-scale ---- */
  --z-nav: 1000;
  --z-overlay: 1100;
  --z-toast: 1200;

  /* ---- Light theme (default): paper + ink + one confident cobalt accent ---- */
  --bg: #f5f1e6;
  --bg-alt: #ece6d4;
  --bg-raised: #fffdf7;
  --text-primary: #15130f;
  --text-secondary: #504a3e;
  --text-tertiary: #837a67;
  --border: rgba(21, 19, 15, 0.14);
  --border-soft: rgba(21, 19, 15, 0.08);
  --border-strong: rgba(21, 19, 15, 0.9);

  --accent: #1d3ed8;
  --accent-hover: #1631ad;
  --accent-soft: #dde3fb;
  --accent-ink: #fffdf7;
  --stamp: #e8402c;
  --stamp-soft: #fbdcd6;

  --glass-nav-bg: rgba(245, 241, 230, 0.78);
  --glass-nav-border: rgba(21, 19, 15, 0.12);
  --glass-card-bg: rgba(255, 253, 247, 0.68);
  --glass-card-border: rgba(21, 19, 15, 0.12);
  --glass-field-bg: #fffdf7;
  --glass-field-border: rgba(21, 19, 15, 0.22);
  --glass-shadow: 0 22px 44px -20px rgba(21, 19, 15, 0.28);
  --glass-shadow-sm: 0 10px 22px -14px rgba(21, 19, 15, 0.22);

  --hard-shadow: 6px 6px 0 var(--border-strong);
  --hard-shadow-sm: 4px 4px 0 var(--border-strong);
  --hard-shadow-accent: 6px 6px 0 var(--accent);

  --success: #1c7a4d;
  --error: #c0392b;
}

[data-theme='dark'] {
  --bg: #131117;
  --bg-alt: #1b1820;
  --bg-raised: #1f1c25;
  --text-primary: #f4f1e8;
  --text-secondary: #b7b2a4;
  --text-tertiary: #837c6d;
  --border: rgba(244, 241, 232, 0.14);
  --border-soft: rgba(244, 241, 232, 0.08);
  --border-strong: rgba(244, 241, 232, 0.92);

  --accent: #6d84ff;
  --accent-hover: #8a9dff;
  --accent-soft: rgba(109, 132, 255, 0.16);
  --accent-ink: #0e0c18;
  --stamp: #ff6a50;
  --stamp-soft: rgba(255, 106, 80, 0.16);

  --glass-nav-bg: rgba(19, 17, 23, 0.72);
  --glass-nav-border: rgba(244, 241, 232, 0.1);
  --glass-card-bg: rgba(31, 28, 37, 0.62);
  --glass-card-border: rgba(244, 241, 232, 0.12);
  --glass-field-bg: rgba(244, 241, 232, 0.05);
  --glass-field-border: rgba(244, 241, 232, 0.18);
  --glass-shadow: 0 22px 44px -20px rgba(0, 0, 0, 0.6);
  --glass-shadow-sm: 0 10px 22px -14px rgba(0, 0, 0, 0.5);

  --hard-shadow: 6px 6px 0 var(--border-strong);
  --hard-shadow-sm: 4px 4px 0 var(--border-strong);
  --hard-shadow-accent: 6px 6px 0 var(--accent);

  --success: #4fbd8b;
  --error: #e0685a;
}

body {
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: 1.65;
  color: var(--text-primary);
  background: var(--bg);
  overflow-x: hidden;
  transition: background var(--dur-base) var(--ease-in-out), color var(--dur-base) var(--ease-in-out);
}

/* Flat paper texture: a faint fixed grain, no soft gradient blobs */
body {
  background-image:
    linear-gradient(var(--border-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--border-soft) 1px, transparent 1px);
  background-size: 64px 64px;
  background-position: -1px -1px;
  background-attachment: fixed;
  opacity: 1;
}

img {
  max-width: 100%;
  display: block;
}

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

ul {
  list-style: none;
}

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

/* ---- Typography ---- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

h1 { font-size: var(--fs-3xl); font-weight: 800; }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-xl); }
h4 { font-size: var(--fs-lg); font-weight: 600; }

p {
  color: var(--text-secondary);
  max-width: 65ch;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
}

.eyebrow::before {
  content: '';
  width: 22px;
  height: 2px;
  background: var(--accent);
  border-radius: var(--r-pill);
}

/* ---- Layout helpers ---- */
.container {
  max-width: 1220px;
  margin: 0 auto;
  padding: 0 clamp(20px, 4vw, 40px);
}

.section {
  padding: var(--sp-12) 0;
}

@media (max-width: 720px) {
  .section { padding: var(--sp-10) 0; }
}

.section-header {
  max-width: 640px;
  margin-bottom: var(--sp-8);
}

.section-header.center {
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

.section-header p {
  margin-top: var(--sp-3);
  font-size: var(--fs-md);
}

.section-header.center p {
  margin-left: auto;
  margin-right: auto;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Skip link for keyboard users */
.skip-link {
  position: absolute;
  top: -100px;
  left: var(--sp-4);
  z-index: var(--z-toast);
  background: var(--accent);
  color: var(--accent-ink);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--r-md);
  transition: top var(--dur-base) var(--ease-out);
}

.skip-link:focus {
  top: var(--sp-4);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

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