/* ═══════════════════════════════════════
   ECHO — how.css  ("How it works", homepage #process)
   Port of docs/mockups/how-it-works.html. Left: a stage with one live
   scene per step; right: the four steps as a list that drives it.
   Mockup tokens map onto the site's (base.css); only --hw-muted / --hw-halo
   are new values. The site has no dark theme, so none is defined here.
   Hidden start states live under html.js only. JS: JS/how.js.
   ═══════════════════════════════════════ */

.hw {
  --hw-bg: var(--surface);               /* section + panel fill   (mockup --bg) */
  --hw-surface: var(--surface-2);        /* stage background       (mockup --surface) */
  --hw-line: var(--border);
  --hw-ink: var(--text);
  --hw-ink-soft: var(--text-muted);
  --hw-muted: #6f6794;                   /* new: quiet labels, 4.9:1 on --surface */
  --hw-accent: var(--accent);
  --hw-halo: rgba(91, 43, 224, 0.14);    /* new: soft accent fill */
  --hw-mono: 'DM Mono', ui-monospace, monospace;
  --hw-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --hw-ease-inout: cubic-bezier(0.65, 0, 0.35, 1);
  position: relative;
  overflow-x: clip;                     /* the entry horizon may rise above the section */
  background: var(--hw-bg);
  color: var(--hw-ink);
}

.hw__eyebrow {
  font-family: var(--hw-mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--hw-accent);
  margin: 0;
}
.hw__eyebrow--muted { color: var(--hw-muted); }
.hw__title {
  font-family: var(--font-head);
  font-weight: 400;
  font-size: clamp(2.6rem, 1.6rem + 3.4vw, 4.5rem);
  line-height: 1;
  letter-spacing: -0.015em;
  margin: 1rem 0 0;
  text-wrap: balance;
}
.hw__title em { font-weight: 300; font-style: italic; color: var(--hw-accent); }

/* reveal (intro, once) */
.hw-rv { transition: transform 0.9s var(--hw-ease-out), opacity 0.9s var(--hw-ease-out); }
@media (prefers-reduced-motion: no-preference) {
  html.js .hw:not(.is-in) .hw-rv { transform: translateY(28px); opacity: 0; }
}
.hw .hw__body .hw-rv:nth-child(2) { transition-delay: 0.12s; }

/* ── Body ── */
.hw__body { display: grid; gap: 3rem; margin-top: 4rem; align-items: start; }
@media (min-width: 960px) {
  .hw__body { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(48px, 6vw, 112px); }
}

/* ── Stage ── */
.hw-stage {
  position: relative;
  aspect-ratio: 4 / 3;
  max-width: 100%;
  border: 1px solid var(--hw-line);
  border-radius: 10px;
  background: var(--hw-surface);
  overflow: hidden;
}
.hw-scene {
  position: absolute; inset: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);   /* lets the drawing fit by height in wide frames */
  padding: clamp(16px, 2.4vw, 28px);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.6s var(--hw-ease-out), transform 0.6s var(--hw-ease-out);
  pointer-events: none;
}
.hw-scene:first-child { opacity: 1; transform: none; }
.hw.is-live .hw-scene { opacity: 0; transform: translateY(10px); }
.hw.is-live .hw-scene.is-active { opacity: 1; transform: none; transition-delay: 0.15s; }
.hw-scene__cap {
  display: flex; justify-content: space-between; gap: 12px;
  font-family: var(--hw-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--hw-muted);
}
.hw-scene__cap b { font-weight: 500; color: var(--hw-accent); }
.hw-scene svg { width: 100%; height: 100%; min-height: 0; overflow: visible; align-self: center; }
.hw-pager {
  position: absolute;
  left: clamp(16px, 2.4vw, 28px); right: clamp(16px, 2.4vw, 28px);
  bottom: clamp(14px, 2vw, 22px);
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
}
.hw-pager i { height: 2px; border-radius: 2px; background: var(--hw-line); overflow: hidden; position: relative; }
.hw-pager i::after { content: ''; position: absolute; inset: 0; background: var(--hw-accent); transform: scaleX(0); transform-origin: left; }
.hw-pager i.done::after { transform: scaleX(1); }
.hw-pager i.now::after { transform: scaleX(1); transition: transform 0.6s var(--hw-ease-out); }
.hw-pager i::after { transition: transform 0.6s var(--hw-ease-out); }

