/* ============================================================
   Base system styles. Every value references tokens.css.
   ============================================================ */

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

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

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--text-body);
  line-height: var(--leading-body);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* §13 fine organic grain over large dark backgrounds. SVG feTurbulence noise,
   soft-light, opacity token. Fixed full-viewport layer, no pointer events. */
.grain {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: var(--grain-opacity);
  mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- typography ---------- */

h1, h2, h3, h4 { margin: 0; }

.display-hero,
.display-h1,
.display-h2 {
  font-family: var(--font-display);
  font-weight: var(--weight-display);
  letter-spacing: var(--tracking-serif);
  line-height: var(--leading-display);
  text-wrap: balance;
}

.display-hero { font-size: var(--text-hero); }
.display-h1 { font-size: var(--text-h1); }
.display-h2 { font-size: var(--text-h2); line-height: var(--leading-heading); }

.h3 {
  font-family: var(--font-body);
  font-size: var(--text-h3);
  font-weight: var(--weight-h3);
  letter-spacing: var(--tracking-sans-heading);
  line-height: var(--leading-heading);
}

.lead {
  font-size: var(--text-lead);
  line-height: var(--leading-lead);
}

p { margin: 0 0 var(--space-4); max-width: 75ch; text-wrap: pretty; }
p:last-child { margin-bottom: 0; }

.muted { color: var(--color-text-muted); }
.subtle { color: var(--color-text-subtle); }

/* §2 / §11 eyebrow: mono, uppercase, tracked, olive with terracotta option */
.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--text-label);
  font-weight: var(--weight-label);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--color-olive);
}
.eyebrow--accent { color: var(--color-accent); }

.label {
  font-family: var(--font-body);
  font-size: var(--text-label);
  font-weight: var(--weight-label);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}

.mono {
  font-family: var(--font-mono);
  font-size: var(--text-label);
}

a {
  color: var(--color-text);
  text-decoration: none;
  transition: color var(--duration-hover) var(--ease);
}
a:hover { color: var(--color-link-hover); }

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

::selection {
  background: var(--color-accent);
  color: var(--color-cta-text);
}

/* ---------- layout ---------- */

.container {
  max-width: var(--max-width);
  margin-inline: auto;
  padding-inline: var(--gutter-mobile);
}
@media (min-width: 720px) {
  .container { padding-inline: var(--gutter-tablet); }
}
@media (min-width: 1080px) {
  .container { padding-inline: var(--gutter-desktop); }
}

/* §6 12-col grid, 24px gutters */
.grid-12 {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--grid-gap);
}

/* §4 section rhythm: standard 96px, major 128px, mobile 64–80px */
.section { padding-block: var(--space-16); position: relative; overflow: clip; }
.section--major { padding-block: calc(var(--space-16) + var(--space-2)); }
@media (min-width: 720px) {
  .section { padding-block: var(--space-24); }
  .section--major { padding-block: var(--space-32); }
}

/* color-band variants paint their own ground and text color (body is dark) */
.section-light,
.section-terra {
  background: var(--color-bg);
  color: var(--color-text);
}

/* a section that ends in a structural seam divider hands its bottom
   padding to the divider's margin-top instead */
.section.section--to-seam { padding-bottom: 0; }

.section-head { max-width: var(--text-column); margin-bottom: var(--space-12); }
.section-head .eyebrow { display: block; margin-bottom: var(--space-4); }
.section-head p { margin-top: var(--space-6); }

.text-col { max-width: var(--text-column); }

/* ---------- buttons (§8) ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px; /* §15 touch target */
  padding: 14px 22px;
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-size: var(--text-button);
  font-weight: var(--weight-button);
  letter-spacing: var(--tracking-button);
  cursor: pointer;
  border: none;
  transition:
    background var(--duration-hover) var(--ease),
    border-color var(--duration-hover) var(--ease),
    color var(--duration-hover) var(--ease),
    transform var(--duration-hover) var(--ease),
    box-shadow var(--duration-hover) var(--ease);
}

.btn-primary {
  background: var(--color-cta);
  color: var(--color-cta-text);
}
.btn-primary:hover {
  background: var(--color-cta-hover);
  color: var(--color-cta-text);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25); /* §8 soft shadow on hover */
}
.btn-primary:active { transform: translateY(0); box-shadow: none; }

.btn-secondary {
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border-strong);
}
.btn-secondary:hover {
  background: var(--card-bg);
  border-color: var(--color-cream);
  color: var(--color-text);
}
.btn-secondary:active { background: transparent; }

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* §8 text link with arrow */
.textlink {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  font-weight: var(--weight-h3);
  font-size: var(--text-button);
  color: var(--color-accent);
}
.textlink:hover { color: var(--color-accent-hover); }
.textlink .arrow { transition: transform var(--duration-hover) var(--ease); }
.textlink:hover .arrow { transform: translate(2px, -2px); }

/* ---------- cards (§9) ---------- */

.card {
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: var(--card-pad);
  /* backlit top edge + soft ambient drop for depth over the banded ground */
  box-shadow:
    inset 0 1px 0 rgba(242, 235, 221, 0.05),
    0 24px 48px -28px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition:
    border-color var(--duration-hover) var(--ease),
    transform var(--duration-hover) var(--ease);
  overflow: hidden;
}
.card:hover,
.card:focus-within {
  border-color: var(--color-border-strong);
  transform: translateY(-3px);
}
.card--static:hover,
.card--static:focus-within { transform: none; border-color: var(--card-border); }

/* §15: --color-text-subtle misses 4.5:1 on the raised card composite (4.19).
   On cards, subtle roles/labels step up to the muted token (6.82). */
