/* ==========================================================================
   Base: reset, typography, layout primitives, motion primitives
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html {
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--hh) + 1.5rem);
  scrollbar-gutter: stable;
}
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.0625rem/1.58 var(--font-text);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}
img, svg, video { display: block; max-width: 100%; height: auto; }
h1, h2, h3, h4, p, ul, ol, figure, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
:where(section, header, footer, main, nav, dialog) { color: var(--fg, inherit); }
[hidden] { display: none !important; }
html.dlg-open { overflow: hidden; }

/* Surface = a band with its own ground */
[data-surface] { background: var(--bg); color: var(--fg); }

/* Focus: one ring, tinted by surface, always offset so it reads against any fill */
:focus-visible {
  outline: 2px solid var(--ring, var(--ink));
  outline-offset: 3px;
  border-radius: 4px;
}
:focus:not(:focus-visible) { outline: none; }

::selection { background: var(--red); color: var(--paper); }

/* skip link */
.skip {
  position: fixed; left: 1rem; top: -4rem; z-index: 100;
  padding: 0.75rem 1.1rem; border-radius: 999px;
  background: var(--ink); color: var(--paper); font-weight: 700; text-decoration: none;
  transition: top var(--t-ui) var(--ease-out);
}
.skip:focus-visible { top: 1rem; outline-color: var(--paper); }

/* Layout */
.wrap { width: 100%; max-width: var(--max); margin-inline: auto; padding-inline: var(--gutter); }
.section { padding-block: var(--section); }
.stack > * + * { margin-top: var(--stack, 1.25rem); }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Type */
.display {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.015em;
  text-wrap: balance;
  font-variation-settings: 'opsz' 40;      /* sturdier hairlines than the display-size default */
}
.display em { font-style: italic; font-weight: 600; letter-spacing: -0.01em; }
.h-xl { font-size: clamp(2.9rem, 1.2rem + 6.4vw, 6rem); }
.h-lg { font-size: clamp(2.25rem, 1.2rem + 3.8vw, 4.25rem); }
.h-md { font-size: clamp(1.75rem, 1.1rem + 2vw, 2.75rem); line-height: 1.04; }
.h-sm { font-size: clamp(1.4rem, 1.1rem + 0.9vw, 1.85rem); line-height: 1.1; letter-spacing: -0.01em; }
.lead { font-size: clamp(1.125rem, 1rem + 0.5vw, 1.375rem); line-height: 1.5; max-width: 38em; text-wrap: pretty; }
.prose { max-width: 68ch; text-wrap: pretty; }
.prose > * + * { margin-top: 1.1em; }
.prose a, .inline-link {
  color: inherit; text-decoration: underline; text-decoration-thickness: 0.09em; text-underline-offset: 0.22em;
  text-decoration-color: var(--accent);
}
.small { font-size: 0.9375rem; }
.muted { color: var(--fg-2); }
.nums { font-variant-numeric: tabular-nums lining-nums; }

/* Hairline rule that draws in when revealed */
.rule { height: 1px; background: var(--line); border: 0; margin: 0; transform-origin: left; }

/* --------------------------------------------------------------------------
   Perforation: the one recurring device. Film sprocket holes = ticket notches.
   -------------------------------------------------------------------------- */
.perf {
  --perf-hole: var(--paper);
  height: 2.1rem;
  background: var(--bg, var(--ink));
  position: relative;
}
.perf::before {
  content: '';
  position: absolute; inset: 0;
  background: var(--perf-hole);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='34' height='34'%3E%3Crect x='8' y='9' width='18' height='16' rx='4'/%3E%3C/svg%3E") repeat-x center / 34px 100%;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='34' height='34'%3E%3Crect x='8' y='9' width='18' height='16' rx='4'/%3E%3C/svg%3E") repeat-x center / 34px 100%;
}

/* --------------------------------------------------------------------------
   Reveal system. Content is visible by default; only when JS is running and
   motion is allowed do we start elements hidden. Each reveal has its own shape.
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
  .js [data-reveal] { transition: opacity var(--t-reveal) var(--ease-out), transform var(--t-reveal) var(--ease-out), clip-path 900ms var(--ease-out); transition-delay: calc(var(--i, 0) * 60ms); }

  .js [data-reveal='rise']:not(.is-in)  { opacity: 0; transform: translateY(1.4rem); }
  .js [data-reveal='settle']:not(.is-in){ opacity: 0; transform: translateY(2rem) rotate(var(--from, -6deg)) scale(0.96); }
  .js [data-reveal='scale']:not(.is-in) { opacity: 0; transform: scale(1.06); }
  .js [data-reveal='draw']:not(.is-in)  { transform: scaleX(0); }
  .js [data-reveal='wipe']:not(.is-in)  { clip-path: inset(0 100% 0 0); }
  .js [data-reveal='rows'] > *          { transition: opacity var(--t-reveal) var(--ease-out), transform var(--t-reveal) var(--ease-out); transition-delay: calc(var(--i, 0) * 70ms); }
  .js [data-reveal='rows']:not(.is-in) > * { opacity: 0; transform: translateY(0.9rem); }

  /* headline words assemble from a mask */
  .w { display: inline-block; overflow: hidden; vertical-align: top; padding: 0 0.24em 0.14em 0.24em; margin: 0 -0.24em -0.14em -0.24em; }
  .w > span { display: inline-block; }
  .js [data-split] .w > span { transform: translateY(108%); transition: transform 900ms var(--ease-out); transition-delay: calc(var(--i, 0) * 55ms + var(--d, 0ms)); }
  .js [data-split].is-in .w > span { transform: none; }
}

/* Cross-document view transitions: page-to-page is one continuous cut */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 280ms; animation-timing-function: var(--ease-out); }
.site-header { view-transition-name: site-header; }
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
}

/* Anything you can press shows the hand; disabled things say so. */
a[href], button, summary, select, label[for], [role='button'], [role='tab'], input[type='checkbox'], input[type='radio'], input[type='submit'] { cursor: pointer; }
button:disabled, [aria-disabled='true'] { cursor: not-allowed; }

/* Touch: the logo is a small target, so it gets an invisible 44px hit area. */
@media (pointer: coarse) { .site-header .logo { padding: 0.45rem 0.6rem; margin: -0.45rem -0.6rem; } }