/* Scene drawing system */
.hw .sc *{fill:none;stroke:var(--hw-line);stroke-width:1.25;stroke-linecap:round;stroke-linejoin:round;vector-effect:non-scaling-stroke}
.hw .sc .ln{stroke:var(--hw-ink-soft);opacity:.35}
.hw .sc .ac{stroke:var(--hw-accent)}
.hw .sc .fl{fill:var(--hw-accent);stroke:none}
.hw .sc .sf{fill:var(--hw-halo);stroke:none}
.hw .sc .pn{fill:var(--hw-bg);stroke:var(--hw-line)}
.hw .sc text{fill:var(--hw-muted);stroke:none;font-family:var(--hw-mono);font-size:12px;letter-spacing:.14em}

.hw .sc text.tk{fill:var(--hw-accent)}
.hw .sc [class*="a-"]{transform-box:fill-box}
/* Each scene's loop runs only while it is the active scene */

@keyframes hwScan{0%{transform:translateY(0);opacity:0}6%{opacity:1}70%{transform:translateY(186px);opacity:1}80%,100%{transform:translateY(186px);opacity:0}}
.hw .a-pop{transform-origin:center}
.hw.is-running .hw-scene.is-active .a-pop{animation-duration:4.5s;animation-timing-function:var(--hw-ease-out);animation-iteration-count:infinite;animation-fill-mode:both}
.hw.is-running .hw-scene.is-active .a-pop.d1{animation-name:hwPop1}.hw.is-running .hw-scene.is-active .a-pop.d2{animation-name:hwPop2}.hw.is-running .hw-scene.is-active .a-pop.d3{animation-name:hwPop3}
@keyframes hwPop1{0%,20%{opacity:0;transform:scale(.4)}26%,92%{opacity:1;transform:scale(1)}100%{opacity:0}}
@keyframes hwPop2{0%,40%{opacity:0;transform:scale(.4)}46%,92%{opacity:1;transform:scale(1)}100%{opacity:0}}
@keyframes hwPop3{0%,60%{opacity:0;transform:scale(.4)}66%,92%{opacity:1;transform:scale(1)}100%{opacity:0}}
.hw.is-running .hw-scene.is-active .a-pop.d4{animation-name:hwPop4}
@keyframes hwPop4{0%,66%{opacity:0;transform:scale(.4)}72%,92%{opacity:1;transform:scale(1)}100%{opacity:0}}   /* plan tick: lands with "You approve the plan" */
.hw.is-running .hw-scene.is-active .a-ping{animation:hwPing 1.6s var(--hw-ease-out) infinite}
.hw .a-ping{transform-origin:center}
@keyframes hwPing{0%{transform:scale(1);opacity:.7}100%{transform:scale(2.6);opacity:0}}
.hw.is-running .hw-scene.is-active .a-grow{animation:hwGrowx 4.5s var(--hw-ease-out) infinite both}
.hw .a-grow{transform-origin:0 50%}
@keyframes hwGrowx{0%,8%{transform:scaleX(0)}30%,92%{transform:scaleX(1)}100%{transform:scaleX(0)}}
.hw.is-running .hw-scene.is-active .a-grow.g2{animation-delay:.15s}.hw.is-running .hw-scene.is-active .a-grow.g3{animation-delay:.3s}
.hw.is-running .hw-scene.is-active .a-write{animation:hwGrowx 4.5s steps(12,end) infinite both}
.hw.is-running .hw-scene.is-active .a-write.g2{animation-delay:.5s}.hw.is-running .hw-scene.is-active .a-write.g3{animation-delay:1s}


@keyframes hwDraw{0%,20%{stroke-dashoffset:1;opacity:1}60%,92%{stroke-dashoffset:0;opacity:1}100%{stroke-dashoffset:0;opacity:0}}
.hw.is-running .hw-scene.is-active .a-dart{animation:hwDart 4.5s var(--hw-ease-out) infinite both}
@keyframes hwDart{0%,30%{transform:translate(60px,-40px);opacity:0}36%{opacity:1}48%,92%{transform:translate(0,0);opacity:1}100%{opacity:0}}
.hw .a-knob{transform:translateX(18px)}
.hw.is-running .hw-scene.is-active .a-knob{animation:hwKnob 4.5s var(--hw-ease-inout) infinite both}
@keyframes hwKnob{0%,10%{transform:translateX(0)}20%,92%{transform:translateX(18px)}100%{transform:translateX(0)}}
.hw .a-sw{fill:var(--hw-halo)}
.hw.is-running .hw-scene.is-active .a-sw{animation:hwSw 4.5s var(--hw-ease-inout) infinite both}
@keyframes hwSw{0%,10%{fill:transparent}20%,92%{fill:var(--hw-halo)}100%{fill:transparent}}
.hw.is-running .hw-scene.is-active .k2{animation-delay:.4s}.hw.is-running .hw-scene.is-active .k3{animation-delay:.8s}


