:root {
  --abyss: #050713;
  --horizon: #102B5C;
  --violet: #6E4BFF;
  --pearl: #EAF7FF;
  --mint: #8FFFE0;
  --chrome: #B9C6D8;
  --opal: #161827;
  --serif: "Instrument Serif", serif;
  --geist: "Geist", sans-serif;
  --mono: "Azeret Mono", monospace;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  color: var(--pearl);
  font-family: var(--geist);
  background: var(--abyss);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(circle at 50% 45%, rgba(143, 255, 224, 0.09), transparent 8%),
    radial-gradient(circle at 18% 28%, rgba(110, 75, 255, 0.18), transparent 28%),
    radial-gradient(circle at 82% 72%, rgba(16, 43, 92, 0.42), transparent 34%),
    linear-gradient(180deg, #050713 0%, #081126 47%, #050713 100%);
}

.void-field,
.persistent-loop,
.loop-nav { position: fixed; }

.void-field {
  inset: 0;
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
}

.void-field::after {
  content: "";
  position: absolute;
  inset: -20%;
  opacity: 0.18;
  background-image:
    linear-gradient(rgba(234, 247, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(234, 247, 255, 0.05) 1px, transparent 1px);
  background-size: 92px 92px;
  transform: rotate(-8deg);
  mask-image: radial-gradient(ellipse at center, black, transparent 70%);
}

.radial-well {
  position: absolute;
  border-radius: 50%;
  filter: blur(4px);
  mix-blend-mode: screen;
}

.well-one {
  width: 46vw;
  height: 28vw;
  left: -8vw;
  top: 17vh;
  border: 1px solid rgba(185, 198, 216, 0.22);
  background: radial-gradient(ellipse, rgba(16, 43, 92, 0.5), transparent 67%);
  animation: wellDrift 18s ease-in-out infinite;
}

.well-two {
  width: 52vw;
  height: 34vw;
  right: -10vw;
  bottom: 10vh;
  border: 1px solid rgba(143, 255, 224, 0.18);
  background: radial-gradient(ellipse, rgba(110, 75, 255, 0.27), transparent 70%);
  animation: wellDrift 23s ease-in-out infinite reverse;
}

.well-three {
  width: 28vw;
  height: 28vw;
  left: 40vw;
  top: 38vh;
  background: radial-gradient(circle, rgba(234, 247, 255, 0.08), transparent 62%);
  animation: pulseWell 9s ease-in-out infinite;
}

.persistent-loop {
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0.94;
}

.persistent-loop svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.infinity-trace,
.infinity-shadow {
  fill: none;
  transform-origin: 50% 50%;
}

.infinity-trace {
  stroke: url(#loopGradient);
  stroke-width: 2.6;
  stroke-linecap: round;
  filter: url(#loopGlow);
  stroke-dasharray: var(--dash, 2300);
  stroke-dashoffset: var(--offset, 2300);
  opacity: var(--loop-opacity, 0.74);
  transition: stroke-width 0.2s linear, opacity 0.2s linear;
}

.infinity-shadow {
  stroke: rgba(185, 198, 216, 0.09);
  stroke-width: 38;
  filter: blur(18px);
  opacity: 0.42;
}

.loop-nav {
  right: 2.2rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 8;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.loop-nav a {
  color: rgba(185, 198, 216, 0.55);
  text-decoration: none;
  position: relative;
  padding-right: 1.35rem;
  transition: color 0.4s ease, transform 0.4s ease;
}

.loop-nav a::before {
  content: attr(data-index);
  position: absolute;
  right: 100%;
  margin-right: 0.7rem;
  color: rgba(143, 255, 224, 0.38);
}

.loop-nav a::after {
  content: "";
  position: absolute;
  right: 0;
  top: 50%;
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: rgba(234, 247, 255, 0.24);
  box-shadow: 0 0 14px rgba(143, 255, 224, 0.25);
  transform: translateY(-50%);
}

.loop-nav a.active,
.loop-nav a:hover {
  color: var(--pearl);
  transform: translateX(-0.25rem);
}

.loop-nav a.active::after {
  background: var(--mint);
  box-shadow: 0 0 22px var(--mint), 0 0 36px var(--violet);
}

.loop-journey {
  position: relative;
  z-index: 3;
}

.chamber {
  min-height: 100vh;
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 8vw;
  isolation: isolate;
}

.chamber::before {
  content: "";
  position: absolute;
  inset: 8vh 8vw;
  border: 1px solid rgba(185, 198, 216, 0.08);
  border-radius: 50%;
  transform: rotate(var(--oval-tilt, -12deg));
  background: radial-gradient(ellipse at center, rgba(22, 24, 39, 0.35), transparent 62%);
  z-index: -2;
}

.chamber::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--glint-x, 50%) var(--glint-y, 50%), rgba(143, 255, 224, 0.08), transparent 18%);
  opacity: var(--visible, 0.2);
  transition: opacity 0.8s ease;
  z-index: -3;
}

.origin-core {
  text-align: center;
  max-width: 760px;
  transform: translateY(calc(var(--local-progress, 0) * -40px));
}

.coordinate {
  margin: 0 0 1rem;
  font-family: var(--mono);
  font-size: clamp(0.62rem, 0.85vw, 0.78rem);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(143, 255, 224, 0.62);
}

.wordmark {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(5rem, 16vw, 16rem);
  font-weight: 400;
  letter-spacing: -0.075em;
  color: var(--pearl);
  text-shadow: 0 0 38px rgba(234, 247, 255, 0.28), 0 0 100px rgba(110, 75, 255, 0.26);
  animation: wordEmergence 2.6s cubic-bezier(0.2, 0.8, 0.1, 1) both;
}

.opening-line {
  max-width: 560px;
  margin: 1rem auto 2.4rem;
  font-size: clamp(1.05rem, 1.7vw, 1.4rem);
  line-height: 1.7;
  color: rgba(234, 247, 255, 0.76);
}

.poetic-entry,
.return-loop {
  display: inline-block;
  color: var(--mint);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  text-decoration: none;
  border-bottom: 1px solid rgba(143, 255, 224, 0.55);
  padding: 0 0 0.55rem;
  transition: letter-spacing 0.5s ease, color 0.5s ease;
}

.poetic-entry:hover,
.return-loop:hover {
  letter-spacing: 0.38em;
  color: var(--pearl);
}

.chamber-orbit {
  position: absolute;
  width: 52vw;
  height: 26vw;
  border: 1px solid rgba(185, 198, 216, 0.12);
  border-radius: 50%;
  left: -12vw;
  top: 14vh;
  transform: rotate(-16deg);
  box-shadow: inset 0 0 80px rgba(16, 43, 92, 0.38), 0 0 80px rgba(110, 75, 255, 0.11);
}

.pearl-field span,
.seed-particle {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--pearl);
  box-shadow: 0 0 12px var(--mint), 0 0 26px rgba(110, 75, 255, 0.5);
  opacity: 0.7;
}

.side-whisper {
  position: absolute;
  max-width: 210px;
  margin: 0;
  font-family: var(--mono);
  font-size: 0.67rem;
  line-height: 1.8;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(185, 198, 216, 0.46);
}

.whisper-a { left: 9vw; bottom: 14vh; transform: rotate(-18deg); }
.whisper-b { right: 12vw; top: 19vh; transform: rotate(16deg); }

.scene-copy {
  position: relative;
  max-width: 470px;
  padding: 2rem 2.2rem;
  border: 1px solid rgba(185, 198, 216, 0.13);
  border-radius: 44% 56% 52% 48% / 46% 40% 60% 54%;
  background: linear-gradient(135deg, rgba(22, 24, 39, 0.62), rgba(16, 43, 92, 0.14));
  box-shadow: inset 0 1px 0 rgba(234, 247, 255, 0.16), 0 30px 100px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(18px);
}

.scene-copy h2 {
  margin: 0 0 1rem;
  font-family: var(--serif);
  font-size: clamp(3.3rem, 8vw, 8.5rem);
  font-weight: 400;
  line-height: 0.88;
  letter-spacing: -0.055em;
  color: var(--pearl);
  text-shadow: 0 0 32px rgba(110, 75, 255, 0.25);
}

.scene-copy p:not(.coordinate) {
  margin: 0;
  color: rgba(234, 247, 255, 0.72);
  font-size: clamp(1rem, 1.35vw, 1.18rem);
  line-height: 1.75;
}

.chamber-fold { --oval-tilt: 13deg; --glint-x: 32%; --glint-y: 44%; }
.fold-copy { justify-self: start; margin-left: 5vw; transform: rotate(-4deg); }

.ribbon {
  position: absolute;
  width: 92vw;
  height: 22vh;
  left: 3vw;
  top: 44vh;
  border-radius: 50%;
  transform: rotate(-12deg);
  background: linear-gradient(90deg, transparent, rgba(185, 198, 216, 0.12), rgba(143, 255, 224, 0.18), rgba(110, 75, 255, 0.12), transparent);
  border-top: 1px solid rgba(234, 247, 255, 0.26);
  border-bottom: 1px solid rgba(16, 43, 92, 0.4);
  filter: blur(0.2px);
}

.ribbon-back { z-index: -1; opacity: 0.48; }
.ribbon-front { z-index: 4; opacity: 0.74; mix-blend-mode: screen; transform: rotate(-12deg) translateY(9vh); }

.recursive-window {
  position: absolute;
  right: 14vw;
  top: 20vh;
  width: min(34vw, 430px);
  aspect-ratio: 1;
  animation: orbitalLean 12s ease-in-out infinite;
}

.recursive-window span {
  position: absolute;
  inset: calc(var(--i, 0) * 8%);
  border: 1px solid rgba(143, 255, 224, 0.22);
  border-radius: 42% 58% 46% 54% / 50% 42% 58% 50%;
  transform: rotate(calc(var(--i, 0) * 15deg));
  box-shadow: 0 0 50px rgba(110, 75, 255, 0.12);
}

.recursive-window span:nth-child(1) { --i: 1; }
.recursive-window span:nth-child(2) { --i: 2; }
.recursive-window span:nth-child(3) { --i: 3; }
.recursive-window span:nth-child(4) { --i: 4; }

.chamber-basin { --oval-tilt: -4deg; --glint-x: 54%; --glint-y: 60%; }

.basin-surface {
  position: absolute;
  width: min(74vw, 930px);
  height: 31vh;
  left: 10vw;
  bottom: 12vh;
  border-radius: 50%;
  background:
    radial-gradient(ellipse at 50% 5%, rgba(234, 247, 255, 0.18), transparent 20%),
    linear-gradient(180deg, rgba(16, 43, 92, 0.08), rgba(143, 255, 224, 0.08));
  border: 1px solid rgba(185, 198, 216, 0.16);
  box-shadow: inset 0 0 80px rgba(143, 255, 224, 0.08), 0 30px 100px rgba(0, 0, 0, 0.45);
  transform: rotate(-5deg);
  overflow: hidden;
}

.basin-glint {
  position: absolute;
  inset: 44% -10% auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--pearl), var(--mint), transparent);
  animation: glintSlide 7s ease-in-out infinite;
}

