/* ===========================================
   Super Maths Hero - Animations CSS
   Keyframes and Animation Classes
   =========================================== */

/* ===== Keyframe Definitions ===== */

/* Fade Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInLeft {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Slide Animations */
@keyframes slideInDown {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideInUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideOutUp {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(-100%);
    opacity: 0;
  }
}

/* Scale Animations */
@keyframes scaleIn {
  from {
    transform: scale(0);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes scaleOut {
  from {
    transform: scale(1);
    opacity: 1;
  }
  to {
    transform: scale(0);
    opacity: 0;
  }
}

@keyframes pop {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes popIn {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  60% {
    transform: scale(1.2);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Bounce Animations */
@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

@keyframes bounceIn {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.1);
  }
  70% {
    transform: scale(0.95);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes bounceOut {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(0);
    opacity: 0;
  }
}

/* Shake Animation */
@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: translateX(-10px);
  }
  20%, 40%, 60%, 80% {
    transform: translateX(10px);
  }
}

@keyframes shakeSmall {
  0%, 100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  50% {
    transform: translateX(5px);
  }
  75% {
    transform: translateX(-5px);
  }
}

/* Pulse Animation */
@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

@keyframes pulseGlow {
  0%, 100% {
    box-shadow: var(--shadow-comic), 0 0 0 0 rgba(255, 214, 0, 0.4);
  }
  50% {
    box-shadow: var(--shadow-comic), 0 0 0 15px rgba(255, 214, 0, 0);
  }
}

/* Rotate Animations */
@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes rotateIn {
  from {
    transform: rotate(-180deg) scale(0);
    opacity: 0;
  }
  to {
    transform: rotate(0deg) scale(1);
    opacity: 1;
  }
}

@keyframes wobble {
  0%, 100% {
    transform: rotate(0deg);
  }
  25% {
    transform: rotate(-5deg);
  }
  75% {
    transform: rotate(5deg);
  }
}

/* Float Animation */
@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-15px);
  }
}

/* Heartbeat Animation */
@keyframes heartbeat {
  0%, 100% {
    transform: scale(1);
  }
  14% {
    transform: scale(1.3);
  }
  28% {
    transform: scale(1);
  }
  42% {
    transform: scale(1.3);
  }
  70% {
    transform: scale(1);
  }
}

/* Jello Animation */
@keyframes jello {
  0%, 100% {
    transform: scale3d(1, 1, 1);
  }
  30% {
    transform: scale3d(1.25, 0.75, 1);
  }
  40% {
    transform: scale3d(0.75, 1.25, 1);
  }
  50% {
    transform: scale3d(1.15, 0.85, 1);
  }
  65% {
    transform: scale3d(0.95, 1.05, 1);
  }
  75% {
    transform: scale3d(1.05, 0.95, 1);
  }
}

/* Tada Animation */
@keyframes tada {
  0%, 100% {
    transform: scale(1) rotate(0deg);
  }
  10%, 20% {
    transform: scale(0.9) rotate(-3deg);
  }
  30%, 50%, 70%, 90% {
    transform: scale(1.1) rotate(3deg);
  }
  40%, 60%, 80% {
    transform: scale(1.1) rotate(-3deg);
  }
}

/* Swing Animation */
@keyframes swing {
  20% {
    transform: rotate(15deg);
  }
  40% {
    transform: rotate(-10deg);
  }
  60% {
    transform: rotate(5deg);
  }
  80% {
    transform: rotate(-5deg);
  }
  100% {
    transform: rotate(0deg);
  }
}

/* Flash Animation */
@keyframes flash {
  0%, 50%, 100% {
    opacity: 1;
  }
  25%, 75% {
    opacity: 0;
  }
}

/* Rubber Band Animation */
@keyframes rubberBand {
  0%, 100% {
    transform: scale3d(1, 1, 1);
  }
  30% {
    transform: scale3d(1.25, 0.75, 1);
  }
  40% {
    transform: scale3d(0.75, 1.25, 1);
  }
  50% {
    transform: scale3d(1.15, 0.85, 1);
  }
  65% {
    transform: scale3d(0.95, 1.05, 1);
  }
  75% {
    transform: scale3d(1.05, 0.95, 1);
  }
}

