/* Motion for the TV and the phones (motion.js): critters alive while idle, and answers to what happens. Nothing
   plays because a screen appeared. With Reduce Motion, nothing moves. */

.critter {
  position: relative; display: inline-block; flex-shrink: 0; border-radius: 9999px; overflow: hidden;
  background: var(--pc); aspect-ratio: 1; transform-origin: 50% 100%;
}
.critter picture, .critter img { display: block; width: 100%; height: 100%; }

/* The rig: the drawing breathes from its shoulders; the eyes are a layer that blinks and glances. */
.critter .rig { position: relative; display: block; width: 100%; height: 100%; transform-origin: 50% 100%; }
.critter.live .rig { animation: breathe var(--breath-len, 3.8s) ease-in-out var(--breath-at, 0s) infinite; }
@keyframes breathe { 50% { scale: 1.012 1.03; } }
.critter .eyes {
  position: absolute; inset: 0; transform-origin: 50% var(--eye, 45%);
  transition: scale 0.07s ease-in, translate 0.32s cubic-bezier(0.3, 1.3, 0.5, 1);
}
.critter.m-blink .eyes { scale: 1 0.1; }
.critter.look-l .eyes, .critter.m-look-l .eyes { translate: -4% 0; }
.critter.look-r .eyes, .critter.m-look-r .eyes { translate: 4% 0; }

/* Fidgets, now and then, one critter at a time. */
.m-tilt { animation: tilt 1s cubic-bezier(0.4, 0, 0.3, 1); }
@keyframes tilt { 30% { rotate: -7deg; } 65% { rotate: 3deg; } 100% { rotate: 0deg; } }
.m-tilt-r { animation: tilt-r 1s cubic-bezier(0.4, 0, 0.3, 1); }
@keyframes tilt-r { 30% { rotate: 7deg; } 65% { rotate: -3deg; } 100% { rotate: 0deg; } }
.m-hop { animation: hop 0.8s linear; }
@keyframes hop {
  0% { translate: 0 0; scale: 1 1; }
  15% { translate: 0 0; scale: 1.08 0.9; animation-timing-function: cubic-bezier(0.2, 0.7, 0.4, 1); }
  45% { translate: 0 -14%; scale: 0.96 1.05; animation-timing-function: cubic-bezier(0.6, 0, 0.8, 0.4); }
  70% { translate: 0 0; scale: 1.06 0.93; }
  85% { scale: 0.98 1.02; }
  100% { translate: 0 0; scale: 1 1; }
}
.m-wiggle { animation: wiggle 0.7s ease-in-out; }
@keyframes wiggle { 20% { rotate: -5deg; } 40% { rotate: 4deg; } 60% { rotate: -3deg; } 80% { rotate: 2deg; } 100% { rotate: 0deg; } }

/* A reaction to a tap, a pick or a vote landing: squash, jump, land, wiggle. */
.m-react { animation: react 0.75s linear; }
@keyframes react {
  0% { translate: 0 0; scale: 1 1; rotate: 0deg; }
  12% { scale: 1.14 0.84; animation-timing-function: cubic-bezier(0.2, 0.8, 0.4, 1); }
  40% { translate: 0 -22%; scale: 0.92 1.1; rotate: -4deg; animation-timing-function: cubic-bezier(0.6, 0, 0.9, 0.5); }
  62% { translate: 0 0; scale: 1.12 0.88; rotate: 3deg; }
  78% { scale: 0.97 1.04; rotate: -2deg; }
  100% { translate: 0 0; scale: 1 1; rotate: 0deg; }
}

/* Things that arrive while you watch (data-arrive): a player sitting down, a vote landing, a new speaker. */
.m-fade { animation: fade 0.22s ease-out; }
@keyframes fade { from { opacity: 0; } }
.m-pop { animation: pop 0.42s cubic-bezier(0.3, 1.7, 0.5, 1); }
@keyframes pop { from { opacity: 0; scale: 0.3; } }
.m-swap { animation: swap 0.34s cubic-bezier(0.3, 1.5, 0.5, 1); }
@keyframes swap { from { opacity: 0.4; scale: 0.82; } }
.m-drop { animation: drop 0.85s linear; }
@keyframes drop {
  0% { opacity: 0; translate: 0 -150%; animation-timing-function: cubic-bezier(0.5, 0, 1, 0.6); }
  45% { opacity: 1; translate: 0 0; scale: 1.12 0.84; animation-timing-function: cubic-bezier(0.2, 0.7, 0.4, 1); }
  65% { translate: 0 -12%; scale: 0.95 1.06; animation-timing-function: cubic-bezier(0.5, 0, 0.8, 0.5); }
  82% { translate: 0 0; scale: 1.04 0.96; }
  100% { translate: 0 0; scale: 1 1; }
}

/* The slow light in the room, behind everything. */
.glow { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.glow::before, .glow::after { content: ""; position: absolute; border-radius: 50%; }
.glow::before { width: 70vmax; height: 70vmax; left: -15vmax; top: -20vmax; background: radial-gradient(closest-side, var(--glow-lamp), transparent); animation: drift 30s ease-in-out infinite alternate; }
.glow::after { width: 80vmax; height: 80vmax; right: -20vmax; bottom: -25vmax; background: radial-gradient(closest-side, var(--glow-tv), transparent); animation: drift 38s ease-in-out infinite alternate-reverse; }
@keyframes drift { to { transform: translate(10vmax, 6vmax) scale(1.12); } }

/* Whose turn it is: a slow pulse round them (status, not decoration). */
.ring-pulse { animation: ring-pulse 2s ease-out infinite; }
@keyframes ring-pulse { from { box-shadow: 0 0 0 0 var(--accent); } to { box-shadow: 0 0 0 1em transparent; } }

/* Confetti, only for a winner. */
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 50; }
.confetti i {
  position: absolute; top: -4vh; left: var(--x); width: 1.1vmin; height: 1.8vmin; border-radius: 0.2vmin;
  background: var(--pc); animation: fall var(--fall) cubic-bezier(0.25, 0.4, 0.5, 1) var(--wait) both;
}
.confetti i.round { border-radius: 50%; width: 1.2vmin; height: 1.2vmin; }
@keyframes fall {
  from { transform: translate(0, 0) rotate(0); opacity: 1; }
  85% { opacity: 1; }
  to { transform: translate(var(--drift), 110vh) rotate(var(--spin)); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* The time left in a step (timer.js): a capsule, with a bar running down along its bottom. */
.timer {
  position: relative; display: inline-flex; align-items: center; justify-content: center; overflow: hidden;
  min-width: 3.2em; height: 2em; padding: 0 0.8em; border-radius: 9999px;
  background: var(--accent-soft-bg); border: 1px solid var(--accent-soft-border); color: var(--accent);
  font-family: var(--mono); font-weight: 500; font-variant-numeric: tabular-nums;
}
.timer i { position: absolute; left: 0; bottom: 0; height: 3px; width: calc(var(--left, 1) * 100%); background: var(--accent); transition: width 0.25s linear; }
.timer.low { background: var(--accent); color: var(--accent-text); }
.timer.low i { background: var(--accent-text); }

