/* How it works: three small looping phone animations, one above each step.
   how.js sets data-step on each .mini-phone; every rule below just says what each step looks like.
   The phone runs off the bottom of its gray box on purpose (the bottom 64px are hidden),
   so everything inside is placed above that line: "bottom: 56px" = the bottom edge you can see. */

.how-stage {
  position: relative; height: 340px; margin-bottom: 22px; overflow: hidden;
  border-radius: var(--radius-card); background: var(--bg-gray);
}

/* The phone (only its top part shows) */
.mini-phone {
  position: absolute; top: 28px; left: 50%; width: 250px; height: 376px; margin-left: -125px;
  padding: 8px; border-radius: 40px; background: #111111; box-shadow: 0 20px 40px rgba(0, 0, 0, 0.14);
  color: #000000; text-align: left;
}
.mini-side {
  position: absolute; right: -3px; top: 96px; width: 3px; height: 46px;
  border-radius: 0 2px 2px 0; background: #111111;
}
.mini-screen {
  position: relative; height: 100%; overflow: hidden;
  border-radius: 32px 32px 0 0; background: #F2F2F7;
}
.mini-status {
  position: relative; height: 30px; padding: 0 22px;
  display: flex; align-items: center; font-size: 12px; font-weight: 600;
}
.mini-island {
  position: absolute; top: 8px; left: 50%; width: 70px; height: 20px; margin-left: -35px;
  border-radius: 10px; background: #000000;
}

