/* ============================================================
   CCRS process-steps.css : Phase 3
   Animates the existing 3-step "How It Works" section.
   Load after motion.css. NO HTML changes: the connecting line is drawn
   with pseudo-elements on .hiw-card, and the "icons" are the existing
   numbered .hiw-num badges. All text stays visible at all times.

   Default (no JS / reduced motion / failure) = COMPLETED state.
   JS adds .hiw-anim (dim start), then .hiw-playing (desktop sequence)
   or .is-on per card (mobile).
   ============================================================ */

/* The cards are information, not links: no lift. The line geometry
   below also depends on the cards staying put. */
.how-it-works .hiw-card { position: relative; }
.how-it-works .hiw-card:hover { transform: none; }

/* ---------- Badge ("icon") ---------- */
.how-it-works .hiw-num {
  transition:
    opacity var(--motion-standard, 220ms) var(--motion-ease, ease),
    transform var(--motion-standard, 220ms) var(--motion-ease, ease),
    box-shadow var(--motion-standard, 220ms) var(--motion-ease, ease);
}
/* Start state (only while JS is waiting to play the sequence) */
.how-it-works.hiw-anim .hiw-num {
  opacity: .6;
  transform: scale(.92);
}
/* Active: ring + full strength */
.how-it-works.hiw-playing .hiw-card .hiw-num,
.how-it-works.hiw-anim .hiw-card.is-on .hiw-num {
  opacity: 1;
  transform: none;
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--brand) 18%, transparent);
}

/* ---------- Connecting line (desktop only) ---------- */
@media (min-width: 769px) {
  .how-it-works .hiw-card:not(:last-child)::before,
  .how-it-works .hiw-card:not(:last-child)::after {
    content: "";
    position: absolute;
    /* vertical centre of the 46px badge: card padding-top 1.75rem + 23px */
    top: calc(1.75rem + 23px - 1.5px);
    left: calc(50% + 31px);                       /* 23px radius + 8px air */
    width: calc(100% + 2px + 1.25rem - 62px);     /* to next badge, 8px air */
    height: 3px;
    border-radius: 3px;
    pointer-events: none;
  }
  /* track */
  .how-it-works .hiw-card:not(:last-child)::after {
    background: var(--border-strong);
  }
  /* fill (drawn over the track); completed by default */
  .how-it-works .hiw-card:not(:last-child)::before {
    background: linear-gradient(90deg, var(--brand), var(--accent));
    z-index: 1;
    transform: scaleX(1);
    transform-origin: left center;
    transition: transform var(--motion-reveal, 500ms) var(--motion-ease, ease);
  }
  .how-it-works.hiw-anim .hiw-card:not(:last-child)::before {
    transform: scaleX(0);
  }
  .how-it-works.hiw-playing .hiw-card:not(:last-child)::before {
    transform: scaleX(1);
  }

  /* Sequence timing: step 1, line, step 2, line, step 3. Plays once. */
  .how-it-works.hiw-playing .hiw-card:nth-child(1) .hiw-num { transition-delay: 0ms; }
  .how-it-works.hiw-playing .hiw-card:nth-child(1)::before  { transition-delay: 250ms; }
  .how-it-works.hiw-playing .hiw-card:nth-child(2) .hiw-num { transition-delay: 700ms; }
  .how-it-works.hiw-playing .hiw-card:nth-child(2)::before  { transition-delay: 950ms; }
  .how-it-works.hiw-playing .hiw-card:nth-child(3) .hiw-num { transition-delay: 1400ms; }
}
/* Mobile (single column): no line, so nothing crosses the text.
   Each badge highlights as its card scrolls into view. */

/* ---------- Reduced motion / high contrast ---------- */
@media (prefers-reduced-motion: reduce) {
  .how-it-works .hiw-num,
  .how-it-works .hiw-card::before { transition: none !important; }
}
html[data-motion="reduced"] .how-it-works .hiw-num,
html[data-motion="reduced"] .how-it-works .hiw-card::before { transition: none !important; }

/* Keep full contrast in every state */
html[data-contrast="high"] .how-it-works.hiw-anim .hiw-num {
  opacity: 1;
  transform: none;
}
html[data-contrast="high"] .how-it-works .hiw-card:not(:last-child)::after { background: #fff; }
html[data-contrast="high"] .how-it-works .hiw-card:not(:last-child)::before { background: #ffe600; }
