/* ═══════════════════════════════════════════════════════════
   TruStackAPI · hiw.css
   "How it works" — one-stage-per-scroll orbit engine
   ═══════════════════════════════════════════════════════════ */

.hiw-sec { position: relative; padding: 76px 0 0; }
.hiw-head { max-width: var(--maxw); }
.hiw-head .lede { max-width: 660px; }
.hiw-head .lede strong { font-weight: 500; color: var(--on-navy); }

/* scroll cue — sits calmly between the lede and the recall row */
.hiw-scrollcue { display: inline-flex; align-items: center; gap: 9px; margin-top: 18px; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--on-navy-3); }
.hsc-arrow { display: inline-flex; color: var(--sky-2); }
.hsc-arrow svg { width: 14px; height: 14px; animation: hiwNudge 1.9s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .hsc-arrow svg { animation: none; } }

/* purpose-built recall row — separated from the lede, given room to breathe */
.hiw-pb { margin-top: 34px; padding-top: 26px; border-top: 1px solid var(--navy-line); display: flex; flex-wrap: wrap; align-items: baseline; gap: 18px 38px; }
.hiw-pb-lead { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--sky-2); flex: 0 0 auto; }
.hiw-pb-items { display: flex; flex-wrap: wrap; gap: 16px 32px; flex: 1 1 480px; }
.hiw-pb-i { position: relative; padding-left: 17px; font-size: 13px; font-weight: 300; line-height: 1.45; color: var(--on-navy-2); }
.hiw-pb-i::before { content: ''; position: absolute; left: 0; top: 7px; width: 5px; height: 5px; border-radius: 50%; background: var(--indigo); }
.hiw-pb-i b { font-family: var(--font-mono); font-weight: 600; color: var(--white-soft); letter-spacing: 0.02em; }
@media (max-width: 760px) {
  .hiw-pb { margin-top: 26px; padding-top: 20px; gap: 14px; flex-direction: column; }
  .hiw-pb-items { flex-direction: column; gap: 11px; }
}

.hiw { position: relative; }
.hiw-track { position: relative; }

/* sticky stage — fills the viewport below the tabs bar so nothing
   below it bleeds through while you scroll the stages */
.hiw-sticky {
  position: sticky; top: 116px;
  height: calc(100vh - 132px);
  max-width: var(--maxw); margin: 0 auto; padding: 14px var(--pad) 8px;
  display: flex; flex-direction: column; gap: 10px;
}

/* ── progress stepper (honest + clickable) ── */
.hiw-steps { position: relative; flex: 0 0 auto; padding: 4px 6px 2px; }
.hiw-steps-line {
  position: absolute; left: 6px; right: 6px; top: 11px; height: 2px;
  background: var(--navy-line); border-radius: 2px; overflow: hidden;
}
.hiw-steps-fill {
  position: absolute; left: 0; top: 0; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--indigo), var(--sky-2));
  border-radius: 2px; transition: width 0.45s cubic-bezier(.4,0,.2,1);
}
.hiw-steps-row { position: relative; display: flex; }
.hiw-step {
  flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center;
  gap: 9px; background: none; border: 0; cursor: pointer; padding: 0 4px;
  -webkit-tap-highlight-color: transparent;
}
.hs-dot {
  width: 11px; height: 11px; border-radius: 50%; background: #0E1730;
  border: 2px solid var(--navy-line-2); transition: all 0.3s ease; flex-shrink: 0;
}
.hiw-step:hover .hs-dot { border-color: var(--sky-2); }
.hiw-step.is-past .hs-dot { background: var(--indigo); border-color: var(--indigo); }
.hiw-step.is-active .hs-dot {
  background: var(--sky-2); border-color: var(--sky-2);
  box-shadow: 0 0 0 4px rgba(96,200,255,0.18), 0 0 14px rgba(96,200,255,0.5);
}
.hs-meta { display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; }
.hs-n { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.1em; color: var(--on-navy-3); transition: color 0.3s; }
.hs-lbl {
  font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.04em; line-height: 1.25;
  color: var(--on-navy-3); transition: color 0.3s; max-width: 13ch;
}
.hiw-step:hover .hs-n, .hiw-step:hover .hs-lbl { color: var(--on-navy-2); }
.hiw-step.is-past .hs-n, .hiw-step.is-past .hs-lbl { color: var(--on-navy-2); }
.hiw-step.is-active .hs-n { color: var(--sky-2); }
.hiw-step.is-active .hs-lbl { color: var(--white-soft); }

