/* ==========================================================================
   02 Descent (scale dive) · 03 Electroadsorption lab · 04 Mission log
   ========================================================================== */

/* ---------- 02 · Descent ---------- */

.dive {
  position: relative;
  height: calc(var(--stages, 6) * 85svh + 100svh);
  background: var(--paper);
}

.dive__sticky {
  position: sticky;
  top: 0;
  height: 100svh;
  overflow: hidden;
  isolation: isolate;
}

.dive__shade {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--orbit);
  opacity: var(--shade, 0);
}

.dive__inner {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  align-items: center;
  gap: var(--s-7);
  padding-top: 72px;
  color: var(--ink);
  transition: color 500ms var(--ease-out);
}
.dive.is-dark .dive__inner {
  color: var(--on-orbit);
}

.dive__copy {
  display: grid;
  gap: var(--s-5);
  align-content: center;
}
.dive__copy > .label {
  opacity: 0.7;
}

.dive__readout {
  display: flex;
  align-items: baseline;
  gap: var(--s-4);
  flex-wrap: wrap;
}
.dive__size {
  font-size: clamp(3.4rem, 1.6rem + 6vw, 7.4rem);
  font-weight: 800;
  font-stretch: 125%;
  line-height: 0.9;
  letter-spacing: -0.03em;
  min-width: 5.2ch;
}
.dive__exp {
  color: var(--accent);
}

.dive__texts {
  position: relative;
  list-style: none;
  min-height: 9.5rem;
}
.dive__text {
  position: absolute;
  inset: 0 0 auto;
  opacity: 0;
  transform: translateY(14px);
  transition:
    opacity 500ms var(--ease-out),
    transform 600ms var(--ease-out);
}
.dive__text.is-active {
  opacity: 1;
  transform: none;
}
.dive__text h2 {
  margin-bottom: var(--s-3);
}
.dive__text p {
  max-width: 38ch;
  opacity: 0.8;
}
.dive__text a {
  margin-top: var(--s-3);
}

.dive__scale {
  position: relative;
  height: 28px;
  max-width: 420px;
  border-bottom: 1px solid currentColor;
  opacity: 0.85;
}
.dive__scale span {
  position: absolute;
  bottom: 0;
  inset-inline-start: calc(var(--x) * 100%);
  width: 1px;
  height: 10px;
  background: currentColor;
}
.dive__scale span::after {
  content: attr(data-t);
  position: absolute;
  bottom: 14px;
  left: 50%;
  translate: -50% 0;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.04em;
  white-space: nowrap;
  opacity: 0.7;
}
.dive__scale i {
  position: absolute;
  bottom: -5px;
  inset-inline-start: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  transform: translateX(calc((var(--dp, 0) * 420px - 5px) * var(--flip)));
}
@media (max-width: 520px) {
  .dive__scale i {
    transform: translateX(calc((var(--dp, 0) * (100vw - 2 * var(--gutter)) - 5px) * var(--flip)));
  }
}

.dive__lens {
  position: relative;
  justify-self: center;
  width: min(74svh, 100%);
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  background: var(--sand);
  box-shadow:
    0 0 0 1px color-mix(in oklch, var(--ink) 18%, transparent),
    0 40px 80px -50px color-mix(in oklch, var(--ink) 80%, transparent);
  isolation: isolate;
}
.dive__scene {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  opacity: 0;
  will-change: transform, opacity;
}
.dive__scene svg,
.dive__scene img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.dive__scene {
  border-radius: 50%;
  overflow: hidden;
}