@keyframes hwLive{from{stroke-dashoffset:1}to{stroke-dashoffset:0}}
.hw.is-running .hw-scene.is-active .a-blink{animation:hwBlink 1.2s steps(2,end) infinite}
@keyframes hwBlink{50%{opacity:.2}}


@keyframes hwGrowy{0%,4%{transform:scaleY(0)}16%,92%{transform:scaleY(1)}100%{transform:scaleY(0)}}


/* 04 compound: one echo per week (1.4s), each landing on a wider ring; 4 weeks per loop */
.hw .sc .a-pulse{transform-box:view-box;transform-origin:200px 168px;opacity:0}
.hw.is-running .hw-scene.is-active .a-pulse{animation:hwPulse 5.6s infinite}
@keyframes hwPulse{
  0%{transform:scale(.07);opacity:.9;animation-timing-function:cubic-bezier(.19,1,.22,1)}15%{transform:scale(.326);opacity:.9}22%{transform:scale(.36);opacity:0}24.9%{transform:scale(.07);opacity:0}
  25%{transform:scale(.07);opacity:.9;animation-timing-function:cubic-bezier(.19,1,.22,1)}40%{transform:scale(.472);opacity:.9}47%{transform:scale(.51);opacity:0}49.9%{transform:scale(.07);opacity:0}
  50%{transform:scale(.07);opacity:.9;animation-timing-function:cubic-bezier(.19,1,.22,1)}65%{transform:scale(.6875);opacity:.9}72%{transform:scale(.73);opacity:0}74.9%{transform:scale(.07);opacity:0}
  75%{transform:scale(.07);opacity:.9;animation-timing-function:cubic-bezier(.19,1,.22,1)}90%{transform:scale(1);opacity:.9}97%{transform:scale(1.04);opacity:0}100%{transform:scale(.07);opacity:0}}
.hw .sc .a-ring{stroke-width:1.6}
.hw.is-running .hw-scene.is-active .a-ring{animation:5.6s ease-out infinite both}
.hw.is-running .hw-scene.is-active .a-ring.w5{animation-name:hwW5}.hw.is-running .hw-scene.is-active .a-ring.w6{animation-name:hwW6}
.hw.is-running .hw-scene.is-active .a-ring.w7{animation-name:hwW7}.hw.is-running .hw-scene.is-active .a-ring.w8{animation-name:hwW8}
@keyframes hwW5{0%,14%{opacity:0}17%,25%{opacity:1}30%,96%{opacity:.65}100%{opacity:0}}
@keyframes hwW6{0%,39%{opacity:0}42%,50%{opacity:1}55%,96%{opacity:.75}100%{opacity:0}}
@keyframes hwW7{0%,64%{opacity:0}67%,75%{opacity:1}80%,96%{opacity:.85}100%{opacity:0}}
@keyframes hwW8{0%,89%{opacity:0}92%,96%{opacity:1}100%{opacity:0}}
.hw .sc .rp{opacity:0}.hw .sc .rp.r4{opacity:1}
.hw.is-running .hw-scene.is-active .rp{animation:5.6s step-end infinite both}
.hw.is-running .hw-scene.is-active .rp.r1{animation-name:hwRp1}.hw.is-running .hw-scene.is-active .rp.r2{animation-name:hwRp2}
.hw.is-running .hw-scene.is-active .rp.r3{animation-name:hwRp3}.hw.is-running .hw-scene.is-active .rp.r4{animation-name:hwRp4}
@keyframes hwRp1{0%,24%{opacity:1}25%,100%{opacity:0}}
@keyframes hwRp2{0%,24%{opacity:0}25%,49%{opacity:1}50%,100%{opacity:0}}
@keyframes hwRp3{0%,49%{opacity:0}50%,74%{opacity:1}75%,100%{opacity:0}}
@keyframes hwRp4{0%,74%{opacity:0}75%,100%{opacity:1}}


