:root {
  --sky: #f4e7ce;
  --stone: #d9bc8c;
  --stone-mid: #a87c4f;
  --shadow: #4a3a28;
  --deep: #1a1410;
  --water: #070a0b;
  --teal: #16463f;
  --sindoor: #c1440e;

  --display: 'Bodoni Moda', Georgia, serif;
  --body: 'Archivo', system-ui, sans-serif;
  --mono: 'Space Mono', ui-monospace, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: auto; }

body {
  background: var(--deep);
  color: var(--sky);
  font-family: var(--body);
  overflow-x: hidden;
  cursor: default;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  z-index: 0;
}

/* the page is only a scroll surface — every pixel you see is the canvas */
#scroll-track { height: 7200vh; }

/* --- film treatment ------------------------------------------------------ */
#grain, #vignette { position: fixed; inset: 0; pointer-events: none; z-index: 2; }

#vignette {
  background: radial-gradient(ellipse at 50% 46%, transparent 30%, rgba(6, 5, 3, .5) 72%, rgba(4, 3, 2, .88) 100%);
}

#grain {
  opacity: .10;
  will-change: opacity;
  transform: translateZ(0);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ONE gradient, on its own compositor layer. Two stacked full-screen gradients
   plus the grain layer's overlay blend pushed max frame time to 140ms. */
#landing-scrim {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  will-change: opacity;
  transform: translateZ(0);
  background: radial-gradient(ellipse at 50% 40%,
    rgba(6, 5, 4, .24) 0%, rgba(6, 5, 4, .58) 56%, rgba(4, 3, 2, .84) 100%);
}

/* --- hero ---------------------------------------------------------------- */
/* Dead centre, both axes. The landing frame is perfectly symmetrical so the
   wordmark should sit on its axis, not float above it. */
#hero {
  position: fixed;
  z-index: 4;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  will-change: opacity;
}

#hero-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  will-change: transform;
}

#hero h1 {
  display: flex;
  /* Bodoni at display size wants the 96pt optical master — hairlines get finer
     and the contrast reads as cut rather than printed. Tracking goes slightly
     negative, because a didone set loose at 12vw falls apart. */
  font-family: var(--display);
  font-variation-settings: 'opsz' 96;
  font-weight: 800;
  font-size: clamp(3.6rem, 13.5vw, 13.5rem);
  line-height: .9;
  letter-spacing: -0.012em;
  color: #fbf4e6;
}

/* each letter is a mask so the reveal can slide inside it */
#hero h1 .ltr {
  display: block;
  overflow: hidden;
  padding: 0 .012em .09em;
}
#hero h1 .ltr > span { display: block; }

.hero-rule {
  width: clamp(90px, 15vw, 220px);
  height: 1px;
  margin-top: 1.5rem;
  background: linear-gradient(90deg, transparent, rgba(251, 244, 230, .55), transparent);
}

.hero-sub {
  margin-top: 1.1rem;
  font-family: var(--mono);
  font-size: clamp(.56rem, .72vw, .68rem);
  letter-spacing: .46em;
  padding-left: .46em;
  text-transform: uppercase;
  color: rgba(251, 244, 230, .66);
}

/* --- scroll cue ---------------------------------------------------------- */
#scroll-cue {
  position: fixed;
  z-index: 3;
  right: clamp(1.2rem, 3vw, 2.6rem);
  bottom: clamp(1.4rem, 4vh, 2.8rem);
  display: flex;
  align-items: center;
  gap: .8rem;
  font-family: var(--mono);
  font-size: .58rem;
  letter-spacing: .28em;
  color: rgba(244, 231, 206, .62);
  pointer-events: none;
  transition: opacity .4s ease;
}

.cue-track {
  position: relative;
  width: 62px; height: 1px;
  background: rgba(244, 231, 206, .22);
  overflow: hidden;
}

#scroll-cue.idle .cue-run { animation: none; }

.cue-run {
  position: absolute;
  inset: 0;
  background: var(--sky);
  transform-origin: left;
  animation: run 2.4s cubic-bezier(.6, 0, .3, 1) infinite;
}

