:root {
  /* Typography tokens preserved for compliance: JetBrains Mono** from Google Fonts for script fragments; Space Grotesk** from Google Fonts for body copy, prose and **JetBrains Mono** annotations for a distinctive balance of force and calm. */
  --black: #050713;
  --shadow: #161B3D;
  --cyan: #35F6FF;
  --orchid: #C15CFF;
  --mint: #A8FFB2;
  --frost: #EAF7FF;
  --lavender: #7F86B8;
  --wash: rgba(234, 247, 255, 0.10);
  --edge: rgba(53, 246, 255, 0.32);
  --display: "Archivo Black", Impact, sans-serif;
  --body: "Space Grotesk", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--frost);
  background:
    radial-gradient(circle at 18% 10%, rgba(53, 246, 255, 0.16), transparent 30rem),
    radial-gradient(circle at 78% 26%, rgba(193, 92, 255, 0.15), transparent 34rem),
    radial-gradient(circle at 45% 72%, rgba(168, 255, 178, 0.08), transparent 30rem),
    linear-gradient(180deg, var(--black), #080B1E 45%, var(--black));
  font-family: var(--body);
}

body.refracting .refract-text,
body.refracting .chapter-title,
body.refracting .glass-copy { text-shadow: -2px 0 var(--cyan), 2px 0 var(--orchid), 0 0 28px rgba(234, 247, 255, 0.28); }

.mineral-noise {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  opacity: 0.18;
  background-image:
    radial-gradient(circle at 18% 22%, rgba(234, 247, 255, 0.35) 0 1px, transparent 1.5px),
    radial-gradient(circle at 72% 61%, rgba(127, 134, 184, 0.35) 0 1px, transparent 1.5px);
  background-size: 91px 77px, 137px 113px;
  mix-blend-mode: screen;
}

.cursor-smudge {
  position: fixed;
  width: 16rem;
  height: 16rem;
  left: 0;
  top: 0;
  z-index: 15;
  pointer-events: none;
  border-radius: 50%;
  opacity: 0;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(234,247,255,0.16), rgba(53,246,255,0.06) 38%, transparent 70%);
  filter: blur(12px);
  transition: opacity 600ms ease;
}

.etched-nav {
  position: fixed;
  top: 1.2rem;
  left: clamp(1rem, 4vw, 4rem);
  right: clamp(1rem, 4vw, 4rem);
  z-index: 30;
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  align-items: center;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  color: var(--lavender);
  opacity: 0.48;
}

.etched-nav span { margin-right: auto; color: var(--cyan); }
.etched-nav a { color: inherit; text-decoration: none; border-bottom: 1px solid transparent; }
.etched-nav a:hover { color: var(--frost); border-color: var(--edge); }

.story-graph {
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 420vh;
  z-index: 2;
  pointer-events: none;
  opacity: 0.86;
}

