:root {
  /* DESIGN typography tokens: Space Grotesk** in bold weights for the domain mark */
  --void: #050814;
  --cyan: #32F5FF;
  --green: #5CFFB1;
  --magenta: #FF4FD8;
  --violet: #7A5CFF;
  --amber: #FFC857;
  --trace: #DDE7FF;
  --display: "Space Grotesk", "Space", "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "Spline Sans Mono", "Space Mono", "SFMono-Regular", Consolas, monospace;
  --serif: "Instrument Serif", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--trace);
  font-family: var(--display);
  background:
    radial-gradient(circle at 78% 12%, rgba(122, 92, 255, .18), transparent 28rem),
    radial-gradient(circle at 18% 85%, rgba(50, 245, 255, .11), transparent 34rem),
    var(--void);
}

.grain, .pulse-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.grain {
  opacity: .16;
  background-image: radial-gradient(circle, rgba(221, 231, 255, .55) 0 1px, transparent 1px);
  background-size: 19px 23px;
  mix-blend-mode: screen;
}

.pulse-grid {
  opacity: .28;
  background:
    linear-gradient(90deg, rgba(221, 231, 255, .055) 1px, transparent 1px),
    linear-gradient(0deg, rgba(221, 231, 255, .04) 1px, transparent 1px);
  background-size: 72px 72px;
  transform: perspective(800px) rotateX(58deg) translateY(-20vh) scale(1.25);
  transform-origin: top center;
  animation: gridDrift 18s linear infinite;
}

.vertical-rail {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 92px;
  z-index: 8;
  border-right: 1px solid rgba(221, 231, 255, .12);
  background: linear-gradient(90deg, rgba(5, 8, 20, .92), rgba(5, 8, 20, .18));
}

.rail-line {
  position: absolute;
  left: 42px;
  top: 28px;
  bottom: 28px;
  width: 1px;
  background: linear-gradient(var(--cyan), var(--violet), var(--green));
  box-shadow: 0 0 18px rgba(50, 245, 255, .8);
}

.domain-mark {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%) rotate(-90deg);
  transform-origin: center;
  white-space: nowrap;
  font-family: var(--display);
  font-size: clamp(1.6rem, 3.5vw, 3.9rem);
  font-weight: 800;
  letter-spacing: -.055em;
  color: var(--trace);
  text-shadow: 0 0 24px rgba(50, 245, 255, .34);
}

.rail-ticks {
  position: absolute;
  inset: 9vh 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
}

.rail-ticks span {
  width: 15px;
  height: 2px;
  background: var(--amber);
  box-shadow: 0 0 10px var(--amber);
}

.event-theater { position: relative; z-index: 2; }

.scene {
  min-height: 100vh;
  position: relative;
  padding: clamp(38px, 6vw, 88px) clamp(24px, 7vw, 96px) clamp(38px, 6vw, 88px) clamp(118px, 13vw, 190px);
  overflow: hidden;
  isolation: isolate;
}

.scene::before {
  content: attr(data-phase);
  position: absolute;
  right: 5vw;
  top: 6vh;
  font-family: var(--mono);
  font-size: clamp(3.8rem, 12vw, 10rem);
  font-weight: 800;
  letter-spacing: -.08em;
  color: rgba(221, 231, 255, .035);
  z-index: -1;
}

.hero-copy {
  position: absolute;
  left: clamp(128px, 14vw, 210px);
  top: 15vh;
  max-width: 760px;
}

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

h1 { font-size: clamp(4.3rem, 12vw, 12.7rem); max-width: 9ch; }
h2 { font-size: clamp(3.3rem, 8vw, 8.4rem); max-width: 10ch; }

p {
  font-size: clamp(1rem, 1.55vw, 1.35rem);
  line-height: 1.55;
  max-width: 560px;
  color: rgba(221, 231, 255, .76);
}

.serif-note {
  font-family: var(--serif);
  font-size: clamp(1.35rem, 2.5vw, 2.45rem);
  line-height: 1.12;
  color: rgba(221, 231, 255, .9);
}

.scheduler-label, .chapter-command, .scheduler-log {
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: .14em;
  font-size: .74rem;
  color: var(--cyan);
}

.chapter-command {
  position: absolute;
  left: clamp(128px, 14vw, 210px);
  top: 9vh;
  color: var(--amber);
}

