/* ============================================================
   lotabin — Services · "The Case" spiral staircase
   Scroll-pinned stage (same mechanical as the production orbit):
   a sticky pin, a HUD with typewriter stage title + progress fill
   + a clickable 3-step rail, reason panels crossfading in, all over
   a three.js spiral staircase the camera descends with progress.

   Progressive enhancement: without JS (.svc3-stair has no .is-live)
   the section un-pins and the three reasons stack and read normally.
   ============================================================ */

.svc3-stair { position: relative; margin-top: clamp(40px, 6vh, 72px); }
.co-track   { height: 890vh; }

.co-pin {
  position: sticky;
  top: var(--co-sticky, 76px);
  height: calc(100svh - var(--co-sticky, 76px));
  min-height: 600px;
  overflow: hidden;
  background: transparent;
}

/* three.js canvas */
.co-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: block;
}

/* real pit footage — fades in over the canvas (same frame) at the wing-on beat */
.co-video {
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.7s ease;
  pointer-events: none;
}

/* soft page-toned vignette so the reason text stays legible over the stairs —
   page-colored + fully transparent on the left, so it reads as depth, not a box */
.co-scrim {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(13,13,17,0) 46%, rgba(13,13,17,0.55) 74%, rgba(13,13,17,0.82) 100%);
}

/* hidden progress carrier — drives the staircase camera (read by case-stair.js) */
.co-progress { position: absolute; width: 0; height: 0; overflow: hidden; opacity: 0; pointer-events: none; }

/* ---------------- HUD ---------------- */
.co-hud {
  position: absolute;
  z-index: 3;
  top: clamp(20px, 3.2vh, 38px);
  left: clamp(20px, 4vw, 60px);
  right: clamp(20px, 4vw, 60px);
}
.co-hud-head { display: flex; align-items: baseline; gap: clamp(14px, 2vw, 26px); flex-wrap: wrap; }
.co-kicker {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-mono);
  font-size: 0.66rem; letter-spacing: 0.24em; text-transform: uppercase;
  color: var(--fg-muted);
}
.co-stage {
  min-width: 0;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.05rem, 0.9rem + 0.7vw, 1.55rem);
  letter-spacing: -0.015em;
  color: var(--paper-50);
  white-space: nowrap; overflow: hidden; text-overflow: clip;
}
.co-stage::after {
  content: "";
  display: inline-block;
  width: 2px; height: 1.05em;
  margin-left: 3px;
  vertical-align: -0.16em;
  background: var(--bronze);
  animation: coCaret 1.1s steps(1) infinite;
}
.co-stage.co-typing::after { animation: none; opacity: 1; }
@keyframes coCaret { 0%,50% { opacity: 1; } 50.01%,100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .co-stage::after { animation: none; } }

.co-rail {
  position: relative;
  height: 2px;
  margin: clamp(14px, 2vh, 22px) 0 clamp(12px, 1.6vh, 18px);
  background: var(--rule);
}
.co-fill {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--bronze-deep), var(--bronze));
  box-shadow: 0 0 16px rgba(200,168,118,0.30);
}

.co-steps { display: flex; gap: clamp(10px, 2vw, 28px); }
.co-step {
  flex: 1 1 0;
  position: relative;
  display: flex; align-items: baseline; gap: 8px;
  padding: 0 0 9px;
  background: none; border: 0; cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.64rem; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink-300);
  text-align: left;
  transition: color var(--d-med) var(--e-out);
}
.co-step-n { color: var(--bronze-deep); font-size: 0.58rem; }
.co-step::before {
  content: ""; position: absolute; left: 0; bottom: 0;
  width: 100%; height: 2px; background: var(--rule);
}
.co-step::after {
  content: ""; position: absolute; left: 0; bottom: 0;
  width: calc(var(--seg, 0) * 100%); height: 2px;
  background: var(--bronze);
  transition: none;
}
.co-step:hover { color: var(--paper-200); }
.co-step.is-active { color: var(--paper-50); }
.co-step.is-active .co-step-n { color: var(--bronze); }
.co-step:focus-visible { outline: 2px solid var(--bronze); outline-offset: 4px; }

