/**
 * Animation Keyframes
 * Reusable animation keyframes for consistent UI animations
 * Consolidated from list-spot-3step.css and other CSS files
 */

/* ============================================================================
   LOADING ANIMATIONS
   ============================================================================ */

/* Spin animation - canonical definition (used by .animate-spin) */
@-webkit-keyframes spin {
  to {
    -webkit-transform: rotate(360deg);
    transform: rotate(360deg);
  }
}

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

/* ============================================================================
   FADE ANIMATIONS
   ============================================================================ */

@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

/* ============================================================================
   SLIDE ANIMATIONS (MIGRATED FROM UNIFIED ANIMATION MANAGER)
   ============================================================================ */

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

@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 slideOutRight {
  0% { transform: translateX(0); opacity: 1; }
  100% { transform: translateX(100%); opacity: 0; }
}

/* ============================================================================
   SCALE ANIMATIONS (MIGRATED FROM UNIFIED ANIMATION MANAGER)
   ============================================================================ */

@keyframes scaleIn {
  0% { transform: scale(0); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes scaleOut {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(0); opacity: 0; }
}

/* ============================================================================
   FEEDBACK ANIMATIONS
   ============================================================================ */

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* NOTE: @keyframes bounce defined once below (discover-specific, used by .animate-bounce) */

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

.animate-fade-in-up {
  animation: fade-in-up 0.5s ease forwards;
}

.animate-spin {
  -webkit-animation: spin 1s linear infinite;
  animation: spin 1s linear infinite;
}

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

.animate-fadeIn {
  animation: fadeIn 0.3s ease-out;
}

.animate-fadeInScale {
  animation: fadeInScale 0.3s ease-out;
}

.animate-fadeInStep {
  animation: fadeInStep 0.3s ease-out;
}

/* ============================================================================
   SLIDE ANIMATION CLASSES (MIGRATED FROM UNIFIED ANIMATION MANAGER)
   ============================================================================ */

.animate-slideInLeft {
  animation: slideInLeft 0.3s cubic-bezier(0.215, 0.61, 0.355, 1);
}

.animate-slideInRight {
  animation: slideInRight 0.3s cubic-bezier(0.215, 0.61, 0.355, 1);
}

.animate-slideOutLeft {
  animation: slideOutLeft 0.3s cubic-bezier(0.55, 0.055, 0.675, 0.19);
}

.animate-slideOutRight {
  animation: slideOutRight 0.3s cubic-bezier(0.55, 0.055, 0.675, 0.19);
}

/* ============================================================================
   SCALE ANIMATION CLASSES (MIGRATED FROM UNIFIED ANIMATION MANAGER)
   ============================================================================ */

.animate-scaleIn {
  animation: scaleIn 0.2s cubic-bezier(0.215, 0.61, 0.355, 1);
}

.animate-scaleOut {
  animation: scaleOut 0.2s cubic-bezier(0.55, 0.055, 0.675, 0.19);
}

/* ============================================================================
   ENHANCED ANIMATIONS FROM CUSTOM.CSS
   ============================================================================ */

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

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

/* Scale animations from custom.css */
@keyframes scale-in {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Shimmer loading animation from custom.css */
@keyframes shimmer {
  0% { background-position: -200px 0; }
  100% { background-position: calc(200px + 100%) 0; }
}

/* Modal fade effects from custom.css */
@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* ============================================================================
   FADEOUT ANIMATION CLASS (MIGRATED FROM UNIFIED ANIMATION MANAGER)
   ============================================================================ */

.animate-fadeOut {
  animation: fadeOut 0.3s ease-in;
}

@keyframes ripple {
  from { transform: scale(0); opacity: 1; }
  to { transform: scale(2); opacity: 0; }
}

/* Loading states from custom.css */
@keyframes loading-pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.02);
  }
}

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

/* Utility classes */
.animate-fade-in { animation: fadeIn 0.3s ease-out; }
.animate-fade-in-down { animation: fadeInDown 0.3s ease-out; }
.animate-fade-in-left { animation: fadeInLeft 0.3s ease-out; }
.animate-fade-in-right { animation: fadeInRight 0.3s ease-out; }
.animate-scale-in { animation: fadeInScale 0.3s ease-out; }
.animate-bounce { animation: bounce 1s infinite; }

/* Loading states */

/* Shimmer effect */
.shimmer {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200px 100%;
  animation: shimmer 1.5s infinite;
}

/* ============================================================================
   ANIMATION DELAYS
   ============================================================================ */

/* Animation delays from custom.css */
.animate-delay-50 { animation-delay: 50ms; }
.animate-delay-100 { animation-delay: 100ms; }
.animate-delay-200 { animation-delay: 200ms; }
.animate-delay-300 { animation-delay: 300ms; }
.animate-delay-500 { animation-delay: 500ms; }
.animate-delay-700 { animation-delay: 700ms; }
.animate-delay-1000 { animation-delay: 1000ms; }

/* ============================================================================
   DARK MODE ANIMATIONS
   ============================================================================ */

/* Dark mode toggle animations from custom.css */
.animate-ripple::after {
  animation: ripple-effect 0.6s linear;
}

.animate-to-dark {
  animation: fade-in-dark var(--transition-slow) ease-in-out;
}

.animate-to-light {
  animation: fade-in-light var(--transition-slow) ease-in-out;
}

/* Theme switching animations from custom.css */
.theme-switching #theme-toggle {
  animation: pulse 0.6s ease-in-out;
}

/* Page-wide dark mode transition — html/body only (avoid * { transition } jank) */
html.dark-mode-transitioning,
html.dark-mode-transitioning body {
  transition:
    background-color var(--transition-slow) ease-in-out,
    color var(--transition-slow) ease-in-out,
    border-color var(--transition-slow) ease-in-out !important;
}

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

  /* Keep Maps tile/camera transitions intact (see device-compatibility.css). */
  .gm-style,
  .gm-style *,
  .gm-style *::before,
  .gm-style *::after,
  #map-container,
  #map-container *,
  #discover-map-studio,
  #discover-map-studio *,
  #listspot-map-studio,
  #listspot-map-studio * {
    animation-duration: revert !important;
    animation-iteration-count: revert !important;
    transition-duration: revert !important;
  }

  .ss-spinner,
  .ss-btn-spinner.is-visible,
  #loader .ss-spinner,
  .step-transition-loader__spinner-ring,
  .discover-loading-spinner,
  svg.animate-spin,
  .animate-spin.rounded-full {
    animation-duration: 0.75s !important;
    animation-iteration-count: infinite !important;
  }
}

/* NOTE: Dark overlay/text contrast rules live in themes/dark-mode.css only. */

/* ============================================================================
   DISCOVER-SPECIFIC ANIMATIONS (CONSOLIDATED)
   ============================================================================ */

@keyframes bounce {
  0%, 20%, 53%, 80%, 100% {
    transform: translate3d(0,0,0);
  }
  40%, 43% {
    transform: translate3d(0,-8px,0);
  }
  70% {
    transform: translate3d(0,-4px,0);
  }
  90% {
    transform: translate3d(0,-1px,0);
  }
}