.causal-field {
  position: absolute;
  inset: 8vh 8vw 12vh 110px;
  border: 1px solid rgba(221, 231, 255, .08);
  border-radius: 46% 54% 34% 66% / 63% 28% 72% 37%;
  background: radial-gradient(circle at 55% 45%, rgba(50, 245, 255, .1), transparent 36%), rgba(122, 92, 255, .035);
  filter: blur(.1px);
}

.happens-before {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  fill: none;
  pointer-events: none;
}

.happens-before path {
  stroke: rgba(221, 231, 255, .42);
  stroke-width: 1.5;
  stroke-dasharray: 10 18;
  filter: drop-shadow(0 0 6px rgba(50, 245, 255, .35));
  animation: dashFlow 14s linear infinite;
}

.event-particle-field {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.event-token {
  display: block;
  width: 44px;
  height: 14px;
  border-radius: 999px;
  background: var(--cyan);
  box-shadow: 0 0 14px currentColor, 0 0 42px currentColor;
  color: var(--cyan);
}

.event-token.cyan { background: var(--cyan); color: var(--cyan); }
.event-token.green { background: var(--green); color: var(--green); }
.event-token.magenta { background: var(--magenta); color: var(--magenta); }
.event-token.violet { background: var(--violet); color: var(--violet); }
.event-token.amber { background: var(--amber); color: var(--amber); }

.spawn-token {
  position: absolute;
  transform: translate3d(var(--x), var(--y), 0) rotate(var(--r));
  animation: tokenPulse 2.4s ease-in-out infinite;
}

.completion-horizon {
  position: absolute;
  left: 108px;
  right: 0;
  bottom: 32vh;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan), var(--green), transparent);
  box-shadow: 0 0 26px rgba(92, 255, 177, .65);
}

.completion-horizon span {
  position: absolute;
  top: -5px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1px solid var(--green);
  box-shadow: 0 0 16px var(--green);
  animation: horizonCommit 4.5s ease-in-out infinite;
}
.completion-horizon span:nth-child(1) { left: 18%; animation-delay: -.5s; }
.completion-horizon span:nth-child(2) { left: 42%; animation-delay: -1.7s; }
.completion-horizon span:nth-child(3) { left: 61%; animation-delay: -3s; }
.completion-horizon span:nth-child(4) { left: 82%; animation-delay: -2.3s; }

.vector-clock {
  width: 150px;
  height: 150px;
  border: 1px solid rgba(50, 245, 255, .42);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  color: var(--cyan);
  background: radial-gradient(circle, rgba(50, 245, 255, .13), transparent 58%);
  box-shadow: inset 0 0 22px rgba(50, 245, 255, .12), 0 0 30px rgba(50, 245, 255, .16);
  animation: clockSpin 22s linear infinite;
}

.vector-clock b { font-size: .75rem; letter-spacing: .2em; }
.vector-clock span { position: absolute; font-size: .7rem; }
.vector-clock span:nth-child(2) { transform: translateY(-58px); }
.vector-clock span:nth-child(3) { transform: translateX(58px); }
.vector-clock span:nth-child(4) { transform: translateY(58px); }
.vector-clock span:nth-child(5) { transform: translateX(-58px); }

.hero-clock { position: absolute; right: 11vw; top: 18vh; }

.timeout-arc {
  width: 240px;
  height: 240px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: var(--amber);
  border-right-color: rgba(255, 200, 87, .35);
  filter: drop-shadow(0 0 14px rgba(255, 200, 87, .5));
  animation: arcSweep 8s ease-in-out infinite;
}

.hero-timeout { position: absolute; right: 18vw; bottom: 14vh; }

.scene-queue { background: linear-gradient(165deg, rgba(122, 92, 255, .12), transparent 45%); }
.lane-stack { position: absolute; inset: 18vh 6vw 12vh clamp(122px, 16vw, 230px); transform: skewY(-8deg); }

.scheduler-lane {
  position: relative;
  height: 14vh;
  margin: 2vh 0;
  border-top: 1px solid rgba(221, 231, 255, .18);
  border-bottom: 1px solid rgba(221, 231, 255, .08);
  background: linear-gradient(90deg, rgba(50, 245, 255, .08), rgba(122, 92, 255, .04), transparent);
}

.scheduler-lane span {
  position: absolute;
  left: 1rem;
  top: .9rem;
  font-family: var(--mono);
  color: rgba(221, 231, 255, .58);
  font-size: .75rem;
  letter-spacing: .1em;
}