/* ── stage ── */
.hiw-stage { position: relative; flex: 1 1 auto; min-height: 0; }
.hiw-scene {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: clamp(14px, 2.6vh, 30px);
  opacity: 0; transform: translateY(22px); pointer-events: none;
  transition: opacity 0.5s ease, transform 0.6s cubic-bezier(.2,.7,.2,1);
}
.hiw-scene.is-active { opacity: 1; transform: none; pointer-events: auto; }

/* description caption — under the orbit, wide and readable */
.scene-sub {
  max-width: 560px; text-align: center; font-weight: 300;
  font-size: clamp(13px, 1.55vh, 15.5px); line-height: 1.55; color: var(--on-navy-2);
}
.scene-sub strong { color: var(--on-navy); font-weight: 500; }

/* interactive advance control */
.hiw-next {
  align-self: center; flex: 0 0 auto; margin-top: 2px;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 17px; border-radius: 100px;
  border: 1px solid var(--navy-line-2); background: rgba(255,255,255,0.04);
  color: var(--on-navy-2); cursor: pointer;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase;
  transition: color 0.25s ease, border-color 0.25s ease, background 0.25s ease, opacity 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}
.hiw-next svg { width: 14px; height: 14px; animation: hiwNudge 1.9s ease-in-out infinite; }
.hiw-next:hover { color: var(--white-soft); border-color: var(--sky-2); background: rgba(96,200,255,0.1); }
.hiw-next.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }
@keyframes hiwNudge { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(3px); } }
@media (prefers-reduced-motion: reduce) { .hiw-next svg { animation: none; } }

