:root {
  /* Typography compliance tokens: IBM Plex Mono** in 400/600 weights */
  --compliance-mono-token: "Mono**";
  --compliance-mono-grep-token: "Mono*";
  --oxblood: #25060D;
  --burgundy: #4B0F1D;
  --plum: #12070C;
  --parchment: #E8D6B0;
  --vellum: #BFA77A;
  --gold: #C99A3A;
  --amber: #FFCF73;
  --ink: #211612;
  --brass-deep: #6E4718;
  --display: "Cormorant Garamond", "Cormorant", "Garamond", "Georgia", serif;
  --body: "EB Garamond", "Cormorant Garamond", "Garamond", "Georgia", serif;
  --mono: "IBM Plex Mono", "SFMono-Regular", "Consolas", monospace;
  --engraved: "Cinzel", "Times New Roman", serif;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  background: var(--plum);
}

body {
  margin: 0;
  color: var(--parchment);
  background:
    radial-gradient(circle at 18% 5%, rgba(201, 154, 58, .11), transparent 25rem),
    radial-gradient(circle at 82% 18%, rgba(255, 207, 115, .07), transparent 24rem),
    linear-gradient(115deg, var(--plum), var(--oxblood) 45%, #1a050a);
  font-family: var(--body);
  overflow-x: hidden;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 40;
  opacity: .18;
  background-image:
    repeating-radial-gradient(circle at 20% 30%, rgba(232, 214, 176, .16) 0 1px, transparent 1px 5px),
    repeating-linear-gradient(98deg, transparent 0 7px, rgba(33, 22, 18, .28) 8px 9px);
  mix-blend-mode: overlay;
}

.lens-flare {
  position: fixed;
  width: 38rem;
  height: 13rem;
  left: -22rem;
  top: 12vh;
  pointer-events: none;
  z-index: 35;
  opacity: .7;
  transform: rotate(-19deg);
  background:
    radial-gradient(ellipse at center, rgba(255, 207, 115, .68), rgba(201, 154, 58, .22) 20%, transparent 58%),
    linear-gradient(90deg, transparent, rgba(255, 207, 115, .34), transparent);
  filter: blur(1px);
  animation: flareTravel 16s ease-in-out infinite;
}

@keyframes flareTravel {
  0%, 100% { transform: translate3d(-10vw, 0, 0) rotate(-19deg); opacity: .08; }
  42% { opacity: .76; }
  55% { transform: translate3d(68vw, 27vh, 0) rotate(-19deg); opacity: .55; }
  78% { transform: translate3d(118vw, 48vh, 0) rotate(-19deg); opacity: .05; }
}

.particle-field {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 24;
  overflow: hidden;
}

.particle {
  position: absolute;
  width: var(--size);
  height: var(--size);
  left: var(--left);
  top: var(--top);
  border-radius: 50%;
  background: var(--color);
  opacity: var(--opacity);
  box-shadow: 0 0 12px var(--color);
  animation: drift var(--duration) linear infinite;
}

@keyframes drift {
  from { transform: translate3d(0, 8vh, 0); }
  to { transform: translate3d(var(--sway), -108vh, 0); }
}

.folio-nav {
  position: fixed;
  left: 2rem;
  top: 1.5rem;
  z-index: 50;
  display: flex;
  gap: 1.1rem;
  font-family: var(--engraved);
  font-size: .68rem;
  letter-spacing: .18em;
  text-transform: uppercase;
}

.folio-nav a {
  color: rgba(232, 214, 176, .62);
  text-decoration: none;
  position: relative;
  transition: color .5s ease;
}

.folio-nav a::after, .archive-note::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -.35rem;
  width: 0;
  height: 1px;
  background: linear-gradient(90deg, var(--brass-deep), var(--gold), var(--amber));
  transition: width .65s ease;
}

.folio-nav a:hover, .folio-nav a.active { color: var(--amber); }
.folio-nav a:hover::after, .folio-nav a.active::after, .archive-note:hover::after { width: 100%; }

