:root {
  --bg: #08090b;
  --fg: #f4f1e9;
  --fg-soft: rgba(244, 241, 233, .58);
  --fg-faint: rgba(244, 241, 233, .18);
  --fg-hair: rgba(244, 241, 233, .11);
  --accent: #397bff;
  --accent-rgb: 57, 123, 255;
  --pad-x: clamp(22px, 3.3vw, 58px);
  --pad-y: clamp(22px, 3vw, 44px);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-snap: cubic-bezier(.7, 0, .2, 1);
  --nx: 0;
  --ny: 0;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); }
html { overflow: hidden; }
body {
  min-width: 320px;
  color: var(--fg);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  overflow: hidden;
  cursor: none;
}
a { color: inherit; }

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.boot {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-content: center;
  gap: 15px;
  background: var(--bg);
  transition: transform 1s var(--ease-snap), opacity .8s ease;
  transform-origin: top;
}
.boot::before,
.boot::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--fg-hair);
}
.boot::before { top: 36%; }
.boot::after { bottom: 36%; }
.boot__word {
  font-size: clamp(74px, 13vw, 210px);
  font-weight: 950;
  letter-spacing: -.095em;
  line-height: .72;
  transform: scaleX(1.08);
  transform-origin: center;
}
.boot__rule {
  height: 2px;
  width: min(44vw, 420px);
  background: linear-gradient(90deg, var(--accent) 0 28%, rgba(255,255,255,.18) 28% 100%);
  transform: scaleX(0);
  transform-origin: left;
  animation: loadrule .85s .05s var(--ease-out) forwards;
}
.boot__meta {
  justify-self: end;
  color: var(--fg-soft);
  font-size: 9px;
  letter-spacing: .2em;
}
body.is-ready .boot {
  transform: translateY(-100%);
  opacity: .98;
  pointer-events: none;
}
@keyframes loadrule { to { transform: scaleX(1); } }

.gateway {
  position: relative;
  height: 100svh;
  min-height: 560px;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(ellipse at 67% 46%, rgba(var(--accent-rgb), .085), transparent 33%),
    linear-gradient(180deg, #0a0b0d 0%, #07080a 100%);
}
.gateway::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -4;
  background-image:
    linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.02) 1px, transparent 1px);
  background-size: 6.25vw 6.25vw;
  mask-image: linear-gradient(to bottom, transparent, black 18%, black 82%, transparent);
  transform: translate3d(calc(var(--nx) * -5px), calc(var(--ny) * -3px), 0);
  transition: opacity .5s ease;
}

.motion-field {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -3;
  pointer-events: none;
  opacity: .72;
}
.grain {
  position: absolute;
  inset: -80px;
  z-index: 40;
  pointer-events: none;
  opacity: .055;
  mix-blend-mode: screen;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.75'/%3E%3C/svg%3E");
  animation: grainShift .18s steps(2) infinite;
}
@keyframes grainShift {
  0% { transform: translate3d(0,0,0); }
  25% { transform: translate3d(-2%,1%,0); }
  50% { transform: translate3d(1%,-2%,0); }
  75% { transform: translate3d(2%,2%,0); }
  100% { transform: translate3d(-1%,-1%,0); }
}
.edge-light {
  position: absolute;
  z-index: -2;
  top: -20%;
  bottom: -20%;
  left: 58%;
  width: 1px;
  background: linear-gradient(transparent 8%, rgba(var(--accent-rgb), .95) 45%, transparent 82%);
  box-shadow: 0 0 50px 10px rgba(var(--accent-rgb), .08);
  transform: rotate(8deg) translateX(calc(var(--nx) * 24px));
  opacity: .4;
  transition: opacity .6s ease, left .8s var(--ease-out), transform .15s linear;
}

