/* ========== HOW IT WORKS: step illustrations ==========
   Each .step-visual always shows its finished picture. While a step is hovered
   (.is-live, set by how-it-works.js) it plays a short loop that starts and ends on that
   same picture; on touch screens it plays once when it scrolls into view. */

.step-visual {
  position: relative;
  height: 210px;
  margin-bottom: 1.25rem;
  background: var(--surface, #18181b);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
  border-radius: 16px;
  overflow: hidden;
  text-align: left;
  font-size: 12.5px;
  color: var(--text, #fafafa);
}
.step-visual * { box-sizing: border-box; }

/* The pictures carry the order now, so the numbered tiles are dropped */
#how .step-number { display: none; }

/* ---- shared: one loop is 2.4 s; each keyframe starts and ends at rest ---- */
@keyframes hv-pulse { 0% { transform: scale(1); } 8% { transform: scale(1.22); } 18%, 100% { transform: scale(1); } }
@keyframes hv-nudge { 0% { transform: scale(1); } 8% { transform: scale(1.04); } 18%, 100% { transform: scale(1); } }
@keyframes hv-blink { 0%, 100% { opacity: 1; } 10% { opacity: 0.3; } 20% { opacity: 1; } }
@keyframes hv-shake { 0%, 16%, 100% { transform: rotate(0); } 4% { transform: rotate(-12deg); } 8% { transform: rotate(10deg); } 12% { transform: rotate(-6deg); } }
@keyframes hv-remeasure { 0% { transform: scaleX(1); } 12% { transform: scaleX(0.84); } 26% { transform: scaleX(1.03); } 34%, 100% { transform: scaleX(1); } }

/* ===== 1. Connect Slack ===== */
.hv1-link {
  position: absolute;
  top: 16px;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.hv1-tile {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.hv1-slack { background: #3f0e40; color: #fff; font-weight: 800; font-size: 18px; }
.hv1-hear { background: #8b5cf6; }
.hv1-hear i {
  position: absolute;
  left: 50%;
  top: 50%;
  border: 2px solid #fff;
  border-radius: 50%;
}
.hv1-hear i:first-child { width: 14px; height: 14px; margin: -7px 0 0 -7px; opacity: 0.9; }
.hv1-hear i:last-child { width: 22px; height: 22px; margin: -11px 0 0 -11px; opacity: 0.4; }
.hv1-wire {
  position: relative;
  width: 64px;
  height: 0;
  border-top: 2px dashed rgba(255, 255, 255, 0.18);
}
.hv1-wire::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: -2px;
  height: 2px;
  background: #10b981;
  transform-origin: 0 50%;
}
.hv1-spark {
  position: absolute;
  top: -5px;
  left: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #a78bfa;
  opacity: 0;
}
@keyframes hv1-travel { 0% { opacity: 0; transform: translateX(0); } 4% { opacity: 1; } 26% { opacity: 1; } 30%, 100% { opacity: 0; transform: translateX(56px); } }

.hv1-list {
  position: absolute;
  top: 64px;
  left: 22px;
  right: 22px;
}
.hv1-row {
  height: 22px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted-light, #a1a1aa);
}
.hv1-box {
  position: relative;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1.5px solid rgba(255, 255, 255, 0.22);
  flex: none;
}
.hv1-box::after {
  content: '';
  position: absolute;
  inset: -1.5px;
  border-radius: 4px;
  background: #8b5cf6 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath d='M3.5 7.2l2.3 2.2 4.7-5' fill='none' stroke='white' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 14px no-repeat;
}
.hv1-row.private { color: var(--muted, #71717a); }
.hv1-row.private svg { width: 14px; height: 14px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.hv1-never {
  margin-left: auto;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #fb7185;
  background: rgba(244, 63, 94, 0.1);
  border-radius: 5px;
  padding: 1px 6px;
}
.hv1-btn {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 16px;
  height: 30px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 12.5px;
}
.hv1-btn span {
  position: absolute;
  inset: 0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.hv1-btn .a { background: #8b5cf6; color: #fff; opacity: 0; }
.hv1-btn .b { background: rgba(16, 185, 129, 0.14); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.35); }

/* ===== 2. AI analyzes signals ===== */
.hv2-msg {
  position: absolute;
  left: 16px;
  width: 126px;
  height: 40px;
  border-radius: 10px;
  background: #232329;
  padding: 9px 10px 0 34px;
}
.hv2-msg::before {
  content: '';
  position: absolute;
  left: 9px;
  top: 9px;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: var(--c);
}
.hv2-msg b, .hv2-msg u {
  display: block;
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.16);
}
.hv2-msg b { width: 80%; margin-bottom: 6px; }
.hv2-msg u { width: 52%; }
.hv2-m1 { top: 24px; --c: #4a90d9; }
.hv2-m2 { top: 85px; --c: #7d5ba6; }
.hv2-m3 { top: 146px; --c: #e8912d; }

.hv2-dot {
  position: absolute;
  left: 134px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--c);
  opacity: 0;
}
.hv2-d1 { top: 40px; --c: #f43f5e; --tx: 40px; --ty: 52px; }
.hv2-d2 { top: 101px; --c: #f59e0b; --tx: 40px; --ty: 19px; }
.hv2-d3 { top: 162px; --c: #10b981; --tx: 40px; --ty: -14px; }
@keyframes hv2-travel {
  0% { opacity: 0; transform: translate(0, 0) scale(0.5); }
  5% { opacity: 1; transform: translate(calc(var(--tx) * 0.2), 0) scale(1); }
  25%, 100% { opacity: 0; transform: translate(var(--tx), var(--ty)) scale(0.6); }
}

.hv2-spark {
  position: absolute;
  left: 162px;
  right: 16px;
  top: 24px;
  height: 56px;
  width: auto;
  overflow: visible;
}
.hv2-spark path {
  fill: none;
  stroke: #a78bfa;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 200;
  --len: 200;
}
.hv2-spark circle { fill: #f43f5e; }
.hv2-tags {
  position: absolute;
  left: 162px;
  top: 92px;
  display: grid;
  gap: 6px;
}
.hv2-tag {
  justify-self: start;
  height: 22px;
  line-height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 13%, transparent);
}
.hv2-t1 { --c: #fb7185; }
.hv2-t2 { --c: #fbbf24; }
.hv2-t3 { --c: #34d399; }

/* ===== 3. You see what matters ===== */
.hv3-head {
  position: absolute;
  top: 16px;
  left: 18px;
  right: 18px;
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted, #71717a);
}
.hv3-live { color: #34d399; display: flex; align-items: center; gap: 5px; }
.hv3-live::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #10b981; }
.hv3-rows { position: absolute; top: 42px; left: 18px; right: 18px; }
.hv3-row { height: 24px; display: flex; align-items: center; gap: 10px; }
.hv3-row span:first-child { width: 58px; color: var(--muted-light, #a1a1aa); }
.hv3-bar { flex: 1; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.05); overflow: hidden; }
.hv3-bar i { display: block; height: 100%; border-radius: 3px; background: var(--c); transform-origin: 0 50%; }
.hv3-row b { width: 22px; text-align: right; font-weight: 600; color: var(--c); }
.hv3-alert {
  position: absolute;
  left: 14px;
  right: 14px;
  top: 124px;
  height: 32px;
  border-radius: 9px;
  border: 1px solid rgba(244, 63, 94, 0.4);
  background: rgba(244, 63, 94, 0.09);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  color: #fecdd3;
  font-weight: 500;
}
.hv3-alert i { width: 7px; height: 7px; border-radius: 50%; background: #f43f5e; flex: none; }
.hv3-alert em { margin-left: auto; font-style: normal; color: #fb7185; font-weight: 600; }
.hv3-kudos {
  position: absolute;
  left: 14px;
  right: 14px;
  top: 162px;
  height: 32px;
  border-radius: 9px;
  border: 1px solid rgba(16, 185, 129, 0.35);
  background: rgba(16, 185, 129, 0.08);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  color: #a7f3d0;
  font-weight: 500;
}
.hv3-kudos i { width: 7px; height: 7px; border-radius: 50%; background: #10b981; flex: none; }

/* ================= Playback =================
   Nothing is hidden: the resting picture is the finished one. .is-live runs the loop. */
.hv1-row.private svg,
.hv2-spark circle { transform-box: fill-box; transform-origin: center; }
.step.is-live * ,
.step.is-live *::before,
.step.is-live *::after { animation-duration: 2.4s; animation-iteration-count: infinite; animation-fill-mode: both; }

/* 1: a spark runs Slack -> Hear, the channels tick again, the lock holds, Connected nods */
.step.is-live .hv1-spark { animation-name: hv1-travel; animation-timing-function: ease-in-out; }
.step.is-live .hv1-box::after { animation-name: hv-pulse; animation-delay: 0.5s; }
.step.is-live .hv1-row:nth-child(2) .hv1-box::after { animation-delay: 0.62s; }
.step.is-live .hv1-row:nth-child(3) .hv1-box::after { animation-delay: 0.74s; }
.step.is-live .hv1-row.private svg { animation-name: hv-shake; animation-delay: 0.95s; }
.step.is-live .hv1-btn .b { animation-name: hv-nudge; animation-delay: 1.15s; }

/* 2: signals leave the messages, each tag reacts as its signal lands, the trend end pulses */
.step.is-live .hv2-dot { animation-name: hv2-travel; animation-timing-function: ease-in; }
.step.is-live .hv2-d2 { animation-delay: 0.12s; }
.step.is-live .hv2-d3 { animation-delay: 0.24s; }
.step.is-live .hv2-t1 { animation-name: hv-nudge; animation-delay: 0.5s; }
.step.is-live .hv2-t2 { animation-name: hv-nudge; animation-delay: 0.62s; }
.step.is-live .hv2-t3 { animation-name: hv-nudge; animation-delay: 0.74s; }
.step.is-live .hv2-spark circle { animation-name: hv-pulse; animation-delay: 0.95s; }

/* 3: the bars re-measure, LIVE blinks, the alert and the kudos dots pulse */
.step.is-live .hv3-bar i { animation-name: hv-remeasure; animation-timing-function: cubic-bezier(0.45, 0, 0.25, 1); }
.step.is-live .hv3-row:nth-child(2) .hv3-bar i { animation-delay: 0.08s; }
.step.is-live .hv3-row:nth-child(3) .hv3-bar i { animation-delay: 0.16s; }
.step.is-live .hv3-live::before { animation-name: hv-blink; }
.step.is-live .hv3-alert i { animation-name: hv-pulse; animation-delay: 0.7s; }
.step.is-live .hv3-kudos i { animation-name: hv-pulse; animation-delay: 0.95s; }

@media (prefers-reduced-motion: reduce) {
  .step-visual *,
  .step-visual *::before,
  .step-visual *::after { animation: none !important; }
}