@keyframes run {
  0%   { transform: scaleX(0); transform-origin: left; }
  45%  { transform: scaleX(1); transform-origin: left; }
  55%  { transform: scaleX(1); transform-origin: right; }
  100% { transform: scaleX(0); transform-origin: right; }
}

/* --- altimeter ----------------------------------------------------------- */
#altimeter {
  position: fixed;
  z-index: 3;
  right: clamp(1.1rem, 3vw, 2.6rem);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: .95rem;
  pointer-events: none;
  text-shadow: 0 1px 14px rgba(10, 8, 5, .85), 0 0 3px rgba(10, 8, 5, .6);
}

.rail {
  position: relative;
  width: 1px;
  height: min(46vh, 340px);
  background: rgba(244, 231, 206, .22);
}

#rail-fill {
  position: absolute;
  inset: 0;
  background: var(--sky);
  transform-origin: top;
  transform: scaleY(0);
}

.read { font-family: var(--mono); text-align: right; }

#depth {
  font-size: clamp(1.05rem, 1.9vw, 1.55rem);
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--sky);
  font-variant-numeric: tabular-nums;
}

.sub {
  margin-top: .3rem;
  font-size: .58rem;
  letter-spacing: .16em;
  color: rgba(244, 231, 206, .55);
}

/* --- chapter ------------------------------------------------------------- */
#chapter-block {
  position: fixed;
  z-index: 3;
  opacity: 0;
  transition: opacity .45s ease;
  left: clamp(1.1rem, 3vw, 2.6rem);
  bottom: clamp(1.4rem, 4vh, 2.8rem);
  pointer-events: none;
  text-shadow: 0 1px 14px rgba(10, 8, 5, .85), 0 0 3px rgba(10, 8, 5, .6);
}

#chapter {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.5rem, 3.4vw, 2.9rem);
  letter-spacing: .04em;
  color: var(--sky);
}

#chapter-note {
  margin-top: .34rem;
  font-family: var(--mono);
  font-size: .6rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: rgba(244, 231, 206, .58);
}

/* --- dialogue ------------------------------------------------------------ */
.copy {
  position: fixed;
  z-index: 4;
  top: 50%;
  left: clamp(1.5rem, 7vw, 6rem);
  transform: translateY(-50%);
  width: min(42ch, 40vw);
  pointer-events: none;
  opacity: 0;
  transition: opacity .34s ease;
  text-shadow: 0 1px 22px rgba(10, 8, 5, .8);
}

.copy.show { opacity: 1; }

/* placement alternates per beat so the blocks never read as a slide deck */
.copy.right  { right: clamp(1.5rem, 7vw, 6rem); text-align: left; }
.copy.left   { left:  clamp(1.5rem, 7vw, 6rem); text-align: left; }
.copy.centre {
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(52ch, 74vw);
  text-align: center;
}

/* each line is a mask; the inner span slides up inside it */
.copy .line {
  display: block;
  overflow: hidden;
  padding-bottom: .06em;
}
.copy .line > span { display: block; will-change: transform; }

.copy .eyebrow {
  font-family: var(--mono);
  font-size: .6rem;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: rgba(244, 231, 206, .62);
  margin-bottom: 1.1rem;
}

.copy .statement {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.7rem, 3.6vw, 3.4rem);
  line-height: 1.08;
  letter-spacing: .01em;
  color: var(--sky);
}

.copy .body {
  margin-top: 1.35rem;
  font-family: var(--body);
  font-weight: 300;
  font-size: clamp(.88rem, 1.05vw, 1rem);
  line-height: 1.75;
  color: rgba(244, 231, 206, .82);
}

.copy .body[hidden], .copy .eyebrow[hidden] { display: none; }

@media (max-width: 820px) {
  .copy, .copy.centre {
    left: 1.4rem; right: 1.4rem; width: auto;
    transform: translateY(-50%);
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  .arrow { animation: none; }
  .copy .line > span { transform: none !important; }
}

/* --- top bar -------------------------------------------------------------- */
/* There was no navigation of any kind before this. */
#topbar {
  position: fixed;
  z-index: 6;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: clamp(1rem, 2.4vh, 1.7rem) clamp(1.2rem, 3vw, 2.6rem);
  font-family: var(--mono);
  font-size: .6rem;
  letter-spacing: .26em;
  text-shadow: 0 1px 18px rgba(8, 6, 4, .9);
}

