/* "How it works": a cartoon chat (how.js). */

/* The plain-text story in how.html is for crawlers; browsers that run scripts get the cartoon instead. */
@media (scripting: enabled) { .plain-story { display: none; } }

.story { display: flex; flex-direction: column; gap: 14px; padding: 6px 0 4px; min-height: 60vh; }
.story.playing { padding-bottom: 45vh; } /* room to scroll the newest line up from the bottom of the screen */
.story > * { animation: bounce-in 0.45s cubic-bezier(0.3, 1.5, 0.5, 1) both; }
@keyframes bounce-in { from { opacity: 0; transform: translateY(12px) scale(0.85); } to { opacity: 1; transform: none; } }

.step {
  align-self: center; display: flex; align-items: center; gap: 10px;
  margin: 16px 0 2px; padding: 5px 16px 5px 5px; border-radius: 999px;
  background: rgba(232, 196, 106, 0.16); color: var(--gold); font: 700 1.05rem/1.2 var(--display);
}
.step b {
  display: grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: 50%;
  background: var(--gold); color: #251a03; font: 800 0.9rem var(--body);
}

/* Chat lines: Sophie on the left, you on the right. */
.say { display: flex; align-items: flex-end; gap: 8px; max-width: 90%; }
.say.right { align-self: flex-end; flex-direction: row-reverse; }
.say .face { width: 48px; height: 48px; flex: none; }
.bubble {
  margin: 0; padding: 10px 15px; border-radius: 20px;
  background: var(--card); color: var(--card-ink); font-weight: 600; line-height: 1.35;
  box-shadow: 3px 4px 0 rgba(0, 0, 0, 0.3);
  transform-origin: bottom left; animation: bubble 0.4s cubic-bezier(0.3, 1.6, 0.5, 1) both;
}
.say.left .bubble { border-bottom-left-radius: 5px; }
.say.right .bubble { background: #f2d48a; color: #251a03; border-bottom-right-radius: 5px; transform-origin: bottom right; }
@keyframes bubble { from { opacity: 0; transform: scale(0.3); } to { opacity: 1; transform: none; } }

.bubble.typing { display: flex; gap: 5px; padding: 15px 16px; }
.bubble.typing i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: dot 1s ease-in-out infinite; }
.bubble.typing i:nth-child(2) { animation-delay: 0.15s; }
.bubble.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot { 0%, 60%, 100% { opacity: 0.3; transform: none; } 30% { opacity: 0.9; transform: translateY(-4px); } }

/* What you're really thinking. */
.say.think .bubble {
  background: transparent; color: var(--ink); border: 2px dashed rgba(255, 255, 255, 0.45);
  box-shadow: none; font-style: italic; font-weight: 500;
}
.tag {
  display: inline-block; margin-left: 4px; padding: 1px 8px; border-radius: 999px; vertical-align: 2px;
  background: var(--red); color: #fff; font: 800 0.7rem var(--body); letter-spacing: 0.08em; text-transform: uppercase;
}

/* Pictures: the badge, and phones. */
.scene { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 4px 0 0; }
.scene figcaption { color: var(--muted); font-size: 0.875rem; text-align: center; }

.mini-badge {
  display: flex; flex-direction: column; align-items: center; gap: 7px; width: 136px; padding: 12px 12px 14px;
  border-radius: 10px; background: #fff; color: #111; outline: 1.5px solid #111; outline-offset: -5px;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.35);
  transform: rotate(-4deg); animation: hand-over 0.9s cubic-bezier(0.2, 1.2, 0.4, 1) both;
}
@keyframes hand-over { from { transform: translateX(-70vw) rotate(-30deg); } to { transform: rotate(-4deg); } }
.mini-badge b { font: 900 0.66rem var(--display); }
.mini-badge .qr { width: 84px; }
.mini-badge svg { display: block; width: 100%; height: auto; }
.mini-badge .hi { align-self: stretch; display: flex; align-items: baseline; gap: 5px; font: 700 0.75rem var(--display); }
.mini-badge em {
  flex: 1; border-bottom: 1px solid #111; text-align: center; font-style: normal; color: #1f4fa8;
  font: 700 1.05rem/1 'Bradley Hand', 'Segoe Print', 'Comic Sans MS', cursive;
}

.phone { width: 176px; padding: 9px; border-radius: 30px; background: #0b0b0d; box-shadow: inset 0 0 0 2px #3a3a40, 0 14px 30px rgba(0, 0, 0, 0.4); }
.phone .screen {
  position: relative; height: 290px; padding: 14px; border-radius: 22px; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center;
  background: radial-gradient(ellipse 120% 80% at 50% 0%, var(--felt-light) 0%, var(--felt) 50%, var(--felt-dark) 100%);
}
.phone .kicker, .phone .phone-bluff, .phone .phone-name { margin: 0; }
.phone .flip { width: 100px; }
.phone .flip .card { --w: 100px; }
.phone .phone-bluff { font: 700 1.05rem/1.2 var(--display); color: var(--gold); }
.phone .phone-name { font: 800 2.2rem/1 var(--body); }
.phone .headline { margin: 0; font-size: 1.15rem; }
.phone .rank { margin: 0; padding: 2px 10px; font-size: 0.8rem; }
.phone .hand { --hw: 28px; gap: 5px; }
.phone .hand.two-rows { max-width: calc(4 * var(--hw) + 3 * 5px); }
.phone .card.new { box-shadow: 0 0 0 2px var(--gold), 0 4px 12px rgba(0, 0, 0, 0.4); animation: pop 0.5s 0.5s ease-out both; }

/* The camera, finding a badge's QR code. */
.camera { position: absolute; inset: 0; display: grid; place-items: center; background: #1d1d21; }
.scan-frame { position: relative; width: 112px; padding: 10px; border-radius: 6px; background: #fff; }
.scan-frame svg { display: block; width: 100%; height: auto; }
.scan-frame::after {
  --c: var(--gold);
  content: ''; position: absolute; inset: -12px;
  background:
    linear-gradient(var(--c), var(--c)) top left / 24px 4px, linear-gradient(var(--c), var(--c)) top left / 4px 24px,
    linear-gradient(var(--c), var(--c)) top right / 24px 4px, linear-gradient(var(--c), var(--c)) top right / 4px 24px,
    linear-gradient(var(--c), var(--c)) bottom left / 24px 4px, linear-gradient(var(--c), var(--c)) bottom left / 4px 24px,
    linear-gradient(var(--c), var(--c)) bottom right / 24px 4px, linear-gradient(var(--c), var(--c)) bottom right / 4px 24px;
  background-repeat: no-repeat;
}
.found .scan-frame::after { --c: #4ade80; }
.sweep {
  position: absolute; left: 18%; right: 18%; top: 34%; height: 3px; border-radius: 2px;
  background: var(--gold); box-shadow: 0 0 14px var(--gold); animation: sweep 0.8s ease-in-out infinite alternate;
}
@keyframes sweep { to { top: 64%; } }
.found .sweep { display: none; }
.tick { position: absolute; inset: 0; display: grid; place-items: center; opacity: 0; transform: scale(0.4); transition: 0.35s cubic-bezier(0.3, 1.6, 0.5, 1); }
.tick b { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: #22c55e; color: #fff; font-size: 2rem; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4); }
.found .tick { opacity: 1; transform: none; }

.moral { margin: 22px 0 0; text-align: center; font: 700 1.3rem/1.25 var(--display); color: var(--gold); }

@media (prefers-reduced-motion: reduce) {
  .story > *, .bubble, .bubble.typing i, .mini-badge, .sweep { animation: none; }
  .tick { transition: none; }
}
