/* Entrances, exits and ambient movement. Timings come from tokens.css.
   Keyframes use the individual translate / rotate / scale properties so they combine with each element's own skew. */

@keyframes slam-l { from { translate: -90px 0; opacity: 0; } 70% { translate: 6px 0; opacity: 1; } to { translate: 0 0; } }
@keyframes slam-r { from { translate: 90px 0; opacity: 0; } 70% { translate: -6px 0; opacity: 1; } to { translate: 0 0; } }
@keyframes from-top { from { translate: 0 -50px; opacity: 0; } to { translate: 0 0; opacity: 1; } }
@keyframes drop { from { translate: 0 -40px; scale: 1.25; opacity: 0; } 60% { translate: 0 4px; scale: 0.98; opacity: 1; } to { translate: 0 0; scale: 1; } }
@keyframes rise { from { translate: 0 36px; opacity: 0; } 70% { translate: 0 -3px; opacity: 1; } to { translate: 0 0; } }
@keyframes wipe { from { scale: 0 1; } to { scale: 1 1; } }
@keyframes coin-in { from { rotate: y 180deg; scale: 0.2; opacity: 0; } 60% { rotate: y -15deg; scale: 1.1; opacity: 1; } to { rotate: y 0deg; scale: 1; } }
@keyframes swing-in { from { rotate: y 80deg; translate: 70px 0; opacity: 0; } 65% { rotate: y -8deg; translate: -4px 0; opacity: 1; } to { rotate: y 0deg; translate: 0 0; } }
@keyframes spin-in { from { rotate: -200deg; scale: 0; } 65% { rotate: 10deg; scale: 1.08; } to { rotate: 0deg; scale: 1; } }
@keyframes stamp { from { scale: 2.2; opacity: 0; } 55% { scale: 0.92; opacity: 1; } 75% { scale: 1.04; } to { scale: 1; } }
@keyframes band-slam { from { translate: -1100px 0; } 80% { translate: 18px 0; } to { translate: 0 0; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

@keyframes spin-out { to { rotate: 160deg; scale: 0; opacity: 0; } }
@keyframes out-fast { to { opacity: 0; translate: -24px 0; } }
@keyframes scene-out { to { translate: -40px 0; opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }

@keyframes flip { from { rotate: y 0deg; } to { rotate: y 180deg; } }
@keyframes pulse { from { scale: 1.12; } to { scale: 1; } }
@keyframes pulse-hard { 0% { scale: 1.22; } 40% { scale: 0.96; } to { scale: 1; } }
@keyframes breathe { 0%, 100% { scale: 1; } 50% { scale: 1.035; } }
@keyframes bob { 0%, 100% { translate: 0 0; } 50% { translate: -7px 0; } }
@keyframes shake { 0%, 100% { translate: 0 0; } 20% { translate: -14px 6px; } 40% { translate: 12px -5px; } 60% { translate: -8px 3px; } 80% { translate: 5px -2px; } }
@keyframes count-pop { from { scale: 1.3; } to { scale: 1; } }

/* Entrance: motion.js sets --i (order) and optional --extra (ms) on each [data-enter] child. */
.entering [data-enter] {
  animation-duration: var(--enter-dur);
  animation-timing-function: var(--ease-out);
  animation-fill-mode: backwards;
  animation-delay: calc(var(--i, 0) * var(--stagger) + var(--extra, 0ms));
}
.entering [data-enter="slam-l"] { animation-name: slam-l; }
.entering [data-enter="slam-r"] { animation-name: slam-r; }
.entering [data-enter="from-top"] { animation-name: from-top; }
.entering [data-enter="drop"] { animation-name: drop; }
.entering [data-enter="rise"] { animation-name: rise; }
.entering [data-enter="wipe"] { animation-name: wipe; }
.entering [data-enter="coin-in"] { animation-name: coin-in; }
.entering [data-enter="swing-in"] { animation-name: swing-in; }
.entering [data-enter="spin-in"] { animation-name: spin-in; }
.entering [data-enter="stamp"] { animation-name: stamp; }
.entering [data-enter="band-slam"] { animation-name: band-slam; }
.entering [data-enter="fade"] { animation-name: fade-in; }

/* Exits */
.leaving { animation: scene-out var(--exit-dur) var(--ease-in) forwards; pointer-events: none; }
.out-fast { animation: out-fast var(--exit-dur) var(--ease-in) forwards; pointer-events: none; }
.spin-out { animation: spin-out 200ms var(--ease-in) forwards; pointer-events: none; }

/* One-shot effects */
.flip { animation: flip var(--flip-dur) cubic-bezier(0.6, 0, 0.3, 1) forwards; }
/* Two identical keyframe names: switching between them restarts the pulse on every tick. */
@keyframes pulse-2 { from { scale: 1.12; } to { scale: 1; } }
@keyframes pulse-hard-2 { 0% { scale: 1.22; } 40% { scale: 0.96; } to { scale: 1; } }
.pulse-a { animation: pulse 350ms var(--ease-out); }
.pulse-b { animation: pulse-2 350ms var(--ease-out); }
.hard-a { animation: pulse-hard 400ms var(--ease-out); }
.hard-b { animation: pulse-hard-2 400ms var(--ease-out); }
.shake { animation: shake 400ms ease-out 230ms; }

/* Ambient movement: something is always alive on screen. */
.alive-breathe { animation: breathe var(--breathe-dur) ease-in-out 600ms infinite; }
.alive-bob { animation: bob 1.2s ease-in-out infinite; }

/* 3D helpers */
.persp { perspective: 900px; }
.flipper { position: relative; transform-style: preserve-3d; }
.face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.face-back { rotate: y 180deg; }

@media (prefers-reduced-motion: reduce) {
  .tri, .tri polygon, .alive-breathe, .alive-bob, .shake, .rotate svg { animation: none !important; }
  .entering [data-enter] { animation-name: fade-in !important; animation-duration: 200ms !important; animation-delay: 0ms !important; }
  .pulse-a, .pulse-b, .hard-a, .hard-b { animation: none; }
  .leaving, .out-fast, .spin-out { animation-name: fade-out !important; }
  .flip { animation-duration: 0s !important; }
}
