/* =============================================================================
 * stage.css — THE PERFORMANCE LAYER.
 *
 * Michael, on the bar for this deck: "when we can showcase through interaction we do
 * so. we use parallax, we stop with the safe, stale, corporate crap."
 *
 * So the instrument does not sit on the page — it runs. Everything here is transform
 * and opacity only, rAF-driven, IntersectionObserver-gated, and no WebGL: an average
 * laptop composites all of it on the GPU without a paint. With motion off, every
 * effect below resolves to its finished state and the page is complete and legible.
 * ========================================================================== */

/* -----------------------------------------------------------------------------
 * 1. THE BOOT. One orchestrated arrival, not scattered entrances.
 *    The chrome draws itself, the rail cascades, the type rises, the deck deals.
 * -------------------------------------------------------------------------- */

.boot .topbar {
  transform: translateY(-100%);
  animation: boot-bar 0.62s cubic-bezier(0.16, 1, 0.3, 1) 0.05s forwards;
}
@keyframes boot-bar {
  to {
    transform: none;
  }
}

.boot .rail::before {
  transform-origin: top;
  transform: scaleY(0);
  animation: boot-filament 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.3s forwards;
}
@keyframes boot-filament {
  to {
    transform: scaleY(1);
  }
}

.boot .rail-tick {
  opacity: 0;
  animation: boot-tick 0.44s ease-out forwards;
  animation-delay: calc(0.5s + var(--i, 0) * 55ms);
}
@keyframes boot-tick {
  to {
    opacity: 1;
  }
}

/* the hero type rises line by line behind a mask */
.rise {
  display: block;
  overflow: hidden;
}
.rise > span {
  display: block;
  transform: translateY(105%);
}
.boot .rise > span {
  animation: rise-in 0.86s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  animation-delay: calc(0.22s + var(--i, 0) * 100ms);
}
@keyframes rise-in {
  to {
    transform: none;
  }
}

.fade-up {
  opacity: 0;
  transform: translateY(16px);
}
.boot .fade-up {
  animation: fade-up-in 0.7s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  animation-delay: calc(0.55s + var(--i, 0) * 90ms);
}
@keyframes fade-up-in {
  to {
    opacity: 1;
    transform: none;
  }
}

/* -----------------------------------------------------------------------------
 * 2. THE COCKPIT IN DEPTH.
 *    The deck is a real 3D stage. It tilts to the cursor, its cards sit on separate
 *    Z planes, and it rotates level as you scroll into the page — the product
 *    assembling itself in the air rather than being pasted onto the page as an image.
 * -------------------------------------------------------------------------- */

.cockpit {
  perspective: 1600px;
  perspective-origin: 62% 42%;
}

.cockpit-frame {
  transform-style: preserve-3d;
  transform: rotateX(var(--rx, 9deg)) rotateY(var(--ry, -13deg)) rotateZ(var(--rz, 0.6deg))
    translate3d(0, 0, 0);
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.cockpit-frame.live {
  transition: transform 0.16s ease-out;
}

.deck {
  transform-style: preserve-3d;
}

.deck > .card {
  transform: translate3d(0, 0, var(--z, 0px));
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.3s ease,
    border-color 0.3s ease;
}

.boot .deck > .card {
  opacity: 0;
  animation: deck-deal 0.9s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  animation-delay: calc(0.75s + var(--i, 0) * 110ms);
}
@keyframes deck-deal {
  from {
    opacity: 0;
    transform: translate3d(0, 42px, -220px) rotateX(14deg);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, var(--z, 0px));
  }
}

/* -----------------------------------------------------------------------------
 * 3. THE SPECULAR. Glass with a light source that follows the cursor.
 *    This is the one effect applied everywhere, and it is applied everywhere because
 *    it is what glass DOES — the whole page is one material catching one light.
 * -------------------------------------------------------------------------- */

.card::after,
.plate::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
  background: radial-gradient(
    340px circle at var(--mx, 50%) var(--my, 0%),
    rgb(255 255 255 / 0.1),
    transparent 62%
  );
}
.plate {
  position: relative;
}
[data-ground='paper'] .card::after,
[data-ground='paper'] .plate::after {
  background: radial-gradient(
    340px circle at var(--mx, 50%) var(--my, 0%),
    rgb(255 255 255 / 0.75),
    transparent 60%
  );
}

