:root {
  --deep-ink: #090A12;
  --vellum: #F3E7C9;
  --violet: #6B4BFF;
  --aqua: #39DCC8;
  --rose: #FF5C8A;
  --umber: #6D5A4A;
  --serif: "Instrument Serif", serif;
  --sans: "Manrope", sans-serif;
  --recursive: "Recursive", monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--vellum);
  background:
    radial-gradient(circle at 16% 12%, rgba(107, 75, 255, 0.19), transparent 28rem),
    radial-gradient(circle at 74% 48%, rgba(57, 220, 200, 0.10), transparent 32rem),
    linear-gradient(140deg, #090A12 0%, #10101d 46%, #090A12 100%);
  font-family: var(--sans);
}

body.is-stirred .spiral-core { animation-duration: 13s; }
body.is-stirred .punctuation-cloud i { color: var(--aqua); animation-duration: 5s; }

.stage-grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  opacity: 0.34;
  background-image:
    repeating-radial-gradient(circle at 21% 31%, rgba(243, 231, 201, 0.055) 0 1px, transparent 1px 7px),
    linear-gradient(115deg, transparent 0 45%, rgba(243, 231, 201, 0.035) 49%, transparent 53%);
  mix-blend-mode: screen;
}

.cursor-current {
  position: fixed;
  left: 0;
  top: 0;
  width: 17rem;
  height: 17rem;
  border-radius: 50%;
  pointer-events: none;
  z-index: 4;
  transform: translate(-50%, -50%);
  opacity: 0;
  background: radial-gradient(circle, rgba(57, 220, 200, 0.16), rgba(107, 75, 255, 0.08) 45%, transparent 70%);
  filter: blur(5px);
  transition: opacity 0.4s ease;
}

.swirl-field {
  position: fixed;
  inset: 0;
  z-index: 1;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  transform-origin: 50% 50%;
  transition: transform 0.8s cubic-bezier(.2,.8,.1,1), opacity 0.6s ease;
}

