:root {
  --bg: #000;
  --fg: #f2f1ec;
  --muted: #9a9a96;
  --dim: #6e6e6a;
  --line: rgba(255, 255, 255, 0.16);
  --stage: #121212;
  --cyan: #6fd4e4;
  --cyan-deep: #3aa8bc;
  --cyan-soft: #c5eef5;
  --gold: #e6c36a;
  --sans: "Instrument Sans", "Avenir Next", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --ease: cubic-bezier(0.65, 0.05, 0.36, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  overflow: hidden;
}

body { color-scheme: dark; }

.frame {
  position: fixed;
  inset: 12px;
  border: 1px solid var(--line);
  pointer-events: none;
  z-index: 8;
}

.logo-float {
  position: fixed;
  z-index: 16;
  left: 0;
  top: 0;
  width: 240px;
  height: 240px;
  opacity: 0;
  transform-origin: center center;
  transform: translate(calc(50vw - 50%), calc(36vh - 50%)) scale(2.05);
  transition: transform 0.85s var(--ease);
  pointer-events: auto;
}

.logo-float.is-in { animation: logo-in 3s ease forwards; }

.logo-float.is-docked {
  transform: translate(calc(101px - 50%), calc(87px - 50%)) scale(0.575);
}

.menu {
  position: fixed;
  top: max(22px, env(safe-area-inset-top));
  right: max(18px, env(safe-area-inset-right));
  z-index: 30;
}

.nav-toggle {
  pointer-events: auto;
  width: 42px;
  height: 42px;
  margin-right: -6px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 5px;
  transform: scale(1.1);
  transform-origin: right center;
}

.nav-toggle span {
  display: block;
  width: 18px;
  height: 1px;
  background: var(--fg);
  transition: transform 0.35s var(--ease), opacity 0.25s ease;
}

.nav-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(6px) rotate(40deg);
}
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-6px) rotate(-40deg);
}

.nav-pop {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 148px;
  margin: 0;
  padding: 6px 0;
  background: #0a0a0a;
  border: 1px solid var(--line);
}

.nav-pop[hidden] { display: none; }

.nav-item {
  display: block;
  width: 100%;
  margin: 0;
  padding: 9px 16px;
  border: 0;
  background: transparent;
  color: var(--fg);
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-align: left;
  text-transform: uppercase;
  cursor: pointer;
}

.deck {
  height: 100dvh;
  overflow: hidden;
}

.panel {
  position: relative;
  height: 100dvh;
  overflow: hidden;
}

.panel-landing {
  display: grid;
  place-items: center;
}

.panel-scroll {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  touch-action: pan-y;
}

.panel-scroll::before,
.panel-scroll::after {
  content: "";
  flex: 1 0 auto;
  min-height: 160px;
}

.panel-scroll > .sheet,
.panel-scroll > .split {
  flex: 0 0 auto;
}

.sheet {
  max-width: 48rem;
  width: 100%;
  margin-right: auto;
  margin-left: auto;
  padding: 0 clamp(28px, 7vw, 88px);
}

.sheet-wide { max-width: 68rem; }

.sheet h1 {
  margin: 0 0 1.1rem;
  max-width: 18ch;
  font-size: clamp(2rem, 3.6vw, 3.15rem);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.08;
}

.sheet p {
  margin: 0 0 1rem;
  color: #c4c4be;
  font-size: 1.05rem;
  line-height: 1.6;
}

.lede {
  color: var(--fg);
  font-size: clamp(1.45rem, 2.5vw, 2rem);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.28;
}

.counts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  margin: 0.4rem 0 1.2rem;
  padding: 0.2rem 0 0.3rem;
}

.counts p { margin: 0; }

.count {
  display: block;
  color: var(--fg);
  font-family: var(--mono);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1;
}

.count sup {
  font-size: 0.55em;
  letter-spacing: 0;
}

.count-note {
  display: block;
  margin-top: 0.55rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--line);
  color: #b7b7b1;
  font-size: 0.92rem;
  line-height: 1.4;
}

.flow {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 18px;
  margin: 1.6rem 0 0;
  padding: 0;
}

.flow li {
  position: relative;
  margin: 0;
  padding: 16px 10px 0 0;
  border-top: 1px solid rgba(255, 255, 255, 0.42);
}

.flow li::before {
  content: "";
  position: absolute;
  top: -3.5px;
  left: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--fg);
}

.flow li.is-next { border-top-color: var(--cyan); }
.flow li.is-next::before { background: var(--cyan); }

.flow-name {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--fg);
  font-size: 1.12rem;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.flow-note {
  display: block;
  color: #b7b7b1;
  font-size: 0.86rem;
  line-height: 1.4;
}

.flow li.is-next .flow-name { color: var(--cyan); }

.landing-fade {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.landing-fade.is-in {
  animation: logo-in 3s ease forwards;
}

@keyframes logo-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.tagline {
  position: absolute;
  right: 8vw;
  left: 8vw;
  top: calc(36vh + 268px);
  z-index: 17;
  margin: 0;
  text-align: center;
  color: #c8c8c4;
  font-size: clamp(0.92rem, 1.6vw, 1.08rem);
  font-weight: 400;
  letter-spacing: 0.045em;
}

.arrow {
  position: fixed;
  left: 50%;
  z-index: 12;
  width: 44px;
  height: 44px;
  margin-left: -22px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--fg);
  cursor: pointer;
  opacity: 0.72;
}