.masthead {
  position: absolute;
  z-index: 30;
  top: var(--pad-y);
  left: var(--pad-x);
  right: var(--pad-x);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  opacity: 0;
  transform: translateY(-16px);
  transition: opacity .75s .75s ease, transform .85s .72s var(--ease-out);
}
body.is-ready .masthead { opacity: 1; transform: none; }
.brand {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-size: 16px;
  font-weight: 850;
  letter-spacing: -.035em;
}
.brand__dot {
  width: 7px;
  height: 7px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 22px rgba(var(--accent-rgb), .9);
}
.masthead__meta {
  color: var(--fg-soft);
  font-size: 8px;
  letter-spacing: .22em;
  white-space: nowrap;
}
.masthead__slash { margin: 0 7px; color: var(--fg-faint); }
.mode-readout {
  justify-self: end;
  display: flex;
  align-items: baseline;
  gap: 11px;
  min-width: 160px;
  justify-content: flex-end;
  color: var(--fg-soft);
  font-size: 8px;
  letter-spacing: .18em;
}
.mode-readout__index { color: var(--accent); }

.stage { position: absolute; inset: 0; }
.word-system {
  position: absolute;
  z-index: 1;
  left: calc(var(--pad-x) - 1.1vw);
  top: 13%;
  width: 94%;
  height: 54%;
  pointer-events: none;
  opacity: 0;
  transform: translateY(28px);
  transition: opacity .8s 1s ease, transform 1.1s .88s var(--ease-out);
}
body.is-ready .word-system { opacity: 1; transform: none; }
.word-slice,
.word-outline {
  position: absolute;
  inset: 0 auto auto 0;
  margin: 0;
  font-size: clamp(150px, 26vw, 510px);
  font-weight: 950;
  line-height: .72;
  letter-spacing: -.095em;
  white-space: nowrap;
  user-select: none;
  transform-origin: left center;
}
.word-slice { color: rgba(244,241,233,.07); }
.word-slice--a {
  clip-path: inset(0 0 70% 0);
  transform: translate3d(calc(var(--nx) * -18px), calc(var(--ny) * -5px),0) scaleX(1.015);
}
.word-slice--b {
  clip-path: inset(30% 0 35% 0);
  transform: translate3d(calc(var(--nx) * 7px), calc(var(--ny) * 2px),0) scaleX(.995);
}
.word-slice--c {
  clip-path: inset(64% 0 0 0);
  transform: translate3d(calc(var(--nx) * -8px), calc(var(--ny) * 4px),0) scaleX(1.008);
}
.word-outline {
  color: transparent;
  -webkit-text-stroke: 1px rgba(244,241,233,.045);
  transform: translate3d(calc(var(--nx) * 2px), calc(var(--ny) * 1px),0);
}

.axis { position: absolute; z-index: 2; background: var(--fg-hair); pointer-events: none; }
.axis--h {
  left: var(--pad-x); right: var(--pad-x); top: 55.7%; height: 1px;
  transform: scaleX(0); transform-origin: left;
  transition: transform 1.2s 1.15s var(--ease-out);
}
.axis--v {
  top: var(--pad-y); bottom: var(--pad-y); left: 61%; width: 1px;
  transform: scaleY(0); transform-origin: top;
  transition: transform 1.1s 1.05s var(--ease-out);
}
body.is-ready .axis { transform: scale(1); }
.coordinate {
  position: absolute;
  z-index: 5;
  color: rgba(244,241,233,.29);
  font-size: 7px;
  letter-spacing: .18em;
  pointer-events: none;
  opacity: 0;
  transition: opacity .6s 1.7s ease;
}
body.is-ready .coordinate { opacity: 1; }
.coordinate--a { left: var(--pad-x); top: calc(55.7% + 9px); }
.coordinate--b { left: calc(61% + 10px); top: calc(var(--pad-y) + 36px); }