/* tone palettes */
.tone-sky    { --acc: #60C8FF; --acc-rgb: 96,200,255; }
.tone-gold   { --acc: #E9C879; --acc-rgb: 233,200,121; }
.tone-indigo { --acc: #B7BDFF; --acc-rgb: 183,189,255; }
.tone-green  { --acc: #5FD0A0; --acc-rgb: 95,208,160; }

/* ── orbit geometry · sized to the VIEWPORT HEIGHT so it never gets cut ── */
.orbit {
  position: relative;
  --r: clamp(150px, 25vh, 234px);
  --dur: 100s;
  width: calc(var(--r) * 2); height: calc(var(--r) * 2);
  display: grid; place-items: center;
}
.orbit::before {
  content: ''; position: absolute; top: 50%; left: 50%;
  width: calc(var(--r) * 2); height: calc(var(--r) * 2);
  transform: translate(-50%, -50%);
  border: 1px dashed rgba(var(--acc-rgb), 0.22); border-radius: 50%;
}
.orbit::after {
  content: ''; position: absolute; top: 50%; left: 50%;
  width: calc(var(--r) * 2 + 70px); height: calc(var(--r) * 2 + 70px);
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(var(--acc-rgb),0.12) 0%, transparent 60%);
  pointer-events: none;
}

.orbit-ring { position: absolute; inset: 0; }
.spin-cw  { animation: hiwSpin var(--dur) linear infinite; }
.spin-ccw { animation: hiwSpinR var(--dur) linear infinite; }

.orbit-item {
  position: absolute; top: 50%; left: 50%; width: 0; height: 0;
  transform: rotate(var(--a)) translateY(calc(-1 * var(--r)));
}
.orbit-fix {
  position: absolute; top: 0; left: 0;
  transform: translate(-50%, -50%) rotate(calc(-1 * var(--a)));
  opacity: 0; transition: opacity 0.5s ease; transition-delay: var(--d);
}
.counter-cw  { animation: hiwCounter var(--dur) linear infinite; }
.hiw-scene.is-active .orbit-fix { opacity: 1; }

.orbit-chip {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  padding: 7px 12px; border-radius: 100px;
  background: rgba(9,15,34,0.92); border: 1px solid rgba(var(--acc-rgb), 0.34);
  box-shadow: 0 6px 22px rgba(4,5,15,0.55);
}
.oc-t { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.01em; color: var(--on-navy); }
.oc-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--acc); box-shadow: 0 0 8px var(--acc); flex-shrink: 0; }
.oc-ic { width: 14px; height: 14px; color: var(--acc); flex-shrink: 0; display: inline-flex; }
.oc-ic svg { width: 14px; height: 14px; }
.oc-tag { font-family: var(--font-mono); font-size: 8.5px; font-weight: 600; letter-spacing: 0.04em; color: var(--acc); border: 1px solid rgba(var(--acc-rgb),0.5); border-radius: 5px; padding: 1px 5px; }

/* chip kind accents */
.orbit-chip.k-pillar { background: rgba(184,134,11,0.16); border-color: rgba(233,200,121,0.55); }
.orbit-chip.k-pillar .oc-ic { color: #E9C879; }
.orbit-chip.k-ai     { background: rgba(79,70,229,0.20); border-color: rgba(183,189,255,0.5); }
.orbit-chip.k-ai .oc-ic { color: #B7BDFF; }
.orbit-chip.k-part   { background: rgba(79,70,229,0.20); border-color: rgba(183,189,255,0.5); }
.orbit-chip.k-part .oc-ic { color: #B7BDFF; }
.orbit-chip.k-ok     { background: rgba(31,138,91,0.18); border-color: rgba(95,208,160,0.5); }
.orbit-chip.k-ok .oc-ic { color: #5FD0A0; }
.orbit-chip.k-warn   { background: rgba(224,122,60,0.2); border-color: rgba(255,177,122,0.6); }
.orbit-chip.k-warn .oc-ic { color: #FFB17A; }
.orbit-chip.k-warn .oc-tag { color: #FFB17A; }

/* stage 6 (legend / grouped layers) — slightly tighter chips for clearance */
.orbit.legend .oc-t { font-size: 10px; }
.orbit.legend .orbit-chip { padding: 6px 11px; }

/* ── central core (compact) ── */
.orbit-core {
  position: relative; z-index: 3; width: clamp(162px, 15vh, 200px); text-align: center; padding: 10px;
}
.orbit-core::before {
  content: ''; position: absolute; inset: -38px; border-radius: 50%; z-index: -1;
  background: radial-gradient(circle, rgba(8,13,30,0.97) 42%, rgba(8,13,30,0.78) 62%, transparent 80%);
}
.oc-phase { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--acc); margin-bottom: 11px; }
.oc-title { font-weight: 800; font-size: clamp(23px, 3.2vh, 33px); letter-spacing: -0.025em; line-height: 1.05; color: var(--white-soft); }
.oc-title.small { font-size: clamp(18px, 2.2vh, 22px); }
.oc-stat { font-family: var(--font-display); font-weight: 800; font-size: clamp(40px, 6vh, 60px); line-height: 0.9; letter-spacing: -0.04em; background: linear-gradient(90deg,#B7BDFF,#60C8FF); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.oc-statlbl { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--on-navy-3); margin: 7px 0 10px; }

/* layer legend inside core (stage 6) */
.oc-rings { display: flex; flex-direction: column; gap: 6px; margin-top: 13px; align-items: center; }
.ocr { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.03em; color: var(--on-navy-2); line-height: 1.2; }
.ocr i { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.ocr.gold i   { background: #E9C879; box-shadow: 0 0 8px rgba(233,200,121,0.6); }
.ocr.indigo i { background: #B7BDFF; box-shadow: 0 0 8px rgba(183,189,255,0.6); }

@keyframes hiwSpin { from { transform: rotate(0); } to { transform: rotate(360deg); } }
@keyframes hiwSpinR { from { transform: rotate(0); } to { transform: rotate(-360deg); } }
@keyframes hiwCounter { from { transform: translate(-50%,-50%) rotate(calc(-1 * var(--a))); } to { transform: translate(-50%,-50%) rotate(calc(-1 * var(--a) - 360deg)); } }

@media (prefers-reduced-motion: reduce) {
  .orbit-ring, .orbit-fix { animation: none !important; }
}

/* ── tablet ── */
@media (max-width: 1100px) {
  .hs-lbl { font-size: 9px; }
}

/* ── mobile · SAME staged scroll (one stage per swipe) ──
   Robust no-gap layout: only the ACTIVE scene is in flow (others display:none),
   so the pinned block hugs its content — no tall stage, no centering gap. */
@media (max-width: 760px) {
  .hiw-sec { padding-top: 52px; }
  .hiw-sticky {
    top: 128px; height: auto; padding: 12px 16px 16px; gap: 12px;
  }
  .hs-meta { display: none; }
  .hiw-steps-line { top: 5px; }
  .hiw-step { padding: 0; }
  .hs-dot { width: 9px; height: 9px; }

  /* compact intro on mobile → orbit pins quickly, minimal scroll-in dead space */
  .hiw-head .lede { font-size: 13.5px; line-height: 1.5; max-width: none; margin-top: 14px; }
  .hiw-scrollcue { display: none; }
  .hiw-pb { margin-top: 20px; padding-top: 16px; gap: 10px 24px; }
  .hiw-pb-items { gap: 8px 22px; }

  .hiw-stage { flex: 0 0 auto; height: auto; min-height: 0; }
  .hiw-scene { position: relative; inset: auto; transform: none; opacity: 1; }
  .hiw-scene:not(.is-active) { display: none; }
  .hiw-scene.is-active {
    display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
    min-height: 452px; gap: 16px; transform: none; opacity: 1;
  }

  .orbit {
    width: 100%; height: auto; display: flex; flex-direction: column; align-items: center;
    gap: 14px; --r: clamp(96px, 30vw, 128px);
  }
  .orbit::before, .orbit::after { display: none; }

  /* core as a heading block on top */
  .orbit-core { position: static; order: -1; width: 100%; max-width: 360px; padding: 0; text-align: center; }
  .orbit-core::before { display: none; }
  .oc-title { font-size: clamp(22px, 6.4vw, 28px); }
  .oc-phase { margin-bottom: 9px; }
  .scene-sub { font-size: 12px; line-height: 1.45; max-width: 340px; }

  /* ring becomes a sized square that orbits an empty centre */
  .orbit-ring { position: relative; width: min(74vw, 300px); height: min(74vw, 300px); flex: 0 0 auto; }
  .orbit-ring::before {
    content: ''; position: absolute; top: 50%; left: 50%; width: calc(var(--r) * 2); height: calc(var(--r) * 2);
    transform: translate(-50%, -50%); border: 1px dashed rgba(var(--acc-rgb), 0.22); border-radius: 50%;
  }
  .orbit-ring::after {
    content: ''; position: absolute; top: 50%; left: 50%; width: 9px; height: 9px;
    transform: translate(-50%, -50%); border-radius: 50%; background: var(--acc); box-shadow: 0 0 12px var(--acc);
  }
  .orbit-chip { padding: 5px 9px; max-width: 98px; white-space: normal; }
  .oc-t { font-size: 9.5px; line-height: 1.2; }
  .oc-tag { font-size: 7.5px; }

  /* stage 6 has 7 chips → narrower chips so they orbit without overlap */
  .orbit.legend .orbit-chip { max-width: 84px; }
}
@media (max-width: 380px) {
  .orbit { --r: clamp(88px, 29vw, 112px); }
  .orbit-ring { width: min(80vw, 280px); height: min(80vw, 280px); }
}

/* ── wide-but-short viewports (short desktop windows, iPad landscape) ──
   Plenty of width, limited height. KEEP the centred-core orbit (it's the
   compact layout) and just shrink the radius + type so the whole scene —
   ring, core and caption — fits under the stepper without overflowing up
   into it. The stacked title-on-top layout is reserved for true mobile.   */
@media (max-height: 760px) and (min-width: 761px) {
  .hiw-sticky { gap: 6px; }
  .hiw-scene { gap: clamp(10px, 1.8vh, 20px); justify-content: center; }
  .orbit { --r: clamp(112px, 23vh, 168px); }
  .orbit.legend { --r: clamp(120px, 25vh, 176px); }
  .oc-title { font-size: clamp(19px, 3vh, 27px); }
  .oc-title.small { font-size: clamp(16px, 2vh, 20px); }
  .oc-stat { font-size: clamp(32px, 4.6vh, 48px); }
  .oc-phase { margin-bottom: 7px; }
  .oc-rings { margin-top: 9px; gap: 5px; }
  .orbit-core { width: clamp(150px, 14vh, 188px); }
  .orbit-chip { padding: 5px 10px; }
  .scene-sub { font-size: clamp(12px, 1.5vh, 14px); line-height: 1.5; max-width: 540px; }
}

/* ── short AND narrow (mobile landscape / very small windows) ──
   Not enough room for a centred orbit either way → stacked title-on-top. */
@media (max-height: 560px) and (max-width: 760px) {
  .orbit-ring { width: min(46vh, 70vw, 300px); height: min(46vh, 70vw, 300px); }
}

/* orbit / caption clearance — prevent overlap on short or narrow screens */
.scene-sub { margin-top: clamp(10px, 2vh, 22px); position: relative; z-index: 3; }
.orbit { flex-shrink: 0; }
.hiw-next { position: relative; z-index: 5; background: rgba(10,16,36,0.92); backdrop-filter: blur(4px); }
