/* ==========================================================================
   Analytics & AI · 5 — How it works
   "One pipeline": the four steps as one journey, each stage a small scene,
   joined by connectors:
       [Finflow]            ○─○                 "Which villages …"     ┌ ▇▇▇ ┐
       [Your system] ──▶   ○─●─○  ──▶    Web · WhatsApp · …    ──▶  │dash │
       [Any other data]     ○─○                                       └─────┘
        1 Connect           2 Link              3 Ask                4 Build and share
   Arrival (.is-visible on the flow, from reveal.js): a pulse travels the
   pipeline once; each stage lights in turn (--s × 0.55s), its scene plays,
   and the connector to the next draws. Prefixed .hw- and scoped to .hw.
   ========================================================================== */

.hw {
  --hw-frame: #FFFFFF;
  --hw-dot:   rgba(10,47,107,0.13);
  --hw-step:  0.55s;
  padding: clamp(72px, 9vw, 120px) var(--page-px);
  background: var(--surface-raised);
  border-top: 1px solid var(--border);
}
:root[data-theme="dark"] .hw { --hw-frame: #0B1F42; --hw-dot: rgba(147,190,240,0.12); }

.hw-inner { max-width: var(--container); margin: 0 auto; }
.hw-title { margin-bottom: clamp(32px, 4vw, 48px); font-size: var(--fs-section-title); font-weight: 600; line-height: 1.12; letter-spacing: -0.03em; }
.hw-title em { font-style: normal; color: var(--accent); }

.hw-flow { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 40px; margin: 0; padding: 0; list-style: none; }
.hw-step { position: relative; display: flex; flex-direction: column; }

/* each stage: a quiet well with a dot grid */
.hw-stage {
  position: relative;
  isolation: isolate;
  display: grid;
  place-items: center;
  height: 168px;
  padding: 14px;
  background: var(--hw-frame);
  border: 1px solid var(--border);
  border-radius: 14px;
  transition: border-color 0.35s ease, box-shadow 0.35s ease;
}
.hw-stage::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background-image: radial-gradient(circle, var(--hw-dot) 0.9px, transparent 1.3px);
  background-size: 14px 14px;
  background-position: 7px 7px;
  -webkit-mask-image: radial-gradient(ellipse 80% 75% at 50% 50%, #000 30%, transparent 90%);
          mask-image: radial-gradient(ellipse 80% 75% at 50% 50%, #000 30%, transparent 90%);
}
/* the connector to the next stage */
.hw-step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 84px;
  left: 100%;
  width: 40px;
  height: 2px;
  background: linear-gradient(90deg, var(--accent) 0 0) left / 0% 100% no-repeat, var(--border-strong);
  border-radius: 2px;
}
.hw-step:not(:last-child)::before {
  content: '';
  position: absolute;
  top: 80px;
  left: calc(100% + 32px);
  width: 8px; height: 8px;
  border-top: 2px solid var(--border-strong);
  border-right: 2px solid var(--border-strong);
  transform: rotate(45deg);
  z-index: 1;
}

.hw-t { display: flex; align-items: center; gap: 10px; margin-top: 20px; font-family: var(--font-display); font-size: 18px; font-weight: 600; letter-spacing: -0.02em; color: var(--text-primary); }
.hw-t em { display: grid; place-items: center; width: 26px; height: 26px; font-style: normal; font-family: var(--font-mono); font-size: 12px; font-weight: 500; color: var(--accent-text); background: var(--accent-soft); border-radius: 8px; }
.hw-p { margin-top: 8px; font-size: 14px; line-height: 1.6; color: var(--text-secondary); }

/* 1 · Connect */
.hw-srcs { display: flex; flex-direction: column; gap: 7px; width: 100%; max-width: 200px; }
.hw-src { display: flex; align-items: center; gap: 8px; padding: 7px 10px; font-size: 12px; font-weight: 500; color: var(--text-primary); background: var(--hw-frame); border: 1px solid var(--border-strong); border-radius: 9px; }
.hw-src img { display: block; }
.hw-src .ti { font-size: 15px; color: var(--text-muted); }

/* 2 · Link */
.hw-web { width: 100%; max-width: 240px; height: auto; overflow: visible; }
.hw-edges path { fill: none; stroke: var(--accent-line); stroke-width: 1.5; stroke-dasharray: 1; }
.hw-node rect { fill: var(--hw-frame); stroke: var(--border-strong); }
.hw-node text { font-family: var(--font-body); font-size: 10px; font-weight: 500; fill: var(--text-primary); text-anchor: middle; }
.hw-node--hub rect { fill: var(--accent); stroke: none; }
.hw-node--hub text { fill: #FFFFFF; font-weight: 600; }
:root[data-theme="dark"] .hw-node--hub text { fill: #0B1F42; }

/* 3 · Ask */
.hw-ask { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 220px; }
.hw-q { align-self: flex-end; max-width: 92%; padding: 7px 10px; font-size: 11.5px; line-height: 1.35; color: #FFFFFF; background: var(--accent); border-radius: 11px 11px 3px 11px; }
:root[data-theme="dark"] .hw-q { color: #0B1F42; }
.hw-chs { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.hw-chs span { display: inline-flex; align-items: center; gap: 5px; padding: 5px 7px; font-size: 11px; color: var(--text-secondary); background: var(--hw-frame); border: 1px solid var(--border); border-radius: 7px; }
.hw-chs .ti { font-size: 13px; color: var(--accent); }

/* 4 · Build and share */
.hw-dash { width: 100%; max-width: 220px; padding: 10px 11px 9px; background: var(--hw-frame); border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: 0 14px 28px -22px rgba(10,47,107,0.35); }
.hw-dash-h { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 8px; }
.hw-dash-h b { font-size: 11px; font-weight: 600; color: var(--text-primary); white-space: nowrap; }
.hw-dash-h span { display: inline-flex; align-items: center; gap: 3px; padding: 1px 6px; font-size: 9.5px; font-weight: 600; color: var(--good); background: var(--good-soft); border-radius: 99px; }
.hw-dash-h .ti { font-size: 10px; }
.hw-cols { display: flex; align-items: flex-end; gap: 5px; height: 54px; padding-bottom: 1px; border-bottom: 1px solid var(--border); }
.hw-cols i { flex: 1; height: calc(var(--h) * 100%); background: var(--accent); border-radius: 3px 3px 0 0; transform-origin: bottom; }
.hw-dash small { display: inline-flex; align-items: center; gap: 4px; margin-top: 6px; font-size: 9.5px; color: var(--text-muted); }
.hw-dash small .ti { font-size: 10px; }

/* ─── Arrival: one pulse through the pipeline ─────────────────────────── */
html.has-js .hw-flow:not(.is-visible) .hw-stage > * { opacity: 0.35; }
.hw-flow.is-visible .hw-stage { animation: hw-lit 0.9s ease calc(var(--s) * var(--hw-step)) both; }
.hw-flow.is-visible .hw-stage > * { animation: hw-in 0.45s cubic-bezier(0.22, 1, 0.36, 1) calc(var(--s) * var(--hw-step)) both; }
.hw-flow.is-visible .hw-step:not(:last-child)::after { animation: hw-wire 0.4s ease calc(var(--s) * var(--hw-step) + 0.3s) both; }
.hw-flow.is-visible .hw-step:not(:last-child)::before { animation: hw-head 0.2s ease calc(var(--s) * var(--hw-step) + 0.6s) both; }
.hw-flow.is-visible .hw-edges path { animation: hw-draw 0.45s ease calc(var(--hw-step) + 0.1s + var(--i) * 60ms) both; }
.hw-flow.is-visible .hw-node { animation: hw-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) calc(var(--hw-step) + var(--i) * 50ms) both; }
.hw-flow.is-visible .hw-cols i { animation: hw-rise 0.5s cubic-bezier(0.22, 1, 0.36, 1) calc(3 * var(--hw-step) + 0.1s) both; }
.hw-node { transform-box: fill-box; transform-origin: center; }

@keyframes hw-lit  { 0% { border-color: var(--border); } 40% { border-color: var(--accent-line); box-shadow: 0 0 0 4px var(--accent-soft); } 100% { border-color: var(--border); box-shadow: 0 0 0 0 transparent; } }
@keyframes hw-in   { from { opacity: 0.35; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes hw-wire { from { background-size: 0% 100%, auto; } to { background-size: 100% 100%, auto; } }
@keyframes hw-head { from { border-color: var(--border-strong); } to { border-color: var(--accent); } }
@keyframes hw-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes hw-pop  { from { opacity: 0; transform: scale(0.7); } }
@keyframes hw-rise { from { transform: scaleY(0); } }
.hw-flow.is-visible .hw-step:not(:last-child)::after { background-size: 100% 100%, auto; }
.hw-flow.is-visible .hw-step:not(:last-child)::before { border-color: var(--accent); }

@media (max-width: 1000px) {
  .hw-flow { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 44px; }
  .hw-step:nth-child(2)::after, .hw-step:nth-child(2)::before { display: none; }
}
@media (max-width: 560px) {
  .hw-flow { grid-template-columns: minmax(0, 1fr); }
  .hw-step::after, .hw-step::before { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .hw-flow.is-visible *, .hw-flow.is-visible .hw-step::after, .hw-flow.is-visible .hw-step::before { animation: none !important; }
  html.has-js .hw-flow:not(.is-visible) .hw-stage > * { opacity: 1; }
}
