/* ==========================================================================
   Global: reset, base 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) + 16px);
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  background: var(--c-paper);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-optical-sizing: auto;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}

img, svg, video { display: block; max-width: 100%; height: auto; }
img { font-style: italic; } /* alt text styling if image fails */

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }

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

p, ul, ol, dl, figure, blockquote { margin: 0; }
ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: var(--fw-medium);
  line-height: var(--lh-heading);
  letter-spacing: var(--ls-heading);
  text-wrap: balance;
}
h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); letter-spacing: var(--ls-tight); }
h4 { font-size: var(--fs-h4); letter-spacing: var(--ls-tight); line-height: var(--lh-snug); }
h5 { font-size: var(--fs-h5); letter-spacing: 0; line-height: var(--lh-snug); font-weight: var(--fw-semibold); }
h6 { font-size: var(--fs-h6); letter-spacing: 0; line-height: var(--lh-snug); font-weight: var(--fw-semibold); }

p { text-wrap: pretty; }

::selection { background: var(--c-accent); color: var(--c-ink); }

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

/* ---- Layout primitives ------------------------------------------------ */
.container {
  width: 100%;
  max-width: calc(var(--container) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.container--narrow { max-width: calc(var(--container-narrow) + var(--gutter) * 2); }

.section {
  position: relative;
  padding-block: var(--sp-section);
  background: var(--bg);
  color: var(--fg);
}
.section--tight { padding-block: var(--sp-section-sm); }
.section--white { --bg: var(--c-white); }
.section--recessed { --bg: var(--c-paper-2); }

.grid-12 {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--grid-gap);
}

.stack > * + * { margin-top: var(--stack, var(--sp-5)); }

/* ---- Type utilities --------------------------------------------------- */
.t-mega {
  font-size: var(--fs-mega);
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-display);
  font-weight: var(--fw-medium);
}
.t-display {
  font-size: var(--fs-display);
  line-height: 1;
  letter-spacing: var(--ls-display);
  font-weight: var(--fw-medium);
}
.t-lead {
  font-size: var(--fs-lead);
  line-height: 1.5;
  letter-spacing: -0.01em;
  color: var(--fg-muted);
}
.t-muted { color: var(--fg-muted); }
.t-small { font-size: var(--fs-small); }
.t-caption { font-size: var(--fs-caption); line-height: 1.5; }
.t-accent { color: var(--c-accent-strong); }
.theme-dark .t-accent { color: var(--c-accent-soft); }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  font-family: var(--font-mono);
  font-size: var(--fs-eyebrow);
  font-weight: var(--fw-medium);
  letter-spacing: var(--ls-eyebrow);
  text-transform: uppercase;
  color: var(--fg-muted);
}
.eyebrow::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--c-accent);
  flex: none;
}
.eyebrow--plain::before { display: none; }

.mono {
  font-family: var(--font-mono);
  font-size: var(--fs-caption);
  letter-spacing: 0.04em;
}

.prose { max-width: 68ch; }
.prose > * + * { margin-top: 1.1em; }
.prose a { color: var(--link); text-decoration: underline; text-underline-offset: 3px; }

/* ---- Accessibility utilities ----------------------------------------- */
.sr-only {
  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: fixed;
  top: 12px; left: 12px;
  z-index: 200;
  padding: 12px 18px;
  background: var(--c-ink);
  color: #fff;
  border-radius: var(--r-sm);
  transform: translateY(-160%);
  transition: transform var(--dur-base) var(--ease-out);
}
.skip-link:focus { transform: translateY(0); }

/* ---- Reveal states (only when JS has booted; content stays visible without JS) */
.js [data-reveal] { opacity: 0; transform: translateY(28px); }
.js [data-reveal="fade"] { transform: none; }
.js [data-reveal].is-in {
  opacity: 1;
  transform: none;
  transition: opacity var(--dur-xslow) var(--ease-out), transform var(--dur-xslow) var(--ease-out);
  transition-delay: var(--reveal-delay, 0ms);
}
/* GSAP takes over these when available — inline tweens drive the motion */
.js.has-gsap [data-reveal] { transition: none; }

/* Split headings: words in masks */
[data-split] .w {
  display: inline-block;
  overflow: hidden;
  vertical-align: top;
  padding-bottom: 0.12em;
  margin-bottom: -0.12em;
}
[data-split] .w > span { display: inline-block; }
.js [data-split] .w > span { transform: translateY(110%); }
.js [data-split].is-in .w > span {
  transform: none;
  transition: transform 1.1s var(--ease-out);
  transition-delay: calc(var(--i, 0) * 38ms);
}
.js.has-gsap [data-split] .w > span { transform: none; transition: none; }

/* Hero entrance items (fallback path; GSAP path clears these) */
.js [data-hero-item], .js [data-hv] { opacity: 0; transform: translateY(26px); }
.js [data-hero-item].is-in, .js [data-hv].is-in {
  opacity: 1;
  transform: none;
  transition: opacity 1s var(--ease-out), transform 1.1s var(--ease-out);
}
.js [data-hero-item].is-in:nth-child(2) { transition-delay: 0.1s; }
.js [data-hv].is-in:nth-of-type(2) { transition-delay: 0.15s; }
.js [data-hv].is-in:nth-of-type(3) { transition-delay: 0.3s; }
.js [data-hv].is-in:nth-of-type(4) { transition-delay: 0.45s; }
.js.has-gsap [data-hero-item], .js.has-gsap [data-hv] { opacity: 1; transform: none; transition: none; }

/* Failsafe + reduced motion: always show content */
.reveal-all [data-reveal], .reveal-all [data-hero-item], .reveal-all [data-hv],
.reveal-all [data-split] .w > span { opacity: 1 !important; transform: none !important; }

@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;
  }
  .js [data-reveal], .js [data-hero-item], .js [data-hv], .js [data-split] .w > span { opacity: 1 !important; transform: none !important; }
}