.main-path, .ghost-path {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.main-path { stroke: url(#graphGradient); stroke-width: 3; filter: url(#lineGlow); }
.ghost-path { stroke: rgba(127, 134, 184, 0.28); stroke-width: 1.5; stroke-dasharray: 9 22; }
.svg-node { fill: var(--cyan); filter: drop-shadow(0 0 12px var(--cyan)); }
.svg-node.orchid { fill: var(--orchid); filter: drop-shadow(0 0 14px var(--orchid)); }
.svg-node.mint { fill: var(--mint); filter: drop-shadow(0 0 14px var(--mint)); }

.leaf {
  position: relative;
  z-index: 5;
  min-height: 100vh;
  padding: clamp(5rem, 8vw, 9rem) clamp(1.2rem, 5vw, 5rem);
  display: grid;
  grid-template-columns: repeat(14, minmax(0, 1fr));
  gap: clamp(0.6rem, 1.2vw, 1.2rem);
  align-items: center;
  isolation: isolate;
}

.glass-pane, .script-crystal, .opening-stroke {
  background: linear-gradient(135deg, rgba(234, 247, 255, 0.14), rgba(22, 27, 61, 0.48));
  border: 1px solid var(--edge);
  box-shadow: inset 0 1px rgba(234,247,255,0.22), 0 28px 90px rgba(0,0,0,0.35), 0 0 40px rgba(53,246,255,0.06);
  backdrop-filter: blur(18px) saturate(135%);
}

.glass-pane::before, .script-crystal::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(115deg, rgba(234,247,255,0.18), transparent 22%, rgba(193,92,255,0.08) 58%, transparent);
  clip-path: polygon(0 0, 100% 0, 88% 100%, 0 88%);
}

.mono { font-family: var(--mono); color: var(--lavender); letter-spacing: 0.08em; }

.hero { align-content: center; overflow: hidden; }

.breath-ring {
  position: absolute;
  width: min(64vw, 52rem);
  aspect-ratio: 1;
  left: 50%;
  top: 50%;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(53,246,255,0.18);
  box-shadow: inset 0 0 7rem rgba(53,246,255,0.05), 0 0 8rem rgba(193,92,255,0.07);
  animation: breathe 8s ease-in-out infinite;
}

.opening-stroke {
  grid-column: 3 / 11;
  align-self: end;
  padding: 1.2rem;
  border-radius: 2rem;
  transform: rotate(-2deg);
}

.opening-stroke svg { width: 100%; overflow: visible; }
.opening-stroke path { fill: none; stroke: var(--cyan); stroke-width: 5; stroke-linecap: round; stroke-dasharray: 900; stroke-dashoffset: 900; animation: drawOpening 3.4s ease forwards 0.35s; filter: drop-shadow(0 0 18px var(--cyan)); }
.opening-stroke circle { fill: var(--black); stroke: var(--orchid); stroke-width: 4; opacity: 0; animation: appear 600ms ease forwards 2.5s; filter: drop-shadow(0 0 15px var(--orchid)); }

.margin-mark { grid-column: 2 / 5; align-self: start; font-size: 0.76rem; }
.wordmark {
  grid-column: 2 / 14;
  margin: 0;
  font-family: var(--display);
  font-size: clamp(4rem, 12vw, 12.5rem);
  line-height: 0.78;
  letter-spacing: -0.08em;
  color: var(--frost);
  filter: blur(16px);
  opacity: 0;
  animation: clearTitle 2s ease forwards 2.1s;
}

.hero-line {
  grid-column: 8 / 13;
  max-width: 34rem;
  color: var(--lavender);
  font-size: clamp(1rem, 1.5vw, 1.35rem);
  line-height: 1.7;
  opacity: 0;
  animation: appear 1.2s ease forwards 3.1s;
}

.dense { align-items: stretch; padding-top: 12vh; }
.margin-note {
  position: relative;
  grid-column: 1 / 4;
  align-self: start;
  padding: 1.2rem;
  border-radius: 1.5rem 0.5rem 1.5rem 0.5rem;
  color: var(--lavender);
  line-height: 1.7;
}

.chapter-kicker { grid-column: 5 / 9; align-self: end; font-size: 0.75rem; color: var(--cyan); }
.chapter-title {
  grid-column: 4 / 12;
  margin: 0;
  font-family: var(--display);
  font-size: clamp(4.5rem, 10vw, 11rem);
  line-height: 0.82;
  letter-spacing: -0.06em;
  text-transform: lowercase;
}

.copy-block {
  position: relative;
  grid-column: 6 / 11;
  align-self: start;
  padding: clamp(1.3rem, 3vw, 2.4rem);
  border-radius: 2rem;
  color: var(--frost);
}

.copy-block p, .meditation p, .observatory-pane p { line-height: 1.75; color: rgba(234,247,255,0.82); }
code { display: block; margin-top: 1.5rem; font-family: var(--mono); color: var(--mint); white-space: normal; }

.node-field { grid-column: 11 / 15; display: grid; gap: 1.2rem; align-content: center; }
.node {
  width: 7rem;
  height: 7rem;
  border-radius: 50%;
  border: 1px solid var(--edge);
  background: radial-gradient(circle, rgba(53,246,255,0.25), rgba(22,27,61,0.38));
  color: var(--frost);
  font-family: var(--mono);
  cursor: pointer;
  box-shadow: 0 0 32px rgba(53,246,255,0.13), inset 0 0 30px rgba(234,247,255,0.07);
  transition: transform 400ms ease, filter 400ms ease;
}
.node:nth-child(2) { margin-left: 3rem; }
.node.hot { background: radial-gradient(circle, rgba(193,92,255,0.35), rgba(22,27,61,0.42)); }
.node.mint { background: radial-gradient(circle, rgba(168,255,178,0.26), rgba(22,27,61,0.42)); }
.node:hover { transform: scale(1.12) rotate(-5deg); filter: saturate(1.5); }

.script-crystal {
  position: absolute;
  width: 18rem;
  height: 18rem;
  right: 10vw;
  top: 18vh;
  display: grid;
  place-items: center;
  clip-path: polygon(47% 0, 92% 20%, 100% 70%, 58% 100%, 9% 83%, 0 28%);
  cursor: grab;
  transform: rotate(var(--crystal-rot, 8deg));
  transition: filter 300ms ease;
  animation: drift 12s ease-in-out infinite;
}
.script-crystal.dragging { cursor: grabbing; filter: drop-shadow(0 0 35px rgba(53,246,255,0.48)); }
.script-crystal span { position: absolute; font-family: var(--mono); font-size: 0.8rem; color: var(--frost); text-shadow: 0 0 10px var(--cyan); }
.script-crystal span:nth-child(1) { top: 28%; left: 22%; }
.script-crystal span:nth-child(2) { top: 52%; left: 30%; color: var(--orchid); }
.script-crystal span:nth-child(3) { bottom: 24%; right: 25%; color: var(--mint); }

.interlude { align-content: center; }
.folded-corner { grid-column: 2 / 5; height: 11rem; border: 1px solid var(--edge); background: linear-gradient(135deg, rgba(234,247,255,0.13), transparent); clip-path: polygon(0 0, 100% 0, 0 100%); }
.single-word { grid-column: 4 / 10; margin: 0; font-family: var(--display); font-size: clamp(7rem, 19vw, 20rem); line-height: 0.75; color: transparent; -webkit-text-stroke: 2px var(--frost); text-shadow: 0 0 60px rgba(193,92,255,0.22); }
.meditation { position: relative; grid-column: 9 / 14; padding: 2rem; border-radius: 2.2rem; }
.breath-orbit { position: absolute; inset: 16% auto auto 13%; width: 24rem; height: 24rem; border-radius: 50%; }
.breath-orbit span { position: absolute; inset: 0; border-radius: 50%; border: 1px solid rgba(53,246,255,0.16); animation: breathe 7s ease-in-out infinite; }
.breath-orbit span:nth-child(2) { inset: 12%; animation-delay: -2s; border-color: rgba(193,92,255,0.18); }
.breath-orbit span:nth-child(3) { inset: 24%; animation-delay: -4s; border-color: rgba(168,255,178,0.15); }

.cascade { align-content: center; }
.right { grid-column: 12 / 15; }
.resolve-title { grid-column: 2 / 9; }
.cascade-lines { grid-column: 5 / 13; display: grid; gap: 1rem; }
.line { position: relative; margin: 0; padding: 1.1rem 1.4rem; border-radius: 1.4rem; font-family: var(--mono); color: var(--frost); transform: translateX(var(--shift, 0)); }
.line:nth-child(2) { --shift: 4rem; color: var(--cyan); }
.line:nth-child(3) { --shift: 8rem; color: var(--mint); }
.facets { position: absolute; right: 12vw; bottom: 14vh; display: flex; gap: 1.4rem; }
.facet { width: 5rem; height: 5rem; display: grid; place-items: center; color: var(--orchid); border: 1px solid rgba(193,92,255,0.38); background: rgba(234,247,255,0.08); clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); font-size: 2rem; animation: drift 9s ease-in-out infinite; }
.facet.cyan { color: var(--cyan); animation-delay: -3s; }
.facet.mint { color: var(--mint); animation-delay: -6s; }

.observatory { min-height: 110vh; align-content: center; }
.observatory-pane { position: relative; grid-column: 4 / 11; padding: clamp(2rem, 5vw, 4rem); border-radius: 3rem; }
.observatory-pane h2 { margin: 0.2rem 0; font-family: var(--display); font-size: clamp(3rem, 7vw, 8rem); line-height: 0.88; letter-spacing: -0.06em; }
.inscription { display: inline-block; margin-top: 2rem; color: var(--black); background: var(--frost); padding: 0.8rem 1.3rem; border-radius: 999px; text-decoration: none; font-family: var(--mono); box-shadow: 0 0 30px rgba(53,246,255,0.22); }
.constellation { grid-column: 11 / 15; position: relative; height: 28rem; }
.constellation i { position: absolute; width: 0.8rem; height: 0.8rem; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 22px var(--cyan); }
.constellation i:nth-child(1) { left: 15%; top: 20%; }.constellation i:nth-child(2) { left: 68%; top: 12%; background: var(--orchid); }.constellation i:nth-child(3) { left: 45%; top: 46%; background: var(--mint); }.constellation i:nth-child(4) { left: 80%; top: 64%; }.constellation i:nth-child(5) { left: 20%; top: 76%; background: var(--orchid); }.constellation i:nth-child(6) { left: 58%; top: 88%; background: var(--mint); }

.reveal { opacity: 0; transform: translateY(4rem) scale(0.98); filter: blur(12px); transition: opacity 1.2s ease, transform 1.2s ease, filter 1.2s ease; }
.reveal.visible { opacity: 1; transform: none; filter: blur(0); }

@keyframes drawOpening { to { stroke-dashoffset: 0; } }
@keyframes clearTitle { to { opacity: 1; filter: blur(0); } }
@keyframes appear { to { opacity: 1; } }
@keyframes breathe { 50% { transform: translate(-50%, -50%) scale(1.08); opacity: 0.42; } }
@keyframes drift { 50% { translate: 0 -1.2rem; rotate: 7deg; } }

@media (max-width: 760px) {
  .etched-nav { left: 1rem; right: 1rem; gap: 0.6rem; }
  .etched-nav span { display: none; }
  .leaf { grid-template-columns: 1fr; padding: 5rem 1rem; gap: 1.5rem; }
  .opening-stroke, .margin-mark, .wordmark, .hero-line, .margin-note, .chapter-kicker, .chapter-title, .copy-block, .node-field, .folded-corner, .single-word, .meditation, .right, .resolve-title, .cascade-lines, .observatory-pane, .constellation { grid-column: 1; }
  .wordmark { font-size: 4.4rem; word-break: break-word; }
  .chapter-title { font-size: 4.7rem; }
  .single-word { font-size: 7rem; }
  .script-crystal { position: relative; right: auto; top: auto; width: 14rem; height: 14rem; margin-left: auto; }
  .node-field { display: flex; flex-wrap: wrap; }
  .node { width: 5.6rem; height: 5.6rem; }
  .node:nth-child(2), .line, .line:nth-child(2), .line:nth-child(3) { margin-left: 0; --shift: 0; }
  .breath-orbit { width: 18rem; height: 18rem; left: -5rem; }
  .facets { position: relative; right: auto; bottom: auto; }
}