.character-scene {
  --char-x: 0px;
  --char-y: 0px;
  position: absolute;
  z-index: 7;
  left: 61%;
  top: 49.5%;
  width: min(43vw, 670px);
  height: min(82vh, 900px);
  transform: translate(-48%, -49%) translate3d(var(--char-x), var(--char-y), 0);
  opacity: 0;
  transition: opacity .8s .98s ease, filter .7s var(--ease-out), transform .9s var(--ease-out);
  pointer-events: none;
}
body.is-ready .character-scene { opacity: 1; }
.character-base,
.character-slice {
  position: absolute;
  inset: 0;
  transform-origin: 52% 60%;
  will-change: transform, filter;
}
.character-base img,
.character-slice img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
}
.character-base {
  z-index: 3;
  filter: saturate(.83) contrast(1.055) brightness(.96);
  transform: translate3d(calc(var(--nx) * 7px), calc(var(--ny) * 5px), 0) rotate(calc(var(--nx) * .18deg));
}
.character-slice {
  z-index: 4;
  opacity: .72;
  mix-blend-mode: screen;
  filter: saturate(.52) contrast(1.12) brightness(.92);
}
.character-slice--top {
  clip-path: polygon(0 0,100% 0,100% 28%,0 36%);
  transform: translate3d(calc(var(--nx) * -10px), calc(var(--ny) * -3px),0);
}
.character-slice--mid {
  clip-path: polygon(0 31%,100% 25%,100% 60%,0 62%);
  transform: translate3d(calc(var(--nx) * 12px), calc(var(--ny) * 3px),0);
}
.character-slice--low {
  clip-path: polygon(0 60%,100% 58%,100% 100%,0 100%);
  transform: translate3d(calc(var(--nx) * -6px), calc(var(--ny) * 5px),0);
}
.character-shadow {
  position: absolute;
  z-index: 0;
  left: 15%; right: 4%; bottom: 5%; height: 10%;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(0,0,0,.75), transparent 68%);
  filter: blur(17px);
  transform: translate3d(calc(var(--nx) * -4px), 0, 0);
}
.character-line {
  position: absolute;
  z-index: 5;
  left: 50%; top: 12%; bottom: 9%; width: 1px;
  background: linear-gradient(transparent, rgba(var(--accent-rgb),.8), transparent);
  opacity: .32;
  transform: translateX(calc(var(--nx) * 16px));
}
.orbit {
  position: absolute;
  z-index: 1;
  left: 50%; top: 53%;
  border: 1px solid rgba(244,241,233,.08);
  border-radius: 50%;
  transform: translate(-50%,-50%) rotate(0deg);
}
.orbit::after {
  content: "";
  position: absolute;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 18px rgba(var(--accent-rgb),.9);
}
.orbit--one { width: 82%; aspect-ratio: 1; animation: orbit1 14s linear infinite; }
.orbit--one::after { top: 15%; left: 10%; }
.orbit--two { width: 56%; aspect-ratio: 1; animation: orbit2 10s linear infinite reverse; opacity: .54; }
.orbit--two::after { bottom: 7%; right: 17%; }
@keyframes orbit1 { to { transform: translate(-50%,-50%) rotate(360deg); } }
@keyframes orbit2 { to { transform: translate(-50%,-50%) rotate(360deg); } }

.statement {
  position: absolute;
  z-index: 11;
  left: var(--pad-x);
  top: 31%;
  width: min(27vw, 360px);
  opacity: 0;
  transform: translateY(18px);
  transition: opacity .75s 1.35s ease, transform .9s 1.27s var(--ease-out);
}
body.is-ready .statement { opacity: 1; transform: none; }
.statement__eyebrow {
  display: block;
  margin-bottom: 12px;
  color: var(--fg-soft);
  font-size: 8px;
  letter-spacing: .19em;
}
.statement p {
  margin: 0;
  font-size: clamp(19px, 1.55vw, 26px);
  font-weight: 560;
  line-height: 1.2;
  letter-spacing: -.045em;
}