/* ---------------- reason panels (right column) ---------------- */
.co-panels {
  position: absolute;
  z-index: 3;
  right: clamp(20px, 4vw, 66px);
  top: 50%;
  transform: translateY(-50%);
  width: min(44vw, 470px);
  height: min(62vh, 460px);
}
.co-panel {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; justify-content: center;
  gap: clamp(12px, 1.6vh, 20px);
  opacity: 0;
  will-change: opacity, transform;
}
.co-num {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(2.4rem, 1.6rem + 2.4vw, 3.6rem);
  line-height: 0.8;
  color: transparent;
  -webkit-text-stroke: 1px var(--bronze-deep);
}
.co-h3 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.5rem, 1.1rem + 1.4vw, 2.4rem);
  line-height: 1.04;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--paper-50);
}
.co-h3 em { font-style: italic; color: var(--bronze); }
.co-copy {
  margin: 0;
  font-size: clamp(0.92rem, 0.86rem + 0.25vw, 1.05rem);
  line-height: 1.55;
  font-weight: 300;
  color: var(--paper-200);
  max-width: 46ch;
}
.co-rows { margin-top: clamp(4px, 1vh, 10px); }

/* the spec list inherits .svc3-rows styling; tighten for the stage */
.co-panels .svc3-rows { font-size: 0.82rem; }
.co-panels .svc3-rows li { padding: 10px 2px; gap: 16px; }
.co-panels .svc3-rows .k { white-space: nowrap; }
.co-panels .svc3-rows .v { font-size: 0.95rem; text-wrap: normal; }

/* scroll cue */
.co-cue {
  position: absolute;
  z-index: 3;
  left: clamp(20px, 4vw, 60px);
  bottom: clamp(18px, 3vh, 30px);
  display: inline-flex; align-items: center; gap: 12px;
  font-family: var(--font-mono);
  font-size: 0.62rem; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--fg-muted);
}
.co-cue .bar {
  width: 30px; height: 1px; background: var(--bronze);
  transform-origin: left center;
  animation: coCueBar 2.4s var(--e-in-out) infinite;
}
@keyframes coCueBar { 0%,100% { transform: scaleX(0.4); opacity: 0.5; } 50% { transform: scaleX(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .co-cue .bar { animation: none; } }

/* ---------------- mobile: stack stairs over, panel below ---------------- */
@media (max-width: 820px) {
  .co-scrim {
    background: linear-gradient(180deg, rgba(13,13,17,0) 36%, rgba(13,13,17,0.7) 60%, rgba(13,13,17,0.92) 100%);
  }
  .co-panels {
    right: clamp(18px, 5vw, 30px);
    left: clamp(18px, 5vw, 30px);
    width: auto;
    top: auto; bottom: clamp(54px, 9vh, 84px);
    transform: none;
    height: min(52vh, 380px);
  }
  .co-panel { justify-content: flex-end; }
  .co-copy { max-width: none; }
  .co-cue { display: none; }
}

/* ---------------- progressive-enhancement fallback (no JS) ---------------- */
.svc3-stair:not(.is-live) .co-track { height: auto; }
.svc3-stair:not(.is-live) .co-pin {
  position: static; height: auto; min-height: 0;
  padding: clamp(40px, 7vh, 90px) 0;
}
.svc3-stair:not(.is-live) .co-bg,
.svc3-stair:not(.is-live) .co-scrim,
.svc3-stair:not(.is-live) .co-cue,
.svc3-stair:not(.is-live) .co-rail { display: none; }
.svc3-stair:not(.is-live) .co-hud { position: static; margin-bottom: 40px; }
.svc3-stair:not(.is-live) .co-panels {
  position: static; transform: none; width: auto; height: auto;
  display: grid; gap: clamp(40px, 7vh, 80px);
}
.svc3-stair:not(.is-live) .co-panel {
  position: static; inset: auto; opacity: 1;
  border-top: 1px solid var(--rule); padding-top: clamp(28px, 4vh, 48px);
}