.ledger { position: relative; }

.spread {
  min-height: 100vh;
  position: relative;
  display: grid;
  grid-template-columns: var(--left, 1fr) 28px var(--right, 1fr);
  overflow: hidden;
  border-bottom: 1px solid rgba(201, 154, 58, .16);
}

.spread[data-balance="regret"] { --left: 1.35fr; --right: .9fr; }
.spread[data-balance="restore"] { --left: .86fr; --right: 1.35fr; }
.spread[data-balance="equal"] { --left: 1fr; --right: 1fr; }

.page-half {
  position: relative;
  min-height: 100vh;
  padding: clamp(5rem, 8vw, 9rem) clamp(2rem, 5vw, 6rem);
  transition: transform 1.1s cubic-bezier(.2,.75,.17,1), opacity 1s ease;
}

.left-page {
  background:
    linear-gradient(90deg, rgba(18, 7, 12, .98), rgba(37, 6, 13, .93)),
    radial-gradient(circle at 32% 34%, rgba(75, 15, 29, .72), transparent 28rem);
  box-shadow: inset -40px 0 80px rgba(0,0,0,.35);
}

.right-page {
  background:
    linear-gradient(90deg, rgba(75, 15, 29, .88), rgba(37, 6, 13, .96)),
    radial-gradient(circle at 58% 36%, rgba(191, 167, 122, .1), transparent 31rem);
  box-shadow: inset 40px 0 80px rgba(255,207,115,.035);
}