.basin-reflection {
  position: absolute;
  left: 28%;
  top: 35%;
  font-family: var(--serif);
  font-size: clamp(3rem, 10vw, 9rem);
  color: rgba(234, 247, 255, 0.06);
  transform: scaleY(-1) skewX(-8deg);
  letter-spacing: -0.08em;
}

.basin-copy { justify-self: end; margin-right: 10vw; transition: transform 0.7s cubic-bezier(0.2, 0.8, 0.2, 1); }
.basin-copy.inverted { transform: scaleX(-1) rotate(2deg); }

.chamber-archive { --oval-tilt: 22deg; --glint-x: 72%; --glint-y: 38%; }
.archive-copy { justify-self: start; align-self: end; margin: 0 0 10vh 4vw; }

.archive-rings {
  position: absolute;
  right: 9vw;
  top: 15vh;
  width: min(48vw, 640px);
  height: min(48vw, 640px);
}

.eclipse-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(185, 198, 216, 0.15);
  box-shadow: inset 0 0 60px rgba(16, 43, 92, 0.25), 0 0 70px rgba(110, 75, 255, 0.1);
}

.ring-one { inset: 5%; animation: orbitRing 20s linear infinite; }
.ring-two { inset: 20%; border-color: rgba(143, 255, 224, 0.2); animation: orbitRing 15s linear infinite reverse; }
.ring-three { inset: 35%; border-color: rgba(110, 75, 255, 0.28); animation: pulseWell 6s ease-in-out infinite; }