.card:hover::after,
.card:focus-within::after,
.plate:hover::after {
  opacity: 1;
}

.card:hover {
  border-color: rgb(255 255 255 / 0.24);
}

/* -----------------------------------------------------------------------------
 * 4. PARALLAX. The atmosphere runs at a different rate from the page.
 * -------------------------------------------------------------------------- */

/* the carriers take the scroll rate; see .sky-layer in site.css for why */

.par {
  will-change: transform;
}

/* -----------------------------------------------------------------------------
 * 5. THE SEAM — the interactive wire. One record, five modules, live.
 * -------------------------------------------------------------------------- */

.wire-stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
}

.wire-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  overflow: visible;
}

.wire-path {
  fill: none;
  stroke: var(--line-2);
  stroke-width: 1.5;
  transition: stroke 0.3s ease, stroke-width 0.3s ease;
}
.wire-path.hot {
  stroke: var(--bright);
  stroke-width: 2.5;
}

.wire-pulse {
  fill: none;
  stroke: var(--bright);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: 14 240;
  opacity: 0;
}
.wire-pulse.run {
  opacity: 1;
  animation: pulse-run 1.15s linear infinite;
}
@keyframes pulse-run {
  from {
    stroke-dashoffset: 254;
  }
  to {
    stroke-dashoffset: 0;
  }
}

.claim {
  position: relative;
  z-index: 2;
  cursor: pointer;
  border: 1px solid var(--floor-line);
  transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.24s ease,
    background 0.24s ease;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
}
.claim:hover,
.claim[aria-pressed='true'] {
  transform: translateX(10px);
  border-color: var(--bright);
}
.claim[aria-pressed='true'] .claim-line {
  color: var(--bright);
}

.seam-person {
  position: relative;
  z-index: 2;
}

.seam-record {
  position: relative;
  z-index: 2;
  padding: var(--space-5);
  border-radius: var(--radius-card);
  background: var(--floor);
  border: 1px solid var(--floor-line);
  border-top-color: var(--floor-line-top);
  display: grid;
  gap: var(--space-4);
}

.record-id {
  font-family: var(--mono);
  font-size: var(--t-micro);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--micro);
}

.record-readout {
  font-family: var(--mono);
  font-size: var(--t-small);
  line-height: 1.7;
  color: var(--ink);
  min-height: 5.1em;
}
.record-readout b {
  color: var(--bright);
  font-weight: 700;
}
.record-readout .k {
  color: var(--micro);
}

/* -----------------------------------------------------------------------------
 * 6. THE BENCH — cards deal out and in when the app changes.
 * -------------------------------------------------------------------------- */

.vignette > .card {
  animation: bench-deal 0.62s cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: calc(var(--i, 0) * 70ms);
}
@keyframes bench-deal {
  from {
    opacity: 0;
    transform: translateY(22px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.vignette.out > .card {
  animation: bench-clear 0.2s ease-in forwards;
  animation-delay: 0s;
}
@keyframes bench-clear {
  to {
    opacity: 0;
    transform: translateY(-10px);
  }
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--elev-3);
}
.deck > .card:hover {
  transform: translate3d(0, -6px, calc(var(--z, 0px) + 30px));
}

/* -----------------------------------------------------------------------------
 * 7. THE GROUND CROSSING. The chrome re-themes as the paper band passes under it.
 *    This is the named risk made visible: the site changes ground mid-scroll, and
 *    the top bar and the rail change with it, because they are the OS's chrome and
 *    an OS's chrome follows its ground.
 * -------------------------------------------------------------------------- */

.topbar,
.rail {
  transition: background-color 0.42s ease, border-color 0.42s ease, color 0.42s ease;
}

.ground-readout {
  position: fixed;
  right: clamp(12px, 2vw, 26px);
  bottom: clamp(12px, 2vw, 24px);
  z-index: 45;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  border-radius: var(--radius-pill);
  background: var(--chrome-glass);
  -webkit-backdrop-filter: var(--chrome-filter);
  backdrop-filter: var(--chrome-filter);
  border: 1px solid var(--chrome-glass-line);
  font-family: var(--mono);
  font-size: var(--t-micro);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--micro);
  pointer-events: none;
  transition: background-color 0.42s ease, border-color 0.42s ease, color 0.42s ease;
}
.ground-readout i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--bright);
  display: block;
  transition: background 0.42s ease;
}