/* Shared: small labels and the bottom status strip (phases synced to each scene's loop) */
.hw .sc text.sm{font-size:10px}
.hw .sc .ph{opacity:0}.hw .sc .ph.last{opacity:1}
.hw.is-running .hw-scene.is-active .ph{animation:4.5s step-end infinite both}
.hw.is-running .hw-scene.is-active .p4a{animation-name:hwP4a}.hw.is-running .hw-scene.is-active .p4b{animation-name:hwP4b}
.hw.is-running .hw-scene.is-active .p4c{animation-name:hwP4c}.hw.is-running .hw-scene.is-active .p4d{animation-name:hwP4d}
@keyframes hwP4a{0%,19%{opacity:1}20%,100%{opacity:0}}
@keyframes hwP4b{0%,19%{opacity:0}20%,39%{opacity:1}40%,100%{opacity:0}}
@keyframes hwP4c{0%,39%{opacity:0}40%,59%{opacity:1}60%,100%{opacity:0}}
@keyframes hwP4d{0%,59%{opacity:0}60%,100%{opacity:1}}
.hw.is-running .hw-scene.is-active .p3a{animation-name:hwP3a}.hw.is-running .hw-scene.is-active .p3b{animation-name:hwP3b}.hw.is-running .hw-scene.is-active .p3c{animation-name:hwP3c}
@keyframes hwP3a{0%,32%{opacity:1}33%,100%{opacity:0}}
@keyframes hwP3b{0%,32%{opacity:0}33%,65%{opacity:1}66%,100%{opacity:0}}
@keyframes hwP3c{0%,65%{opacity:0}66%,100%{opacity:1}}
.hw.is-running .hw-scene.is-active .a-scan1{animation:hwScan1 4.5s var(--hw-ease-inout) infinite}
@keyframes hwScan1{0%{transform:translateY(0);opacity:0}6%{opacity:1}60%{transform:translateY(132px);opacity:1}68%,100%{transform:translateY(132px);opacity:0}}
.hw .sc .a-settle{vector-effect:none;stroke-width:1.6;stroke-dasharray:1;stroke-dashoffset:0}
.hw.is-running .hw-scene.is-active .a-settle{animation:hwSettle 4.5s var(--hw-ease-inout) infinite both}
@keyframes hwSettle{0%,4%{stroke-dashoffset:1;opacity:1}90%,96%{stroke-dashoffset:0;opacity:1}100%{stroke-dashoffset:0;opacity:0}}


/* ── Roadmap: a spine through the four milestones. how.js fills it to a
   reading line as you scroll; a signal head rides the fill; each node it
   reaches fills and sends out two echo rings; the last keeps looping. ── */
.hw-roadmap { position: relative; --node: 44px; }
.hw-road {
  position: absolute;
  left: calc(var(--node) / 2 - 1px);
  top: var(--road-top, 22px);
  height: var(--road-h, calc(100% - 44px));
  width: 2px;
  border-radius: 2px;
  background: var(--hw-line);
  pointer-events: none;
}
.hw-road__fill {
  position: absolute; inset: 0;
  border-radius: 2px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--hw-accent) 45%, transparent), var(--hw-accent));
  transform-origin: top;
  transform: scaleY(var(--p, 1));           /* no-JS: fully drawn */
}
.hw-road__head {
  position: absolute;
  left: 50%; top: 0;
  width: 10px; height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  background: var(--hw-accent);
  box-shadow: 0 0 0 4px var(--hw-halo), 0 0 18px 4px color-mix(in srgb, var(--hw-accent) 45%, transparent);
  transform: translateY(var(--y, 0px));
  opacity: var(--head-o, 0);
  transition: opacity 0.4s ease;
}

