:root {
  /* Typography: Space Grotesk for large chapter labels; IBM Plex Mono for coordinates. */
  --void: #070814;
  --film: #EEF2FF;
  --graphite: #1A2440;
  --cyan: #37E6FF;
  --violet: #8B5CF6;
  --vermilion: #FF4D5E;
  --mint: #79FFB8;
  --grid: #B9C5E8;
  --display: "Space Grotesk", "Space", "Avenir Next", "Inter", system-ui, sans-serif;
  --text: "Inter", "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", "SFMono-Regular", "Menlo", "Consolas", monospace;
  --serif: "Instrument Serif", "Lora", "Iowan Old Style", "Georgia", serif;
  --scroll: 0;
  --mouse-x: 50vw;
  --mouse-y: 50vh;
}

* { box-sizing: border-box; }

html {
  background: var(--void);
  color: var(--film);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: var(--text);
  background:
    radial-gradient(circle at var(--mouse-x) var(--mouse-y), rgba(55, 230, 255, .13), transparent 18rem),
    radial-gradient(circle at 76% 18%, rgba(139, 92, 246, .23), transparent 34rem),
    linear-gradient(180deg, #070814 0%, #0b1024 45%, #070814 100%);
}

.scanner-grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 40;
  opacity: .18;
  mix-blend-mode: screen;
  background-image:
    repeating-radial-gradient(circle at 17% 31%, rgba(238, 242, 255, .16) 0 1px, transparent 1px 5px),
    repeating-linear-gradient(90deg, transparent 0 7px, rgba(185, 197, 232, .04) 7px 8px);
}

.fixed-marginal {
  position: fixed;
  left: 1rem;
  top: 1rem;
  z-index: 31;
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: rgba(185, 197, 232, .64);
  writing-mode: vertical-rl;
  mix-blend-mode: screen;
}

.axis-tunnel {
  position: relative;
  min-height: 520vh;
  isolation: isolate;
}

.axis-spine {
  position: absolute;
  inset: 0 0 auto 0;
  width: 100%;
  height: 520vh;
  z-index: 7;
  overflow: visible;
  pointer-events: none;
}