.arrow svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1;
}

.arrow-down { bottom: max(18px, env(safe-area-inset-bottom)); animation: hint 2.8s ease-in-out infinite; }
.arrow-up { top: max(18px, env(safe-area-inset-top)); }

.arrow:hover { opacity: 1; }
.arrow[hidden] { display: none; }

@keyframes hint {
  0%, 100% { transform: translateY(0); opacity: 0.45; }
  50% { transform: translateY(5px); opacity: 0.9; }
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  grid-template-areas: "copy specimen";
  gap: clamp(28px, 4vw, 72px);
  align-items: center;
  height: auto;
  padding: 0 6.5vw;
  direction: ltr;
}

.copy { grid-area: copy; }
.specimen { grid-area: specimen; }

.copy h1 {
  margin: 0 0 1.15rem;
  max-width: 16ch;
  font-size: clamp(2rem, 3.5vw, 3.15rem);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.08;
}

.copy p {
  margin: 0 0 0.95rem;
  max-width: 38rem;
  color: #c4c4be;
  font-size: 1.02rem;
  line-height: 1.6;
}

.kicker {
  margin: 0 0 0.85rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dim);
}

.specimen { margin: 0; min-width: 0; }

.stage {
  position: relative;
  height: min(52vh, 520px);
  background: var(--stage);
  border: 1px solid var(--line);
}

#viewport {
  width: 100%;
  height: 100%;
  touch-action: none;
}

.stage { touch-action: none; }

button,
.arrow,
.nav-item {
  touch-action: manipulation;
}

.badge {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  margin: 0;
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
  pointer-events: none;
}

.legend {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 2;
  display: flex;
  gap: 10px;
  pointer-events: none;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
}

.swatch {
  width: 9px;
  height: 9px;
  display: inline-block;
  margin: 0;
  padding: 0;
  max-width: none;
  flex: 0 0 auto;
}

.swatch.helix { background: var(--cyan); height: 11px; }
.swatch.beta { background: var(--cyan-deep); }
.swatch.loop { background: var(--cyan-soft); height: 3px; }
.swatch.cys { background: var(--gold); border-radius: 50%; }

.status {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.9rem;
  z-index: 1;
  pointer-events: none;
}

.status.hidden { display: none; }

.specimen figcaption { padding-top: 16px; }

.specimen h2 {
  margin: 0 0 0.55rem;
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: -0.015em;
  line-height: 1.35;
}

.specimen h2 em { font-style: italic; font-weight: 400; }

.specimen figcaption p:last-child {
  margin: 0;
  color: #b7b7b1;
  font-size: 0.92rem;
  line-height: 1.55;
  max-width: 46rem;
}

button:focus-visible,
a:focus-visible {
  outline: 1px solid var(--fg);
  outline-offset: 4px;
}

@media (max-width: 800px) {
  .frame { inset: 8px; }
  .logo-float {
    transform: translate(calc(50vw - 50%), calc(30vh - 50%)) scale(1.15);
  }
  .logo-float.is-docked {
    transform: translate(calc(77px - 50%), calc(59px - 50%)) scale(0.414);
  }
  .logo-float.is-docked #chain {
    opacity: 1;
    transition: opacity 0.7s ease;
  }
  .logo-float.is-docked.is-covered {
    pointer-events: none;
  }
  .logo-float.is-docked.is-covered #chain {
    opacity: 0;
  }
  .tagline {
    top: auto;
    right: 28px;
    bottom: max(76px, calc(env(safe-area-inset-bottom) + 64px));
    left: 28px;
    font-size: 0.92rem;
  }
  .menu { right: max(12px, env(safe-area-inset-right)); }
  .panel-scroll,
  .panel-thesis {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
  }
  .panel-scroll::before,
  .panel-scroll::after {
    min-height: 108px;
  }
  .panel-scroll::after {
    min-height: max(72px, calc(env(safe-area-inset-bottom) + 56px));
  }
  .split {
    grid-template-columns: 1fr;
    grid-template-areas:
      "copy"
      "specimen";
    align-content: start;
    height: auto;
    min-height: 0;
    gap: 22px;
    padding: 0 22px;
  }
  .copy h1 {
    max-width: 16ch;
    font-size: 1.85rem;
  }
  .copy p { font-size: 0.98rem; }
  .sheet { padding: 0 22px; }
  .sheet h1 { font-size: 1.85rem; }
  .lede { font-size: 1.28rem; }
  .counts { grid-template-columns: 1fr; gap: 18px; }
  .flow {
    grid-template-columns: 1fr;
    gap: 0;
    margin-top: 1.2rem;
  }
  .flow li {
    padding: 0 0 16px 16px;
    border-top: 0;
    border-left: 1px solid rgba(255, 255, 255, 0.42);
  }
  .flow li.is-next { border-left-color: var(--cyan); }
  .flow li::before { top: 4px; left: -3.5px; }
  .stage { height: min(52vh, 420px); min-height: 240px; }
  .legend { flex-wrap: wrap; max-width: 70%; }
  .nav-toggle { width: 44px; height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .logo-float { transition: none; }
  .logo-float.is-in,
  .landing-fade.is-in { animation: none; opacity: 1; }
  .arrow-down { animation: none; }
}