.brand {
  display: flex;
  align-items: center;
  gap: .7rem;
  color: var(--sky);
  text-decoration: none;
}
.brand-deva { font-family: var(--display); letter-spacing: .1em; font-size: .82rem; }
.brand-sep { width: 16px; height: 1px; background: rgba(244, 231, 206, .5); }
.brand-latin { letter-spacing: .3em; }

.tools { display: flex; gap: 1.4rem; }

.tool {
  display: flex;
  align-items: center;
  gap: .5rem;
  background: none;
  border: 0;
  padding: .35rem 0;
  color: rgba(244, 231, 206, .72);
  font: inherit;
  letter-spacing: .26em;
  cursor: pointer;
  transition: color .25s ease;
}
.tool:hover, .tool:focus-visible { color: var(--sky); outline: none; }

.tool .dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  border: 1px solid currentColor;
  transition: background .25s ease;
}
.tool.on .dot { background: currentColor; }

/* --- the record (bottom left) --------------------------------------------- */
#meta {
  position: fixed;
  z-index: 3;
  left: clamp(1.2rem, 3vw, 2.6rem);
  bottom: clamp(1.4rem, 4vh, 2.8rem);
  max-width: 30ch;
  pointer-events: none;
  transition: opacity .45s ease;
}

.meta-rule { display: block; width: 34px; height: 1px; background: rgba(244, 231, 206, .5); margin-bottom: .9rem; }

.meta-title {
  font-family: var(--display);
  font-size: clamp(1.05rem, 1.9vw, 1.5rem);
  letter-spacing: .02em;
  color: var(--sky);
}

.meta-sub {
  margin-top: .3rem;
  font-family: var(--mono);
  font-size: .58rem;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: rgba(244, 231, 206, .6);
}

.meta-line {
  margin-top: 1rem;
  font-family: var(--body);
  font-weight: 300;
  font-size: .82rem;
  line-height: 1.6;
  color: rgba(244, 231, 206, .72);
}

/* --- chapter index -------------------------------------------------------- */
#index-panel {
  position: fixed;
  z-index: 7;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 8vh clamp(1.4rem, 8vw, 7rem);
  background: rgba(9, 7, 5, .93);
  opacity: 0;
  transition: opacity .3s ease;
}
#index-panel.show { opacity: 1; }

/* `display: flex` above silently overrides the UA's `[hidden] { display:none }`,
   so the panel stayed spread across the whole viewport at z-index 7 and ate
   every click meant for the top bar. That is why BOTH buttons were dead. */
#index-panel[hidden] { display: none; }

#index-list { list-style: none; counter-reset: ix; }

#index-list li { border-top: 1px solid rgba(244, 231, 206, .12); }
#index-list li:last-child { border-bottom: 1px solid rgba(244, 231, 206, .12); }

#index-list button {
  counter-increment: ix;
  display: flex;
  align-items: baseline;
  gap: 1.6rem;
  width: 100%;
  padding: clamp(.7rem, 1.6vh, 1.15rem) 0;
  background: none;
  border: 0;
  cursor: pointer;
  text-align: left;
  color: rgba(244, 231, 206, .74);
  transition: color .22s ease, padding-left .3s cubic-bezier(.22,.61,.36,1);
}
#index-list button::before {
  content: counter(ix, decimal-leading-zero);
  font-family: var(--mono);
  font-size: .58rem;
  letter-spacing: .2em;
  color: rgba(244, 231, 206, .4);
}
#index-list button:hover, #index-list button:focus-visible {
  color: var(--sky);
  padding-left: 1rem;
  outline: none;
}

.ix-name {
  font-family: var(--display);
  font-size: clamp(1.3rem, 3.2vw, 2.4rem);
  letter-spacing: .02em;
}

.index-foot {
  margin-top: 3vh;
  font-family: var(--mono);
  font-size: .56rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: rgba(244, 231, 206, .45);
}

@media (max-width: 820px) {
  .tool-label { display: none; }
  .tool .dot { width: 7px; height: 7px; }
  #meta .meta-line { display: none; }
}