.spine-path {
  fill: none;
  stroke: url(#spineGradient);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: url(#glow);
  stroke-dasharray: 1;
  stroke-dashoffset: calc(1 - var(--scroll));
}

.spine-shadow {
  stroke: rgba(55, 230, 255, .13);
  stroke-width: 22;
  filter: blur(14px);
}

.axis-ticks path,
.polar-rings circle,
.polar-rings path,
.constellation-lines path {
  fill: none;
  stroke: rgba(185, 197, 232, .45);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.polar-rings {
  opacity: calc(.08 + (var(--scroll) * .5));
  transform-origin: 50% 50%;
  animation: rotateRings 38s linear infinite;
}

.constellation-lines path {
  stroke: rgba(121, 255, 184, .36);
  stroke-dasharray: 10 18;
  animation: dashDrift 16s linear infinite;
}

.scene {
  position: relative;
  min-height: 104vh;
  display: grid;
  align-items: center;
  padding: clamp(2rem, 5vw, 6rem);
  overflow: hidden;
}

.grid-layer,
.moire-field,
.curve-field {
  position: absolute;
  inset: -15%;
  pointer-events: none;
  z-index: 0;
}

.grid-layer {
  opacity: .26;
  background-image:
    linear-gradient(rgba(185, 197, 232, .16) 1px, transparent 1px),
    linear-gradient(90deg, rgba(185, 197, 232, .16) 1px, transparent 1px),
    linear-gradient(rgba(55, 230, 255, .08) 2px, transparent 2px),
    linear-gradient(90deg, rgba(55, 230, 255, .08) 2px, transparent 2px);
  background-size: 48px 48px, 48px 48px, 240px 240px, 240px 240px;
  transform: translateY(calc(var(--scroll) * -70px));
}

.grid-tilt { transform: rotate(-7deg) scale(1.12); opacity: .34; }
.grid-edge { transform: rotate(11deg) scale(1.25); opacity: .2; }

.vellum-layer {
  position: relative;
  z-index: 10;
  width: min(760px, 88vw);
  padding: clamp(1.4rem, 4vw, 3.6rem);
  border: 1px solid rgba(238, 242, 255, .15);
  background: linear-gradient(135deg, rgba(238, 242, 255, .08), rgba(26, 36, 64, .18));
  box-shadow: 0 28px 80px rgba(0, 0, 0, .38), inset 0 0 60px rgba(55, 230, 255, .035);
  backdrop-filter: blur(9px);
}

.vellum-layer::before,
.vellum-layer::after {
  content: "";
  position: absolute;
  width: 34px;
  height: 34px;
  border-color: rgba(121, 255, 184, .5);
  pointer-events: none;
}

.vellum-layer::before { left: 16px; top: 16px; border-left: 1px solid; border-top: 1px solid; }
.vellum-layer::after { right: 16px; bottom: 16px; border-right: 1px solid; border-bottom: 1px solid; }

.hero-sheet {
  margin-left: 8vw;
  transform: translateY(-5vh) rotate(-2deg);
  border-left: 3px solid rgba(55, 230, 255, .62);
}

.wordmark {
  margin: .15em 0 .1em;
  font-family: var(--display);
  font-size: clamp(4.2rem, 14vw, 13rem);
  line-height: .82;
  letter-spacing: -.09em;
  font-weight: 700;
  color: var(--film);
  text-shadow: 0 0 22px rgba(55, 230, 255, .28);
}

.wordmark::after {
  content: "";
  display: block;
  width: min(52vw, 520px);
  height: 1px;
  margin-top: .22em;
  background: linear-gradient(90deg, var(--cyan), transparent);
}

h2 {
  margin: .2em 0 .42em;
  max-width: 12ch;
  font-family: var(--display);
  font-size: clamp(3.2rem, 9vw, 9rem);
  line-height: .83;
  letter-spacing: -.075em;
  color: var(--film);
}

.instrument-note,
.poetic-line {
  max-width: 680px;
  font-family: var(--serif);
  font-size: clamp(1.35rem, 3.2vw, 3.2rem);
  line-height: 1.05;
  color: rgba(238, 242, 255, .86);
}

.coordinate-caption,
.transform-label,
.axis-label,
.formula-cluster,
.fixed-marginal,
.tick-ruler,
.polar-readout,
.final-coordinate span,
.final-coordinate em {
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: .13em;
  font-size: .78rem;
  color: rgba(185, 197, 232, .78);
}

.transform-label { color: var(--mint); }
.axis-label { position: absolute; z-index: 12; color: var(--cyan); }
.x-label { right: 8vw; top: 43vh; }
.y-label { left: 6vw; bottom: 12vh; transform: rotate(-90deg); transform-origin: left center; }

.origin-marker,
.progress-origin,
.node {
  position: absolute;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 22px var(--mint), 0 0 50px rgba(121, 255, 184, .34);
  z-index: 16;
}

.origin-marker { width: 13px; height: 13px; left: 49.6%; top: 39.5%; }
.blink { animation: blinkOnce 3s ease 1 both; }

.progress-origin {
  position: fixed;
  right: 1.15rem;
  top: calc(10vh + (var(--scroll) * 78vh));
  width: 18px;
  height: 18px;
  z-index: 30;
  background: transparent;
  border: 1px solid var(--cyan);
}

.progress-origin span {
  position: absolute;
  inset: 5px;
  border-radius: inherit;
  background: var(--cyan);
  box-shadow: 0 0 20px var(--cyan);
}

.tilted-sheet { margin-left: auto; margin-right: 5vw; transform: rotate(4deg); border-top: 2px solid rgba(139, 92, 246, .65); }
.polar-sheet { margin-left: 10vw; transform: rotate(-5deg); border-right: 2px solid rgba(121, 255, 184, .55); }
.limit-sheet { margin-left: auto; margin-right: 9vw; transform: rotate(2deg); border-bottom: 2px solid rgba(55, 230, 255, .55); }

.formula-cluster {
  position: absolute;
  left: 8vw;
  bottom: 12vh;
  z-index: 14;
  display: grid;
  gap: .75rem;
  color: rgba(55, 230, 255, .82);
}

.formula-cluster span {
  padding-left: 1rem;
  border-left: 1px solid var(--cyan);
}

.tick-ruler {
  position: absolute;
  left: 14vw;
  right: 12vw;
  top: 51vh;
  z-index: 9;
  display: flex;
  justify-content: space-between;
  color: rgba(185, 197, 232, .62);
  border-top: 1px solid rgba(185, 197, 232, .26);
  transform: rotate(-2deg);
}

.tick-ruler span {
  position: relative;
  padding-top: .8rem;
}

.tick-ruler span::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 1px;
  height: .55rem;
  background: rgba(55, 230, 255, .5);
}

.asymptote {
  position: absolute;
  z-index: 8;
  width: 1px;
  height: 96vh;
  background: repeating-linear-gradient(to bottom, rgba(255, 77, 94, .72) 0 8px, transparent 8px 18px);
  box-shadow: 0 0 18px rgba(255, 77, 94, .18);
  opacity: .72;
}

.asymptote-a { left: 28vw; top: 1vh; transform: rotate(12deg); }
.asymptote-b { right: 19vw; bottom: -7vh; transform: rotate(-18deg); opacity: .42; }

.limit-cut {
  position: absolute;
  z-index: 13;
  width: 4px;
  height: 92px;
  background: var(--vermilion);
  box-shadow: 0 0 18px rgba(255, 77, 94, .8);
  transform: rotate(24deg);
}
.cut-a { left: 64vw; top: 28vh; }
.cut-b { left: 18vw; top: 30vh; transform: rotate(-16deg); }
.cut-c { right: 17vw; bottom: 24vh; transform: rotate(53deg); }

.node {
  width: 14px;
  height: 14px;
  cursor: crosshair;
  transition: transform .35s ease, background .35s ease;
}
.node:hover { transform: scale(2.1); background: var(--film); }
.node-one { left: 73vw; top: 54vh; }
.node-two { left: 36vw; top: 23vh; background: var(--cyan); box-shadow: 0 0 22px var(--cyan); }
.node-three { left: 22vw; top: 68vh; }
.node-four { left: 72vw; top: 36vh; background: var(--violet); box-shadow: 0 0 24px var(--violet); }
.node-five { left: 54vw; top: 18vh; background: var(--cyan); box-shadow: 0 0 24px var(--cyan); }

.fragment-tooltip {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, calc(-100% - 18px));
  padding: .7rem .85rem;
  border: 1px solid rgba(121, 255, 184, .45);
  background: rgba(7, 8, 20, .82);
  color: var(--mint);
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  box-shadow: 0 0 28px rgba(121, 255, 184, .18);
  transition: opacity .22s ease;
}
.fragment-tooltip.is-visible { opacity: 1; }

