/* ============================================
   CRISLYN'S MATH ADVENTURE — Animations
   ============================================ */

/* --- Entrance Animations --- */
.fade-in {
  animation: fadeIn 0.5s var(--ease-smooth) both;
}

.fade-in-up {
  animation: fadeInUp 0.5s var(--ease-bounce) both;
}

.fade-in-down {
  animation: fadeInDown 0.5s var(--ease-bounce) both;
}

.pop-in {
  animation: popIn 0.4s var(--ease-bounce) both;
}

.slide-in-left {
  animation: slideInLeft 0.5s var(--ease-bounce) both;
}

.slide-in-right {
  animation: slideInRight 0.5s var(--ease-bounce) both;
}

/* Staggered children: add delay-1, delay-2, etc. */
.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }
.delay-4 { animation-delay: 0.4s; }
.delay-5 { animation-delay: 0.5s; }
.delay-6 { animation-delay: 0.6s; }
.delay-7 { animation-delay: 0.7s; }
.delay-8 { animation-delay: 0.8s; }

/* --- Looping Animations --- */
.pulse {
  animation: pulse 2s var(--ease-smooth) infinite;
}

.bounce {
  animation: bounce 1s var(--ease-bounce) infinite;
}

.float {
  animation: float 3s ease-in-out infinite;
}

.glow {
  animation: glow 2s ease-in-out infinite alternate;
}

.sparkle {
  animation: sparkle 1.5s ease-in-out infinite;
}

.wiggle {
  animation: wiggle 0.5s ease-in-out;
}

.spin {
  animation: spin 2s linear infinite;
}

/* --- Star Animations --- */
.star-earned {
  animation: starEarned 0.6s var(--ease-bounce) both;
}

.star-empty {
  opacity: 0.3;
  filter: grayscale(1);
}

/* --- Number Counter Animation --- */
.counter-roll {
  animation: counterRoll 0.3s var(--ease-smooth);
}

/* --- Keyframes --- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@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 popIn {
  from {
    opacity: 0;
    transform: scale(0.5);
  }
  60% {
    transform: scale(1.1);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

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

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

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

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

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes glow {
  from { box-shadow: 0 0 10px rgba(168, 85, 247, 0.3); }
  to { box-shadow: 0 0 25px rgba(168, 85, 247, 0.6); }
}

@keyframes sparkle {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.2); }
}

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

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

@keyframes starEarned {
  0% { transform: scale(0) rotate(-180deg); opacity: 0; }
  60% { transform: scale(1.3) rotate(10deg); }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

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

/* --- Celebration burst (used after quiz completion) --- */
@keyframes celebrationBurst {
  0% { transform: scale(0); opacity: 1; }
  50% { transform: scale(1.5); opacity: 0.8; }
  100% { transform: scale(2); opacity: 0; }
}

.celebration-burst {
  animation: celebrationBurst 0.8s var(--ease-smooth) both;
}

/* --- Correct/Wrong feedback flashes --- */
.flash-green {
  animation: flashGreen 0.5s ease-out;
}

.flash-red {
  animation: flashRed 0.5s ease-out;
}

@keyframes flashGreen {
  0% { background-color: var(--color-success-light); }
  100% { background-color: transparent; }
}

@keyframes flashRed {
  0% { background-color: var(--color-error-light); }
  100% { background-color: transparent; }
}

/* --- Typewriter effect for number names --- */
.typewriter {
  overflow: hidden;
  border-right: 3px solid var(--color-primary);
  white-space: nowrap;
  animation:
    typing 2s steps(40, end),
    blinkCursor 0.75s step-end infinite;
}

@keyframes typing {
  from { width: 0; }
  to { width: 100%; }
}

@keyframes blinkCursor {
  from, to { border-color: transparent; }
  50% { border-color: var(--color-primary); }
}

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