/* Motion layer – shared by all themes (always loaded, after the theme stylesheets).
   Themes provide the colours through --motion-* variables:
     --motion-accent   main accent (progress, glow, rings)
     --motion-ok       "everyone is ready" / consensus colour
     --motion-track    empty progress track
     --motion-muted    thinking dots
     --motion-radius   rounding for the progress bar and vote bars
     --bar-top         colour of the most-voted bar in the result */

:root {
  --motion-bounce: cubic-bezier(.3, 1.5, .5, 1);
  --motion-smooth: cubic-bezier(.2, .9, .25, 1);
}

body { transition: background-color .4s ease, color .4s ease; }

/* ---------- Dark-mode icon spins when switching ---------- */
#theme-toggle svg { transition: transform .6s var(--motion-bounce); }
:root[data-theme="dark"] #theme-toggle svg { transform: rotate(360deg); }

/* ---------- Progress bar ---------- */
.meter {
  height: 6px; margin-top: .4rem; overflow: hidden;
  background: var(--motion-track, rgba(128, 128, 128, .25));
  border-radius: var(--motion-radius, 0);
}
.meter-fill {
  position: relative; height: 100%; width: 0; overflow: hidden;
  background: var(--motion-accent, #e17000); border-radius: inherit;
  transition: width .6s var(--motion-bounce), background-color .4s ease;
}
.meter-fill.done { background: var(--motion-ok, #39870c); }
.meter-fill.done::after { /* shine sweeping across when everyone is ready */
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .6), transparent);
  transform: translateX(-100%); animation: motion-shimmer 1.4s ease-in-out infinite;
}
@keyframes motion-shimmer { to { transform: translateX(100%); } }

/* ---------- Buttons: ripple + "ready" glow ---------- */
.btn { position: relative; overflow: hidden; }
.ripple {
  position: absolute; width: 20px; height: 20px; margin: -10px 0 0 -10px; border-radius: 50%;
  background: currentColor; opacity: .35; pointer-events: none;
  animation: motion-ripple .6s ease-out forwards;
}
@keyframes motion-ripple { to { transform: scale(18); opacity: 0; } }
#reveal.ready:not(:disabled) { animation: motion-glow 1.6s ease-in-out infinite; }
@keyframes motion-glow {
  50% {
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--motion-accent, #e17000) 55%, transparent),
                0 0 18px color-mix(in srgb, var(--motion-accent, #e17000) 45%, transparent);
  }
}

/* ---------- Your hand: deal, tilt, undeal ---------- */
.deck { perspective: 900px; }
.deck.dealing .card {
  animation: motion-deal .6s var(--motion-bounce) backwards;
  animation-delay: calc(var(--i, 0) * 55ms);
}
@keyframes motion-deal { from { opacity: 0; transform: translateY(160%) rotate(calc(var(--r, 0) * 1deg)) scale(.7); } }
.deck.undealing .card {
  animation: motion-undeal .45s ease-in forwards;
  animation-delay: calc(var(--i, 0) * 30ms);
  pointer-events: none;
}
@keyframes motion-undeal { to { opacity: 0; transform: translateY(140%) rotate(calc(var(--r, 0) * -1deg)) scale(.8); } }

/* The copy of your card that flies to your seat */
.card.flying {
  position: fixed; z-index: 60; margin: 0; pointer-events: none;
  animation: none; transition: none;
  box-shadow: 0 14px 28px rgba(0, 0, 0, .3);
}

/* ---------- Team ---------- */
.person.enter {
  animation: motion-seat-in .5s var(--motion-bounce) backwards;
  animation-delay: calc(var(--i, 0) * 70ms);
}
@keyframes motion-seat-in { from { opacity: 0; transform: translateX(-16px); } }
.person.extreme { animation: motion-ring 1.1s ease-out 2; }
@keyframes motion-ring {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--motion-accent, #e17000) 70%, transparent); }
  100% { box-shadow: 0 0 0 12px transparent; }
}
.person .tag:not(:empty) { animation: motion-tag-in .4s var(--motion-bounce); }
@keyframes motion-tag-in { from { opacity: 0; transform: translateY(4px); } }

/* Card dropping onto a seat, and being collected for a new round */
.mini.drop { animation: motion-drop .5s var(--motion-bounce); }
@keyframes motion-drop { from { transform: translateY(-26px) rotate(-18deg); opacity: 0; } }
.mini.collect { animation: motion-collect .4s ease-in forwards; }
@keyframes motion-collect { to { transform: translateY(-22px) rotate(12deg) scale(.7); opacity: 0; } }
.mini.awaiting { visibility: hidden; } /* your card is still in the air */

/* "Thinking" dots while someone is choosing */
.dots { display: flex; gap: 2px; }
.dots i {
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--motion-muted, currentColor);
  animation: motion-dot 1s ease-in-out infinite;
}
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
@keyframes motion-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30% { transform: translateY(-4px); opacity: 1; }
}
.mini.voted .dots, .person.offline .dots, #room-view.is-revealed .dots { display: none; }

/* ---------- Result ---------- */
.summary.arriving { animation: motion-result-in .55s var(--motion-bounce); transform-origin: top center; }
@keyframes motion-result-in { from { opacity: 0; transform: translateY(-12px) scaleY(.4); } }
.summary.leaving { animation: motion-result-out .35s ease-in forwards; transform-origin: top center; }
@keyframes motion-result-out { to { opacity: 0; transform: translateY(-8px) scaleY(.6); } }
.summary .big { display: inline-block; font-variant-numeric: tabular-nums; }
.summary .big.thump { animation: motion-thump .6s var(--motion-bounce) .1s; }
@keyframes motion-thump { 40% { transform: scale(1.35); } }

/* Votes per card as growing bars */
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; min-width: 10rem; }
.bar-row {
  display: grid; grid-template-columns: 1.75rem minmax(3rem, 1fr) 2.25rem;
  align-items: center; gap: .5rem; font-size: .875rem;
}
.bar-v { font-weight: 700; font-size: 1rem; text-align: right; }
.bar-track {
  position: relative; height: 10px; overflow: hidden;
  background: color-mix(in srgb, currentColor 18%, transparent);
  border-radius: var(--motion-radius, 0);
}
.bar-track i {
  position: absolute; inset: 0 auto 0 0; width: 0; border-radius: inherit;
  background: currentColor; opacity: .55;
  transition: width .7s var(--motion-bounce);
}
.bar-track.top i { opacity: 1; background: var(--bar-top, currentColor); }
.bar-c { opacity: .85; font-variant-numeric: tabular-nums; }

/* Confetti canvas (created by app.js on consensus) */
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 70; pointer-events: none; }

/* ---------- Reduced motion: keep the information, drop the movement ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    animation-delay: 0ms !important; transition-duration: .01ms !important; transition-delay: 0ms !important;
  }
  .meter-fill.done::after { display: none; }
  .dots i { opacity: .6; }
}
