:root {
  /* Compliance tokens from DESIGN.md: Sans** paragraphs Grotesk** wordmark */
  --parchment: #E8D8B8;
  --plum: #2D1B32;
  --teal: #4F7C78;
  --persimmon: #C66A3D;
  --brass: #B99B54;
  --blue: #536F9B;
  --cream: #F5EACB;
  --night: #151126;
  --display: "Space Grotesk", "Arial Black", system-ui, sans-serif;
  --body: "IBM Plex Sans", "Helvetica Neue", Arial, sans-serif;
  --label: "Archivo", Impact, sans-serif;
  --accent: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--plum);
  background: var(--parchment);
  font-family: var(--body);
  overflow-x: hidden;
}

button { font: inherit; color: inherit; }

.grain {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  opacity: .32;
  background:
    radial-gradient(circle at 20% 30%, rgba(45,27,50,.08) 0 1px, transparent 1px 7px),
    radial-gradient(circle at 70% 60%, rgba(198,106,61,.08) 0 1px, transparent 1px 9px),
    linear-gradient(90deg, rgba(245,234,203,.12), rgba(45,27,50,.04), rgba(245,234,203,.1));
  mix-blend-mode: multiply;
}

.folio {
  min-height: 100vh;
  position: relative;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: clamp(14px, 1.8vw, 28px);
  padding: clamp(34px, 5vw, 82px);
  isolation: isolate;
  overflow: hidden;
  border-bottom: 2px solid rgba(45,27,50,.2);
  background:
    linear-gradient(90deg, rgba(79,124,120,.16) 1px, transparent 1px) 0 0/8.333% 100%,
    radial-gradient(circle at 78% 18%, rgba(185,155,84,.34), transparent 26rem),
    var(--parchment);
}

.folio:nth-child(even) {
  background:
    linear-gradient(90deg, rgba(83,111,155,.14) 1px, transparent 1px) 0 0/8.333% 100%,
    radial-gradient(circle at 10% 82%, rgba(198,106,61,.18), transparent 24rem),
    var(--cream);
}

.folio::before,
.folio::after {
  content: "";
  position: absolute;
  z-index: -1;
  pointer-events: none;
}

.folio::before {
  width: 52vmin;
  height: 52vmin;
  border: 1px dashed rgba(45,27,50,.22);
  border-radius: 50%;
  right: -12vmin;
  top: 10vmin;
}

.folio::after {
  inset: 20px;
  border: 1px solid rgba(45,27,50,.16);
}

.cover-copy { grid-column: 1 / 7; align-self: center; z-index: 2; }

.stamp,
.chapter,
.caption,
.metadata,
.vertical-label,
.folio-rail,
.moon-dial,
.map-label,
.instrument-card b,
.paper-tab,
.result-seal {
  font-family: var(--label);
  letter-spacing: .12em;
  text-transform: uppercase;
}

.stamp {
  display: inline-block;
  padding: .55rem .75rem;
  color: var(--persimmon);
  border: 2px solid var(--persimmon);
  transform: rotate(-2deg);
  background: rgba(245,234,203,.42);
}

h1,
h2 {
  margin: 0;
  font-family: var(--display);
  line-height: .86;
  letter-spacing: -.065em;
}

h1 { font-size: clamp(5.2rem, 13vw, 14.4rem); }
h2 { font-size: clamp(3.2rem, 7.3vw, 8.4rem); max-width: 10ch; }

p { font-size: clamp(1rem, 1.35vw, 1.25rem); line-height: 1.55; }

.dek { max-width: 38rem; font-size: clamp(1.2rem, 2vw, 1.8rem); }

.metadata {
  display: grid;
  gap: .45rem;
  max-width: 31rem;
  margin-top: 2rem;
  color: var(--teal);
  font-size: .78rem;
}

.vertical-label {
  position: absolute;
  left: clamp(10px, 1.4vw, 24px);
  top: 50%;
  transform: translateY(-50%) rotate(-90deg);
  transform-origin: left center;
  color: var(--blue);
  font-size: .75rem;
}

