/* ============================================================
   Tektome — "How It Works" animation suggestions.
   Three switchable directions, driven by [data-howanim] on
   .how-section. All respect prefers-reduced-motion and follow the
   brand motion vocabulary (fades + small slides, out-quart easing,
   no bounce/overshoot). Tokens from colors_and_type.css.

     build     — scroll-triggered staggered entrance (illustration
                 then text cascade in, column by column)
     flow      — continuous "data flows through the pipeline": a
                 purple pulse travels across the columns + living
                 micro-motion on the step illustrations
     spotlight — auto-cycling guided walkthrough: inactive steps
                 recede, the active step lifts and regains full colour
   ============================================================ */

@media (prefers-reduced-motion: no-preference) {

  /* ---------- 1. BUILD: staggered scroll entrance ---------- */
  /* Hidden state is gated on :not(.how-anim-in) so that once revealed
     NO opacity/transform rule targets the cards — they return to their
     natural visible state with zero cascade ambiguity. */
  .how-section[data-howanim="build"]:not(.how-anim-in) .step-card {
    opacity: 0;
    transform: translateY(18px);
  }
  .how-section[data-howanim="build"]:not(.how-anim-in) .step-illustration,
  .how-section[data-howanim="build"]:not(.how-anim-in) .step-text > * {
    opacity: 0;
    transform: translateY(10px);
  }
  .how-section[data-howanim="build"] .step-card {
    transition: opacity var(--duration-slow) var(--ease-out),
                transform var(--duration-slow) var(--ease-out);
  }
  .how-section[data-howanim="build"] .step-illustration,
  .how-section[data-howanim="build"] .step-text > * {
    transition: opacity var(--duration-base) var(--ease-out),
                transform var(--duration-base) var(--ease-out);
  }
  /* column cascade */
  .how-section[data-howanim="build"].how-anim-in .step-card:nth-child(1) { transition-delay: 0ms; }
  .how-section[data-howanim="build"].how-anim-in .step-card:nth-child(2) { transition-delay: 110ms; }
  .how-section[data-howanim="build"].how-anim-in .step-card:nth-child(3) { transition-delay: 220ms; }
  .how-section[data-howanim="build"].how-anim-in .step-card:nth-child(4) { transition-delay: 330ms; }
  /* within a column: illustration first, then badge → h3 → p */
  .how-section[data-howanim="build"].how-anim-in .step-card:nth-child(1) :is(.step-illustration) { transition-delay: 120ms; }
  .how-section[data-howanim="build"].how-anim-in .step-card:nth-child(2) :is(.step-illustration) { transition-delay: 230ms; }
  .how-section[data-howanim="build"].how-anim-in .step-card:nth-child(3) :is(.step-illustration) { transition-delay: 340ms; }
  .how-section[data-howanim="build"].how-anim-in .step-card:nth-child(4) :is(.step-illustration) { transition-delay: 450ms; }
  .how-section[data-howanim="build"].how-anim-in .step-text > *:nth-child(1) { transition-delay: 200ms; }
  .how-section[data-howanim="build"].how-anim-in .step-text > *:nth-child(2) { transition-delay: 280ms; }
  .how-section[data-howanim="build"].how-anim-in .step-text > *:nth-child(3) { transition-delay: 360ms; }

  /* ---------- 2. FLOW: continuous pipeline pulse ---------- */
  .how-section[data-howanim="flow"] .steps-grid { position: relative; }
  /* travelling pulse along the seam between illustration and text rows */
  .how-section[data-howanim="flow"] .steps-grid::after {
    content: "";
    position: absolute;
    top: 232px;            /* illustration cell height — sits on the divider */
    left: 0;
    width: 26%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--color-arch-purple), transparent);
    opacity: 0.9;
    animation: howFlowSweep 4.2s var(--ease-in-out) infinite;
    pointer-events: none;
  }
  @keyframes howFlowSweep {
    0%   { transform: translateX(-30%); opacity: 0; }
    12%  { opacity: 0.95; }
    88%  { opacity: 0.95; }
    100% { transform: translateX(385%); opacity: 0; }
  }
  /* gentle living motion on each illustration, staggered per column */
  .how-section[data-howanim="flow"] .step-illustration svg,
  .how-section[data-howanim="flow"] .s4-wrap {
    animation: howBreathe 3.6s var(--ease-in-out) infinite;
  }
  .how-section[data-howanim="flow"] .step-card:nth-child(2) .step-illustration svg { animation-delay: 0.5s; }
  .how-section[data-howanim="flow"] .step-card:nth-child(3) .step-illustration svg { animation-delay: 1.0s; }
  .how-section[data-howanim="flow"] .step-card:nth-child(4) .s4-wrap { animation-delay: 1.5s; }
  @keyframes howBreathe {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-4px); }
  }
  /* badge keeps a soft active glow that ripples across the row */
  .how-section[data-howanim="flow"] .step-num-badge {
    animation: howBadgePulse 4.2s var(--ease-in-out) infinite;
  }
  .how-section[data-howanim="flow"] .step-card:nth-child(2) .step-num-badge { animation-delay: 1.05s; }
  .how-section[data-howanim="flow"] .step-card:nth-child(3) .step-num-badge { animation-delay: 2.10s; }
  .how-section[data-howanim="flow"] .step-card:nth-child(4) .step-num-badge { animation-delay: 3.15s; }
  @keyframes howBadgePulse {
    0%, 70%, 100% { background: var(--state-enabled-bg); color: var(--color-arch-purple); }
    18%, 40%      { background: var(--color-arch-purple); color: var(--color-draft-white); }
  }

  /* ---------- 3. SPOTLIGHT: auto-cycling walkthrough ---------- */
  .how-section[data-howanim="spotlight"] .step-card {
    opacity: 0.5;
    transition: opacity var(--duration-slow) var(--ease-out),
                transform var(--duration-slow) var(--ease-out),
                box-shadow var(--duration-slow) var(--ease-out);
  }
  .how-section[data-howanim="spotlight"] .step-illustration {
    filter: saturate(0.45) opacity(0.8);
    transition: filter var(--duration-slow) var(--ease-out);
  }
  .how-section[data-howanim="spotlight"] .step-card.is-active {
    opacity: 1;
    transform: translateY(-6px);
    box-shadow: var(--shadow-md);
    z-index: 2;
  }
  .how-section[data-howanim="spotlight"] .step-card.is-active .step-illustration {
    filter: none;
  }
  .how-section[data-howanim="spotlight"] .step-card.is-active .step-num-badge {
    background: var(--color-arch-purple);
    color: var(--color-draft-white);
  }
}