/* A screen inside a phone: fades in on its own step (each demo lists which steps below) */
.hw-scene {
  position: absolute; top: 30px; left: 12px; right: 12px; bottom: 68px;
  opacity: 0; transform: translateY(8px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

/* "Finger" tap */
.hw-tap {
  position: absolute; width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50%;
  background: rgba(0, 0, 0, 0.25); opacity: 0; transform: scale(1.6);
  transition: opacity 0.2s ease, transform 0.2s ease; pointer-events: none;
}

/* ---------- Step 1: say it or type it ---------- */
.hw-pad { position: absolute; top: 30px; left: 12px; right: 12px; }
.hw-title { font-size: 15px; font-weight: 700; margin: 4px 0 8px; }

/* Say it | Type it switch; the white pill slides to whichever is in use */
.hw-seg {
  position: relative; display: flex; padding: 2px; margin-bottom: 10px;
  border-radius: 9px; background: #E3E3E8; font-size: 12px; font-weight: 600;
}
.hw-seg span { position: relative; z-index: 1; flex: 1; padding: 5px 0; text-align: center; }
.hw-seg::before {
  content: ""; position: absolute; top: 2px; bottom: 2px; left: 2px; width: calc(50% - 2px);
  border-radius: 7px; background: #FFFFFF; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  transition: transform 0.3s ease;
}
[data-step^="type"] .hw-seg::before { transform: translateX(100%); }

.hw-text {
  min-height: 88px; padding: 11px 12px; border-radius: 14px; background: #FFFFFF;
  font-size: 15px; line-height: 1.35; font-weight: 500; transition: opacity 0.3s ease;
}
[data-step$="-end"] .hw-text { opacity: 0; }
.hw-word { opacity: 0; transition: opacity 0.25s ease; }
.hw-word.shown { opacity: 1; }
.hw-caret {
  display: inline-block; width: 2px; height: 17px; margin-left: 1px; vertical-align: -3px;
  background: #007AFF; animation: hw-blink 1s steps(1) infinite;
}
@keyframes hw-blink { 50% { opacity: 0; } }

/* Talking: red sound waves + stop button */
.hw-voice {
  position: absolute; left: 0; right: 0; bottom: 56px; height: 86px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  opacity: 0; transition: opacity 0.3s ease;
}
[data-step="say"] .hw-voice, [data-step="say-stop"] .hw-voice { opacity: 1; }
.hw-waves { display: flex; align-items: center; gap: 4px; height: 22px; }
.hw-waves i { width: 4px; height: 5px; border-radius: 2px; background: #FF3B30; }
[data-step="say"] .hw-waves i { animation: hw-wave 0.9s ease-in-out infinite; }
.hw-waves i:nth-child(2) { animation-delay: -0.2s; }
.hw-waves i:nth-child(3) { animation-delay: -0.5s; }
.hw-waves i:nth-child(4) { animation-delay: -0.1s; }
.hw-waves i:nth-child(5) { animation-delay: -0.6s; }
.hw-waves i:nth-child(6) { animation-delay: -0.3s; }
.hw-waves i:nth-child(7) { animation-delay: -0.7s; }
@keyframes hw-wave { 0%, 100% { height: 5px; } 50% { height: 20px; } }
.hw-stop {
  width: 44px; height: 44px; border-radius: 50%; background: #FF3B30;
  box-shadow: 0 0 0 6px #FFE5E3; display: grid; place-items: center; transition: transform 0.15s ease;
}
.hw-stop span { width: 15px; height: 15px; border-radius: 4px; background: #FFFFFF; }
[data-step="say-stop"] .hw-stop { transform: scale(0.86); }

/* Typing: a keyboard slides up (how.js adds the keys). Its bottom edge runs off the visible part, like the phone. */
.hw-keys {
  position: absolute; left: 0; right: 0; bottom: 40px; padding: 6px 3px 6px;
  display: flex; flex-direction: column; gap: 5px; background: #D1D3D9;
  transform: translateY(calc(100% + 40px)); transition: transform 0.35s ease;
}
[data-step="type"] .hw-keys { transform: none; }
.hw-key-row { display: flex; gap: 4px; }
.hw-key-row:nth-child(2) { padding: 0 10px; }
.hw-key-row:nth-child(3) { padding: 0 30px; }
.hw-key-row i {
  flex: 1; height: 20px; border-radius: 4px; background: #FFFFFF;
  box-shadow: 0 1px 0 #898A8D; transition: background 0.08s ease;
}
.hw-key-row i.down { background: #AEB2BA; }

/* ---------- Step 2: PayZolo builds the link ---------- */
[data-step="think"] .hw-think,
[data-step="review"] .hw-review,
[data-step="tap"] .hw-review,
[data-step="copied"] .hw-review { opacity: 1; transform: none; }

/* Thinking: "Building your pay link…" over a placeholder card, centered on the screen */
.hw-think { display: flex; flex-direction: column; justify-content: center; }
.hw-thinking { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 12px; font-size: 13px; color: #8A8A8E; }
.hw-dots { display: flex; gap: 4px; }
.hw-dots i { width: 6px; height: 6px; border-radius: 50%; background: #007AFF; animation: hw-bounce 0.9s ease-in-out infinite; }
.hw-dots i:nth-child(2) { animation-delay: 0.15s; }
.hw-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes hw-bounce { 0%, 60%, 100% { transform: none; opacity: 0.4; } 30% { transform: translateY(-4px); opacity: 1; } }
.hw-skeleton { display: grid; gap: 9px; padding: 14px; border-radius: 14px; background: #FFFFFF; }
.hw-skeleton i { height: 10px; border-radius: 5px; background: #E5E5EA; animation: hw-pulse 1s ease-in-out infinite; }
.hw-skeleton i:nth-child(1) { width: 45%; }
.hw-skeleton i:nth-child(2) { width: 70%; height: 20px; }
.hw-skeleton i:nth-child(3) { width: 90%; }
@keyframes hw-pulse { 50% { opacity: 0.45; } }

.hw-review-title { font-size: 17px; font-weight: 700; margin: 4px 0 8px; }
.hw-card { padding: 12px; border-radius: 14px; background: #FFFFFF; font-size: 12px; }
.hw-card-biz { font-weight: 600; }
.hw-card-what { color: #8A8A8E; margin-top: 1px; }
.hw-card-amount { font-size: 24px; font-weight: 600; letter-spacing: -0.5px; margin: 4px 0 6px; font-variant-numeric: tabular-nums; }
.hw-card-amount small { font-size: 11px; font-weight: 500; color: #8A8A8E; letter-spacing: 0; }
/* Amounts never shrink or wrap; the words get whatever room is left (iPhone fonts are wider). */
.hw-row { display: flex; align-items: center; gap: 6px; padding: 5px 0; border-top: 1px solid #E5E5EA; }
.hw-row-text { flex: 1; min-width: 0; }
.hw-row-text em { display: block; font-style: normal; font-size: 10px; color: #8A8A8E; margin-top: 1px; }
.hw-row > span:last-child { flex: none; white-space: nowrap; padding-left: 4px; }
.hw-icon { width: 15px; height: 15px; flex: none; }
.hw-icon-paid circle { fill: #34C759; }
.hw-icon-paid path { fill: none; stroke: #FFFFFF; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.hw-icon-repeat path { fill: none; stroke: #007AFF; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* The review card's parts slide in one after another */
.hw-review .hw-card > *, .hw-copy { opacity: 0; transform: translateY(6px); transition: opacity 0.3s ease, transform 0.3s ease; }
[data-step="review"] .hw-card > *, [data-step="tap"] .hw-card > *, [data-step="copied"] .hw-card > *,
[data-step="review"] .hw-copy, [data-step="tap"] .hw-copy, [data-step="copied"] .hw-copy { opacity: 1; transform: none; }
.hw-card > :nth-child(2) { transition-delay: 0.05s; }
.hw-card > :nth-child(3) { transition-delay: 0.1s; }
.hw-card > :nth-child(4) { transition-delay: 0.2s; }
.hw-card > :nth-child(5) { transition-delay: 0.3s; }
.hw-copy { transition-delay: 0.4s; }

/* Copy link → Link copied. Stays green through "fade" so the blue never flashes before the loop restarts. */
.hw-copy {
  position: absolute; left: 0; right: 0; bottom: 0; height: 42px; border-radius: 12px;
  background: #007AFF; color: #FFFFFF; font-size: 14px; font-weight: 600; display: grid; place-items: center;
}
[data-step="tap"] .hw-copy { transform: scale(0.96); transition-delay: 0s; }
[data-step="copied"] .hw-copy, [data-step="fade"] .hw-copy { background: #34C759; transition: background 0.25s ease; }
.hw-copy-label, .hw-copied-label { grid-area: 1 / 1; transition: opacity 0.2s ease; }
.hw-copied-label { display: flex; align-items: center; gap: 5px; opacity: 0; }
[data-step="copied"] .hw-copy-label, [data-step="fade"] .hw-copy-label { opacity: 0; }
[data-step="copied"] .hw-copied-label, [data-step="fade"] .hw-copied-label { opacity: 1; }
.hw-copied-label svg { fill: none; stroke: #FFFFFF; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.hw-copied-label path { stroke-dasharray: 22; stroke-dashoffset: 22; }
[data-step="copied"] .hw-copied-label path, [data-step="fade"] .hw-copied-label path { stroke-dashoffset: 0; transition: stroke-dashoffset 0.35s ease 0.1s; }
.hw-review .hw-tap { left: 50%; bottom: 21px; }
[data-step="tap"] .hw-review .hw-tap { opacity: 1; transform: scale(1); }

/* ---------- Step 3: the customer pays with Apple Pay ---------- */
[data-step="page"] .hw-page,
[data-step="pick"] .hw-page,
[data-step="sheet"] .hw-page,
[data-step="confirm"] .hw-page,
[data-step="done"] .hw-page,
[data-step="paid"] .hw-paid { opacity: 1; transform: none; }

.hw-page { text-align: center; }
.hw-merchant { font-size: 12px; font-weight: 600; color: #8A8A8E; margin-top: 6px; }
.hw-what { font-size: 13px; margin-top: 2px; }
.hw-big { font-size: 28px; font-weight: 600; letter-spacing: -0.6px; margin: 2px 0 12px; font-variant-numeric: tabular-nums; }
.hw-label { font-size: 10px; font-weight: 600; color: #8A8A8E; text-transform: uppercase; letter-spacing: 0.3px; text-align: left; margin-bottom: 5px; }
.hw-methods { position: relative; display: grid; gap: 6px; }
.hw-method {
  display: flex; align-items: center; gap: 9px; height: 36px; padding: 0 10px;
  border: 1.5px solid transparent; border-radius: 10px; background: #FFFFFF;
  font-size: 13px; font-weight: 500; transition: border-color 0.2s ease;
}
.hw-method img { height: 18px; width: auto; display: block; }
.hw-method .hw-card-icon { width: 26px; height: 18px; flex: none; }
.hw-card-icon rect { fill: none; stroke: #3A3A3C; stroke-width: 1.6; }
.hw-card-icon path { stroke: #3A3A3C; stroke-width: 2.4; }
[data-step="pick"] .hw-method-apple, [data-step="sheet"] .hw-method-apple,
[data-step="confirm"] .hw-method-apple, [data-step="done"] .hw-method-apple { border-color: #007AFF; }
.hw-methods .hw-tap { left: 50%; top: 18px; }
[data-step="pick"] .hw-methods .hw-tap { opacity: 1; transform: scale(1); }

/* The Apple Pay sheet rises from the bottom; the page behind it dims */
.hw-dim { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.28); opacity: 0; transition: opacity 0.3s ease; }
.hw-sheet {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 14px 70px;
  border-radius: 18px 18px 0 0; background: #FFFFFF; font-size: 13px;
  transform: translateY(100%); transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}
[data-step="sheet"] .hw-dim, [data-step="confirm"] .hw-dim, [data-step="done"] .hw-dim { opacity: 1; }
[data-step="sheet"] .hw-sheet, [data-step="confirm"] .hw-sheet, [data-step="done"] .hw-sheet { transform: none; }
.hw-sheet-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.hw-sheet-top img { height: 22px; width: auto; display: block; }
.hw-sheet-close {
  width: 22px; height: 22px; border-radius: 50%; background: #E9E9EB; color: #8A8A8E;
  display: grid; place-items: center; font-size: 13px; line-height: 1;
}
.hw-sheet-row { display: flex; align-items: center; gap: 9px; padding: 9px 0; border-top: 1px solid #E5E5EA; }
.hw-sheet-row > span:first-of-type { flex: 1; min-width: 0; }
.hw-sheet-row > span:last-child { flex: none; white-space: nowrap; }
.hw-mini-card {
  width: 30px; height: 20px; flex: none; border-radius: 4px; background: #1A1F71;
  display: grid; place-items: center;
}
.hw-mini-card img { height: 7px; width: auto; filter: brightness(0) invert(1); }
.hw-sheet-pay { color: #8A8A8E; }
.hw-sheet-amount { font-weight: 600; font-size: 15px; }
.hw-sheet-bottom { position: relative; height: 40px; margin-top: 6px; }
.hw-confirm, .hw-done {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; font-size: 11px; color: #3A3A3C; transition: opacity 0.25s ease;
}
.hw-confirm svg { width: 22px; height: 22px; fill: none; stroke: #3A3A3C; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.hw-done { opacity: 0; color: #007AFF; font-weight: 600; }
.hw-done svg { width: 24px; height: 24px; }
.hw-done circle { fill: #007AFF; }
.hw-done path { fill: none; stroke: #FFFFFF; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
[data-step="done"] .hw-confirm { opacity: 0; }
[data-step="done"] .hw-done { opacity: 1; }

/* Double-click the side button: it glows twice */
[data-step="confirm"] .mini-side { animation: hw-side 0.5s ease 2; }
@keyframes hw-side { 50% { background: #007AFF; box-shadow: 0 0 8px 2px rgba(0, 122, 255, 0.6); } }

/* Paid */
.hw-paid { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 4px; }
.hw-paid svg { width: 52px; height: 52px; margin-bottom: 6px; }
.hw-paid circle { fill: #34C759; }
.hw-paid path { fill: none; stroke: #FFFFFF; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.hw-paid strong { font-size: 18px; }
.hw-paid span { font-size: 13px; color: #8A8A8E; }

/* People who turn off motion on their device see each phone's finished screen, still. */
@media (prefers-reduced-motion: reduce) {
  .mini-phone *, .mini-phone *::before { transition: none !important; animation: none !important; }
}
