/* ============================================================
   $PIPER — RESET + PRIMITIVES
   ============================================================ */

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

* { margin: 0; }

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

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  min-height: 100svh;
  /* forest-ink ground with one faint emerald light bleeding from the top —
     depth, not decoration. Kept low so it reads as atmosphere. */
  background:
    radial-gradient(135% 70% at 50% -8%,
      color-mix(in srgb, var(--brand) 7%, transparent), transparent 58%),
    var(--paper);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--f-body);
  font-size: var(--t-body);
  line-height: var(--lh-body);
  font-synthesis-weight: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

/* ---- Vellum grain. Pure CSS, no external asset. ---- */
body::before {
  content: "";
  position: fixed;
  inset: -20%;
  z-index: var(--z-noise);
  pointer-events: none;
  opacity: var(--noise-op);
  mix-blend-mode: var(--noise-blend);
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Everything real sits above the grain. */
.nav, main, .foot { position: relative; z-index: var(--z-body); }
.nav { z-index: var(--z-nav); }

img, svg, video { display: block; max-width: 100%; }
svg { fill: currentColor; }

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

ul, ol { padding: 0; list-style: none; }

a { color: inherit; }

/* ============================================================
   TYPE PRIMITIVES
   ============================================================ */

.display, h1, h2, h3 {
  font-family: var(--f-display);
  font-weight: 700;
  line-height: var(--lh-head);
  letter-spacing: -.015em;
  text-wrap: balance;
}

.t-hero { font-size: var(--t-hero); line-height: var(--lh-tight); letter-spacing: -.03em; }
.t-h1   { font-size: var(--t-h1); }
.t-h2   { font-size: var(--t-h2); }
.t-h3   { font-size: var(--t-h3); }

.lede {
  font-size: var(--t-lede);
  color: var(--ink-2);
  max-width: var(--measure);
  text-wrap: pretty;
}

.prose { max-width: var(--measure); }
.prose p + p { margin-top: var(--sp-4); }
.prose p { text-wrap: pretty; }

/* Small-caps eyebrow with rules on both sides. */
.kicker {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  font-family: var(--f-mono);
  font-size: var(--t-small);
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: var(--sp-4);
}
.kicker::before {
  content: "";
  width: 1.75rem;
  height: 1px;
  background: var(--gold);
  flex: none;
}
.kicker--center { justify-content: center; }
.kicker--center::after {
  content: "";
  width: 1.75rem;
  height: 1px;
  background: var(--gold);
  flex: none;
}

.mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.blood { color: var(--blood); }
/* On light, raw --gold fails AA as text. --gold-ink is the readable twin. */
.gilt { color: var(--gold-ink); }

/* Drop cap — the manuscript move. */
.dropcap::first-letter {
  float: left;
  font-family: var(--f-display);
  font-size: 4.1em;
  line-height: .78;
  font-weight: 700;
  padding: .06em .12em 0 0;
  color: var(--blood);
}

/* Hand-inked underline that draws itself. */
.ink-link {
  color: inherit;
  text-decoration: none;
  background-image: linear-gradient(var(--blood), var(--blood));
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 0% 2px;
  transition: background-size var(--d-2) var(--e-out);
  padding-bottom: 1px;
}
.ink-link:hover, .ink-link:focus-visible { background-size: 100% 2px; }

/* ============================================================
   LAYOUT
   ============================================================ */

.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--pad);
}
.wrap--narrow { max-width: var(--maxw-nar); }

.section { padding-block: clamp(3.25rem, 1.5rem + 7vw, 7rem); }
.section--tight { padding-block: clamp(2rem, 1rem + 4vw, 4rem); }

.stack > * + * { margin-top: var(--sp-4); }
.stack-lg > * + * { margin-top: var(--sp-6); }

.center { text-align: center; }
.center .lede, .center .prose { margin-inline: auto; }

.grid { display: grid; gap: clamp(1rem, .5rem + 1.6vw, 1.85rem); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 21rem), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 16.5rem), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); }

.row { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; }
.row--center { justify-content: center; }

/* ============================================================
   ACCESSIBILITY
   ============================================================ */

:where(a, button, [tabindex], summary, input):focus-visible {
  outline: 3px solid var(--blood);
  outline-offset: 3px;
  border-radius: var(--r-1);
}

.skip {
  position: absolute;
  left: 50%;
  top: 0;
  translate: -50% -140%;
  z-index: var(--z-top);
  background: var(--ink);
  color: var(--paper);
  padding: var(--sp-3) var(--sp-5);
  border-radius: 0 0 var(--r-2) var(--r-2);
  text-decoration: none;
  font-family: var(--f-mono);
  font-size: var(--t-small);
  transition: translate var(--d-2) var(--e-out);
}
.skip:focus-visible { translate: -50% 0; }

.vh {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Sprite host injected by piper.js — never rendered. */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ============================================================
   SCROLL REVEAL — opt-in, and a no-op when JS is off or the
   user asked for less motion.
   ============================================================ */

.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition:
    opacity var(--d-3) var(--e-out),
    transform var(--d-3) var(--e-out);
  transition-delay: var(--reveal-delay, 0ms);
}
.reveal.is-in { opacity: 1; transform: none; }

/* No JS? Show everything. */
html:not(.js) .reveal { opacity: 1; transform: none; }

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

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