/* =====================================================================
   LOVEBUG — base.css
   Tokens, reset, typography, chrome (nav / rail / grain), hero, intro,
   reveal utilities, footer.
   ===================================================================== */

:root {
  /* Palette — above ground */
  --ivory: #f3ece2;
  --ivory-2: #e8ded0;
  --apricot: #f6c8a2;
  --dusk: #e9a58a;
  --ink: #12100e;
  --ink-2: #4b433c;
  --ink-3: #8a8077;

  /* Palette — below ground */
  --night: #0b0a09;
  --night-2: #16120f;
  --soil: #1f1710;
  --cream: #f3ece2;
  --cream-2: #b9afa3;
  --cream-3: #7c7369;

  /* Specimen */
  --accent: #f2552c;
  --accent-2: #ff8a5b;
  --egg: #efe2b6;
  --larva: #9b8467;
  --pupa: #c98a45;

  --font-display: "Instrument Serif", "Iowan Old Style", "Palatino Linotype", "Times New Roman", serif;
  --font-body: "Manrope", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-in-out: cubic-bezier(.65, 0, .35, 1);
  --ease-expo: cubic-bezier(.7, 0, .2, 1);

  --gutter: clamp(20px, 4vw, 64px);
  --radius: 28px;
  --nav-h: 72px;

  --vh100: 100vh;
  color-scheme: dark light;
}
@supports (height: 100dvh) {
  :root { --vh100: 100dvh; }
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--night);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}
h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
img, svg { display: block; max-width: 100%; }
::selection { background: var(--accent); color: var(--ivory); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

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

/* ---------- Type utilities ---------- */
.mono {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  font-weight: 500;
}
.serif { font-family: var(--font-display); font-weight: 400; }
em, .it { font-family: var(--font-display); font-style: italic; font-weight: 400; }

/* ---------- Scene stacking ---------- */
main { position: relative; }
.scene { position: relative; z-index: var(--z, 1); }
.scene--cover { margin-top: calc(-1 * var(--vh100)); }
.scene--pinned { height: calc(var(--travel, 300vh) + 2 * var(--vh100)); }
.scene__pin {
  position: sticky; top: 0;
  height: var(--vh100);
  overflow: hidden;
  isolation: isolate;
  border-radius: var(--r, 0) var(--r, 0) 0 0;
  box-shadow: 0 -30px 80px rgba(0,0,0,.28);
  transform: translateZ(0);
}
.scene--flow {
  border-radius: var(--r, 0) var(--r, 0) 0 0;
  box-shadow: 0 -30px 80px rgba(0,0,0,.28);
}

/* ---------- Canvas swarm ---------- */
.swarm {
  position: fixed; inset: 0; width: 100%; height: 100%;
  z-index: 40; pointer-events: none;
}

/* ---------- Windshield glass + wiper ---------- */
.windshield { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 39; pointer-events: none; }
.wiper-blade {
  position: fixed; left: 50%; bottom: -40px; width: 14px; height: var(--R, 120vmax);
  margin-left: -7px; transform-origin: 50% 100%; transform: rotate(-88deg);
  z-index: 42; pointer-events: none; will-change: transform;
}
.wiper-blade::before {
  /* the arm */
  content: ""; position: absolute; left: 5px; right: 5px; top: 8%; bottom: 0;
  background: linear-gradient(90deg, #2a2522, #4a423c 45%, #241f1c);
  border-radius: 3px;
}
.wiper-blade i {
  /* the rubber */
  position: absolute; left: 2px; right: 2px; top: 0; height: 88%;
  background: linear-gradient(90deg, #0d0b0a, #35302b 40%, #0d0b0a);
  border-radius: 6px;
  box-shadow: -10px 0 26px rgba(0,0,0,.28), 10px 0 26px rgba(0,0,0,.18);
}
.wiper-blade[hidden] { display: none; }
html.is-aiming, html.is-aiming * { cursor: crosshair !important; }

/* ---------- Grain ---------- */
body::after {
  content: "";
  position: fixed; inset: -50%;
  width: 200%; height: 200%;
  z-index: 60; pointer-events: none;
  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='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 240px 240px;
  opacity: .07;
  mix-blend-mode: overlay;
  animation: grain 1.2s steps(4) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-3%, 2%); }
  50% { transform: translate(2%, -3%); }
  75% { transform: translate(-1%, -1%); }
  100% { transform: translate(0, 0); }
}

/* ---------- Nav ---------- */
.nav {
  position: fixed; inset: 0 0 auto 0;
  height: var(--nav-h);
  z-index: 80;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--gutter);
  color: #fff;
  mix-blend-mode: difference;
  pointer-events: none;
}
.nav > * { pointer-events: auto; }
.nav__brand { display: flex; align-items: center; gap: 12px; }
.nav__brand svg { width: 34px; height: 18px; }
.nav__brand span { font-family: var(--font-display); font-size: 22px; letter-spacing: .01em; }
.nav__links { display: flex; gap: 32px; }
.nav__links a { position: relative; padding: 6px 0; opacity: .85; transition: opacity .3s; }
.nav__links a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
  background: currentColor; transform: scaleX(0); transform-origin: left;
  transition: transform .5s var(--ease-out);
}
.nav__links a:hover { opacity: 1; }
.nav__links a:hover::after { transform: scaleX(1); }
.nav__cta {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 10px 16px; border: 1px solid rgba(255,255,255,.55); border-radius: 999px;
  transition: background .4s, color .4s;
}
.nav__cta:hover { background: #fff; color: #000; }

.nav__right { display: flex; align-items: center; gap: 12px; }
.nav__wipe {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 9px 14px 9px 12px; border: 1px solid rgba(255,255,255,.55); border-radius: 999px;
  transition: background .4s, color .4s, transform .3s var(--ease-out);
}
.nav__wipe svg { width: 22px; height: 19px; }
.nav__wipe:hover { background: #fff; color: #000; }
.nav__wipe:active { transform: scale(.96); }
.nav__wipe.is-wiping svg { animation: wipeIcon .7s var(--ease-in-out); transform-origin: 50% 90%; }
@keyframes wipeIcon { 0% { transform: rotate(0); } 50% { transform: rotate(-70deg); } 100% { transform: rotate(0); } }
.nav__count { font-family: var(--font-display); font-weight: 400; font-size: 20px; line-height: 1; min-width: 1ch; font-variant-numeric: tabular-nums; }
.nav__count.is-bump { animation: bump .35s var(--ease-out); }
@keyframes bump { 0% { transform: scale(1.5); } 100% { transform: scale(1); } }
.nav__hint {
  opacity: 0; transform: translateX(10px); white-space: nowrap;
  transition: opacity .5s var(--ease-out), transform .5s var(--ease-out);
  pointer-events: none;
}
.nav__hint.is-on { opacity: .9; transform: none; }

/* ---------- Rail (lifecycle stage index) ---------- */
.rail {
  position: fixed; left: var(--gutter); top: 50%;
  transform: translateY(-50%);
  z-index: 80; color: #fff; mix-blend-mode: difference;
  display: flex; gap: 18px;
  opacity: 0; pointer-events: none;
  transition: opacity .6s var(--ease-out);
}
.rail.is-on { opacity: 1; pointer-events: auto; }
.rail__track { position: relative; width: 1px; background: rgba(255,255,255,.25); }
.rail__fill { position: absolute; left: 0; top: 0; width: 100%; height: 0%; background: #fff; }
.rail__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 26px; }
.rail__list button {
  display: grid; grid-template-columns: 28px 1fr; gap: 12px; align-items: baseline;
  opacity: .45; transition: opacity .4s, transform .5s var(--ease-out); text-align: left;
}
.rail__list button:hover, .rail__list button.is-active { opacity: 1; }
.rail__list button.is-active { transform: translateX(6px); }
.rail__list .serif { font-size: 20px; letter-spacing: .01em; }

/* ---------- Reveal utilities ---------- */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  filter: blur(8px);
  transition: opacity 1s var(--ease-out), transform 1s var(--ease-out), filter 1s var(--ease-out);
  transition-delay: calc(var(--i, 0) * 90ms);
}
.reveal.is-in { opacity: 1; transform: none; filter: none; }

.words .w { display: inline-block; overflow: hidden; vertical-align: bottom; }
.words .w > span {
  display: inline-block;
  transform: translateY(110%);
  transition: transform 1.1s var(--ease-out);
  transition-delay: calc(var(--i, 0) * 22ms);
}
.words.is-in .w > span { transform: none; }

.rule { height: 1px; background: currentColor; opacity: .14; transform: scaleX(0); transform-origin: left; transition: transform 1.4s var(--ease-expo); }
.rule.is-in { transform: scaleX(1); }

/* =====================================================================
   HERO
   ===================================================================== */
.hero { --z: 1; }
.hero__pin {
  background: var(--ivory);
  color: var(--ink);
  display: grid;
  grid-template-rows: 1fr auto;
  padding: calc(var(--nav-h) + 2vh) var(--gutter) 4vh;
}
.hero__body {
  align-self: center;
  display: grid; gap: clamp(20px, 3vh, 40px);
  transform: translateY(calc(var(--p, 0) * -14vh)) scale(calc(1 - var(--p, 0) * .08));
  opacity: calc(1 - var(--p, 0) * .72);
  filter: blur(calc(var(--p, 0) * 5px));
  will-change: transform, opacity;
}
.hero__eyebrow { display: flex; align-items: center; gap: 14px; color: var(--ink-2); }
.hero__eyebrow i { display: inline-block; width: 36px; height: 1px; background: currentColor; }
.hero__title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(48px, 8.8vw, 150px);
  line-height: .9;
  letter-spacing: -.025em;
  max-width: 11ch;
  text-wrap: balance;
}
.hero__title em { color: var(--accent); }
.hero__title .l { display: block; overflow: hidden; }
.hero__title .l > span { display: block; transform: translateY(105%); transition: transform 1.3s var(--ease-out); }
.hero__title.is-in .l:nth-child(1) > span { transition-delay: .1s; }
.hero__title.is-in .l:nth-child(2) > span { transition-delay: .22s; }
.hero__title.is-in .l > span { transform: none; }
.hero__sub {
  max-width: 46ch; font-size: clamp(16px, 1.35vw, 20px); line-height: 1.55; color: var(--ink-2);
}
.hero__foot {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 24px;
  color: var(--ink-2);
}
.hero__meta { display: grid; gap: 8px; }
.hero__meta b { font-weight: 600; color: var(--ink); }

