/* ============================================================================
   Aurevon Interlude — "How it works" step slideshow
   Cohesive with the landing design system (styles.css tokens) and the signature
   product demo. CSS only, no remote assets. Transform/opacity motion only.

   Progressive-enhancement / layering model (mirrors `html.js .scroll-reveal`
   and the `.demo-panel.demo-live` pattern):

   - DEFAULT (no `.hiw-live`) = the accessible, no-JS / reduced-motion baseline:
     all five steps are legible cards, stacked and read top-to-bottom. NONE of
     the collapsing rules apply, so a blocked or failed script never hides a
     step. The controls stay `hidden`.
   - LIVE (`.hiw.hiw-live`, added by howitworks.js only when motion is allowed)
     = the single-stage cross-fading slideshow. Steps are stacked in one
     reserved-height stage; only `.is-active` shows. Controls become visible.

   Zero-CLS: in live mode `.hiw-track` reserves a fixed min-height sized for the
   tallest step, so steps cross-fade in/out without ever shifting layout.
   ========================================================================== */

/* Screen-reader-only helper (no `.sr-only` exists in styles.css). Used for the
   aria-live step announcer, which must be present in the DOM but not visible. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hiw {
  padding: clamp(34px, 7vw, 58px) 0;
  border-top: 1px solid var(--hairline);
}

.hiw-head {
  text-align: center;
  max-width: 640px;
  margin: 0 auto 24px;
}
.hiw-head .kicker { justify-content: center; }
.hiw-caption {
  margin: 10px auto 0;
  font-size: clamp(14px, 2.1vw, 15.5px);
  max-width: 560px;
}

/* ---- Stage + steps ------------------------------------------------------- */
.hiw-stage {
  max-width: 640px;
  margin: 0 auto;
}

.hiw-track {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 14px;
  counter-reset: none;
}

.hiw-step {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: clamp(20px, 4vw, 28px);
  border-radius: var(--r-lg);
  background: linear-gradient(160deg, var(--glass), var(--glass-2));
  border: 1px solid var(--hairline-strong);
  box-shadow: var(--shadow-1);
}

.hiw-num {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: var(--r-pill);
  background: linear-gradient(135deg, var(--blue-700), var(--blue-500));
  color: #EDF1F7;
  font-weight: 800;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  box-shadow: var(--glow-gold);
}

.hiw-body { min-width: 0; }
.hiw-step-title {
  margin: 2px 0 6px;
  font-size: clamp(16px, 2.4vw, 18.5px);
  letter-spacing: -0.01em;
  color: var(--ink);
}
.hiw-step-copy {
  margin: 0;
  font-size: clamp(14px, 2.1vw, 15px);
  color: var(--muted);
}

/* ---- Controls (revealed by JS; `hidden` in the no-JS baseline) ----------- */
.hiw-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 20px auto 0;
  max-width: 640px;
}

.hiw-btn {
  flex: 0 0 auto;
  width: var(--tap);
  height: var(--tap);
  display: inline-grid;
  place-items: center;
  border-radius: var(--r-pill);
  border: 1px solid var(--hairline-strong);
  background: var(--glass);
  color: var(--gold-hi);
  cursor: pointer;
  box-shadow: var(--shadow-1);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: transform 0.18s ease, box-shadow 0.18s ease, color 0.18s ease,
    border-color 0.18s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.hiw-btn:hover {
  color: var(--ink);
  border-color: rgba(111, 168, 255, 0.5);
  box-shadow: var(--shadow-2), var(--glow-cyan);
  transform: translateY(-2px);
}
.hiw-btn:active { transform: translateY(0); }
.hiw-btn:focus-visible { outline: 2px solid var(--blue-300); outline-offset: 2px; }

.hiw-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}
/* Each dot is a real <button> (built by JS). The visible pip is small, but the
   tap target is a full 44px so it is comfortably operable on touch. */
.hiw-dot {
  position: relative;
  width: var(--tap);
  height: var(--tap);
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.hiw-dot::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  transform: translate(-50%, -50%);
  border-radius: var(--r-pill);
  background: rgba(140, 155, 176, 0.4);
  transition: background 0.2s ease, width 0.2s ease, box-shadow 0.2s ease;
}
.hiw-dot:hover::before { background: rgba(111, 168, 255, 0.6); }
.hiw-dot:focus-visible { outline: 2px solid var(--blue-300); outline-offset: -6px; border-radius: var(--r-pill); }
.hiw-dot[aria-current="true"]::before {
  width: 22px;
  background: linear-gradient(100deg, var(--gold), var(--gold-hi));
  box-shadow: var(--glow-gold);
}

/* ---- Slim per-step progress bar (built by JS, lives at the top of the stage,
   live mode only) --------------------------------------------------------- */
.hiw-progress {
  height: 3px;
  width: 100%;
  max-width: 640px;
  margin: 0 auto 14px;
  border-radius: var(--r-pill);
  background: var(--hairline);
  overflow: hidden;
}
.hiw-progress-fill {
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(100deg, var(--gold-hi), var(--gold) 60%, var(--cyan));
  transform-origin: left center;
  transform: scaleX(0);
}
/* Restarted per step by toggling `.run` (JS forces a reflow between). Pausing is
   done via element.style.animationPlayState (CSSOM, CSP-safe). */
.hiw-progress-fill.run {
  animation: hiw-fill var(--hiw-step-ms, 3500ms) linear forwards;
}
@keyframes hiw-fill {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

/* ==========================================================================
   LIVE MODE — single cross-fading stage. Everything below is gated behind
   `.hiw-live`, so the no-JS baseline above is never collapsed.
   ========================================================================== */
.hiw-live .hiw-track {
  display: block;
  position: relative;
  /* Reserve the stage for the tallest step so cross-fades never shift layout. */
  min-height: 208px;
}
.hiw-live .hiw-step {
  position: absolute;
  inset: 0;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.5s ease, transform 0.5s ease;
  pointer-events: none;
  box-shadow: var(--shadow-2);
}
.hiw-live .hiw-step.is-active {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

/* Taller reserve where copy wraps to more lines on narrow viewports. */
@media (max-width: 560px) {
  .hiw-live .hiw-track { min-height: 260px; }
}
@media (max-width: 380px) {
  .hiw-live .hiw-track { min-height: 300px; }
}

/* ==========================================================================
   REDUCED MOTION — belt-and-suspenders. howitworks.js already refrains from
   adding `.hiw-live` under reduced motion, so the steps stay stacked; these
   rules also neutralise any transition/animation should the class ever apply.
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .hiw-live .hiw-track {
    display: grid;
    position: static;
    min-height: 0;
  }
  .hiw-live .hiw-step {
    position: static;
    inset: auto;
    opacity: 1;
    transform: none;
    transition: none;
    pointer-events: auto;
  }
  .hiw-progress-fill.run { animation: none; transform: scaleX(1); }
}