.bloom { opacity: 0.85; filter: url(#liquidBlur); }
.spiral-core { transform-origin: 600px 400px; animation: liquidTurn 28s linear infinite; }
.spiral-line, .marble-vein {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 7 16;
  animation: redraw 7s ease-in-out infinite alternate;
}
.spiral-line.violet { stroke: #6B4BFF; stroke-width: 2.5; opacity: 0.8; }
.spiral-line.aqua { stroke: #39DCC8; stroke-width: 1.8; opacity: 0.7; animation-delay: -1.4s; }
.spiral-line.rose { stroke: #FF5C8A; stroke-width: 1.4; opacity: 0.62; animation-delay: -2.3s; }
.marble-vein { stroke: #F3E7C9; stroke-width: 0.9; opacity: 0.25; stroke-dasharray: 2 13; }
.marble-vein.thin { stroke: #6D5A4A; opacity: 0.45; animation-delay: -3s; }

.arc-domain {
  font-family: var(--serif);
  font-size: 66px;
  fill: #F3E7C9;
  letter-spacing: 0.04em;
  opacity: 0.24;
}

.ribbon-text {
  font-family: var(--recursive);
  font-size: 18px;
  font-variation-settings: "MONO" 0.5, "CASL" 1, "slnt" -9, "wght" 520;
  opacity: 0.72;
  animation: fragmentWeight 4s ease-in-out infinite alternate;
}
.violet-text { fill: #6B4BFF; }
.aqua-text { fill: #39DCC8; animation-delay: -1s; }
.rose-text { fill: #FF5C8A; animation-delay: -2s; }

.scene-marks {
  position: fixed;
  z-index: 7;
  left: 1.35rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.scene-dot {
  width: 0.72rem;
  height: 0.72rem;
  border-radius: 50%;
  border: 1px solid rgba(243, 231, 201, 0.46);
  background: rgba(9, 10, 18, 0.7);
  color: #F3E7C9;
  text-decoration: none;
  position: relative;
  transition: background 0.3s ease, border-color 0.3s ease, transform 0.3s ease;
}
.scene-dot span {
  position: absolute;
  left: 1.25rem;
  top: 50%;
  transform: translateY(-50%) rotate(-2deg);
  white-space: nowrap;
  font: 500 0.68rem var(--recursive);
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: rgba(243, 231, 201, 0.55);
  opacity: 0;
  transition: opacity 0.3s ease, color 0.3s ease;
}
.scene-dot.active { background: #39DCC8; border-color: #39DCC8; transform: scale(1.35); }
.scene-dot.active span, .scene-dot:hover span { opacity: 1; color: #39DCC8; }

.rehearsal { position: relative; z-index: 3; }
.scene {
  min-height: 100vh;
  position: relative;
  display: grid;
  place-items: center;
  padding: clamp(5rem, 10vw, 9rem) clamp(1.4rem, 8vw, 8rem);
  overflow: hidden;
}

.scene::before {
  content: "";
  position: absolute;
  inset: 6vh 4vw;
  border: 1px solid rgba(243, 231, 201, 0.08);
  border-left-color: rgba(57, 220, 200, 0.22);
  border-radius: 52% 48% 55% 45% / 48% 61% 39% 52%;
  transform: rotate(var(--scene-tilt, -5deg));
}

.cue-label {
  display: inline-block;
  font: 700 0.72rem var(--recursive);
  font-variation-settings: "MONO" 1, "CASL" 0, "slnt" -4, "wght" 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #39DCC8;
}

.blank-pool { --scene-tilt: 10deg; align-items: start; justify-items: start; }
.wordmark {
  margin: 12vh 0 0 7vw;
  max-width: 14ch;
  font-family: var(--serif);
  font-size: clamp(5.1rem, 13.5vw, 15rem);
  font-weight: 400;
  line-height: 0.78;
  letter-spacing: -0.065em;
  color: #F3E7C9;
  filter: drop-shadow(0 0 1.5rem rgba(107, 75, 255, 0.24));
}
.wordmark span {
  display: inline-block;
  opacity: 0;
  transform: translate(calc(var(--x, 0) * 1px), calc(var(--y, 0) * 1px)) rotate(var(--r, 0deg));
  animation: letterOrbit 1.8s cubic-bezier(.2,.8,.12,1) forwards;
  animation-delay: calc(var(--i, 0) * 70ms + 120ms);
}
.pool-note {
  position: absolute;
  right: 9vw;
  bottom: 16vh;
  width: min(26rem, 72vw);
}
.stage-note, .scene-copy p, .final-line p, .vellum-panel p {
  color: rgba(243, 231, 201, 0.76);
  font-size: clamp(1rem, 1.45vw, 1.25rem);
  line-height: 1.75;
  font-weight: 400;
}

.cue-tab {
  position: absolute;
  left: 12vw;
  bottom: 16vh;
  border: 1px solid rgba(255, 92, 138, 0.7);
  border-radius: 999px;
  padding: 0.74rem 1.15rem;
  color: #FF5C8A;
  background: rgba(9, 10, 18, 0.58);
  font: 700 0.72rem var(--recursive);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transform: rotate(-5deg);
  box-shadow: 0 0 2rem rgba(255, 92, 138, 0.13);
}
.cue-tab:hover { background: rgba(255, 92, 138, 0.12); }

.punctuation-cloud { position: absolute; inset: 0; pointer-events: none; }
.punctuation-cloud i {
  position: absolute;
  left: calc(50% + var(--px));
  top: calc(50% + var(--py));
  color: rgba(243, 231, 201, 0.48);
  font: italic 2.1rem var(--serif);
  transform-origin: calc(var(--px) * -1) calc(var(--py) * -1);
  animation: punctuationOrbit 9s linear infinite;
  animation-delay: var(--delay);
}

.scene-copy {
  width: min(34rem, 78vw);
  position: relative;
  z-index: 2;
}
.scene-copy h2, .vellum-panel h2, .final-line h2 {
  margin: 0.4rem 0 1rem;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(3.4rem, 8vw, 8rem);
  line-height: 0.88;
  color: #F3E7C9;
}
.tangent-left { justify-self: start; align-self: center; transform: rotate(-5deg); margin-left: 7vw; }
.tangent-right { justify-self: end; align-self: center; transform: rotate(4deg); margin-right: 7vw; }

.paper-strip {
  position: absolute;
  z-index: 2;
  padding: 0.9rem 3rem;
  color: #090A12;
  background: linear-gradient(90deg, rgba(243, 231, 201, 0.92), rgba(243, 231, 201, 0.64));
  box-shadow: 0 1rem 3rem rgba(9, 10, 18, 0.38);
  clip-path: polygon(3% 8%, 100% 0, 96% 82%, 0 100%);
  font: 700 0.82rem var(--recursive);
  letter-spacing: 0.08em;
}
.strip-one { right: 7vw; top: 17vh; transform: rotate(15deg); }
.strip-two { left: 9vw; bottom: 14vh; transform: rotate(-13deg); }

.nib-symbol {
  position: absolute;
  right: 20vw;
  bottom: 19vh;
  width: 5.5rem;
  height: 8rem;
  background: linear-gradient(160deg, #F3E7C9, #6D5A4A);
  clip-path: polygon(50% 0, 88% 43%, 55% 100%, 45% 100%, 12% 43%);
  opacity: 0.65;
  transform: rotate(31deg);
}
.nib-symbol::after {
  content: "";
  position: absolute;
  left: 42%;
  top: 41%;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: #090A12;
  box-shadow: 0 1.1rem 0 -0.37rem #090A12;
}
.rail {
  position: absolute;
  left: 4vw;
  bottom: 7vh;
  color: rgba(57, 220, 200, 0.42);
  font: 500 0.82rem var(--recursive);
  letter-spacing: 0.22em;
  transform: rotate(-8deg);
}

.nested-panel {
  justify-self: end;
  margin-right: 10vw;
  width: min(38rem, 82vw);
  padding: clamp(1.5rem, 4vw, 3rem);
  background: rgba(243, 231, 201, 0.12);
  border: 1px solid rgba(243, 231, 201, 0.24);
  box-shadow: 0 2rem 8rem rgba(9, 10, 18, 0.45), inset 0 0 5rem rgba(243, 231, 201, 0.04);
  backdrop-filter: blur(10px);
  clip-path: polygon(2% 0, 98% 4%, 100% 91%, 72% 100%, 0 94%);
  transform: rotate(4deg);
}
.code-fragment {
  margin-top: 1.3rem;
  color: #39DCC8;
  font-family: var(--recursive);
  font-variation-settings: "MONO" 1, "CASL" 0.5, "slnt" -11, "wght" 650;
  font-size: clamp(0.9rem, 2vw, 1.2rem);
}
.cue-rings { position: absolute; left: 14vw; top: 20vh; width: 28rem; height: 28rem; }
.cue-rings span {
  position: absolute;
  inset: calc(var(--ring) * 3rem);
  border: 1px solid rgba(57, 220, 200, 0.3);
  border-right-color: rgba(255, 92, 138, 0.65);
  border-radius: 50%;
  animation: ringCue 8s linear infinite;
  animation-delay: calc(var(--ring) * -1s);
}

.rewrite-knot {
  position: absolute;
  left: 16vw;
  top: 19vh;
  width: 25rem;
  height: 25rem;
  border-radius: 50%;
  border: 1px dashed rgba(255, 92, 138, 0.45);
  animation: liquidTurn 18s linear infinite reverse;
}
.rewrite-knot span {
  position: absolute;
  left: 50%;
  top: 50%;
  color: #FF5C8A;
  font-family: var(--serif);
  font-size: 3rem;
  transform: rotate(calc(var(--k) * 90deg)) translateX(10rem) rotate(calc(var(--k) * -90deg));
}
.editor-loop {
  position: absolute;
  right: 14vw;
  bottom: 16vh;
  width: 13rem;
  height: 6rem;
  display: grid;
  place-items: center;
  color: #FF5C8A;
  border: 2px solid #FF5C8A;
  border-radius: 50%;
  transform: rotate(-18deg);
  font: 800 0.76rem var(--recursive);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.curtain-resolve { align-items: end; }
.curtain-fold {
  position: absolute;
  inset: 0 0 auto auto;
  width: 56vw;
  height: 100%;
  background:
    repeating-linear-gradient(92deg, rgba(243, 231, 201, 0.08) 0 1.2rem, rgba(107, 75, 255, 0.04) 1.2rem 2.4rem),
    linear-gradient(90deg, transparent, rgba(243, 231, 201, 0.09));
  clip-path: polygon(18% 0, 100% 0, 100% 100%, 0 89%, 12% 46%);
}
.final-line {
  position: relative;
  z-index: 2;
  width: min(45rem, 84vw);
  margin: 0 auto 16vh;
  text-align: center;
}
.final-tab { position: static; display: inline-block; margin-top: 1rem; transform: rotate(2deg); }
.resolved-script {
  position: absolute;
  left: 50%;
  bottom: 7vh;
  transform: translateX(-50%);
  white-space: nowrap;
  font: 600 clamp(0.85rem, 1.5vw, 1.1rem) var(--recursive);
  letter-spacing: 0.24em;
  color: rgba(57, 220, 200, 0.72);
}

@keyframes liquidTurn { to { transform: rotate(360deg); } }
@keyframes redraw { to { stroke-dashoffset: 190; opacity: 0.95; } }
@keyframes fragmentWeight {
  to { font-variation-settings: "MONO" 0.2, "CASL" 1, "slnt" -2, "wght" 760; }
}
@keyframes letterOrbit {
  0% { opacity: 0; transform: translate(calc(var(--x) * 1px), calc(var(--y) * 1px)) rotate(var(--r)); }
  58% { opacity: 1; transform: translate(calc(var(--x) * -0.22px), calc(var(--y) * -0.22px)) rotate(calc(var(--r) * -0.5)); }
  100% { opacity: 1; transform: translateY(0) rotate(calc((var(--i) - 7) * 0.6deg)); }
}
@keyframes punctuationOrbit { to { transform: rotate(360deg); } }
@keyframes ringCue { to { transform: rotate(360deg) scale(1.08); } }

@media (max-width: 760px) {
  .scene-marks { left: 0.8rem; }
  .scene-dot span { display: none; }
  .wordmark { margin-left: 1.4rem; font-size: clamp(4.4rem, 19vw, 7rem); }
  .pool-note, .cue-tab { left: 1.4rem; right: auto; width: calc(100% - 2.8rem); }
  .pool-note { bottom: 23vh; }
  .tangent-left, .tangent-right, .nested-panel { margin: 0; transform: rotate(0deg); justify-self: center; }
  .paper-strip, .nib-symbol, .rail, .editor-loop { opacity: 0.75; }
  .cue-rings, .rewrite-knot { left: 50%; transform: translateX(-50%); width: 18rem; height: 18rem; }
  .rewrite-knot span { font-size: 2rem; transform: rotate(calc(var(--k) * 90deg)) translateX(7rem) rotate(calc(var(--k) * -90deg)); }
}