/* Scene drawing roles (shared by the lens plates and the cartridge diagram) */
.sc-light { fill: var(--sand); }
.sc-mist { fill: var(--mist); }
.sc-dark { fill: var(--orbit); }
.sc-water { fill: color-mix(in oklch, var(--quell) 32%, transparent); }
.sc-ink { fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.sc-focus { fill: var(--signal); }
.sc-focus-aqua { fill: var(--quell); }
.sc-specks circle { fill: var(--quell-deep); }
.sc-faint { fill: none; stroke: var(--on-orbit-2); opacity: 0.3; stroke-linecap: round; }
.sc-rust { fill: oklch(0.5 0.08 48); stroke: oklch(0.68 0.08 55); stroke-width: 1.5; stroke-linejoin: round; }
.sc-grit { fill: oklch(0.66 0.04 80); stroke: oklch(0.82 0.03 80); stroke-width: 1.2; stroke-linejoin: round; }
.sc-aqua { fill: color-mix(in oklch, var(--quell) 16%, transparent); stroke: var(--quell); stroke-width: 2; }
.sc-virus { fill: color-mix(in oklch, var(--quell) 18%, transparent); stroke: var(--quell); stroke-width: 2.2; stroke-linecap: round; }
.sc-virus .knob { stroke-width: 8; }
.sc-fibre { fill: none; stroke: var(--signal); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.sc-plus { fill: none; stroke: var(--signal); stroke-width: 2; stroke-linecap: round; }
.sc-shell { fill: var(--orbit-2); stroke: var(--on-orbit-2); stroke-width: 1.5; }
.sc-cut { fill: var(--orbit); stroke: var(--orbit-line); }
.sc-carbon { fill: none; stroke: var(--on-orbit-2); stroke-width: 4; stroke-dasharray: 0 7; stroke-linecap: round; }
.sc-silver { fill: none; stroke: oklch(0.88 0.01 250); stroke-width: 1.4; }
.sc-core { fill: none; stroke: var(--quell); stroke-width: 3; stroke-dasharray: 10 8; stroke-linecap: round; }
.sc-core-arrow { fill: none; stroke: var(--quell); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.sc-leader path { fill: none; stroke: var(--on-orbit-2); stroke-width: 1; opacity: 0.6; }
.sc-text { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em; fill: var(--on-orbit); }
.sc-text--signal { fill: var(--signal); }
.sc-text--aqua { fill: var(--quell); }

.lab__side {
  display: grid;
  gap: var(--s-5);
}

.dive__rim {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px color-mix(in oklch, white 20%, transparent);
}

@media (max-width: 900px) {
  .dive__inner {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    align-content: center;
    gap: var(--s-5);
    padding-top: 84px;
    padding-bottom: var(--s-5);
  }
  .dive__lens {
    order: -1;
    width: min(44svh, 88vw);
  }
  .dive__copy {
    gap: var(--s-3);
  }
  .dive__texts {
    min-height: 8rem;
  }
  .dive__size {
    font-size: clamp(2.6rem, 1.6rem + 6vw, 4rem);
  }
}

/* ---------- 03 · Electroadsorption lab (dark) ---------- */

.lab {
  background: var(--orbit);
  color: var(--on-orbit);
  line-height: 1.7;
}
.lab .body,
.lab .lead {
  color: var(--on-orbit-2);
}
.lab .label {
  color: var(--on-orbit-2);
}

.lab__grid {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: var(--s-8) var(--s-8);
  align-items: start;
}

.lab__intro {
  position: sticky;
  top: 110px;
  display: grid;
  gap: var(--s-5);
}
.lab__intro .h2 .accent {
  display: block;
}

.lab__sim {
  display: grid;
  gap: var(--s-4);
}
.lab__frame {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--orbit-2);
  box-shadow: 0 0 0 1px var(--orbit-line);
  touch-action: pan-y;
}
.lab__frame canvas {
  width: 100%;
  aspect-ratio: 4 / 3.2;
  cursor: crosshair;
}
.lab__tag {
  position: absolute;
  left: var(--s-4);
  font-family: var(--font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--on-orbit-2);
  pointer-events: none;
}
.lab__tag--in {
  top: var(--s-4);
}
.lab__tag--out {
  bottom: var(--s-4);
  color: var(--quell);
}
/* Sits just above the fibre band (band starts at 42% of the canvas height) */
.lab__tag--band {
  right: var(--s-4);
  left: auto;
  top: calc(42% - 46px);
  color: var(--signal);
}

.lab__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
  min-height: 44px;
  color: var(--on-orbit);
}
.switch__track {
  position: relative;
  width: 52px;
  height: 30px;
  border-radius: 999px;
  background: var(--orbit-line);
  transition: background-color 250ms var(--ease-out);
}
.switch__thumb {
  position: absolute;
  top: 3px;
  inset-inline-start: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--on-orbit);
  display: grid;
  place-items: center;
  font: 700 14px/1 var(--font-mono);
  color: var(--ink);
  transition: transform 300ms var(--ease-out);
}
.switch[aria-checked="true"] .switch__track {
  background: var(--signal);
}
.switch[aria-checked="true"] .switch__thumb {
  transform: translateX(calc(22px * var(--flip)));
}

.lab__meter {
  display: flex;
  gap: var(--s-6);
}
.lab__meter div {
  display: grid;
}
.lab__big {
  font-size: 1.6rem;
  font-weight: 750;
  font-stretch: 115%;
  line-height: 1.1;
}
.lab__big--rate {
  color: var(--signal);
}

.lab__caption {
  font-size: var(--text-sm);
  color: var(--on-orbit-2);
}

.ledger {
  display: grid;
  border-top: 1px solid var(--line);
}
.ledger > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--s-4);
  align-items: baseline;
  padding-block: var(--s-3);
  border-bottom: 1px solid var(--line);
}
.ledger dd {
  font-weight: 700;
  font-stretch: 112%;
  text-align: end;
}
.ledger--dark {
  border-color: var(--orbit-line);
}
.ledger--dark > div {
  border-color: var(--orbit-line);
}
.ledger sup a {
  color: var(--quell);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.7em;
  padding-inline: 2px;
}

.lab__facts {
  grid-column: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--s-6);
  align-items: start;
}
.lab__limits {
  display: grid;
  gap: var(--s-3);
  padding: var(--s-5);
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px var(--orbit-line);
  font-size: var(--text-sm);
  color: var(--on-orbit-2);
}
.lab__limits strong {
  color: var(--on-orbit);
  font-stretch: 110%;
}
.lab__limits a {
  color: var(--quell);
}
.lab__source {
  font-size: var(--text-xs);
  color: var(--on-orbit-2);
}
.lab__source a {
  color: var(--on-orbit);
}

