/*
 * Scroll-driven platform section.
 * .platform is ~4 viewports tall; .platform__stage sticks while it scrolls.
 * Left column has three zones: finished steps (top), the active panel
 * (centered), upcoming steps (bottom). platform.js toggles .is-shown /
 * .is-active and writes --beam / --beam-y and the layer transforms.
 */
.platform { --beam: var(--step-1); height: 420vh; position: relative; }
.platform__stage {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
}

.platform__copy {
  position: relative;
  display: grid;
  grid-template-rows: 184px 1fr auto;
  padding: var(--section-y) var(--pad) 40px;
  border-right: 1px solid var(--line);
}
.rail { position: absolute; left: -1px; top: 0; bottom: 0; width: 1px; background: var(--line); }
/*
 * Beam: platform.js drives its height (eased toward a scroll-linked tip) and
 * its color (blended between step colors). The mask fades the top so the
 * line grows out of the dark.
 */
.rail__beam {
  position: absolute;
  inset: 0 0 auto;
  height: 0;
  background: var(--step-1);
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 160px);
  mask-image: linear-gradient(to bottom, transparent, #000 160px);
}

/* active tick draws in as the beam arrives */
.panel.is-active .step-item__marker { animation: marker-in 0.45s 0.55s cubic-bezier(.2, .7, .2, 1) both; }
@keyframes marker-in { from { width: 0; } }

/* step labels: rail tick, number, name */
.step-item {
  position: relative;
  display: flex;
  gap: 12px;
  font: 400 16px/16px var(--sans);
  letter-spacing: -0.01em;
  color: var(--muted);
}
.step-item__num { color: #514e4b; }
.step-item__marker {
  position: absolute;
  left: calc(-1 * var(--pad) - 5px);
  top: 7px;
  width: 0;
  height: 1px;
  background: var(--step-color);
  transition: width 0.4s cubic-bezier(.2, .7, .2, 1);
}
.step-item.is-active { color: #d4cfc6; }
.step-item.is-active .step-item__num { color: var(--muted); }
.step-item.is-active .step-item__marker { width: 12px; }

/* prev / next lists: items collapse when not shown */
.step-nav > li {
  height: 0;
  opacity: 0;
  overflow: visible;
  pointer-events: none;
  transition: height 0.45s cubic-bezier(.2, .7, .2, 1), opacity 0.3s, padding 0.45s;
}
.step-nav > li.is-shown { height: 30px; opacity: 1; pointer-events: auto; }
.step-nav--prev > li.is-shown { padding-bottom: 16px; }
.step-nav--next > li.is-shown { padding-top: 16px; }
.step-nav--next { align-self: end; }

/* panels stack in one grid cell and crossfade */
.panels { display: grid; align-items: center; }
.panel {
  grid-area: 1 / 1;
  display: grid;
  gap: 16px;
  opacity: 0;
  translate: 0 14px;
  pointer-events: none;
  transition: opacity 0.4s, translate 0.5s cubic-bezier(.2, .7, .2, 1);
}
.panel.is-active { opacity: 1; translate: 0 0; pointer-events: auto; transition-delay: 0.1s; }
.panel__head { display: grid; gap: 8px; }
.panel__title { font: 400 44px/1.05 var(--sans); letter-spacing: -0.045em; }
.panel__text { font: 400 19px/28px var(--sans); max-width: 480px; letter-spacing: -0.01em; color: var(--muted); }
/* key numbers under each step: hairline rows, label left, value right */
.panel__facts { display: grid; max-width: 420px; margin-top: 28px; border-top: 1px solid var(--line-soft); }
.panel__facts > div {
  display: flex; justify-content: space-between; gap: 16px; padding: 11px 0;
  border-bottom: 1px solid var(--line-soft); font: 400 15px/20px var(--sans);
}
.panel__facts dt { color: var(--faint); }
.panel__facts dd { margin: 0; color: var(--text); text-align: right; }
.panel__text a { text-decoration: underline; text-underline-offset: 4px; text-decoration-color: var(--muted); }

/* right column: dot grid + isometric stack */
.platform__visual {
  position: relative;
  background: radial-gradient(circle, #363533 1px, transparent 1px) 0 0 / 16px 16px;
}
.stack {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(400px, 78%);
  aspect-ratio: 360 / 240;
  translate: -50% -50%;
}
.layer { position: absolute; inset: 0; will-change: transform, opacity; }
/* the tax falling through the stack: a dotted line from the top slab to the
   active one (platform.js sets top/height/color), with dashes dropping along it */
.drop {
  position: absolute;
  left: 50%;
  width: 1px;
  translate: -50% 0;
  background: linear-gradient(currentColor 50%, transparent 0) 0 0 / 1px 6px;
}
.drop i {
  position: absolute;
  left: -1px;
  width: 3px;
  height: 16px;
  background: currentColor;
  animation: drop-fall 1.8s linear calc(var(--n, 0) * -0.6s) infinite;
}
@keyframes drop-fall {
  from { top: -16px; opacity: 0; }
  15%, 85% { opacity: 1; }
  to { top: 100%; opacity: 0; }
}
.layer svg { width: 100%; height: 100%; overflow: visible; }

.callout {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 8px;
  font: 400 14px/1.3 var(--sans);
  letter-spacing: -0.01em;
  white-space: nowrap;
  opacity: 0;
  translate: 0 6px;
  transition: opacity 0.35s, translate 0.35s;
}
.callout::before { content: ""; width: 6px; height: 6px; background: var(--step-color); }
.layer.is-active .callout { opacity: 1; translate: 0 0; }

/* slab drawing lives in layers.css */

@media (max-width: 860px) {
  .panel__facts { display: none; } /* no room above the stack; the text carries it */
  .platform__stage { grid-template-columns: 1fr; grid-template-rows: 330px 1fr; }
  .platform__copy { grid-template-rows: 1fr; padding: calc(var(--nav-h) + 28px) var(--pad) 0; border-right: 0; }
  .step-nav, .rail, .step-item__marker { display: none; }
  .panels { align-items: start; }
  .panel__title { font-size: 32px; }
  .panel__head { gap: 8px; }
  .panel__head .step-item { font-size: 14px; line-height: 14px; }
  .panel__text { font-size: 16px; line-height: 22px; }
  .platform__visual { background: none; }
  .stack { width: min(280px, 72%); }
  .callout { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .panel, .step-nav > li, .callout, .rail__beam { transition: none; }
  .drop i { display: none; }
  .panel.is-active .step-item__marker { animation: none; }
}
