/* ==========================================================================
   2D Football Wars — animations.css
   Keyframes and animation utility classes: goal celebrations, menu
   transitions, score popups, screen fades, UI micro-interactions.
   ========================================================================== */

/* ---- Generic keyframes --------------------------------------------------- */

@keyframes pulse-soft {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(26px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes drop-in {
  0% { opacity: 0; transform: translateY(-40px) scale(1.1); }
  60% { opacity: 1; transform: translateY(6px) scale(1); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes pop-in {
  0% { opacity: 0; transform: scale(0.6); }
  70% { opacity: 1; transform: scale(1.06); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes ball-bounce {
  0%, 100% { transform: translateY(0) scaleX(1) scaleY(1); }
  45% { transform: translateY(-30px); }
  92% { transform: translateY(2px) scaleX(1.12) scaleY(0.86); }
}

@keyframes ball-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ---- Announcer / goal celebration ---------------------------------------- */

@keyframes goal-slam {
  0% { opacity: 0; transform: scale(3.2) rotate(-6deg); filter: blur(10px); }
  35% { opacity: 1; transform: scale(0.94) rotate(1deg); filter: blur(0); }
  50% { transform: scale(1.06) rotate(-0.5deg); }
  65% { transform: scale(1) rotate(0deg); }
  85% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.25); filter: blur(6px); }
}
.anim-goal-slam { animation: goal-slam 2s var(--ease-out) forwards; }

@keyframes count-punch {
  0% { opacity: 0; transform: scale(2.6); filter: blur(8px); }
  30% { opacity: 1; transform: scale(0.92); filter: blur(0); }
  45% { transform: scale(1.04); }
  70% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.7); }
}
.anim-count-punch { animation: count-punch 0.92s var(--ease-out) forwards; }

@keyframes banner-sweep {
  0% { opacity: 0; transform: translateX(calc(var(--stage-w) * -0.6)) skewX(-12deg); }
  25% { opacity: 1; transform: translateX(0) skewX(0); }
  75% { opacity: 1; transform: translateX(0); }
  100% { opacity: 0; transform: translateX(calc(var(--stage-w) * 0.6)) skewX(12deg); }
}
.anim-banner-sweep { animation: banner-sweep 1.9s var(--ease-in-out) forwards; }

@keyframes whistle-shake {
  0%, 100% { transform: translate(0, 0) rotate(0); }
  20% { transform: translate(-6px, 2px) rotate(-1.5deg); }
  40% { transform: translate(5px, -3px) rotate(1deg); }
  60% { transform: translate(-4px, -2px) rotate(-0.8deg); }
  80% { transform: translate(3px, 2px) rotate(0.6deg); }
}
.anim-shake { animation: whistle-shake 0.45s linear; }

/* Score value bump when a goal is scored */
@keyframes score-bump {
  0% { transform: scale(1); }
  35% { transform: scale(1.8); color: var(--c-gold); text-shadow: 0 0 24px var(--c-gold); }
  100% { transform: scale(1); }
}
.anim-score-bump { animation: score-bump 0.85s var(--ease-bounce); }

/* ---- Power slot feedback -------------------------------------------------- */

@keyframes power-ready-flash {
  0% { box-shadow: 0 0 0 0 rgba(56, 224, 140, 0.9); }
  100% { box-shadow: 0 0 0 18px rgba(56, 224, 140, 0); }
}

@keyframes power-fire {
  0% { transform: scale(1); }
  40% { transform: scale(1.28); }
  100% { transform: scale(1); }
}
.anim-power-fire { animation: power-fire 0.4s var(--ease-bounce); }

/* ---- Screen transitions --------------------------------------------------- */

.screen.visible { animation: fade-in var(--t-med) var(--ease-out); }
.screen.visible .panel,
.screen.visible .setup-panel { animation: rise-in var(--t-med) var(--ease-out); }
.screen.visible .screen-title { animation: drop-in var(--t-slow) var(--ease-out); }
.screen.visible .mode-card { animation: rise-in var(--t-med) var(--ease-out) backwards; }
.screen.visible .mode-card:nth-child(2) { animation-delay: 40ms; }
.screen.visible .mode-card:nth-child(3) { animation-delay: 80ms; }
.screen.visible .mode-card:nth-child(4) { animation-delay: 120ms; }
.screen.visible .mode-card:nth-child(5) { animation-delay: 160ms; }
.screen.visible .mode-card:nth-child(6) { animation-delay: 200ms; }
.screen.visible .mode-card:nth-child(7) { animation-delay: 240ms; }
.screen.visible .mode-card:nth-child(8) { animation-delay: 280ms; }
.screen.visible .mode-card:nth-child(9) { animation-delay: 320ms; }
.screen.visible .mode-card:nth-child(10) { animation-delay: 360ms; }

.menu-buttons .btn { animation: rise-in var(--t-slow) var(--ease-out) backwards; }
.menu-buttons .btn:nth-child(1) { animation-delay: 60ms; }
.menu-buttons .btn:nth-child(2) { animation-delay: 130ms; }
.menu-buttons .btn:nth-child(3) { animation-delay: 200ms; }
.menu-buttons .btn:nth-child(4) { animation-delay: 270ms; }
.menu-buttons .btn:nth-child(5) { animation-delay: 340ms; }

.menu-hero { animation: drop-in 0.7s var(--ease-out); }

/* ---- Toast notifications --------------------------------------------------- */

@keyframes toast-in {
  0% { opacity: 0; transform: translateY(24px) scale(0.9); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(10px) scale(0.94); }
}
.toast { animation: toast-in 0.35s var(--ease-bounce); }
.toast.leaving { animation: toast-out 0.3s var(--ease-out) forwards; }

/* ---- Victory screen -------------------------------------------------------- */

@keyframes trophy-float {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-0.22em) rotate(3deg); }
}
.victory-trophy {
  font-size: calc(var(--u) * 5.4);
  animation: trophy-float 2.6s ease-in-out infinite;
  filter: drop-shadow(0 10px 30px rgba(255, 207, 77, 0.5));
}

@keyframes stripe-scroll {
  from { background-position: 0 0; }
  to { background-position: 80px 0; }
}
#screen-victory.visible {
  background-image:
    repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.025) 0 20px, transparent 20px 40px),
    radial-gradient(85% 70% at 50% 20%, rgba(40, 80, 180, 0.18) 0%, transparent 60%);
  animation: fade-in var(--t-med) var(--ease-out);
}

/* ---- Pause overlay --------------------------------------------------------- */

@keyframes pause-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
.pause-hint { animation: pause-blink 1.8s ease-in-out infinite; }

/* ---- Reduced motion -------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
  }
}
html.reduced-motion *,
html.reduced-motion *::before,
html.reduced-motion *::after {
  animation-duration: 0.001s !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001s !important;
}