.portals {
  position: absolute;
  z-index: 20;
  left: var(--pad-x);
  bottom: clamp(66px, 8vh, 94px);
  width: min(38vw, 520px);
  display: grid;
  gap: 2px;
  opacity: 0;
  transform: translateY(22px);
  transition: opacity .8s 1.5s ease, transform 1s 1.38s var(--ease-out);
}
body.is-ready .portals { opacity: 1; transform: none; }
.portal {
  --mag-x: 0px;
  --mag-y: 0px;
  position: relative;
  display: grid;
  grid-template-columns: 46px 1fr auto;
  align-items: center;
  min-height: 78px;
  gap: 15px;
  padding: 9px 14px 9px 0;
  border-top: 1px solid var(--fg-hair);
  text-decoration: none;
  outline: none;
  transform: translate3d(var(--mag-x), var(--mag-y), 0);
  transition: color .35s ease, opacity .45s ease, transform .2s linear;
}
.portal:last-child { border-bottom: 1px solid var(--fg-hair); }
.portal::before {
  content: "";
  position: absolute;
  inset: 0 -18px;
  z-index: -1;
  background: rgba(var(--accent-rgb), .96);
  transform: scaleY(0);
  transform-origin: bottom;
  transition: transform .55s var(--ease-out);
}
.portal__no {
  color: var(--fg-soft);
  font-size: 9px;
  letter-spacing: .14em;
  transition: color .3s ease, transform .5s var(--ease-out);
}
.portal__content { display: grid; gap: 4px; }
.portal__eyebrow {
  color: var(--fg-soft);
  font-size: 7px;
  letter-spacing: .19em;
  transition: color .3s ease, transform .55s var(--ease-out);
}
.portal__title {
  font-size: clamp(25px, 2.6vw, 43px);
  line-height: .95;
  font-weight: 680;
  letter-spacing: -.06em;
}
.portal__arrow {
  font-size: 22px;
  color: var(--fg-soft);
  transition: color .3s ease, transform .55s var(--ease-out);
}
.portal__track {
  position: absolute;
  left: 0; right: 0; bottom: -1px; height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .7s var(--ease-out);
}
.portal:is(:hover,:focus-visible)::before { transform: scaleY(1); }
.portal:is(:hover,:focus-visible) .portal__no,
.portal:is(:hover,:focus-visible) .portal__eyebrow,
.portal:is(:hover,:focus-visible) .portal__arrow { color: #fff; }
.portal:is(:hover,:focus-visible) .portal__no { transform: translateX(7px); }
.portal:is(:hover,:focus-visible) .portal__eyebrow { transform: translateX(5px); }
.portal:is(:hover,:focus-visible) .portal__arrow { transform: translate(5px,-5px) rotate(3deg); }
.portal:is(:hover,:focus-visible) .portal__track { transform: scaleX(1); }

.vertical-note {
  position: absolute;
  z-index: 10;
  right: calc(var(--pad-x) - 5px);
  top: 50%;
  color: rgba(244,241,233,.24);
  font-size: 7px;
  letter-spacing: .2em;
  writing-mode: vertical-rl;
  transform: translateY(-50%);
}
.footer {
  position: absolute;
  z-index: 30;
  left: var(--pad-x); right: var(--pad-x); bottom: var(--pad-y);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  color: rgba(244,241,233,.32);
  font-size: 7px;
  letter-spacing: .18em;
  opacity: 0;
  transition: opacity .6s 1.8s ease;
}
body.is-ready .footer { opacity: 1; }
.footer > :last-child { justify-self: end; }
.footer__pulse { display: inline-flex; align-items: center; gap: 7px; }
.footer__pulse i {
  display: block;
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(var(--accent-rgb),.8);
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .25; transform: scale(.7); } }