.archive-label {
  position: absolute;
  font-family: var(--mono);
  font-size: 0.63rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(143, 255, 224, 0.52);
}

.label-one { left: 3%; top: 36%; transform: rotate(-16deg); }
.label-two { right: 7%; bottom: 25%; transform: rotate(19deg); }

.chamber-horizon { --oval-tilt: -18deg; --glint-x: 50%; --glint-y: 50%; }

.horizon-portal {
  position: absolute;
  width: min(82vw, 1100px);
  height: min(44vw, 520px);
  border-radius: 50%;
  border: 1px solid rgba(234, 247, 255, 0.12);
  background:
    radial-gradient(ellipse at center, transparent 48%, rgba(143, 255, 224, 0.08) 49%, transparent 52%),
    radial-gradient(ellipse at center, rgba(110, 75, 255, 0.16), transparent 60%);
  box-shadow: inset 0 0 120px rgba(16, 43, 92, 0.46), 0 0 140px rgba(143, 255, 224, 0.08);
  animation: portalBreathe 10s ease-in-out infinite;
}

.horizon-copy {
  text-align: center;
  margin-top: -8vh;
}

.return-loop {
  position: absolute;
  bottom: 12vh;
}

@keyframes wordEmergence {
  from { opacity: 0; filter: blur(22px); transform: scale(0.86); }
  to { opacity: 1; filter: blur(0); transform: scale(1); }
}