.folio-number {
  position: absolute;
  right: clamp(24px, 4vw, 62px);
  top: clamp(20px, 4vw, 54px);
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(5rem, 13vw, 14rem);
  line-height: .7;
  color: rgba(185,155,84,.34);
}

.orbital-plate {
  grid-column: 7 / 13;
  align-self: center;
  justify-self: center;
  width: min(44rem, 82vw);
  aspect-ratio: 1;
  position: relative;
  border-radius: 50%;
}

.ring {
  position: absolute;
  inset: 9%;
  border: 4px solid rgba(185,155,84,.82);
  border-radius: 50%;
  box-shadow: 8px 5px 0 rgba(79,124,120,.22), -4px -2px 0 rgba(198,106,61,.16);
}

.ring-two { inset: 23%; border-style: dashed; transform: rotate(28deg); }
.ring-three { inset: 37%; border-color: rgba(45,27,50,.74); border-width: 2px; }

.node,
.star,
.tick {
  position: absolute;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: var(--persimmon);
  box-shadow: 4px 3px 0 rgba(79,124,120,.52), 0 0 0 8px rgba(185,155,84,.18);
  cursor: pointer;
  transition: transform .25s ease, box-shadow .25s ease;
}

.node:hover,
.star:hover,
.tick:hover { transform: scale(1.55) rotate(18deg); box-shadow: 2px 2px 0 var(--teal), 0 0 0 13px rgba(185,155,84,.23); }
.n1 { left: 15%; top: 37%; }
.n2 { right: 18%; top: 22%; }
.n3 { right: 31%; bottom: 13%; }
.n4 { left: 35%; bottom: 24%; }

.theorem-wheel {
  position: absolute;
  inset: 34%;
  display: grid;
  place-items: center;
  border: 3px solid var(--plum);
  border-radius: 50%;
  background: rgba(245,234,203,.68);
  transition: transform .5s cubic-bezier(.2,.8,.2,1);
}

.theorem-wheel::before,
.theorem-wheel::after {
  content: "";
  position: absolute;
  inset: 12%;
  border: 2px dashed var(--teal);
  border-radius: 50%;
}

.theorem-wheel span { font: 700 clamp(2rem, 5vw, 4.5rem)/1 var(--display); }
.node-note { position: absolute; left: 13%; bottom: 7%; padding: .8rem 1rem; background: rgba(245,234,203,.78); border: 1px solid var(--plum); font-family: var(--accent); transform: rotate(-3deg); }
.reveal-line { position: absolute; right: 8%; bottom: 7%; color: var(--persimmon); opacity: 0; transform: translateY(14px); transition: .8s ease; font-family: var(--display); font-weight: 700; }
.cover.ready .reveal-line { opacity: 1; transform: translateY(0); }

.spread-copy { grid-column: 2 / 7; align-self: center; max-width: 44rem; }
.right-copy { grid-column: 8 / 13; }
.chapter { color: var(--persimmon); font-size: .85rem; margin-bottom: 1rem; }
.caption { color: var(--blue); font-size: .78rem; max-width: 22rem; border-top: 1px solid var(--blue); padding-top: .8rem; }

.vellum-card,
.instrument-card {
  background: rgba(245,234,203,.62);
  border: 1px solid rgba(45,27,50,.42);
  box-shadow: 16px 16px 0 rgba(83,111,155,.16), -7px -5px 0 rgba(198,106,61,.08);
  backdrop-filter: blur(2px);
}

.vellum-card { grid-column: 7 / 10; align-self: end; padding: 1.35rem; display: grid; gap: .6rem; }
.tilted { transform: rotate(4deg); }

.constellation-map {
  grid-column: 7 / 13;
  align-self: center;
  height: min(58vh, 34rem);
  position: relative;
  border: 2px solid rgba(45,27,50,.52);
  border-radius: 46% 54% 43% 57%;
  background: radial-gradient(circle, rgba(21,17,38,.92), rgba(45,27,50,.86));
  box-shadow: inset 0 0 0 14px rgba(245,234,203,.08), 14px 11px 0 rgba(79,124,120,.22);
}