.moire-field {
  opacity: .38;
  background:
    repeating-radial-gradient(circle at 50% 52%, transparent 0 18px, rgba(55, 230, 255, .14) 19px 20px),
    repeating-radial-gradient(circle at 52% 48%, transparent 0 21px, rgba(139, 92, 246, .18) 22px 23px);
  animation: moireTurn 28s linear infinite;
}

.orbit-system {
  position: absolute;
  z-index: 11;
  left: 50%;
  top: 51%;
  width: min(58vw, 520px);
  aspect-ratio: 1;
  border: 1px solid rgba(55, 230, 255, .28);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: rotateRings 22s linear infinite reverse;
}
.orbit-system::before, .orbit-system::after {
  content: "";
  position: absolute;
  inset: 19%;
  border: 1px solid rgba(185, 197, 232, .22);
  border-radius: 50%;
}
.orbit-system::after { inset: 36%; }
.orbit-dot { position: absolute; width: 11px; height: 11px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 20px var(--mint); }
.dot-a { left: 48%; top: -5px; }
.dot-b { right: 8%; bottom: 18%; background: var(--cyan); box-shadow: 0 0 20px var(--cyan); }
.dot-c { left: 13%; bottom: 24%; background: var(--violet); box-shadow: 0 0 20px var(--violet); }

.bezier-handles i {
  position: absolute;
  z-index: 12;
  width: 80px;
  height: 1px;
  background: rgba(238, 242, 255, .38);
}
.bezier-handles i::after { content: ""; position: absolute; right: -5px; top: -5px; width: 10px; height: 10px; border: 1px solid var(--grid); border-radius: 50%; }
.bezier-handles i:nth-child(1) { left: 28vw; top: 30vh; transform: rotate(31deg); }
.bezier-handles i:nth-child(2) { right: 24vw; top: 36vh; transform: rotate(-23deg); }
.bezier-handles i:nth-child(3) { left: 21vw; bottom: 22vh; transform: rotate(-42deg); }
.bezier-handles i:nth-child(4) { right: 14vw; bottom: 28vh; transform: rotate(58deg); }

.polar-readout {
  position: absolute;
  z-index: 14;
  right: 8vw;
  bottom: 10vh;
  color: rgba(121, 255, 184, .76);
  padding: .7rem 1rem;
  border: 1px solid rgba(121, 255, 184, .22);
  background: rgba(7, 8, 20, .36);
}

