/**
 * Learneta Animations - World-Class Motion Design
 * GSAP-like effects using CSS
 */

/**
 * CORE ANIMATION KEYFRAMES
 */

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(40px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-60px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(60px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes popIn {
  0% {
    opacity: 0;
    transform: scale(0.5);
  }
  70% {
    transform: scale(1.1);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes bounceIn {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    transform: scale(1.05);
  }
  70% {
    transform: scale(0.9);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes flipIn {
  from {
    opacity: 0;
    transform: perspective(400px) rotateY(90deg);
  }
  to {
    opacity: 1;
    transform: perspective(400px) rotateY(0);
  }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.05);
    opacity: 0.8;
  }
}

@keyframes glow {
  0%, 100% {
    box-shadow: 0 0 5px rgba(108, 190, 69, 0.4),
                0 0 20px rgba(108, 190, 69, 0.2);
  }
  50% {
    box-shadow: 0 0 20px rgba(108, 190, 69, 0.6),
                0 0 40px rgba(108, 190, 69, 0.3);
  }
}

@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

@keyframes wiggle {
  0%, 100% { transform: rotate(-3deg); }
  50% { transform: rotate(3deg); }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes dash {
  to {
    stroke-dashoffset: 0;
  }
}

/**
 * TASK CARD ANIMATIONS
 */

.task-card.animate-in {
  animation: card-enter 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  opacity: 0;
  transform: translateY(30px);
}

@keyframes card-enter {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.task-card.active {
  animation: card-active 0.5s ease forwards;
}

@keyframes card-active {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.01);
  }
  100% {
    transform: scale(1);
  }
}

/**
 * MIC BUTTON ANIMATIONS
 */

.mic-btn {
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.mic-btn:hover:not(:disabled) {
  transform: scale(1.1);
  animation: glow 2s ease-in-out infinite;
}

.mic-btn--recording {
  animation: mic-recording 1.2s ease-in-out infinite;
}

@keyframes mic-recording {
  0%, 100% {
    background: #fee2e2;
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
  }
  50% {
    background: #fecaca;
    box-shadow: 0 0 0 15px rgba(239, 68, 68, 0);
  }
}

.mic-btn__pulse {
  animation: mic-pulse 2s ease-out infinite;
}

@keyframes mic-pulse {
  0% {
    transform: scale(1);
    opacity: 0.6;
  }
  100% {
    transform: scale(1.8);
    opacity: 0;
  }
}

/**
 * AUDIO WAVE ANIMATION
 */

.audio-wave--playing .audio-wave__bar {
  animation: wave-bar 0.8s ease-in-out infinite;
}

.audio-wave--playing .audio-wave__bar:nth-child(1) { animation-delay: 0s; }
.audio-wave--playing .audio-wave__bar:nth-child(2) { animation-delay: 0.1s; }
.audio-wave--playing .audio-wave__bar:nth-child(3) { animation-delay: 0.2s; }
.audio-wave--playing .audio-wave__bar:nth-child(4) { animation-delay: 0.3s; }
.audio-wave--playing .audio-wave__bar:nth-child(5) { animation-delay: 0.4s; }
.audio-wave--playing .audio-wave__bar:nth-child(6) { animation-delay: 0.5s; }
.audio-wave--playing .audio-wave__bar:nth-child(7) { animation-delay: 0.1s; }
.audio-wave--playing .audio-wave__bar:nth-child(8) { animation-delay: 0.2s; }
.audio-wave--playing .audio-wave__bar:nth-child(9) { animation-delay: 0.3s; }
.audio-wave--playing .audio-wave__bar:nth-child(10) { animation-delay: 0.4s; }
.audio-wave--playing .audio-wave__bar:nth-child(11) { animation-delay: 0.5s; }
.audio-wave--playing .audio-wave__bar:nth-child(12) { animation-delay: 0.6s; }

@keyframes wave-bar {
  0%, 100% {
    height: 4px;
  }
  50% {
    height: 24px;
  }
}

/**
 * MEMORY CARD ANIMATIONS
 */

.memory-card {
  perspective: 1000px; /* Better depth, applied correctly */
}

/* Remove direct flip rotation on card container, evaluation.css handles .memory-card__inner */

.memory-card.matched .memory-card__inner {
  animation: card-matched 0.6s ease forwards;
}

@keyframes card-matched {
  0% {
    transform: rotateY(180deg) scale(1);
  }
  50% {
    transform: rotateY(180deg) scale(1.1);
    box-shadow: 0 0 30px rgba(108, 190, 69, 0.6);
  }
  100% {
    transform: rotateY(180deg) scale(1);
  }
}

@media (hover: hover) and (pointer: fine) {
  .memory-card:hover:not(.flipped):not(.matched) {
    transform: translateY(-5px);
  }
}

/**
 * BUTTON INTERACTIONS
 */

.btn {
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn:active {
  transform: scale(0.95);
}

.btn--primary {
  position: relative;
  overflow: hidden;
}

.btn--primary::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.btn--primary:active::after {
  width: 300px;
  height: 300px;
}

/**
 * CONFETTI ANIMATION
 */

.confetti-piece {
  position: absolute;
  animation: confetti-fall 3s ease-out forwards;
}

@keyframes confetti-fall {
  0% {
    opacity: 1;
    transform: translateY(0) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translateY(300px) rotate(720deg);
  }
}

/**
 * LOADING ANIMATIONS
 */

.loading-dots span {
  animation: dot-bounce 1.4s ease-in-out infinite both;
}

.loading-dots span:nth-child(1) {
  animation-delay: -0.32s;
}

.loading-dots span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes dot-bounce {
  0%, 80%, 100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}

/**
 * SUCCESS ANIMATIONS
 */

.success-ring {
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
  animation: dash 0.6s ease-in-out forwards;
}

.success-check {
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  animation: dash 0.3s ease-in-out 0.6s forwards;
}

/**
 * STAGGER ANIMATIONS
 */

.stagger-1 { animation-delay: 0.1s; }
.stagger-2 { animation-delay: 0.2s; }
.stagger-3 { animation-delay: 0.3s; }
.stagger-4 { animation-delay: 0.4s; }
.stagger-5 { animation-delay: 0.5s; }
.stagger-6 { animation-delay: 0.6s; }

/**
 * HOVER EFFECTS
 */

.hover-lift {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hover-lift:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.hover-scale {
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.hover-scale:hover {
  transform: scale(1.05);
}

/**
 * SCROLL ANIMATIONS
 */

.scroll-reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.scroll-reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/**
 * PROGRESS RING ANIMATION
 */

.progress-ring__circle {
  transition: stroke-dashoffset 0.35s;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
}

/**
 * WORD CHIP ANIMATIONS
 */

.word-chip {
  animation: chip-in 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes chip-in {
  from {
    opacity: 0;
    transform: scale(0.5) rotate(-10deg);
  }
  to {
    opacity: 1;
    transform: scale(1) rotate(0);
  }
}

/**
 * CHAT BUBBLE ANIMATIONS
 */

.chat-bubble--ai {
  animation: bubble-in-left 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.chat-bubble--user {
  animation: bubble-in-right 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes bubble-in-left {
  from {
    opacity: 0;
    transform: translateX(-20px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes bubble-in-right {
  from {
    opacity: 0;
    transform: translateX(20px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

/**
 * TOAST NOTIFICATION
 */

.toast-enter {
  animation: toast-in 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.toast-exit {
  animation: toast-out 0.3s ease forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(100px) scale(0.8);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateX(-50%) translateY(20px) scale(0.9);
  }
}

/**
 * REDUCED MOTION
 */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