/* Confetti Fall */
@keyframes confettiFall {
  0% {
    transform: translateY(-100vh) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

/* Star Burst */
@keyframes starBurst {
  0% {
    transform: scale(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: scale(2) rotate(180deg);
    opacity: 0;
  }
}

/* Number Count Up */
@keyframes countUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.8);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ===== Animation Utility Classes ===== */

/* Basic Animations */
.animate-fadeIn {
  animation: fadeIn var(--transition-normal) forwards;
}

.animate-fadeOut {
  animation: fadeOut var(--transition-normal) forwards;
}

.animate-fadeInUp {
  animation: fadeInUp var(--transition-normal) forwards;
}

.animate-fadeInDown {
  animation: fadeInDown var(--transition-normal) forwards;
}

.animate-slideInDown {
  animation: slideInDown var(--transition-normal) forwards;
}

.animate-slideInUp {
  animation: slideInUp var(--transition-normal) forwards;
}

/* Scale Animations */
.animate-scaleIn {
  animation: scaleIn var(--transition-normal) forwards;
}

.animate-pop {
  animation: pop 0.3s ease forwards;
}

.animate-popIn {
  animation: popIn 0.4s ease forwards;
}

/* Bounce Animations */
.animate-bounce {
  animation: bounce 0.5s ease infinite;
}

.animate-bounceIn {
  animation: bounceIn 0.5s ease forwards;
}

/* Shake Animations */
.animate-shake {
  animation: shake 0.5s ease;
}

.animate-shakeSmall {
  animation: shakeSmall 0.3s ease;
}

/* Pulse Animations */
.animate-pulse {
  animation: pulse 1s ease infinite;
}

.animate-pulseGlow {
  animation: pulseGlow 2s ease infinite;
}

/* Rotate Animations */
.animate-rotate {
  animation: rotate 1s linear infinite;
}

.animate-rotateIn {
  animation: rotateIn 0.5s ease forwards;
}

.animate-wobble {
  animation: wobble 0.5s ease;
}

/* Float Animation */
.animate-float {
  animation: float 3s ease-in-out infinite;
}

/* Special Animations */
.animate-heartbeat {
  animation: heartbeat 1.5s ease infinite;
}

.animate-jello {
  animation: jello 0.9s ease;
}

.animate-tada {
  animation: tada 1s ease;
}

.animate-swing {
  animation: swing 1s ease;
  transform-origin: top center;
}

.animate-flash {
  animation: flash 1s ease;
}

.animate-rubberBand {
  animation: rubberBand 1s ease;
}

/* ===== Animation Delays ===== */
.delay-100 {
  animation-delay: 100ms;
}

.delay-200 {
  animation-delay: 200ms;
}

.delay-300 {
  animation-delay: 300ms;
}

.delay-400 {
  animation-delay: 400ms;
}

.delay-500 {
  animation-delay: 500ms;
}

/* ===== Animation Durations ===== */
.duration-fast {
  animation-duration: 0.15s;
}

.duration-normal {
  animation-duration: 0.3s;
}

.duration-slow {
  animation-duration: 0.5s;
}

.duration-slower {
  animation-duration: 1s;
}

/* ===== Animation Fill Modes ===== */
.fill-forwards {
  animation-fill-mode: forwards;
}

.fill-backwards {
  animation-fill-mode: backwards;
}

.fill-both {
  animation-fill-mode: both;
}

/* ===== Hover Animations ===== */
.hover-bounce:hover {
  animation: bounce 0.5s ease;
}

.hover-pulse:hover {
  animation: pulse 0.5s ease;
}

.hover-wobble:hover {
  animation: wobble 0.5s ease;
}

.hover-pop:hover {
  animation: pop 0.3s ease;
}

.hover-jello:hover {
  animation: jello 0.9s ease;
}

/* ===== Transition Classes ===== */
.transition-all {
  transition: all var(--transition-normal);
}

.transition-fast {
  transition: all var(--transition-fast);
}

.transition-slow {
  transition: all var(--transition-slow);
}

.transition-transform {
  transition: transform var(--transition-normal);
}

.transition-opacity {
  transition: opacity var(--transition-normal);
}

/* ===== Game-Specific Animations ===== */

/* Correct Answer Animation */
.correct-animation {
  animation: bounceIn 0.5s ease, pulse 0.5s ease 0.5s;
}

/* Wrong Answer Animation */
.wrong-animation {
  animation: shake 0.5s ease;
}

/* Badge Unlock Animation */
.badge-unlock-animation {
  animation: tada 1s ease, pulseGlow 2s ease 1s infinite;
}

/* Level Up Animation */
.levelup-animation {
  animation: bounceIn 0.5s ease, heartbeat 1.5s ease 0.5s;
}

/* Score Update Animation */
.score-update-animation {
  animation: pop 0.3s ease, pulse 0.5s ease 0.3s;
}

/* Timer Warning Animation */
.timer-warning-animation {
  animation: pulse 0.5s ease infinite;
}

/* Timer Danger Animation */
.timer-danger-animation {
  animation: heartbeat 0.3s ease infinite;
}

/* Mascot Animations */
.mascot-idle {
  animation: float 3s ease-in-out infinite;
}

.mascot-happy {
  animation: bounce 0.5s ease;
}

.mascot-sad {
  animation: shakeSmall 0.3s ease;
}

.mascot-celebrate {
  animation: tada 1s ease;
}

/* Button Press Animation */
.btn-press {
  animation: pop 0.2s ease;
}

/* Card Entrance Animations */
.card-enter-1 {
  animation: fadeInUp 0.4s ease forwards;
  animation-delay: 0.1s;
  opacity: 0;
}

.card-enter-2 {
  animation: fadeInUp 0.4s ease forwards;
  animation-delay: 0.2s;
  opacity: 0;
}

.card-enter-3 {
  animation: fadeInUp 0.4s ease forwards;
  animation-delay: 0.3s;
  opacity: 0;
}

/* Confetti Container */
.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
  z-index: var(--z-toast);
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  animation: confettiFall 3s ease-out forwards;
}

/* Star Celebration */
.star-celebration {
  position: absolute;
  font-size: 2rem;
  animation: starBurst 1s ease forwards;
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .animate-float,
  .animate-bounce,
  .animate-pulse,
  .animate-heartbeat,
  .mascot-idle {
    animation: none !important;
  }
}
