/* ============================================
   Kids Learning Platform - Animations
   Fun, engaging animations for children
   ============================================ */

/* === Correct Answer - Green flash + checkmark === */
@keyframes correctFlash {
  0% { background-color: transparent; }
  20% { background-color: rgba(76, 175, 80, 0.2); }
  100% { background-color: transparent; }
}

@keyframes checkmarkPop {
  0% { transform: scale(0) rotate(-45deg); opacity: 0; }
  50% { transform: scale(1.3) rotate(0deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.anim-correct { animation: correctFlash 0.6s ease-out; }
.anim-checkmark { animation: checkmarkPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); }

/* === Wrong Answer - Gentle shake === */
@keyframes gentleShake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-6px); }
  30% { transform: translateX(5px); }
  45% { transform: translateX(-4px); }
  60% { transform: translateX(3px); }
  75% { transform: translateX(-2px); }
}

.anim-wrong { animation: gentleShake 0.5s ease-out; }

/* === Button bounce on hover/active === */
@keyframes buttonBounce {
  0% { transform: scale(1); }
  40% { transform: scale(1.08); }
  60% { transform: scale(0.97); }
  100% { transform: scale(1.05); }
}

.btn-bounce:hover {
  animation: buttonBounce 0.3s ease-out forwards;
}
.btn-bounce:active {
  transform: scale(0.95);
  transition: transform 0.1s;
}

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

.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  top: -10px;
  width: 10px;
  height: 14px;
  border-radius: 2px;
  animation: confettiFall 2.5s ease-in forwards;
}