.lab__cartridge {
  position: relative;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}
.lab__cartridge svg {
  width: 82%;
}
.lab__cartridge img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

@media (max-width: 960px) {
  .lab__grid {
    grid-template-columns: 1fr;
    gap: var(--s-7);
  }
  .lab__intro {
    position: static;
  }
  .lab__facts {
    grid-column: 1;
    grid-template-columns: 1fr;
  }
  .lab__frame canvas {
    aspect-ratio: 1 / 1.05;
  }
}

/* ---------- 04 · Mission log (dark) ---------- */

.log {
  background: var(--orbit-2);
  color: var(--on-orbit);
  overflow: clip;
}
.log .label {
  color: var(--on-orbit-2);
}

.log__head {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: var(--s-5) var(--s-7);
  align-items: end;
}
.log__head .label {
  grid-column: 1 / -1;
}
.log__head p.body {
  color: var(--on-orbit-2);
}

.log__track {
  position: relative;
  margin-top: var(--s-9);
}
.log__arc {
  position: absolute;
  inset: 0 0 auto;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
.log__arc path {
  fill: none;
  stroke: var(--quell);
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
  stroke-dasharray: 1;
  stroke-dashoffset: calc(1 - var(--draw, 0));
}
.log__arc .ghost {
  stroke: var(--orbit-line);
  stroke-dasharray: 0.004 0.006;
  stroke-dashoffset: 0;
}

.log__list {
  position: relative;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--s-5);
  align-items: end;
  min-height: 520px;
}
.log__entry {
  display: grid;
  gap: var(--s-3);
  padding-top: var(--s-4);
  border-top: 1px solid var(--orbit-line);
  align-self: end;
  margin-bottom: var(--lift, 0);
}
.log__entry:nth-child(1) {
  --lift: 0px;
}
.log__entry:nth-child(2) {
  --lift: 70px;
}
.log__entry:nth-child(3) {
  --lift: 160px;
}
.log__entry:nth-child(4) {
  --lift: 260px;
}
.log__entry:nth-child(5) {
  --lift: 350px;
}
.log__year {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  font-size: var(--text-xl);
  font-weight: 800;
  font-stretch: 125%;
  line-height: 1;
}
.log__year::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--quell);
  box-shadow: 0 0 0 5px color-mix(in oklch, var(--quell) 20%, transparent);
}
.log__entry--now .log__year {
  color: var(--on-orbit);
}
.log__entry--now .log__year::before {
  background: var(--on-orbit);
  box-shadow: 0 0 0 5px color-mix(in oklch, var(--quell) 45%, transparent);
}
.log__entry p {
  font-size: var(--text-sm);
  color: var(--on-orbit-2);
  line-height: 1.55;
}
.log__entry p strong {
  color: var(--on-orbit);
  font-weight: 650;
}

.log__water {
  position: absolute;
  inset-inline-start: 2%;
  top: -30px;
  width: clamp(140px, 18vw, 260px);
  aspect-ratio: 1;
  pointer-events: none;
}
.log__water img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.log__water .sphere {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 30%, oklch(0.98 0.02 200 / 0.9) 0 7%, transparent 12%),
    radial-gradient(circle at 60% 66%, oklch(0.8 0.1 195 / 0.5) 0 22%, transparent 55%),
    radial-gradient(circle at 50% 50%, oklch(0.55 0.1 220 / 0.25) 0 60%, oklch(0.74 0.1 192 / 0.6) 100%);
  box-shadow:
    0 0 60px -10px oklch(0.74 0.1 192 / 0.45),
    inset -10px -16px 30px oklch(0.2 0.05 250 / 0.5);
  animation: wobble 9s var(--ease-in-out) infinite;
}
@keyframes wobble {
  33% {
    border-radius: 48% 52% 50% 50% / 52% 47% 53% 48%;
    transform: translateY(-6px);
  }
  66% {
    border-radius: 52% 48% 47% 53% / 48% 53% 47% 52%;
    transform: translateY(4px);
  }
}

.log__disclaimer {
  margin-top: var(--s-8);
  max-width: 80ch;
  text-transform: none;
  letter-spacing: 0.02em;
  line-height: 1.7;
}

@media (max-width: 960px) {
  .log__head {
    grid-template-columns: 1fr;
  }
  .log__arc {
    display: none;
  }
  .log__list {
    grid-template-columns: 1fr;
    min-height: 0;
    gap: 0;
    padding-inline-start: var(--s-5);
    border-inline-start: 1px solid var(--orbit-line);
  }
  .log__entry {
    --lift: 0 !important;
    margin: 0;
    padding-block: var(--s-5);
    border-top: 0;
  }
  .log__year::before {
    margin-inline-start: calc(-1 * var(--s-5) - 5px);
  }
  .log__water {
    display: none;
  }
}

.log__water img {
  animation: sphere-drift 10s var(--ease-in-out) infinite;
}
@keyframes sphere-drift {
  50% {
    transform: translateY(-10px) rotate(4deg);
  }
}