.constellation-map svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.star { width: 14px; height: 14px; background: var(--cream); box-shadow: 3px 2px 0 var(--persimmon), 0 0 18px rgba(245,234,203,.55); }
.s1 { left: 15%; top: 50%; } .s2 { left: 42%; top: 19%; } .s3 { left: 69%; top: 38%; } .s4 { left: 36%; bottom: 20%; } .s5 { right: 11%; bottom: 29%; }
.star-line { fill: none; stroke: var(--brass); stroke-width: 2; stroke-dasharray: 7 9; opacity: .18; transition: opacity .25s ease, stroke-width .25s ease; }
.constellation-map.line-A .line-A,
.constellation-map.line-B .line-B,
.constellation-map.line-C .line-C { opacity: .95; stroke-width: 4; }
.map-label { position: absolute; left: 1rem; bottom: .8rem; color: var(--cream); font-size: .72rem; }

.method-grid { grid-column: 2 / 12; display: grid; grid-template-columns: 1.1fr .9fr; gap: clamp(28px, 5vw, 80px); align-items: center; position: relative; }
.proof-lines { position: absolute; inset: 6% 42% 2% 7%; background: repeating-linear-gradient(135deg, transparent 0 20px, rgba(79,124,120,.35) 21px 22px); transform: rotate(-4deg); }
.method-grid article { position: relative; z-index: 1; }
.instrument-card { position: relative; z-index: 1; padding: clamp(1.4rem, 3vw, 2.4rem); }
.meter { height: 8rem; display: flex; align-items: end; gap: .65rem; margin-bottom: 1.2rem; border-bottom: 3px solid var(--plum); }
.meter i { flex: 1; display: block; background: var(--teal); height: 30%; box-shadow: 4px 0 0 rgba(198,106,61,.55); transition: height .35s ease; }
.meter i:nth-child(2) { height: 55%; } .meter i:nth-child(3) { height: 42%; } .meter i:nth-child(4) { height: 78%; }
.instrument-card.flipped .meter i:nth-child(1) { height: 74%; } .instrument-card.flipped .meter i:nth-child(2) { height: 35%; } .instrument-card.flipped .meter i:nth-child(3) { height: 86%; } .instrument-card.flipped .meter i:nth-child(4) { height: 48%; }
.paper-tab { border: 0; background: var(--brass); padding: .75rem 1rem; margin: .8rem 0; box-shadow: 5px 5px 0 var(--plum); cursor: pointer; }

.dense-column { grid-column: 2 / 7; align-self: center; columns: 1; max-width: 40rem; }
blockquote { margin: 2rem 0 0; font: 700 clamp(1.7rem, 3vw, 3rem)/1.05 var(--accent); color: var(--persimmon); }
.misregistration { grid-column: 7 / 13; align-self: center; height: 70vh; position: relative; }
.cube { position: absolute; width: 23rem; aspect-ratio: 1; border: 4px solid var(--plum); transform: rotate(45deg) skew(-10deg); left: 18%; top: 18%; }
.c-teal { border-color: var(--teal); transform: translate(16px, 12px) rotate(45deg) skew(-10deg); opacity: .75; }
.stamp-ring { position: absolute; right: 10%; bottom: 14%; width: 12rem; aspect-ratio: 1; border: 4px double var(--persimmon); border-radius: 50%; display: grid; place-items: center; text-align: center; color: var(--persimmon); font: 700 1.15rem/1.2 var(--label); transform: rotate(12deg); }