.curve-field i {
  position: absolute;
  width: 70vw;
  height: 28vh;
  border: 1px solid transparent;
  border-top-color: rgba(55, 230, 255, .55);
  border-radius: 50%;
  filter: drop-shadow(0 0 16px rgba(55, 230, 255, .25));
  animation: curveBreathe 7s ease-in-out infinite alternate;
}
.curve-field i:nth-child(1) { left: -12vw; top: 8vh; transform: rotate(8deg); border-top-color: rgba(55, 230, 255, .65); }
.curve-field i:nth-child(2) { left: 20vw; top: 18vh; transform: rotate(-16deg); border-top-color: rgba(139, 92, 246, .7); animation-delay: -.7s; }
.curve-field i:nth-child(3) { right: -18vw; top: 32vh; transform: rotate(21deg); border-top-color: rgba(121, 255, 184, .55); animation-delay: -1.4s; }
.curve-field i:nth-child(4) { left: 2vw; bottom: 18vh; transform: rotate(-7deg); border-top-color: rgba(238, 242, 255, .38); animation-delay: -2s; }
.curve-field i:nth-child(5) { left: 38vw; bottom: 10vh; transform: rotate(28deg); border-top-color: rgba(255, 77, 94, .55); animation-delay: -2.7s; }
.curve-field i:nth-child(6) { left: -20vw; top: 50vh; transform: rotate(37deg); border-top-color: rgba(139, 92, 246, .45); animation-delay: -3.4s; }
.curve-field i:nth-child(7) { right: -16vw; top: 4vh; transform: rotate(-29deg); border-top-color: rgba(55, 230, 255, .44); animation-delay: -4s; }
.curve-field i:nth-child(8) { left: 17vw; top: 63vh; transform: rotate(13deg); border-top-color: rgba(121, 255, 184, .42); animation-delay: -4.7s; }

.constellation-points i {
  position: absolute;
  z-index: 15;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--film);
  box-shadow: 0 0 18px rgba(238, 242, 255, .78);
  animation: starPulse 3.8s ease-in-out infinite alternate;
}
.constellation-points i:nth-child(1) { left: 15vw; top: 24vh; background: var(--cyan); }
.constellation-points i:nth-child(2) { left: 29vw; top: 42vh; animation-delay: -.4s; }
.constellation-points i:nth-child(3) { left: 43vw; top: 21vh; background: var(--mint); animation-delay: -.8s; }
.constellation-points i:nth-child(4) { left: 57vw; top: 55vh; animation-delay: -1.2s; }
.constellation-points i:nth-child(5) { left: 71vw; top: 32vh; background: var(--violet); animation-delay: -1.6s; }
.constellation-points i:nth-child(6) { left: 82vw; top: 66vh; background: var(--cyan); animation-delay: -2s; }
.constellation-points i:nth-child(7) { left: 35vw; top: 72vh; background: var(--vermilion); animation-delay: -2.4s; }

.final-coordinate {
  position: relative;
  z-index: 12;
  display: grid;
  gap: .55rem;
  margin-left: auto;
  margin-right: 7vw;
  transform: rotate(-4deg);
}
.final-coordinate strong {
  font-family: var(--display);
  font-size: clamp(3rem, 10vw, 10rem);
  line-height: .85;
  letter-spacing: -.08em;
  color: var(--film);
}
.final-coordinate em { font-style: normal; color: var(--cyan); }
.poetic-line { position: absolute; left: 8vw; bottom: 13vh; z-index: 12; max-width: 760px; color: rgba(238, 242, 255, .72); }

@keyframes blinkOnce { 0%, 52%, 100% { opacity: 1; transform: scale(1); } 60% { opacity: .05; transform: scale(.3); } 70% { opacity: 1; transform: scale(1.8); } }
@keyframes rotateRings { to { transform: rotate(360deg); } }
@keyframes dashDrift { to { stroke-dashoffset: -220; } }
@keyframes moireTurn { to { transform: rotate(360deg) scale(1.02); } }
@keyframes curveBreathe { to { transform: translateY(-26px) rotate(var(--bend, 12deg)) scaleX(1.08); opacity: .72; } }
@keyframes starPulse { to { transform: scale(1.9); opacity: .48; } }

@media (max-width: 760px) {
  .scene { padding: 1.25rem; }
  .hero-sheet, .tilted-sheet, .polar-sheet, .limit-sheet { margin-left: 0; margin-right: 0; width: 94vw; }
  .axis-label, .formula-cluster { display: none; }
  .fixed-marginal, .tick-ruler, .polar-readout { display: none; }
  .wordmark { font-size: clamp(3.6rem, 19vw, 6rem); }
  h2 { font-size: clamp(3rem, 16vw, 5.8rem); }
  .orbit-system { width: 78vw; }
  .final-coordinate { margin-right: 0; }
}