/* the boundary itself, made loud */
.inverted::before {
  height: 2px;
  box-shadow: 0 0 26px 2px rgb(216 103 40 / 0.45);
}

/* -----------------------------------------------------------------------------
 * 8. THE RACK — the same proof, in the words somebody buying would use.
 * -------------------------------------------------------------------------- */

.rack-unit {
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-family: var(--mono);
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.22s ease,
    background 0.22s ease;
}
.rack-unit:hover {
  transform: translateX(8px);
}
/*
 * The wash goes on TOP of the floor rather than replacing it. Written as `background`
 * it dropped the floor entirely and left a 7% white veil over the open ground, which
 * measured 4.40:1 for the 11.5px cap beside it.
 */
.rack-unit[aria-pressed='true'] {
  border-left-color: var(--bright);
  background-image: linear-gradient(rgb(255 255 255 / 0.07), rgb(255 255 255 / 0.07));
}

.query {
  margin-top: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius);
  background: var(--sunken);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: var(--t-small);
  line-height: 1.8;
}
.query .q {
  color: var(--accent);
}
.query .r {
  color: var(--ink);
}
.query .none {
  color: var(--danger);
  font-weight: 700;
}
.query .cnt {
  color: var(--ok);
}
.caret::after {
  content: '';
  display: inline-block;
  width: 8px;
  height: 1.05em;
  margin-left: 3px;
  vertical-align: -0.18em;
  background: var(--bright);
  animation: blink 1s steps(1) infinite;
}
@keyframes blink {
  50% {
    opacity: 0;
  }
}

/* -----------------------------------------------------------------------------
 * 9. SCROLL-LINKED SECTION HEADS — a little depth, not a carnival.
 * -------------------------------------------------------------------------- */

.reveal-stagger > * {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.66s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.66s cubic-bezier(0.16, 1, 0.3, 1);
  transition-delay: calc(var(--i, 0) * 80ms);
}
.reveal-stagger.in > * {
  opacity: 1;
  transform: none;
}

/* the counting numbers land on a tabular figure so nothing jitters */
.figure-value {
  font-variant-numeric: tabular-nums;
}

/* -----------------------------------------------------------------------------
 * 11. MOTION OFF — every effect above resolves to its finished state.
 *     The page is complete and legible with nothing moving.
 * -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .boot .topbar,
  .boot .rail::before,
  .boot .rail-tick,
  .boot .rise > span,
  .boot .fade-up,
  .boot .deck > .card,
  .vignette > .card,
  .vignette.out > .card {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
  .cockpit-frame {
    transform: none !important;
    transition: none !important;
  }
  .deck > .card {
    transform: none !important;
  }
  .sky,
  .sky-layer,
  .sky-cool,
  .sky-warm,
  .sky-deep,
  .sky-streak {
    transform: none !important;
    transition: none !important;
  }
  .wire-pulse.run {
    animation: none;
    opacity: 0;
  }
  .caret::after {
    animation: none;
  }
  .reveal-stagger > * {
    opacity: 1;
    transform: none;
    transition: none;
  }
  .card:hover,
  .deck > .card:hover,
  .claim:hover,
  .rack-unit:hover {
    transform: none;
  }
  .card::after,
  .plate::after {
    display: none;
  }
}

/* On a phone the 3D stage flattens: a tilted deck at 390px is a deck you cannot read,
   and there is no cursor to tilt it with. */
@media (max-width: 900px) {
  .cockpit-frame {
    transform: none !important;
  }
  .deck > .card {
    transform: none !important;
  }
  .wire-svg {
    display: none;
  }
  .ground-readout {
    display: none;
  }
}