.calibration-wheel { grid-column: 2 / 8; align-self: center; justify-self: center; width: min(38rem, 82vw); aspect-ratio: 1; border-radius: 50%; border: 5px solid var(--teal); position: relative; background: conic-gradient(from 10deg, rgba(185,155,84,.32), transparent 20%, rgba(198,106,61,.25), transparent 65%, rgba(83,111,155,.28)); transition: transform .55s ease; }
.calibration-wheel::before { content: ""; position: absolute; inset: 14%; border: 2px dashed var(--plum); border-radius: 50%; }
.tick { background: var(--brass); }
.t1 { left: 49%; top: -1%; } .t2 { right: 5%; top: 50%; } .t3 { left: 48%; bottom: -1%; } .t4 { left: 4%; top: 49%; }
.moon-window { position: absolute; inset: 34%; border-radius: 50%; background: radial-gradient(circle at 62% 40%, var(--cream) 0 35%, var(--night) 36% 46%, var(--cream) 47% 67%, transparent 68%); border: 3px solid var(--plum); }
#calibrationNote { position: absolute; left: 8%; bottom: 9%; max-width: 16rem; padding: .7rem; background: rgba(245,234,203,.72); border: 1px solid var(--plum); }

.result { background: radial-gradient(circle at center, rgba(83,111,155,.28), transparent 34rem), var(--night); color: var(--cream); }
.result::after { border-color: rgba(245,234,203,.2); }
.result-seal { grid-column: 2 / 4; align-self: start; justify-self: start; padding: .8rem 1rem; border: 2px solid var(--brass); color: var(--brass); transform: rotate(-3deg); }
.monogram { grid-column: 2 / 8; align-self: center; display: flex; gap: clamp(.5rem, 2vw, 1.4rem); font: 700 clamp(6rem, 17vw, 16rem)/.8 var(--display); letter-spacing: -.12em; }
.monogram span { text-shadow: 7px 5px 0 rgba(198,106,61,.55), -5px -3px 0 rgba(79,124,120,.55); transform: translateY(22px); opacity: .35; transition: .9s ease; }
.active-folio .monogram span { opacity: 1; transform: translateY(0); }
.active-folio .monogram span:nth-child(2) { transition-delay: .12s; }
.active-folio .monogram span:nth-child(3) { transition-delay: .24s; }
.closing { grid-column: 8 / 13; align-self: center; max-width: 34rem; }
.theorem { color: var(--brass); font: 700 clamp(1.4rem, 2.2vw, 2.4rem)/1.15 var(--accent); }

.folio-rail {
  position: fixed;
  z-index: 60;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  gap: .5rem;
}
.folio-rail button {
  width: 2.4rem;
  height: 2.4rem;
  border: 1px solid rgba(45,27,50,.48);
  background: rgba(245,234,203,.72);
  cursor: pointer;
}
.folio-rail button.active { background: var(--plum); color: var(--cream); transform: rotate(8deg); }
.moon-dial { position: fixed; z-index: 60; left: 18px; bottom: 18px; display: flex; align-items: center; gap: .65rem; padding: .5rem .75rem; background: rgba(245,234,203,.8); border: 1px solid var(--plum); font-size: .75rem; }
.moon-dial span { width: 1.5rem; height: 1.5rem; border-radius: 50%; background: var(--night); box-shadow: inset var(--moon-shadow, 7px) 0 0 var(--cream); transition: box-shadow .35s ease; }

.active-folio .orbital-plate { animation: drift 8s ease-in-out infinite; }
.active-folio .ring-two { animation: orbit 18s linear infinite; }

@keyframes orbit { to { transform: rotate(388deg); } }
@keyframes drift { 50% { transform: translateY(-10px) rotate(.8deg); } }

@media (max-width: 850px) {
  .folio { display: block; padding: 4.5rem 1.4rem 5.5rem; }
  h1 { font-size: 4.2rem; }
  h2 { max-width: 100%; }
  .orbital-plate,
  .constellation-map,
  .misregistration,
  .calibration-wheel { margin: 2rem auto; }
  .method-grid { display: block; }
  .vellum-card { margin: 1.5rem 0; }
  .closing { max-width: none; }
  .folio-rail { right: 8px; gap: .25rem; }
  .folio-rail button { width: 2rem; height: 2rem; }
  .vertical-label { display: none; }
}