.scheduler-lane .event-token { position: absolute; left: 22%; top: 48%; animation: laneDrift 7s ease-in-out infinite; }
.scheduler-lane .event-token.delayed { left: 46%; animation-delay: -3s; }
.lane-b .event-token { animation-duration: 6s; }
.lane-c .event-token { animation-duration: 8.5s; }
.lane-d .event-token { animation-duration: 7.5s; }

.mailbox-node {
  position: absolute;
  right: 12%;
  top: 35%;
  width: 56px;
  height: 42px;
  border: 1px solid var(--violet);
  border-radius: 6px 6px 14px 14px;
  box-shadow: inset 0 0 18px rgba(122, 92, 255, .18), 0 0 18px rgba(122, 92, 255, .38);
}
.mailbox-node::before { content: ""; position: absolute; inset: 9px; border-top: 1px solid rgba(221, 231, 255, .34); transform: skewY(-18deg); }

.queue-copy, .race-copy, .resolve-copy, .complete-copy { position: absolute; z-index: 5; }
.queue-copy { right: 7vw; bottom: 10vh; max-width: 590px; text-align: right; }

.event-loom {
  position: absolute;
  pointer-events: none;
  opacity: .78;
}
.event-loom span {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan), var(--green), transparent);
  box-shadow: 0 0 12px rgba(50, 245, 255, .42);
  transform: rotate(var(--rot)) translateY(var(--off));
  animation: weave 6s ease-in-out infinite alternate;
}
.event-loom span:nth-child(2) { --rot: -4deg; --off: 28px; background: linear-gradient(90deg, transparent, var(--magenta), var(--violet), transparent); animation-delay: -1s; }
.event-loom span:nth-child(3) { --rot: 6deg; --off: 55px; background: linear-gradient(90deg, transparent, var(--amber), transparent); animation-delay: -2s; }
.event-loom span:nth-child(4) { --rot: -8deg; --off: 82px; animation-delay: -3s; }
.event-loom span:nth-child(5) { --rot: 3deg; --off: 110px; background: linear-gradient(90deg, transparent, var(--green), transparent); animation-delay: -4s; }
.event-loom span:nth-child(6) { --rot: -1deg; --off: 138px; background: linear-gradient(90deg, transparent, var(--violet), var(--cyan), transparent); animation-delay: -5s; }
.queue-loom { left: 14vw; right: 8vw; bottom: 9vh; height: 170px; }
.resolve-loom { left: 10vw; right: 4vw; bottom: 14vh; height: 220px; }
.event-loom span:first-child { --rot: 2deg; --off: 0; }

.scene-race { background: radial-gradient(circle at 52% 50%, rgba(255, 79, 216, .16), transparent 36%); }
.race-band {
  position: absolute;
  left: 85px;
  right: -10vw;
  height: 21vh;
  background: linear-gradient(90deg, transparent, rgba(255, 79, 216, .28), rgba(122, 92, 255, .2), transparent);
  transform: rotate(-11deg);
  filter: blur(.2px);
  mix-blend-mode: screen;
}
.band-one { top: 30vh; animation: raceBreath 5s ease-in-out infinite; }
.band-two { top: 48vh; transform: rotate(8deg); animation: raceBreath 5s ease-in-out infinite reverse; }
.race-copy { left: clamp(128px, 14vw, 210px); top: 16vh; }
.race-collision { position: absolute; right: 16vw; bottom: 22vh; width: 260px; height: 260px; }
.race-collision .event-token { position: absolute; top: 120px; }
.race-collision .event-token.cyan { left: 20px; animation: collideLeft 3s ease-in-out infinite; }
.race-collision .event-token.magenta { right: 20px; animation: collideRight 3s ease-in-out infinite; }
.race-collision .completion-halo { position: absolute; left: 62px; top: 62px; }
.race-collision .vector-clock { position: absolute; left: 55px; top: 55px; transform: scale(.7); }

.completion-halo {
  width: 136px;
  height: 136px;
  border-radius: 50%;
  border: 1px solid var(--green);
  box-shadow: 0 0 32px rgba(92, 255, 177, .54), inset 0 0 22px rgba(92, 255, 177, .18);
  animation: haloPulse 3s ease-in-out infinite;
}