.cursor {
  position: fixed;
  z-index: 999;
  left: 0; top: 0;
  width: 76px; height: 76px;
  margin: -38px 0 0 -38px;
  pointer-events: none;
  mix-blend-mode: difference;
  opacity: 0;
  transition: opacity .2s ease;
}
body.has-pointer .cursor { opacity: 1; }
.cursor__ring {
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(255,255,255,.72);
  border-radius: 50%;
  transform: scale(.5);
  transition: transform .45s var(--ease-out), background .25s ease, border-color .25s ease;
}
.cursor__dot {
  position: absolute;
  left: 50%; top: 50%;
  width: 5px; height: 5px;
  margin: -2.5px;
  border-radius: 50%;
  background: #fff;
}
.cursor__label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 7px;
  letter-spacing: .16em;
  opacity: 0;
  transform: scale(.7);
  transition: opacity .25s ease, transform .45s var(--ease-out);
}
body.cursor-over-link .cursor__ring { transform: scale(1); background: #fff; border-color: #fff; }
body.cursor-over-link .cursor__dot { opacity: 0; }
body.cursor-over-link .cursor__label { color: #000; opacity: 1; transform: scale(1); }

/* Whole-stage mode shifts */
body[data-mode="read"] .word-slice--a { transform: translate3d(-20px,-7px,0) scaleX(1.025); }
body[data-mode="read"] .word-slice--b { transform: translate3d(12px,3px,0) scaleX(.99); }
body[data-mode="read"] .character-slice--top { transform: translate3d(-18px,-4px,0); }
body[data-mode="read"] .character-slice--mid { transform: translate3d(19px,2px,0); }
body[data-mode="read"] .edge-light { left: 63%; opacity: .82; }
body[data-mode="read"] .portal[data-mode="memo"] { opacity: .28; }

body[data-mode="memo"] .word-slice--a { transform: translate3d(12px,4px,0) scaleX(.995); }
body[data-mode="memo"] .word-slice--b { transform: translate3d(-16px,-2px,0) scaleX(1.015); }
body[data-mode="memo"] .character-base { filter: saturate(.58) contrast(1.1) brightness(.87); }
body[data-mode="memo"] .character-slice--top { transform: translate3d(16px,-2px,0); opacity: .9; }
body[data-mode="memo"] .character-slice--mid { transform: translate3d(-20px,5px,0); opacity: .88; }
body[data-mode="memo"] .character-slice--low { transform: translate3d(9px,-3px,0); opacity: .8; }
body[data-mode="memo"] .edge-light { left: 55%; opacity: .72; }
body[data-mode="memo"] .portal[data-mode="read"] { opacity: .28; }

body.is-leaving .gateway { transform: scale(1.025); filter: brightness(.55); transition: transform .75s var(--ease-out), filter .6s ease; }
body.is-leaving .word-system { transform: translateX(-4vw); opacity: 0; transition: transform .65s var(--ease-snap), opacity .45s ease; }
body.is-leaving .character-scene { transform: translate(-42%,-49%) scale(1.09); opacity: 0; transition: transform .7s var(--ease-snap), opacity .5s ease; }

@media (max-width: 980px) {
  .masthead { grid-template-columns: 1fr 1fr; }
  .masthead__meta { display: none; }
  .mode-readout { min-width: 0; }
  .axis--v { left: 66%; }
  .coordinate--b { left: calc(66% + 9px); }
  .character-scene { left: 66%; width: min(50vw, 610px); }
  .statement { top: 28%; width: 33vw; }
  .portals { width: 42vw; }
}

@media (max-width: 700px) {
  body { cursor: auto; }
  :root { --pad-x: 19px; --pad-y: 18px; }
  .gateway { min-height: 620px; }
  .masthead { grid-template-columns: 1fr auto; }
  .mode-readout__name { display: none; }
  .word-system { top: 13%; left: 6px; width: 100%; }
  .word-slice, .word-outline { font-size: 31vw; }
  .axis--h { top: 41%; }
  .axis--v { left: 74%; }
  .coordinate--a { top: calc(41% + 8px); }
  .coordinate--b, .vertical-note { display: none; }
  .character-scene {
    left: 67%; top: 43%;
    width: 81vw; height: 55vh;
    transform: translate(-49%,-48%);
  }
  .orbit--one { width: 92%; }
  .statement {
    left: var(--pad-x); top: 24%;
    width: 46vw;
  }
  .statement__eyebrow { display: none; }
  .statement p { font-size: 15px; }
  .portals {
    left: var(--pad-x); right: var(--pad-x); bottom: 57px;
    width: auto;
    background: linear-gradient(180deg, rgba(8,9,11,0), rgba(8,9,11,.8) 14%, rgba(8,9,11,.94));
  }
  .portal {
    grid-template-columns: 32px 1fr auto;
    min-height: 66px;
  }
  .portal__title { font-size: clamp(24px, 7.4vw, 32px); }
  .portal::before { inset-left: -8px; inset-right: -8px; }
  .footer { grid-template-columns: 1fr auto; }
  .footer__pulse { display: none; }
  .cursor { display: none; }
  .grain { opacity: .04; }
}

@media (max-height: 680px) and (min-width: 701px) {
  .statement { top: 25%; }
  .character-scene { height: 72vh; top: 46%; }
  .portals { bottom: 44px; }
  .footer { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  body { cursor: auto; }
  .boot { display: none; }
  .cursor { display: none; }
  .masthead, .word-system, .character-scene, .statement, .portals, .footer, .coordinate { opacity: 1 !important; transform: none !important; }
  .axis { transform: scale(1) !important; }
}
