/* ============================================
   Animations & Transitions
   ============================================ */

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

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

.pulse {
  animation: pulse 0.6s ease-in-out;
}

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

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

/* Flip Animation */
@keyframes flip {
  0% {
    transform: rotateY(0deg);
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
  100% {
    transform: rotateY(360deg);
    opacity: 1;
  }
}

.flip {
  animation: flip 0.4s ease-in-out;
  transform-style: preserve-3d;
}

/* Slide In Up */
@keyframes slideInUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.slide-in-up {
  animation: slideInUp 0.5s ease-out;
}

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

.fade-in {
  animation: fadeIn 0.3s ease-in-out forwards;
}

/* Bounce Scale Animation */
@keyframes bounceScale {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

.bounce {
  animation: bounceScale 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Error Glow */
@keyframes errorGlow {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(244, 67, 54, 0);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(244, 67, 54, 0.2);
  }
}

.error-glow {
  animation: errorGlow 0.5s ease-in-out;
}

/* Confetti Fall Animation */
@keyframes fall {
  to {
    transform: translateY(100vh) rotateZ(360deg);
    opacity: 0;
  }
}

.confetti {
  position: fixed;
  width: 12px;
  height: 12px;
  top: 50%;
  border-radius: 50%;
  pointer-events: none;
  z-index: 999;
}

/* Twinkle Animation for Stars */
@keyframes twinkle {
  0%, 100% {
    opacity: 0;
    transform: scale(0) translateY(0);
  }
  50% {
    opacity: 1;
    transform: scale(1) translateY(-30px);
  }
}

.star {
  position: fixed;
  font-size: 24px;
  pointer-events: none;
  z-index: 999;
}

/* Mastery Burst */
@keyframes masteryBurst {
  0% {
    transform: scale(1);
    filter: drop-shadow(0 0 0 rgba(255, 193, 7, 0.8));
  }
  50% {
    filter: drop-shadow(0 0 20px rgba(255, 193, 7, 0.8));
  }
  100% {
    transform: scale(1);
    filter: drop-shadow(0 0 0 rgba(255, 193, 7, 0.8));
  }
}

.mastery-burst {
  animation: masteryBurst 1.5s ease-out;
}

/* Spinner Animation */
.spinning {
  animation: spin 1s linear infinite;
}

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

/* Slide and Fade Out */
@keyframes slideOutDown {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(100%);
    opacity: 0;
  }
}

/* Progress Bar Fill Animation */
@keyframes fillProgress {
  from {
    width: 0%;
  }
  to {
    width: 100%;
  }
}

/* Gentle Wobble for Buttons */
@keyframes wobble {
  0%, 100% {
    transform: rotate(0deg);
  }
  25% {
    transform: rotate(-2deg);
  }
  75% {
    transform: rotate(2deg);
  }
}

button:active {
  animation: wobble 0.2s ease-in-out;
}

/* Color Transition */
@keyframes colorShift {
  0% {
    background-color: #fff3e0;
  }
  50% {
    background-color: #fff8e1;
  }
  100% {
    background-color: #fff3e0;
  }
}

/* Highlight Animation */
.highlight {
  animation: colorShift 0.6s ease-in-out;
}

/* Smooth Transitions for Interactive Elements */
button,
input,
select,
textarea,
a {
  transition: all 0.2s ease-in-out;
}

/* Page Transition */
@keyframes pageIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.screen:not(.hidden) {
  animation: pageIn 0.3s ease-out;
}

/* Checkmark Animation */
@keyframes checkmark {
  0% {
    stroke-dashoffset: 100;
  }
  100% {
    stroke-dashoffset: 0;
  }
}

/* Loading Pulse */
@keyframes loadingPulse {
  0%, 100% {
    opacity: 0.3;
  }
  50% {
    opacity: 1;
  }
}

.loading-spinner {
  animation: spin 1s linear infinite;
}

/* Appear and Disappear */
@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Applied to stat cards and feedback */
.stat-card,
.feedback-container:not(.hidden) {
  animation: fadeInScale 0.3s ease-out;
}

/* Smooth Category Transition */
.category-badge {
  animation: slideInUp 0.3s ease-out;
}

/* Progress Bar Animation - specific for stats update */
.progress-bar-fill {
  transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Cascade Animation for Multiple Items */
@keyframes cascadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.category-stat {
  animation: cascadeIn 0.4s ease-out;
  animation-fill-mode: both;
}

.category-stat:nth-child(1) {
  animation-delay: 0s;
}

.category-stat:nth-child(2) {
  animation-delay: 0.1s;
}

.category-stat:nth-child(3) {
  animation-delay: 0.2s;
}

.category-stat:nth-child(4) {
  animation-delay: 0.3s;
}

/* ============================================
   Message Animations
   ============================================ */

/* Mastery Message Animation */
@keyframes masteryMessageSlide {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.mastery-message {
  animation: masteryMessageSlide 0.4s ease-out;
  font-weight: bold;
  color: #4CAF50;
  font-size: 1.1em;
  margin-top: 12px;
  padding: 12px;
  background: rgba(76, 175, 80, 0.1);
  border-radius: 8px;
  text-align: center;
}

/* Streak Message Animation */
@keyframes streakMessagePulse {
  0% {
    opacity: 0;
    transform: scale(0.95);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.streak-message {
  animation: streakMessagePulse 0.3s ease-out;
  font-weight: bold;
  color: #FF9800;
  font-size: 1em;
  margin-top: 8px;
  padding: 8px;
  background: rgba(255, 152, 0, 0.1);
  border-radius: 6px;
  text-align: center;
}

/* Congratulation Message Animation */
@keyframes congratulationGlow {
  0%, 100% {
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
  }
  50% {
    box-shadow: 0 0 20px rgba(76, 175, 80, 0.8);
  }
}

.congratulation-message {
  animation: congratulationGlow 2s ease-in-out infinite;
  padding: 16px;
  margin: 12px 0;
  background: rgba(76, 175, 80, 0.15);
  border: 2px solid #4CAF50;
  border-radius: 8px;
  text-align: center;
  font-weight: bold;
  color: #2E7D32;
}

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