@keyframes wellDrift {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(-3deg); }
  50% { transform: translate3d(4vw, -3vh, 0) rotate(5deg); }
}

@keyframes pulseWell {
  0%, 100% { opacity: 0.35; transform: scale(0.96); }
  50% { opacity: 0.88; transform: scale(1.04); }
}

@keyframes orbitalLean {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(4vh) rotate(10deg); }
}

@keyframes glintSlide {
  0%, 100% { transform: translateX(-40%); opacity: 0.18; }
  50% { transform: translateX(40%); opacity: 0.82; }
}

@keyframes orbitRing {
  to { transform: rotate(360deg); }
}

@keyframes portalBreathe {
  0%, 100% { transform: scale(0.98) rotate(-3deg); opacity: 0.65; }
  50% { transform: scale(1.03) rotate(3deg); opacity: 1; }
}

@media (max-width: 820px) {
  .loop-nav { display: none; }
  .chamber { padding: 16vh 7vw; place-items: center; }
  .scene-copy, .fold-copy, .basin-copy, .archive-copy { justify-self: center; margin: 0; transform: none; }
  .recursive-window, .archive-rings { opacity: 0.42; right: auto; width: 76vw; height: 76vw; }
  .side-whisper { display: none; }
  .ribbon { width: 130vw; left: -15vw; }
}
