/* ============================================================
   Roaminder — story scene animations
   Every animated element is paused until the stage gets .playing,
   so the scenes only run when you (or the scroll) start them.
   ============================================================ */

.scene-stage :where([class*="an-"]) { animation-play-state: paused; }
.scene-stage.playing :where([class*="an-"]) { animation-play-state: running; }

/* ---- shared keyframes ---- */
@keyframes sPop {
  from { opacity: 0; transform: scale(.72); }
  60%  { opacity: 1; transform: scale(1.06); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes sUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes sIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes sOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes sDrop {
  from { opacity: 0; transform: translateY(-46px) rotate(-14deg); }
  70%  { opacity: 1; transform: translateY(6px) rotate(3deg); }
  to   { opacity: 1; transform: translateY(0) rotate(0deg); }
}
@keyframes sDraw { to { stroke-dashoffset: 0; } }
@keyframes sRing {
  from { opacity: .85; transform: scale(.35); }
  to   { opacity: 0;   transform: scale(1.9); }
}
@keyframes sBuzz {
  0%,100% { transform: translate(0,0) rotate(0); }
  15% { transform: translate(-3px,1px) rotate(-2.5deg); }
  30% { transform: translate(3px,-1px) rotate(2.5deg); }
  45% { transform: translate(-2px,1px) rotate(-1.5deg); }
  60% { transform: translate(2px,0) rotate(1.5deg); }
  75% { transform: translate(-1px,0) rotate(-.6deg); }
}
@keyframes sSweep { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes sBreathe {
  0%,100% { opacity: .28; transform: scale(1); }
  50%     { opacity: .6;  transform: scale(1.05); }
}
@keyframes sBob {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(-5px); }
}
@keyframes sLegA {
  0%,100% { transform: rotate(19deg); }
  50%     { transform: rotate(-19deg); }
}
@keyframes sLegB {
  0%,100% { transform: rotate(-19deg); }
  50%     { transform: rotate(19deg); }
}
@keyframes sArmWave {
  0%,100% { transform: rotate(0deg); }
  25%     { transform: rotate(-34deg); }
  75%     { transform: rotate(-14deg); }
}
@keyframes sFlash {
  0%   { opacity: 0; }
  8%   { opacity: .95; }
  30%  { opacity: 0; }
  100% { opacity: 0; }
}
@keyframes sScanline {
  from { transform: translateY(0); }
  to   { transform: translateY(120px); }
}

/* ---- animation utility classes (delays set inline per scene) ---- */
.an-pop   { animation: sPop   .55s cubic-bezier(.22,1,.36,1) both; }
.an-up    { animation: sUp    .6s  cubic-bezier(.22,1,.36,1) both; }
.an-in    { animation: sIn    .5s  ease both; }
.an-out   { animation: sOut   .5s  ease both; }
.an-drop  { animation: sDrop  .65s cubic-bezier(.34,1.4,.5,1) both; }
.an-draw  { animation: sDraw  1.1s ease-out both; }
.an-buzz  { animation: sBuzz  .55s ease-in-out 3 both; }
.an-bob   { animation: sBob   2.4s ease-in-out infinite both; }
.an-flash { animation: sFlash 1.2s ease-out both; }

.an-ring {
  animation: sRing 1.9s ease-out infinite both;
  transform-origin: center;
}
.an-sweep   { animation: sSweep 3.2s linear infinite both; transform-origin: center; }
.an-breathe { animation: sBreathe 2.8s ease-in-out infinite both; transform-origin: center; }
.an-scan    { animation: sScanline 1.6s ease-in-out 2 both; }

.an-legA { animation: sLegA .46s ease-in-out infinite both; }
.an-legB { animation: sLegB .46s ease-in-out infinite both; }
.an-wave { animation: sArmWave 1s ease-in-out 2 both; }

/* transform-origin helpers for limbs (SVG needs explicit boxes) */
.pivot { transform-box: fill-box; transform-origin: top center; }
.pivot-c { transform-box: fill-box; transform-origin: center; }

/* the walk — distance is set per-scene with --walk */
@keyframes sWalk { to { transform: translateX(var(--walk, 300px)); } }
.an-walk { animation: sWalk 2.4s cubic-bezier(.5,0,.5,1) both; }

/* checkmark strokes */
.tick {
  stroke-dasharray: 32;
  stroke-dashoffset: 32;
}
.tick.an-draw { animation: sDraw .45s cubic-bezier(.22,1,.36,1) both; }

/* route line */
.route {
  stroke-dasharray: 620;
  stroke-dashoffset: 620;
}

/* reduced motion: snap every scene to its finished frame */
@media (prefers-reduced-motion: reduce) {
  .scene-stage :where([class*="an-"]) {
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    animation-play-state: running !important;
  }
  .scene-stage .an-out { animation: none !important; opacity: 0 !important; }
  .scene-bar .play { display: none; }
}

/* ============================================================
   interactive Best-Stop demo
   ============================================================ */
.demo-shell {
  display: grid; gap: 26px;
  grid-template-columns: minmax(0, 1fr) minmax(0, .85fr);
  align-items: start;
}
@media (max-width: 820px) { .demo-shell { grid-template-columns: 1fr; } }

.chips { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 22px; }
.chip {
  padding: 10px 17px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-2);
  background: var(--surface);
  color: var(--muted);
  font: inherit; font-size: .92rem; font-weight: 600;
  cursor: pointer;
  transition: all .22s var(--ease);
}
.chip:hover { border-color: var(--teal-500); color: var(--text); transform: translateY(-1px); }
.chip.on {
  background: color-mix(in srgb, var(--teal-500) 18%, transparent);
  border-color: var(--teal-500);
  color: var(--teal-300);
}
.chip.on::before { content: "✓ "; font-weight: 900; }

.demo-out {
  padding: 20px 22px;
  border-radius: var(--r-md);
  background: var(--bg-2);
  border: 1px dashed var(--border-2);
  font-size: .97rem;
  line-height: 1.6;
  min-height: 92px;
}
.demo-out b { color: var(--teal-300); }

/* the amber Best Stop card, straight from the app */
.beststop {
  border-radius: var(--r-md);
  border: 1.5px solid var(--amber);
  background: color-mix(in srgb, var(--amber) 12%, var(--surface));
  padding: 18px 20px;
}
.beststop .bs-tag {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: .68rem; font-weight: 900; letter-spacing: .14em; text-transform: uppercase;
  color: var(--amber); margin-bottom: 8px;
}
.beststop .bs-name { font-size: 1.35rem; font-weight: 800; letter-spacing: -.02em; }
.beststop .bs-sub { color: var(--muted); font-size: .88rem; }