/* Circular scroll cue */
.cue { position: relative; width: 116px; height: 116px; display: grid; place-items: center; }
.cue svg { position: absolute; inset: 0; width: 100%; height: 100%; animation: spin 14s linear infinite; }
.cue text { font-family: var(--font-mono); font-size: 11.5px; letter-spacing: .28em; text-transform: uppercase; fill: currentColor; }
.cue__arrow { width: 14px; height: 22px; position: relative; }
.cue__arrow::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: currentColor; animation: drop 1.8s var(--ease-in-out) infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes drop { 0% { transform: scaleY(0); transform-origin: top; } 50% { transform: scaleY(1); transform-origin: top; } 51% { transform-origin: bottom; } 100% { transform: scaleY(0); transform-origin: bottom; } }

/* Watermark marquee */
.hero__mark {
  position: absolute; left: 0; right: 0; bottom: -5vw;
  overflow: hidden; pointer-events: none; user-select: none;
  font-family: var(--font-display); font-style: italic;
  font-size: clamp(120px, 22vw, 380px); line-height: 1; letter-spacing: -.03em;
  color: transparent; -webkit-text-stroke: 1px rgba(18,16,14,.16);
  white-space: nowrap;
  opacity: calc(1 - var(--p, 0));
}
.hero__mark span { display: inline-block; padding-right: .6em; animation: marquee 40s linear infinite; }
@keyframes marquee { to { transform: translateX(-100%); } }