/* Confetti colors */
.confetti-piece:nth-child(6n+1) { background: #FF6B6B; }
.confetti-piece:nth-child(6n+2) { background: #4A90D9; }
.confetti-piece:nth-child(6n+3) { background: #4CAF50; }
.confetti-piece:nth-child(6n+4) { background: #FFD700; }
.confetti-piece:nth-child(6n+5) { background: #FF8C42; }
.confetti-piece:nth-child(6n+6) { background: #AB47BC; }

/* === Stars bursting (level complete) === */
@keyframes starBurst {
  0% { transform: scale(0) rotate(0deg); opacity: 0; }
  50% { transform: scale(1.5) rotate(180deg); opacity: 1; }
  100% { transform: scale(1) rotate(360deg); opacity: 1; }
}

@keyframes starFloat {
  0% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-15px) scale(1.1); }
  100% { transform: translateY(0) scale(1); }
}

.anim-star-burst { animation: starBurst 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.anim-star-float { animation: starFloat 2s ease-in-out infinite; }

/* === Streak fire effect === */
@keyframes fireGlow {
  0%, 100% { filter: brightness(1) drop-shadow(0 0 4px #FF6B00); }
  50% { filter: brightness(1.2) drop-shadow(0 0 12px #FF8C42); }
}

@keyframes fireGrow {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.anim-streak-fire {
  animation: fireGlow 0.8s ease-in-out infinite, fireGrow 0.8s ease-in-out infinite;
}

/* === Streak counter bounce === */
@keyframes streakBounce {
  0% { transform: scale(1); }
  30% { transform: scale(1.4); }
  50% { transform: scale(0.9); }
  70% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.anim-streak-count { animation: streakBounce 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275); }

/* === Badge fly-in === */
@keyframes badgeFlyIn {
  0% { transform: translateY(-100vh) scale(0.3) rotate(-30deg); opacity: 0; }
  60% { transform: translateY(10px) scale(1.1) rotate(5deg); opacity: 1; }
  80% { transform: translateY(-5px) scale(0.95) rotate(-2deg); }
  100% { transform: translateY(0) scale(1) rotate(0deg); opacity: 1; }
}

@keyframes badgeGlow {
  0%, 100% { box-shadow: 0 0 10px rgba(255, 215, 0, 0.3); }
  50% { box-shadow: 0 0 30px rgba(255, 215, 0, 0.7), 0 0 60px rgba(255, 215, 0, 0.3); }
}

.anim-badge-fly { animation: badgeFlyIn 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.anim-badge-glow { animation: badgeGlow 1.5s ease-in-out 3; }

/* === XP counter rolling up === */
@keyframes xpRollUp {
  0% { transform: translateY(20px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

.anim-xp-roll { animation: xpRollUp 0.3s ease-out; }

/* === Level complete celebration text === */
@keyframes celebrationText {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.2); }
  70% { transform: scale(0.9); }
  100% { transform: scale(1); opacity: 1; }
}

.anim-celebration-text {
  animation: celebrationText 0.7s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* === Page transitions === */
@keyframes slideInRight {
  from { transform: translateX(30px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

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

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

.page-enter { animation: slideInRight 0.2s ease-out; }
.page-enter-up { animation: slideInUp 0.2s ease-out; }
.page-fade { animation: fadeIn 0.2s ease-out; }

/* === Loading - bouncing dots === */
@keyframes loadingBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

.loading-dots {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.loading-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  animation: loadingBounce 1.2s infinite ease-in-out;
}
.loading-dot:nth-child(1) { background: #4A90D9; animation-delay: 0s; }
.loading-dot:nth-child(2) { background: #FF8C42; animation-delay: 0.15s; }
.loading-dot:nth-child(3) { background: #4CAF50; animation-delay: 0.3s; }

/* === Card entrance (staggered) === */
@keyframes cardEntrance {
  from { transform: translateY(30px) scale(0.95); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.card-enter {
  animation: cardEntrance 0.4s ease-out backwards;
}
.card-enter:nth-child(1) { animation-delay: 0s; }
.card-enter:nth-child(2) { animation-delay: 0.08s; }
.card-enter:nth-child(3) { animation-delay: 0.16s; }
.card-enter:nth-child(4) { animation-delay: 0.24s; }
.card-enter:nth-child(5) { animation-delay: 0.32s; }
.card-enter:nth-child(6) { animation-delay: 0.40s; }

/* === Mascot wave === */
@keyframes mascotWave {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(15deg); }
  75% { transform: rotate(-10deg); }
}

.anim-mascot-wave { animation: mascotWave 1s ease-in-out 2; }

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

.anim-pulse { animation: pulse 2s ease-in-out infinite; }

/* === Progress bar fill === */
@keyframes progressFill {
  from { width: 0; }
}

.anim-progress-fill {
  animation: progressFill 1s ease-out;
}

/* === Flower petal grow (mastery visualization) === */
@keyframes petalGrow {
  from { transform: scale(0); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.anim-petal {
  animation: petalGrow 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) backwards;
}
.anim-petal:nth-child(1) { animation-delay: 0s; }
.anim-petal:nth-child(2) { animation-delay: 0.1s; }
.anim-petal:nth-child(3) { animation-delay: 0.2s; }
.anim-petal:nth-child(4) { animation-delay: 0.3s; }
.anim-petal:nth-child(5) { animation-delay: 0.4s; }

/* === Quiz engine: slide out left (question transition) === */
@keyframes slideOutLeft {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(-40px); opacity: 0; }
}

.slide-out-left { animation: slideOutLeft 0.3s ease-in forwards; }

/* === Bounce in (overlay popups) === */
@keyframes bounceIn {
  0% { transform: scale(0.3); opacity: 0; }
  50% { transform: scale(1.08); }
  70% { transform: scale(0.95); }
  100% { transform: scale(1); opacity: 1; }
}

.anim-bounce-in { animation: bounceIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275); }

/* === Staggered fade-in for answer buttons === */
@keyframes staggerFadeIn {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* === Quiz choice button enhanced styles === */
.quiz-choice-btn {
  transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.2s ease, border-color 0.2s ease;
}

/* === Timer animations === */
@keyframes timerPulse { 0%,100% { opacity:1; } 50% { opacity:0.5; } }
@keyframes timerWarning { 0% { transform:scale(1); } 50% { transform:scale(1.15); } 100% { transform:scale(1); } }

/* === Shop item hover effect (subtle scale on hover, NO spinning/bouncing) === */
.shop-item-svg {
    transition: transform 0.2s ease;
}
.shop-item-card:hover .shop-item-svg {
    transform: scale(1.05);
}

/* Coin counter animation */
@keyframes coinBounce { 0% { transform:scale(1); } 30% { transform:scale(1.3); } 100% { transform:scale(1); } }
.coin-bounce { animation: coinBounce 0.4s ease-out; }

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