.hw-steps { list-style: none; margin: 0; padding: 0; position: relative; }
.hw-step {
  position: relative;
  display: grid;
  grid-template-columns: var(--node) minmax(0, 1fr);
  gap: 1.5rem;
  padding-block: 1.4rem;
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}
.hw-step + .hw-step { margin-top: 0.4rem; }
/* the milestone node */
.hw-step__idx {
  position: relative;
  z-index: 1;
  width: var(--node); height: var(--node);
  border-radius: 50%;
  border: 1px solid var(--hw-line);
  background: var(--hw-bg);
  display: grid; place-items: center;
  transition: background-color 0.5s var(--hw-ease-out), border-color 0.5s var(--hw-ease-out), box-shadow 0.5s var(--hw-ease-out);
}
.hw-step__idx b {
  font-family: var(--hw-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--hw-muted);
  transition: color 0.5s var(--hw-ease-out);
}
.hw-step__idx::before,
.hw-step__idx::after {
  content: '';
  position: absolute; inset: -1px;
  border-radius: 50%;
  border: 1px solid var(--hw-accent);
  opacity: 0;
  pointer-events: none;
}
.hw-step.is-reached .hw-step__idx { border-color: var(--hw-accent); box-shadow: 0 0 0 5px var(--hw-halo); }
.hw-step.is-reached .hw-step__idx b { color: var(--hw-accent); }
.hw-step.is-active .hw-step__idx { background: var(--hw-accent); }
.hw-step.is-active .hw-step__idx b { color: #fff; }
/* echo: two rings leave the node the moment the signal reaches it */
.hw-step.is-reached .hw-step__idx::before { animation: hwEcho 1.6s var(--hw-ease-out) 1; }
.hw-step.is-reached .hw-step__idx::after  { animation: hwEcho 1.6s var(--hw-ease-out) 0.3s 1; }
@keyframes hwEcho { 0% { transform: scale(1); opacity: 0.7; } 100% { transform: scale(2.3); opacity: 0; } }
/* the last milestone never ends: a slow orbit around the node */
.hw-step--loop .hw-step__idx > i {
  position: absolute; inset: -9px;
  border-radius: 50%;
  border: 1px dashed color-mix(in srgb, var(--hw-accent) 55%, transparent);
  opacity: 0;
  transition: opacity 0.6s ease;
}
.hw-step--loop.is-reached .hw-step__idx > i { opacity: 1; animation: hwOrbitRing 9s linear infinite; }
@keyframes hwOrbitRing { to { transform: rotate(360deg); } }

.hw-step__main { min-width: 0; display: grid; gap: 6px; align-content: start; padding-top: 0.15rem; }
.hw-step__when {
  justify-self: start;
  font-family: var(--hw-mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--hw-accent);
  background: var(--hw-halo);
  border-radius: 999px;
  padding: 3px 10px;
  margin-bottom: 0.25rem;
}
.hw-step__title {
  font-family: var(--font-head);
  font-weight: 500;
  font-size: clamp(1.4rem, 1.15rem + 0.6vw, 1.75rem);
  line-height: 1.15;
  margin: 0;
  color: var(--hw-ink);
  transition: color 0.25s var(--hw-ease-out);
}
.hw-step__body { margin: 0; color: var(--hw-ink-soft); max-width: 46ch; line-height: 1.6; transition: opacity 0.6s var(--hw-ease-out); }
.hw-free {
  display: inline-block;
  font-family: var(--hw-mono);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--hw-accent);
  border: 1px solid var(--hw-accent);
  border-radius: 999px;
  padding: 1px 8px;
  margin-left: 10px;
  vertical-align: 0.4em;
}
.hw.is-live .hw-step:not(.is-active) .hw-step__body { opacity: 0.55; }
.hw-step:hover .hw-step__title { color: var(--hw-accent); }
.hw-step:focus-visible { outline: 2px solid var(--hw-accent); outline-offset: 4px; border-radius: 6px; }

/* desktop: the stage stays beside the roadmap while you read it */
@media (min-width: 960px) {
  .hw-stage { position: sticky; top: var(--hw-top, 96px); }
}

/* ── Close ── */
.hw-close { display: flex; flex-wrap: wrap; gap: 1rem 2rem; align-items: center; margin-top: 2rem; }
.hw-cta span { display: inline-block; transition: transform 0.25s var(--hw-ease-out); }
.hw-cta:hover span { transform: translateX(4px); }

/* ── Stacked layout: the stage sticks under the header while the steps
   scroll beneath it; how.js activates the row crossing just below it. ── */
@media (max-width: 959px) {
  .hw__body { display: block; }
  .hw__body > .hw-rv + .hw-rv { margin-top: 2.5rem; }
  .hw-stage {
    position: sticky;
    top: var(--hw-top, 84px);
    z-index: 2;
    max-width: 560px;
    margin-inline: auto;
    /* the first shadow is a solid strip of the section colour above the stage:
       it hides list text passing through the gap under the header */
    box-shadow: 0 -14px 0 2px var(--hw-bg), 0 22px 34px -26px rgba(30, 16, 64, 0.35);
  }
}
/* tablets: full-width stage (nothing scrolls past its sides), in a wider
   frame so it doesn't take most of the screen */
@media (min-width: 641px) and (max-width: 959px) {
  .hw-stage { max-width: none; aspect-ratio: 16 / 9; }
}
/* short landscape phones: not enough height to keep the stage on screen */
@media (max-width: 959px) and (max-height: 560px) {
  .hw-stage { position: relative; top: auto; }
}

/* ── Phones ── */
@media (max-width: 640px) {
  .hw__body { margin-top: 2.5rem; }
  .hw-roadmap { --node: 36px; }
  .hw-step { gap: 1rem; padding-block: 1.1rem; }
  .hw-close { flex-direction: column; align-items: stretch; text-align: center; gap: 0.85rem; }
  .hw-cta { justify-content: center; }
  .hw-scene { padding: 14px; }
  .hw-pager { left: 14px; right: 14px; bottom: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .hw .sc *, .hw-step__idx::before, .hw-step__idx::after, .hw-step--loop .hw-step__idx > i { animation: none !important; }
  .hw-road__head { display: none; }
  .hw-rv, .hw-scene { transition: none; }
}