/* =====================================================================
   INTRO
   ===================================================================== */
.intro { --z: 2; background: var(--ivory); color: var(--ink); padding: 12vh var(--gutter) 14vh; }
.intro__grid { display: grid; grid-template-columns: 1fr 2.2fr; gap: 6vw; align-items: start; }
.intro__label { display: grid; gap: 14px; color: var(--ink-3); position: sticky; top: 14vh; }
.intro__label .serif { color: var(--ink); font-size: 30px; line-height: 1.1; }
.intro__lede {
  font-family: var(--font-display);
  font-size: clamp(30px, 3.6vw, 60px);
  line-height: 1.12; letter-spacing: -.015em;
  text-wrap: pretty;
}
.intro__lede em { color: var(--accent); }
.intro__lede small { display: block; letter-spacing: 0; margin-top: 28px; font-family: var(--font-body); font-size: clamp(16px, 1.2vw, 19px); color: var(--ink-2); max-width: 56ch; line-height: 1.6; }

.stats { margin-top: 12vh; display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid rgba(18,16,14,.14); }
.stat { padding: 28px 28px 32px 0; border-right: 1px solid rgba(18,16,14,.14); margin-right: 28px; }
.stat:last-child { border-right: 0; margin-right: 0; }
.stat__n { font-family: var(--font-display); font-size: clamp(48px, 5.4vw, 92px); line-height: 1; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.stat__n sup { font-size: .42em; vertical-align: top; margin-left: .05em; color: var(--accent); }
.stat__l { margin-top: 12px; color: var(--ink-3); }
.stat__d { margin-top: 8px; font-size: 14px; color: var(--ink-2); max-width: 24ch; line-height: 1.45; }

/* =====================================================================
   FOOTER
   ===================================================================== */
.footer { --z: 9; background: var(--night); color: var(--cream); padding: 12vh var(--gutter) 6vh; }
.footer__grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 6vw; }
.footer h2 { font-family: var(--font-display); font-weight: 400; font-size: clamp(36px, 5vw, 76px); line-height: 1; letter-spacing: -.02em; max-width: 12ch; }
.footer h2 em { color: var(--accent); }
.footer__col { display: grid; gap: 14px; align-content: start; color: var(--cream-2); font-size: 14px; line-height: 1.55; }
.footer__col .mono { color: var(--cream-3); }
.footer__col a { border-bottom: 1px solid rgba(243,236,226,.25); transition: border-color .3s, color .3s; }
.footer__col a:hover { color: var(--cream); border-color: var(--cream); }
.footer__end {
  margin-top: 10vh; padding-top: 24px; border-top: 1px solid rgba(243,236,226,.12);
  display: flex; justify-content: space-between; gap: 24px; color: var(--cream-3);
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  body::after { animation: none; }
  .cue svg, .hero__mark span { animation: none; }
  .reveal, .words .w > span, .rule, .hero__title .l > span { transition: none; }
  .reveal, .rule { opacity: 1; transform: none; filter: none; }
  .words .w > span, .hero__title .l > span { transform: none; }
  .swarm { display: none; }
}

/* ---------- Curtain exit: the pinned scene beneath a cover recedes ---------- */
.scene--pinned { --exit: 0; }
.scene__pin { transform: translateZ(0) scale(calc(1 - var(--exit) * .06)); }
.scene__pin.is-exiting { filter: brightness(calc(1 - var(--exit) * .32)); }