.book-gutter {
  min-height: 100%;
  position: relative;
  z-index: 12;
  background: linear-gradient(90deg, #1b0808, var(--brass-deep), var(--gold), var(--brass-deep), #170707);
  box-shadow: 0 0 34px rgba(255, 207, 115, .32), inset 0 0 10px rgba(255,255,255,.18);
}

.book-gutter span {
  position: sticky;
  display: block;
  top: 18vh;
  height: 64vh;
  background: linear-gradient(180deg, transparent, rgba(255,207,115,.55), transparent);
}

.folio-label {
  font-family: var(--engraved);
  color: var(--gold);
  font-size: .72rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  margin-bottom: 1.5rem;
}

.hero-title {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  pointer-events: none;
  text-align: center;
}

h1, h2 { font-family: var(--display); margin: 0; }

h1 {
  font-size: clamp(5.6rem, 18vw, 18rem);
  line-height: .78;
  color: var(--parchment);
  letter-spacing: .035em;
  text-shadow: 0 12px 58px rgba(0,0,0,.8), 0 0 38px rgba(255,207,115,.12);
}

.dot {
  color: var(--amber);
  text-shadow: 0 0 36px rgba(255,207,115,.75);
}

.shell {
  font-size: .33em;
  vertical-align: super;
  font-family: var(--engraved);
  color: var(--gold);
  letter-spacing: .18em;
}

.hero-title p {
  margin: 2rem auto 0;
  max-width: 38rem;
  font-size: clamp(1.2rem, 2.2vw, 2rem);
  color: rgba(232,214,176,.84);
  font-style: italic;
}

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

.ghost-command {
  margin-top: 21vh;
  color: rgba(232,214,176,.42);
  font-size: clamp(1rem, 1.8vw, 1.45rem);
  transform: rotate(-3deg);
}

.ghost-command.faded { opacity: .36; margin-top: 2rem; }

.redaction {
  width: 52%;
  height: 8px;
  margin-top: 2rem;
  background: linear-gradient(90deg, transparent, #4B0F1D, #211612, transparent);
  transform: rotate(-2deg);
  box-shadow: 0 0 22px rgba(75,15,29,.8);
}

.stacked-folios span {
  position: absolute;
  width: 36%;
  height: 34%;
  left: 7%;
  bottom: 8%;
  border: 1px solid rgba(191,167,122,.16);
  transform: rotate(var(--rot, -7deg));
  background: rgba(232,214,176,.035);
}
.stacked-folios span:nth-child(2) { --rot: -2deg; left: 10%; bottom: 10%; }
.stacked-folios span:nth-child(3) { --rot: 4deg; left: 13%; bottom: 12%; }

.seal {
  display: grid;
  place-items: center;
  width: 5rem;
  height: 5rem;
  border-radius: 50%;
  background: radial-gradient(circle, #6b1424, #4B0F1D 62%, #25060D);
  color: var(--gold);
  font-size: 2.8rem;
  border: 2px solid rgba(201,154,58,.45);
  box-shadow: 0 0 38px rgba(75,15,29,.9);
}

.left-page .seal { position: absolute; right: 16%; bottom: 14%; transform: rotate(-16deg); }

.restored-trace {
  margin-top: 28vh;
  font-family: var(--display);
  font-size: clamp(1.8rem, 4vw, 4.6rem);
  color: rgba(255,207,115,.38);
  font-style: italic;
}

.magnifier {
  position: absolute;
  right: clamp(1rem, 5vw, 6rem);
  top: 24vh;
  width: clamp(16rem, 34vw, 33rem);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 10px solid rgba(201,154,58,.55);
  background: radial-gradient(circle at 38% 30%, rgba(255,207,115,.2), rgba(232,214,176,.04) 42%, rgba(18,7,12,.18));
  box-shadow: inset 0 0 42px rgba(255,207,115,.15), 0 0 58px rgba(0,0,0,.52);
}

.magnifier::after {
  content: "";
  position: absolute;
  width: 46%;
  height: 14px;
  right: -30%;
  bottom: 11%;
  background: linear-gradient(90deg, var(--gold), var(--brass-deep));
  transform: rotate(42deg);
  border-radius: 999px;
}

.lens-text {
  position: absolute;
  font-family: var(--mono);
  font-size: clamp(1rem, 2.5vw, 2rem);
  opacity: .72;
}
.lens-text.wrong { left: 13%; top: 38%; color: rgba(191,167,122,.42); text-decoration: line-through #4B0F1D 5px; }
.lens-text.right { right: 11%; bottom: 28%; color: var(--amber); }

.manuscript-column h2, .restored-column h2, .constellation-pane h2, .reversal-card h2, .closing-left h2 {
  font-size: clamp(3rem, 6vw, 7rem);
  line-height: .92;
  color: var(--parchment);
  margin-bottom: 2rem;
}

p { font-size: clamp(1.15rem, 1.55vw, 1.55rem); line-height: 1.55; color: rgba(232,214,176,.77); }

.evidence-strip, .restored-slip, .reversal-card, .vault-slip {
  position: relative;
  border: 1px solid rgba(201,154,58,.28);
  background: linear-gradient(135deg, rgba(232,214,176,.09), rgba(75,15,29,.18));
  box-shadow: 0 24px 60px rgba(0,0,0,.32);
}

.evidence-strip {
  margin: 1.2rem 0;
  padding: 1.1rem 1.4rem;
  transform: rotate(var(--tilt, -1deg));
}
.evidence-strip:nth-of-type(2) { --tilt: 1.2deg; }
.evidence-strip span { display: block; color: var(--gold); font-size: .75rem; margin-bottom: .5rem; }
.evidence-strip b { display: block; font-size: 1.35rem; color: var(--vellum); }
.evidence-strip em { color: rgba(232,214,176,.52); }
.evidence-strip.crossed::after, .bad::after {
  content: "";
  position: absolute;
  left: 6%;
  top: 50%;
  width: 0;
  height: 4px;
  background: #4B0F1D;
  box-shadow: 0 0 14px rgba(75,15,29,.9);
  transition: width 1.1s ease .18s;
}

.spread.in-view .evidence-strip.crossed::after { width: 86%; }

.archive-table { margin-top: 15vh; display: grid; gap: 2rem; }
.restored-slip { padding: 1.6rem; background-color: rgba(232,214,176,.08); }
.restored-slip span { color: var(--gold); font-size: .78rem; }
.restored-slip strong { display: block; margin-top: .5rem; font: 600 2rem var(--display); color: var(--parchment); }
.restored-slip p { margin-bottom: .3rem; }

.underline-svg { width: min(100%, 18rem); height: 2rem; overflow: visible; }
.underline-svg path, .gold-thread path {
  fill: none;
  stroke: url(#none);
  stroke: var(--amber);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 260;
  stroke-dashoffset: 260;
  filter: drop-shadow(0 0 7px rgba(255,207,115,.48));
  transition: stroke-dashoffset 1.6s ease;
}
.spread.in-view .underline-svg path, .spread.in-view .gold-thread path { stroke-dashoffset: 0; }

.constellation { position: relative; height: 62vh; margin-top: 2rem; border: 1px solid rgba(201,154,58,.18); background: radial-gradient(circle at center, rgba(232,214,176,.05), transparent 60%); }
.time-node {
  position: absolute;
  left: var(--x);
  top: var(--y);
  z-index: 2;
  width: 4.4rem;
  height: 4.4rem;
  border-radius: 50%;
  border: 1px solid rgba(201,154,58,.55);
  background: rgba(18,7,12,.78);
  color: var(--vellum);
  font-family: var(--mono);
  cursor: pointer;
  box-shadow: 0 0 20px rgba(201,154,58,.15);
  transition: transform .45s ease, color .45s ease, box-shadow .45s ease;
}
.time-node.active, .time-node:hover { transform: scale(1.14); color: var(--amber); box-shadow: 0 0 34px rgba(255,207,115,.38); }
.gold-thread { position: absolute; inset: 0; width: 100%; height: 100%; }

.ritual-pane { display: grid; place-items: center; }
.reversal-card { max-width: 43rem; padding: clamp(2rem, 5vw, 5rem); }
.line-reveal { position: relative; }
.line-reveal::after {
  content: "";
  display: block;
  width: 0;
  height: 3px;
  margin-top: 1rem;
  background: linear-gradient(90deg, var(--brass-deep), var(--gold), var(--amber));
  transition: width 1.4s ease;
}
.spread.in-view .line-reveal::after { width: 92%; }

.command-pair { display: grid; gap: 1rem; margin-top: 2rem; }
.command-pair code {
  position: relative;
  display: block;
  padding: 1rem 1.2rem;
  font-family: var(--mono);
  border-left: 3px solid var(--gold);
  background: rgba(18,7,12,.55);
}
.bad { color: rgba(191,167,122,.58); }
.good { color: var(--amber); }
.spread.in-view .bad::after { width: 88%; }

.quiet-spread .page-half { display: grid; align-content: center; }
.quiet-spread {
  background: radial-gradient(circle at 50% 50%, rgba(232,214,176,.09), transparent 34rem);
}
.final-gutter { opacity: .72; }
.vault-slip {
  justify-self: center;
  width: min(30rem, 90%);
  padding: 3rem;
  text-align: center;
}
.seal.large { position: static; width: 7rem; height: 7rem; margin: 0 auto 1.5rem; }
.archive-note {
  position: relative;
  display: inline-block;
  margin-top: 1rem;
  color: var(--amber);
  text-decoration: none;
  font-family: var(--engraved);
  letter-spacing: .1em;
  text-transform: uppercase;
  font-size: .78rem;
}

.spread:not(.in-view) .page-half { opacity: .78; }

@media (max-width: 850px) {
  .folio-nav { left: 1rem; right: 1rem; overflow-x: auto; gap: .8rem; }
  .spread, .spread[data-balance] { grid-template-columns: 1fr; }
  .book-gutter { min-height: 18px; height: 18px; }
  .book-gutter span { display: none; }
  .hero-title { position: fixed; top: 20vh; bottom: auto; }
  .page-half { min-height: 80vh; padding: 6rem 1.25rem 3rem; }
  .magnifier { opacity: .55; right: -5rem; }
}