.scene-resolve { background: linear-gradient(24deg, rgba(92, 255, 177, .08), transparent 46%); }
.fork-join { position: absolute; left: clamp(128px, 15vw, 240px); top: 20vh; width: 60vw; height: 54vh; }
.fork-stem, .fork-arm { position: absolute; height: 2px; background: linear-gradient(90deg, var(--cyan), var(--violet), var(--green)); box-shadow: 0 0 14px rgba(50, 245, 255, .45); transform-origin: left center; }
.fork-stem { left: 0; top: 50%; width: 22%; }
.fork-arm { left: 21%; top: 50%; width: 56%; }
.arm-one { transform: rotate(-24deg); }
.arm-two { transform: rotate(0deg); }
.arm-three { transform: rotate(24deg); }
.join-gate { position: absolute; right: 5%; top: calc(50% - 38px); width: 92px; height: 76px; display: grid; place-items: center; border: 1px solid var(--green); border-radius: 50%; font-family: var(--mono); color: var(--green); box-shadow: 0 0 26px rgba(92, 255, 177, .4); }
.fork-join .event-token { position: absolute; left: 28%; top: 48%; animation: forkTravel 5.4s ease-in-out infinite; }
.fork-join .event-token.violet { animation-delay: -1.8s; }
.fork-join .event-token.amber { animation-delay: -3.6s; }
.resolve-copy { right: 7vw; top: 17vh; max-width: 570px; text-align: right; }
.resolve-timeout { position: absolute; left: 14vw; bottom: 10vh; width: 180px; height: 180px; }

.scene-complete { min-height: 108vh; background: radial-gradient(circle at 50% 55%, rgba(92, 255, 177, .16), transparent 34%); }
.final-trace { position: absolute; left: clamp(120px, 13vw, 200px); right: 6vw; top: 26vh; height: 48vh; }
.final-path path:first-child { stroke: rgba(92, 255, 177, .76); stroke-width: 2; stroke-dasharray: 1 0; }
.final-path path:last-child { stroke: rgba(221, 231, 255, .22); stroke-width: 1; }
.final-halo { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(1.6); }
.final-capsules { position: absolute; left: 13%; right: 10%; top: 48%; display: flex; justify-content: space-between; }
.final-capsules .event-token { animation: finalSettle 4s ease-in-out infinite; }
.complete-copy { left: clamp(128px, 14vw, 210px); bottom: 10vh; }

.scheduler-log {
  position: fixed;
  right: 22px;
  bottom: 20px;
  z-index: 9;
  display: flex;
  gap: 10px;
  color: rgba(221, 231, 255, .68);
}
.scheduler-log span { padding: 9px 11px; border: 1px solid rgba(221, 231, 255, .14); background: rgba(5, 8, 20, .72); box-shadow: 0 0 16px rgba(50, 245, 255, .12); }
.scheduler-log span.active { color: var(--green); border-color: rgba(92, 255, 177, .45); }

@keyframes gridDrift { to { background-position: 72px 72px; } }
@keyframes dashFlow { to { stroke-dashoffset: -280; } }
@keyframes tokenPulse { 50% { filter: brightness(1.6); transform: translate3d(var(--x), calc(var(--y) + 16px), 0) rotate(calc(var(--r) + 6deg)); } }
@keyframes horizonCommit { 0%, 100% { opacity: .35; transform: scale(.6); } 50% { opacity: 1; transform: scale(1.35); } }
@keyframes clockSpin { to { rotate: 360deg; } }
@keyframes arcSweep { 50% { transform: rotate(130deg) scale(.86); opacity: .46; } }
@keyframes laneDrift { 50% { transform: translateX(22vw); } }
@keyframes weave { to { transform: rotate(calc(var(--rot) * -1)) translateY(calc(var(--off) + 18px)); } }
@keyframes raceBreath { 50% { opacity: .35; transform: rotate(-4deg) scaleY(.72); } }
@keyframes collideLeft { 50% { transform: translateX(84px); } }
@keyframes collideRight { 50% { transform: translateX(-84px); } }
@keyframes haloPulse { 50% { transform: scale(1.28); opacity: .55; } }
@keyframes forkTravel { 50% { transform: translate(33vw, -12vh); } }
@keyframes finalSettle { 50% { transform: translateY(-16px); filter: brightness(1.4); } }

@media (max-width: 760px) {
  .vertical-rail { width: 62px; }
  .domain-mark { font-size: 1.45rem; left: -22px; }
  .rail-line { left: 30px; }
  .scene { padding-left: 82px; }
  .hero-copy, .chapter-command, .race-copy, .complete-copy { left: 82px; }
  h1 { font-size: 4.1rem; }
  h2 { font-size: 3.25rem; }
  .hero-clock, .hero-timeout, .resolve-timeout { opacity: .45; }
  .queue-copy, .resolve-copy { left: 82px; right: 22px; text-align: left; }
  .scheduler-log { display: none; }
}