.card .subtle { color: var(--color-text-muted); }

/* cards on the cream bands: solid surface, warm shadow, no frost */
.section-light .card,
[data-variant="light"] .card {
  box-shadow: 0 24px 44px -26px rgba(39, 42, 37, 0.35);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* pills / tags — §5 small tags 999px */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--color-border);
  font-family: var(--font-mono);
  font-size: var(--text-label);
  color: var(--color-text-muted);
  white-space: nowrap;
}

/* ---------- images (§10) ---------- */

.img-frame {
  border-radius: var(--radius-lg); /* §5 images 24–32px; 28px token */
  border: 1px solid var(--color-border);
  overflow: hidden;
}
.img-frame img { display: block; width: 100%; height: auto; }

/* ---------- shape assets (§5 + pack rules) ---------- */

.shape {
  position: absolute;
  pointer-events: none;
  opacity: var(--shape-opacity);
  z-index: 0;
}
.shape svg { display: block; width: 100%; height: 100%; }

/* semantic shape colors so pack SVGs respond to the light variant */
:root {
  --shape-cream: var(--color-cream);
  --shape-olive: var(--color-olive);
  --shape-sage: var(--color-sage);
  /* lumen revision: shape warm strokes follow the accent system so the CTA
     stays the page's only warmth */
  --shape-terracotta: var(--color-accent);
}
.section-light,
[data-variant="light"] {
  /* on cream, cream strokes vanish; remap to §14 secondary text tone */
  --shape-cream: var(--color-text-muted);
  --shape-sage: var(--color-text-muted);
}

/* content above shapes */
.section > .container { position: relative; z-index: 1; }

/* ---------- structural seam dividers (pack section_divider_* geometry) ----------
   Placed as the last child of the section ABOVE the color change. The section's
   own ground shows behind the strokes; the fill path is the NEXT band's ground
   (via the --band-* aliases), so the seam is the divider's silhouette. */
.sdiv {
  position: relative;
  z-index: 1;
  height: clamp(90px, 13vw, 170px);
  margin-top: var(--space-16);
  margin-bottom: -2px; /* guard against sub-pixel seams (1px leaked at some zooms) */
  pointer-events: none;
}
/* svg overshoots the section edge by 3px; the section's overflow:clip cuts
   it exactly at the boundary, so the band bg can't peek through the svg's
   antialiased bottom row (terracotta hairline fix, 2026-08-10) */
.sdiv svg { display: block; width: 100%; height: calc(100% + 3px); }
/* opaque backstop strip in the seam's own fill color across the section
   boundary: kills subpixel hairlines the svg edge blending can leave */
.sdiv::after {
  content: '';
  position: absolute;
  inset-inline: 0;
  bottom: -2px;
  height: 6px;
  background: var(--seam-fill, transparent);
  pointer-events: none;
}
.sdiv--to-dark  { --seam-fill: var(--band-dark); }
.sdiv--to-cream { --seam-fill: var(--band-cream); }
.sdiv--to-terra { --seam-fill: var(--band-terra); }
/* the section AFTER a seam paints its own ground and pulls up 2px over the
   boundary: plain dark sections are transparent by default, so the outgoing
   band's fractional bottom-edge pixel (clipped past the svg + ::after) showed
   through as a full-width warm hairline (measured rgb(52,46,41) at 1440).
   The overlapped 2px of seam svg is pure fill color, so nothing changes
   visually except the hairline dies. */
.section--to-seam + .section,
.section--to-seam + footer {
  margin-top: -2px;
  background-color: var(--color-bg);
}
.sdiv--flip svg { transform: scaleX(-1); }
/* the incoming band casts a soft shadow onto the outgoing one */
.sdiv__fill { filter: drop-shadow(0 -12px 20px rgba(0, 0, 0, 0.20)); }

/* ---------- ambient shape motion (2026-08-08) ----------
   Slow, small, continuous. Never faster than the drift tokens. */
@keyframes shape-drift {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(0deg); }
  50% { transform: translate3d(0, -22px, 0) rotate(1.2deg); }
}
@keyframes shape-sway {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(0deg); }
  50% { transform: translate3d(26px, -12px, 0) rotate(-1.4deg); }
}
@keyframes shape-spin { to { transform: rotate(360deg); } }
@keyframes signal-pulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.85; }
}
.shape--drift { animation: shape-drift var(--drift-mid) ease-in-out infinite; }
.shape--drift-slow { animation: shape-drift var(--drift-slow) ease-in-out infinite; }
.shape--sway { animation: shape-sway var(--drift-slow) ease-in-out infinite; }
.shape--spin { animation: shape-spin var(--spin-slow) linear infinite; }
.pulse { animation: signal-pulse 5s ease-in-out infinite; }
.pulse--late { animation-delay: 2.5s; }

/* ---------- motion (§12) ---------- */

/* scoped under html.js (set by the inline head script) so a no-JS render
   still shows every headline; without JS nothing would ever add .is-visible
   and the h1 would sit at opacity 0 forever. */
html.js .reveal {
  opacity: 0;
  transform: translateY(var(--motion-rise));
  transition:
    opacity var(--duration-reveal) var(--ease),
    transform var(--duration-reveal) var(--ease);
}
html.js .reveal.is-visible { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .btn, .card, .textlink .arrow, a { transition: none; }
  .btn-primary:hover, .card:hover { transform: none; }
  .shape, .pulse { animation: none; }
}

/* ---------- a11y helpers ---------- */

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: var(--space-4);
  z-index: 100;
  background: var(--color-cta);
  color: var(--color-cta-text);
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-pill);
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }

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