/* --- loader --------------------------------------------------------------- */
#loader {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.6rem;
  background: #0b0906;
  transition: opacity .8s ease;
}
#loader.done { opacity: 0; pointer-events: none; }

.loader-mark {
  font-family: var(--display);
  font-variation-settings: 'opsz' 96;
  font-weight: 800;
  font-size: clamp(2.2rem, 7vw, 5rem);
  letter-spacing: -.01em;
  color: #fbf4e6;
}

.loader-track {
  position: relative;
  width: min(210px, 40vw);
  height: 1px;
  background: rgba(251, 244, 230, .18);
  overflow: hidden;
}
#loader-fill {
  position: absolute;
  inset: 0;
  background: #fbf4e6;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .3s ease;
}

.loader-pct {
  font-family: var(--mono);
  font-size: .58rem;
  letter-spacing: .3em;
  color: rgba(251, 244, 230, .5);
}

#index-close {
  position: absolute;
  top: clamp(1rem, 2.4vh, 1.7rem);
  right: clamp(1.2rem, 3vw, 2.6rem);
  background: none;
  border: 0;
  padding: .4rem 0;
  font-family: var(--mono);
  font-size: .6rem;
  letter-spacing: .26em;
  color: rgba(244, 231, 206, .7);
  cursor: pointer;
}
#index-close:hover, #index-close:focus-visible { color: var(--sky); outline: none; }

/* --- after the film ------------------------------------------------------- */
/* Opaque, so these pages cover the fixed canvas as they scroll over it. */
#after {
  position: relative;
  z-index: 5;
  background: #0e0b08;
  color: var(--sky);
}

.sec {
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(5rem, 14vh, 11rem) clamp(1.4rem, 5vw, 4rem);
  border-top: 1px solid rgba(244, 231, 206, .1);
}
.sec:first-child { border-top: 0; }

.kicker {
  font-family: var(--mono);
  font-size: .58rem;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: rgba(244, 231, 206, .5);
  margin-bottom: 1.6rem;
}

.sec h2 {
  font-family: var(--display);
  font-variation-settings: 'opsz' 72;
  font-weight: 500;
  font-size: clamp(2rem, 5.4vw, 4.2rem);
  line-height: 1.02;
  letter-spacing: -.008em;
  margin-bottom: clamp(2rem, 5vh, 3.4rem);
  max-width: 18ch;
}

.cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: clamp(2rem, 5vw, 4.5rem);
}

.cols p {
  font-family: var(--body);
  font-weight: 300;
  font-size: clamp(.92rem, 1.1vw, 1.02rem);
  line-height: 1.78;
  color: rgba(244, 231, 206, .8);
  max-width: 46ch;
}
.cols p + p { margin-top: 1.1rem; }
.cols strong { font-weight: 500; color: var(--sky); }

.ledger, .spec { list-style: none; }

.ledger li, .spec li {
  display: grid;
  grid-template-columns: minmax(7.5rem, 11rem) 1fr;
  gap: 1.4rem;
  padding: .95rem 0;
  border-top: 1px solid rgba(244, 231, 206, .1);
}
.ledger li:last-child, .spec li:last-child { border-bottom: 1px solid rgba(244, 231, 206, .1); }

.ledger span, .spec span {
  font-family: var(--mono);
  font-size: .58rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: rgba(244, 231, 206, .52);
  padding-top: .28rem;
}

.ledger em, .spec em {
  font-style: normal;
  font-family: var(--body);
  font-weight: 300;
  font-size: .9rem;
  line-height: 1.6;
  color: rgba(244, 231, 206, .82);
}

.sec-colophon .foot {
  margin-top: clamp(3rem, 8vh, 5rem);
  font-family: var(--mono);
  font-size: .58rem;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: rgba(244, 231, 206, .42);
}

@media (max-width: 620px) {
  .ledger li, .spec li { grid-template-columns: 1fr; gap: .35rem; }
}

/* --- content polish ------------------------------------------------------- */
.sec { position: relative; }

.sec-no {
  position: absolute;
  top: clamp(3.4rem, 9vh, 7rem);
  left: clamp(1.4rem, 5vw, 4rem);
  transform: translateX(-140%);
  font-family: var(--mono);
  font-size: .6rem;
  letter-spacing: .22em;
  color: rgba(244, 231, 206, .3);
}
@media (max-width: 1100px) { .sec-no { display: none; } }

