/**
 * Paril – Animations
 * All keyframe definitions and reusable animation classes.
 * Uses transform + opacity only for GPU acceleration.
 */

/* ============================================================
   KEYFRAMES
   ============================================================ */

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

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

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

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

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

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

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

@keyframes scaleSpring {
  0% { transform: scale(0.7); opacity: 0; }
  70% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

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

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

@keyframes pulseSlow {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-8px) rotate(-1deg); }
  30% { transform: translateX(7px) rotate(1deg); }
  45% { transform: translateX(-6px); }
  60% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
  90% { transform: translateX(2px); }
}

@keyframes correctPop {
  0% { transform: scale(1); }
  40% { transform: scale(1.12); }
  70% { transform: scale(0.96); }
  100% { transform: scale(1); }
}

@keyframes sparkle {
  0% { transform: scale(0) rotate(0deg); opacity: 1; }
  50% { transform: scale(1.2) rotate(180deg); opacity: 1; }
  100% { transform: scale(0) rotate(360deg); opacity: 0; }
}

@keyframes floatUp {
  0% { transform: translateY(0) scale(1); opacity: 1; }
  100% { transform: translateY(-60px) scale(0.5); opacity: 0; }
}

@keyframes heartbeat {
  0% { transform: scale(1); }
  14% { transform: scale(1.25); }
  28% { transform: scale(1); }
  42% { transform: scale(1.18); }
  70% { transform: scale(1); }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes progressFill {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

@keyframes shimmer {
  0% { background-position: -200% center; }
  100% { background-position: 200% center; }
}

@keyframes loadingDot {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

@keyframes xpFloat {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-50px) scale(0.8); }
}

@keyframes streakGlow {
  0%, 100% { filter: drop-shadow(0 0 4px var(--color-streak)); }
  50% { filter: drop-shadow(0 0 12px var(--color-streak)); }
}

@keyframes pathReveal {
  from { stroke-dashoffset: 1000; }
  to { stroke-dashoffset: 0; }
}

@keyframes modalEnter {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.88);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

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

@keyframes toastSlide {
  from {
    opacity: 0;
    transform: translateX(110%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes microWave {
  0%, 100% { transform: scaleY(0.3); }
  50% { transform: scaleY(1); }
}

@keyframes levelUpRing {
  0% { transform: scale(0.5); opacity: 1; }
  100% { transform: scale(2.5); opacity: 0; }
}

@keyframes starBurst {
  0% { transform: scale(0) rotate(0deg); opacity: 1; }
  50% { transform: scale(1.5) rotate(180deg); opacity: 1; }
  100% { transform: scale(0.8) rotate(360deg); opacity: 0; }
}

@keyframes gradientFlow {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes tapRipple {
  0% { transform: scale(0); opacity: 0.5; }
  100% { transform: scale(3); opacity: 0; }
}

@keyframes slideUpModal {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@keyframes slideDownModal {
  from { transform: translateY(0); }
  to { transform: translateY(100%); }
}

@keyframes typing {
  0%, 60%, 100% { opacity: 0; }
  30% { opacity: 1; }
}

/* ============================================================
   ANIMATION UTILITY CLASSES
   ============================================================ */

.animate-fade-in { animation: fadeIn var(--duration-base) var(--ease-decelerate) both; }
.animate-slide-up { animation: slideUp var(--duration-slow) var(--ease-decelerate) both; }
.animate-slide-down { animation: slideDown var(--duration-slow) var(--ease-decelerate) both; }
.animate-slide-left { animation: slideInLeft var(--duration-slow) var(--ease-decelerate) both; }
.animate-slide-right { animation: slideInRight var(--duration-slow) var(--ease-decelerate) both; }
.animate-scale-in { animation: scaleIn var(--duration-base) var(--ease-spring) both; }
.animate-scale-spring { animation: scaleSpring var(--duration-modal) var(--ease-spring) both; }
.animate-bounce-in { animation: bounceIn 0.5s var(--ease-bounce) both; }
.animate-pulse { animation: pulse 1.8s var(--ease-standard) infinite; }
.animate-heartbeat { animation: heartbeat 1.5s ease-in-out infinite; }
.animate-spin { animation: spin 1s linear infinite; }
.animate-shake { animation: shake 0.45s var(--ease-standard); }
.animate-correct { animation: correctPop 0.35s var(--ease-spring); }
.animate-shimmer {
  background: linear-gradient(90deg,
    transparent 0%,
    hsla(0,0%,100%,0.4) 50%,
    transparent 100%
  );
  background-size: 200% auto;
  animation: shimmer 1.5s linear infinite;
}

/* Staggered animation delays for lists */
.stagger-1 { animation-delay: 50ms; }
.stagger-2 { animation-delay: 100ms; }
.stagger-3 { animation-delay: 150ms; }
.stagger-4 { animation-delay: 200ms; }
.stagger-5 { animation-delay: 250ms; }
.stagger-6 { animation-delay: 300ms; }

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

/* ============================================================
   COMBO & FEEDBACK EFFECTS
   ============================================================ */

.lesson-combo-badge {
  display: inline-flex;
  align-items: center;
  background: linear-gradient(135deg, #FF9600, #FF5200);
  color: white;
  padding: 4px 12px;
  border-radius: 12px;
  font-weight: 900;
  font-size: 1.2rem;
  box-shadow: 0 4px 15px rgba(255, 150, 0, 0.4);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.lesson-combo-badge.hidden {
  opacity: 0;
  transform: scale(0.5) translateY(-20px);
  pointer-events: none;
}

.lesson-combo-badge.pop {
  animation: comboPop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes comboPop {
  0% { transform: scale(0.8); }
  50% { transform: scale(1.3) rotate(-5deg); box-shadow: 0 8px 25px rgba(255, 150, 0, 0.6); }
  100% { transform: scale(1) rotate(0); }
}

.feedback-combo-badge {
  display: inline-block;
  margin-top: 5px;
  background: rgba(255, 150, 0, 0.2);
  color: #FF9600;
  padding: 4px 10px;
  border-radius: 8px;
  font-weight: bold;
  font-size: 0.9rem;
  animation: slideUpFade 0.4s ease-out forwards;
}

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

/* Make correct footer glow */
.lesson-footer.is-correct {
  animation: glowCorrect 1s infinite alternate;
}

@keyframes glowCorrect {
  from { box-shadow: 0 -5px 20px rgba(88, 204, 2, 0.2); }
  to { box-shadow: 0 -5px 30px rgba(88, 204, 2, 0.5); }
}

@keyframes progressGlow {
  0% { box-shadow: 0 0 5px var(--color-primary), 0 0 10px var(--color-primary); }
  50% { box-shadow: 0 0 15px var(--color-primary), 0 0 25px var(--color-primary); }
  100% { box-shadow: 0 0 5px var(--color-primary), 0 0 10px var(--color-primary); }
}

.progress-glow {
  animation: progressGlow 1s ease-in-out infinite;
}

@keyframes barBounce {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(1.4); }
}

.bar-bounce {
  animation: barBounce 0.4s var(--ease-spring);
}

@keyframes rewardPop {
  0% { transform: scale(0.5) translateY(20px); opacity: 0; }
  60% { transform: scale(1.2) translateY(-10px); opacity: 1; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

.reward-pop {
  animation: rewardPop 0.6s var(--ease-spring) forwards;
}

@keyframes lessonCompleteBounce {
  0% { transform: scale(0.3); opacity: 0; }
  50% { transform: scale(1.1); opacity: 1; }
  70% { transform: scale(0.9); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}


.lesson-complete-bounce {
  animation: lessonCompleteBounce 0.8s var(--ease-bounce) forwards;
}

/* ============================================================
   TOP BAR REWARD & GLOW ANIMATIONS
   ============================================================ */

@keyframes headerRewardShimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes headerPulseGlow {
  0% { box-shadow: 0 4px 15px rgba(88, 204, 2, 0.1); }
  50% { box-shadow: 0 8px 30px rgba(88, 204, 2, 0.45), 0 0 20px rgba(255, 200, 0, 0.3); }
  100% { box-shadow: 0 4px 15px rgba(88, 204, 2, 0.1); }
}

@keyframes floatXpBadge {
  0% { opacity: 1; transform: translateY(0) scale(0.6); }
  30% { opacity: 1; transform: translateY(-18px) scale(1.25); }
  80% { opacity: 1; transform: translateY(-38px) scale(1); }
  100% { opacity: 0; transform: translateY(-55px) scale(0.7); }
}

@keyframes flamePulse {
  0%, 100% { transform: scale(1) rotate(0deg); filter: drop-shadow(0 0 4px rgba(255, 150, 0, 0.4)); }
  50% { transform: scale(1.3) rotate(8deg); filter: drop-shadow(0 0 16px rgba(255, 82, 0, 0.9)); }
}

.header-reward-glow {
  position: relative;
  overflow: hidden;
  animation: headerPulseGlow 0.8s ease-in-out 2;
}

.header-reward-glow::after {
  content: '';
  position: absolute;
  top: 0; left: -150%; width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
  transform: skewX(-20deg);
  animation: headerRewardShimmer 1.2s ease-in-out;
}

.floating-xp-pop {
  position: absolute;
  top: 10px;
  right: 20px;
  background: linear-gradient(135deg, #FFC800, #FF9600);
  color: white;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1.1rem;
  padding: 4px 12px;
  border-radius: 20px;
  box-shadow: 0 4px 12px rgba(255, 150, 0, 0.4);
  pointer-events: none;
  z-index: 100;
  animation: floatXpBadge 1.2s ease-out forwards;
}

.flame-streak-anim {
  animation: flamePulse 0.6s var(--ease-spring);
}


