/* =========================================================
   Base: reset, typography, layout primitives, utilities.
   ========================================================= */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 1rem);
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--step-0);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
main { flex: 1; }

img, svg, picture { display: block; max-width: 100%; }
img { height: auto; }

h1, h2, h3, h4 {
  margin: 0 0 0.6em;
  color: var(--text-strong);
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-weight: 800;
  text-wrap: balance;
}
h1 { font-size: var(--step-4); letter-spacing: -0.035em; line-height: 1.05; }
h2 { font-size: var(--step-3); letter-spacing: -0.03em; }
h3 { font-size: var(--step-1); letter-spacing: -0.01em; font-weight: 700; }
h4 { font-size: var(--step-0); font-weight: 700; letter-spacing: 0; }

p, ul, ol, dl { margin: 0 0 1em; }
p { text-wrap: pretty; }
strong { color: var(--text-strong); font-weight: 700; }

a { color: var(--link); text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 4px;
}

hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }

::selection { background: var(--c-teal); color: var(--c-navy); }

/* Layout primitives */
.container { width: min(100% - 2 * var(--gutter), var(--container)); margin-inline: auto; }
.container--narrow { width: min(100% - 2 * var(--gutter), var(--container-narrow)); margin-inline: auto; }
.section { padding-block: var(--section-y); }
.section--soft { background: var(--bg-soft); }
.section--tight { padding-block: calc(var(--section-y) * 0.6); }
.stack > * + * { margin-top: 1rem; }

.grid-2 { display: grid; gap: clamp(1.5rem, 4vw, 4rem); grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); align-items: start; }

/* Utilities */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 1rem; top: -4rem; z-index: 200;
  padding: 0.7rem 1.1rem; border-radius: var(--radius-sm);
  background: var(--c-navy); color: var(--c-white); font-weight: 700; text-decoration: none;
}
.skip-link:focus { top: 1rem; }

/* Theme-dependent images and icons */
.theme-light { display: var(--show-light) !important; }
.theme-dark { display: var(--show-dark) !important; }

.mono { font-family: var(--font-mono); }
.muted { color: var(--text-muted); }
.lede { font-size: var(--step-1); line-height: 1.55; color: var(--text-muted); max-width: 40rem; }

.eyebrow {
  display: inline-flex; align-items: center; gap: 0.6rem;
  margin: 0 0 1.1rem;
  font-family: var(--font-mono); font-size: var(--step--2);
  letter-spacing: 0.18em; text-transform: uppercase; color: var(--text-muted);
}
.eyebrow::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; flex: none;
  background: var(--accent); box-shadow: 0 0 0 4px var(--glow);
}

/* Scroll reveal (only when JS is running) */
.js .reveal { opacity: 0; transform: translateY(14px); transition: opacity 0.7s ease, transform 0.7s ease; }
.js .reveal.is-visible { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .js .reveal { opacity: 1; transform: none; }
}