.ledger li { transition: background .3s ease, padding-left .3s cubic-bezier(.22,.61,.36,1); }
.ledger li:hover { background: rgba(244, 231, 206, .035); padding-left: .7rem; }

/* --- the cross-section ---------------------------------------------------- */
.figure-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(260px, 1fr);
  gap: clamp(1.6rem, 4vw, 3.4rem);
  align-items: center;
}
@media (max-width: 900px) { .figure-wrap { grid-template-columns: 1fr; } }

.figure svg { width: 100%; height: auto; display: block; }
.sx-ground { stroke: rgba(244, 231, 206, .22); stroke-width: 1; stroke-dasharray: 3 5; }
.sx-stone  { fill: #1b1611; stroke: rgba(244, 231, 206, .34); stroke-width: 1.2; }
.sx-water  { fill: rgba(58, 96, 62, .68); }
.sx-line   { stroke: #8fbf8a; stroke-width: 1.2; opacity: .85; }
.sx-tag {
  fill: rgba(244, 231, 206, .42);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .22em;
}

.figure-ctl label {
  display: block;
  font-family: var(--mono);
  font-size: .58rem;
  letter-spacing: .26em;
  text-transform: uppercase;
  color: rgba(244, 231, 206, .5);
  margin-bottom: .9rem;
}

#section-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 1px;
  background: rgba(244, 231, 206, .26);
  outline: none;
  cursor: ew-resize;
}
#section-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--sky);
  border: 0;
  cursor: ew-resize;
}
#section-slider::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--sky);
  border: 0;
  cursor: ew-resize;
}

.figure-read { margin-top: 1.4rem; }
.figure-depth {
  display: block;
  font-family: var(--mono);
  font-size: clamp(1.4rem, 2.6vw, 2rem);
  font-weight: 700;
  color: var(--sky);
  font-variant-numeric: tabular-nums;
}
.figure-state {
  display: block;
  margin-top: .5rem;
  font-family: var(--body);
  font-weight: 300;
  font-size: .86rem;
  line-height: 1.6;
  color: rgba(244, 231, 206, .74);
  min-height: 2.7em;
}
.figure-note {
  margin-top: 1.6rem;
  font-family: var(--body);
  font-weight: 300;
  font-size: .82rem;
  line-height: 1.7;
  color: rgba(244, 231, 206, .55);
}

/* --- the end -------------------------------------------------------------- */
.end {
  margin-top: clamp(3rem, 8vh, 5rem);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1.4rem;
}

.again {
  background: none;
  border: 1px solid rgba(244, 231, 206, .28);
  padding: .95rem 1.9rem;
  font-family: var(--mono);
  font-size: .6rem;
  letter-spacing: .26em;
  text-transform: uppercase;
  color: var(--sky);
  cursor: pointer;
  transition: background .3s ease, border-color .3s ease;
}
.again:hover, .again:focus-visible {
  background: rgba(244, 231, 206, .08);
  border-color: rgba(244, 231, 206, .55);
  outline: none;
}
.sec-colophon .foot { margin-top: 0; }

/* --- section layout balance ---------------------------------------------- */
/* The ledger runs far taller than the paragraph beside it, which left a large
   dead void under the left column. Narrowing that column and making it STICK
   means it travels with the ledger instead of stranding at the top — the space
   is now intentional breathing room rather than an accident of unequal height. */
.sec-changed .cols {
  grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.18fr);
  align-items: start;
}

.sec-changed .cols > div:first-child {
  position: sticky;
  top: 22vh;
}

@media (max-width: 900px) {
  .sec-changed .cols { grid-template-columns: 1fr; }
  .sec-changed .cols > div:first-child { position: static; }
}

/* Content scrolls beneath the fixed topbar, so section kickers were colliding
   with the wordmark. A short scrim keeps the bar legible without boxing it in. */
#topbar::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(to bottom, rgba(10, 8, 6, .92) 0%, rgba(10, 8, 6, .65) 55%, transparent 100%);
  pointer-events: none;
}
