/* Card Animations */
@keyframes cardEnter {
  0% {
    transform: scale(0.8) translateY(50px);
    opacity: 0;
  }
  100% {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

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

@keyframes swipeLeft {
  0% {
    transform: translateX(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateX(-150%) rotate(-30deg);
    opacity: 0;
  }
}

@keyframes swipeRight {
  0% {
    transform: translateX(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateX(150%) rotate(30deg);
    opacity: 0;
  }
}

@keyframes cardStack {
  0% {
    transform: scale(0.85) translateY(30px);
    opacity: 0.4;
  }
  100% {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

/* Apply animations */
.book-card.entering {
  animation: cardEnter 0.4s ease-out forwards;
}

.book-card.exiting {
  animation: cardExit 0.3s ease-in forwards;
}

.book-card.animate-swipe-left {
  animation: swipeLeft 0.3s ease-out forwards;
}

.book-card.animate-swipe-right {
  animation: swipeRight 0.3s ease-out forwards;
}

.book-card.animate-stack {
  animation: cardStack 0.3s ease-out forwards;
}

/* Button Animations */
@keyframes buttonPress {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(0.95);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes buttonSuccess {
  0% {
    transform: scale(1);
    background-color: var(--success-color);
  }
  50% {
    transform: scale(1.1);
    background-color: #059669;
  }
  100% {
    transform: scale(1);
    background-color: var(--success-color);
  }
}

@keyframes buttonReject {
  0% {
    transform: scale(1);
    background-color: var(--danger-color);
  }
  50% {
    transform: scale(1.1);
    background-color: #dc2626;
  }
  100% {
    transform: scale(1);
    background-color: var(--danger-color);
  }
}

.action-btn.pressed {
  animation: buttonPress 0.2s ease-out;
}

.action-btn.success-feedback {
  animation: buttonSuccess 0.4s ease-out;
}

.action-btn.reject-feedback {
  animation: buttonReject 0.4s ease-out;
}

/* Screen Transitions */
@keyframes slideInRight {
  0% {
    transform: translateX(100%);
    opacity: 0;
  }
  100% {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOutLeft {
  0% {
    transform: translateX(0);
    opacity: 1;
  }
  100% {
    transform: translateX(-100%);
    opacity: 0;
  }
}

@keyframes fadeIn {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.screen.slide-in {
  animation: slideInRight 0.4s ease-out forwards;
}

.screen.slide-out {
  animation: slideOutLeft 0.4s ease-in forwards;
}

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

/* Progress Bar Animation */
@keyframes progressFill {
  0% {
    width: 0%;
  }
}

.progress-fill.animate {
  animation: progressFill 0.5s ease-out forwards;
}

/* Swipe Indicator Animations */
@keyframes indicatorPulse {
  0% {
    transform: translateY(-50%) scale(0.8);
    opacity: 0;
  }
  50% {
    transform: translateY(-50%) scale(1.1);
    opacity: 1;
  }
  100% {
    transform: translateY(-50%) scale(1);
    opacity: 1;
  }
}

.swipe-indicator.animate {
  animation: indicatorPulse 0.3s ease-out forwards;
}

/* Loading Animations */
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.loading-placeholder {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Floating Animation for Success Icons */
@keyframes float {
  0%,
  100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-10px);
  }
}

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

/* Bounce Animation for Buttons */
@keyframes bounce {
  0%,
  20%,
  53%,
  80%,
  100% {
    transform: translate3d(0, 0, 0);
  }
  40%,
  43% {
    transform: translate3d(0, -10px, 0);
  }
  70% {
    transform: translate3d(0, -5px, 0);
  }
  90% {
    transform: translate3d(0, -2px, 0);
  }
}

.bounce {
  animation: bounce 1s ease-in-out;
}

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

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

/* Glow Effect */
@keyframes glow {
  0% {
    box-shadow: 0 0 5px rgba(99, 102, 241, 0.3);
  }
  50% {
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.6);
  }
  100% {
    box-shadow: 0 0 5px rgba(99, 102, 241, 0.3);
  }
}

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

/* 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;
  }

  .loading-spinner {
    animation: none;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
  }
}

/* Hover Effects */
@media (hover: hover) {
  .action-btn:hover {
    transform: scale(1.05);
  }

  .primary-btn:hover,
  .secondary-btn:hover {
    transform: translateY(-2px);
  }
}
