/**
 * FRIO Ice Cream & Botana - Animation Styles
 * Subtle, functional animations for better user experience
 * All comments and debugging in English as requested
 */

/* === KEYFRAME ANIMATIONS === */

/* Fade in animation */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Fade in from bottom */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Fade in from top */
@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Fade in from left */
@keyframes fadeInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Fade in from right */
@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Scale in animation */
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Slide in from left */
@keyframes slideInLeft {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(0);
  }
}

/* Slide in from right */
@keyframes slideInRight {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

/* Slide out to left */
@keyframes slideOutLeft {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-100%);
  }
}

/* Slide out to right */
@keyframes slideOutRight {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(100%);
  }
}

/* Bounce animation for buttons */
@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-10px);
  }
  60% {
    transform: translateY(-5px);
  }
}

/* Pulse animation for loading states */
@keyframes pulse {
  0% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
  100% {
    opacity: 1;
  }
}

/* Spin animation for loading spinners */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* 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);
  }
}

/* Wobble animation for attention */
@keyframes wobble {
  0% {
    transform: translateX(0%);
  }
  15% {
    transform: translateX(-25px) rotate(-5deg);
  }
  30% {
    transform: translateX(20px) rotate(3deg);
  }
  45% {
    transform: translateX(-15px) rotate(-3deg);
  }
  60% {
    transform: translateX(10px) rotate(2deg);
  }
  75% {
    transform: translateX(-5px) rotate(-1deg);
  }
  100% {
    transform: translateX(0%);
  }
}

/* Glow animation for special elements */
@keyframes glow {
  0% {
    box-shadow: 0 0 5px var(--color-primary);
  }
  50% {
    box-shadow: 0 0 20px var(--color-primary), 0 0 30px var(--color-primary);
  }
  100% {
    box-shadow: 0 0 5px var(--color-primary);
  }
}

/* Floating animation for hero elements */
@keyframes float {
  0% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-10px);
  }
  100% {
    transform: translateY(0px);
  }
}

/* Rotate animation for icons */
@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Scale pulse for featured badges */
@keyframes scalePulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

/* === ANIMATION UTILITY CLASSES === */

/* Fade animations */
.animate-fade-in {
  animation: fadeIn 0.6s ease-out;
}

.animate-fade-in-up {
  animation: fadeInUp 0.6s ease-out;
}

.animate-fade-in-down {
  animation: fadeInDown 0.6s ease-out;
}

.animate-fade-in-left {
  animation: fadeInLeft 0.6s ease-out;
}

.animate-fade-in-right {
  animation: fadeInRight 0.6s ease-out;
}

/* Scale animations */
.animate-scale-in {
  animation: scaleIn 0.4s ease-out;
}

/* Slide animations */
.animate-slide-in-left {
  animation: slideInLeft 0.3s ease-out;
}

.animate-slide-in-right {
  animation: slideInRight 0.3s ease-out;
}

.animate-slide-out-left {
  animation: slideOutLeft 0.3s ease-in;
}

.animate-slide-out-right {
  animation: slideOutRight 0.3s ease-in;
}

/* Action animations */
.animate-bounce {
  animation: bounce 1s;
}

.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.animate-spin {
  animation: spin 1s linear infinite;
}

.animate-shake {
  animation: shake 0.5s ease-in-out;
}

.animate-wobble {
  animation: wobble 1s ease-in-out;
}

.animate-glow {
  animation: glow 2s ease-in-out infinite;
}

.animate-float {
  animation: float 3s ease-in-out infinite;
}

.animate-rotate {
  animation: rotate 2s linear infinite;
}

.animate-scale-pulse {
  animation: scalePulse 2s ease-in-out infinite;
}

/* Animation delays */
.animate-delay-100 {
  animation-delay: 0.1s;
}

.animate-delay-200 {
  animation-delay: 0.2s;
}

.animate-delay-300 {
  animation-delay: 0.3s;
}

.animate-delay-500 {
  animation-delay: 0.5s;
}

.animate-delay-700 {
  animation-delay: 0.7s;
}

.animate-delay-1000 {
  animation-delay: 1s;
}

/* Animation speeds */
.animate-fast {
  animation-duration: 0.3s;
}

.animate-slow {
  animation-duration: 1s;
}

.animate-slower {
  animation-duration: 2s;
}

/* === PAGE LOAD ANIMATIONS === */

/* Hero section animations */
.hero-title {
  animation: fadeInUp 0.8s ease-out;
}

.hero-subtitle {
  animation: fadeInUp 0.8s ease-out 0.2s both;
}

.hero-ctas {
  animation: fadeInUp 0.8s ease-out 0.4s both;
}

.hero-image {
  animation: fadeInRight 1s ease-out 0.3s both;
}

/* Stagger animations for lists */
.stagger-children > * {
  animation: fadeInUp 0.6s ease-out both;
}

.stagger-children > *:nth-child(1) { animation-delay: 0.1s; }
.stagger-children > *:nth-child(2) { animation-delay: 0.2s; }
.stagger-children > *:nth-child(3) { animation-delay: 0.3s; }
.stagger-children > *:nth-child(4) { animation-delay: 0.4s; }
.stagger-children > *:nth-child(5) { animation-delay: 0.5s; }
.stagger-children > *:nth-child(6) { animation-delay: 0.6s; }

/* === COMPONENT-SPECIFIC ANIMATIONS === */

/* Button animations */
.btn {
  transition: all var(--transition-base);
}

.btn:hover {
  transform: translateY(-2px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary:hover {
  box-shadow: 0 8px 25px rgba(249, 79, 79, 0.3);
}

.btn-secondary:hover {
  box-shadow: 0 8px 25px rgba(168, 230, 207, 0.3);
}

/* Card animations */
.product-card,
.category-card,
.review-card {
  transition: all var(--transition-base);
}

.product-card:hover,
.category-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
}

/* Navigation animations */
.mobile-menu {
  transition: all var(--transition-base);
}

.mobile-menu.open {
  animation: slideInLeft 0.3s ease-out;
}

.mobile-menu.closing {
  animation: slideOutLeft 0.3s ease-in;
}

/* Mobile menu items stagger */
.mobile-nav-item {
  opacity: 0;
  transform: translateX(-20px);
  transition: all var(--transition-base);
}

.mobile-menu.open .mobile-nav-item {
  opacity: 1;
  transform: translateX(0);
}

.mobile-menu.open .mobile-nav-item:nth-child(1) { transition-delay: 0.1s; }
.mobile-menu.open .mobile-nav-item:nth-child(2) { transition-delay: 0.15s; }
.mobile-menu.open .mobile-nav-item:nth-child(3) { transition-delay: 0.2s; }
.mobile-menu.open .mobile-nav-item:nth-child(4) { transition-delay: 0.25s; }
.mobile-menu.open .mobile-nav-item:nth-child(5) { transition-delay: 0.3s; }

/* Form animations */
.form-input,
.form-textarea,
.form-select {
  transition: all var(--transition-base);
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  transform: scale(1.02);
}

.form-error {
  animation: fadeInUp 0.3s ease-out;
}

.form-success {
  animation: fadeInUp 0.5s ease-out;
}

/* Form validation shake */
.form-input.error,
.form-textarea.error,
.form-select.error {
  animation: shake 0.5s ease-in-out;
}

/* === LOADING ANIMATIONS === */

/* Loading spinner */
.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--color-border-light);
  border-top: 4px solid var(--color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: var(--space-4) auto;
}

/* Loading skeleton */
.loading-skeleton {
  background: linear-gradient(
    90deg,
    var(--color-bg-gray-light) 25%,
    var(--color-bg-gray) 50%,
    var(--color-bg-gray-light) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Loading dots */
.loading-dots {
  display: inline-flex;
  gap: var(--space-1);
}

.loading-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--color-primary);
  animation: loading-dot 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 loading-dot {
  0%, 80%, 100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}

/* === SPECIAL FRIO ANIMATIONS === */

/* Ice cream float animation for product images */
.product-image img {
  transition: all var(--transition-base);
}

.product-card:hover .product-image img {
  animation: float 2s ease-in-out infinite;
}

/* Spice level indicator animation */
.spice-level-display {
  transition: all var(--transition-base);
}

.spice-level-display:hover {
  animation: scalePulse 0.6s ease-in-out;
}

/* Rating stars animation */
.rating-stars .star {
  transition: all var(--transition-fast);
  display: inline-block;
}

.rating-stars:hover .star {
  animation: bounce 0.6s ease-in-out;
}

.rating-stars .star:nth-child(1) { animation-delay: 0s; }
.rating-stars .star:nth-child(2) { animation-delay: 0.1s; }
.rating-stars .star:nth-child(3) { animation-delay: 0.2s; }
.rating-stars .star:nth-child(4) { animation-delay: 0.3s; }
.rating-stars .star:nth-child(5) { animation-delay: 0.4s; }

/* Phone number CTA glow animation */
.phone-cta-link {
  transition: all var(--transition-base);
}

.phone-cta-link:hover {
  animation: glow 1s ease-in-out;
}

/* Featured badge pulse */
.status-badge.badge-featured {
  animation: scalePulse 2s ease-in-out infinite;
}

/* New badge animation */
.status-badge.badge-new {
  animation: wobble 2s ease-in-out infinite;
}

/* Category color pulse */
.category-card {
  position: relative;
  overflow: hidden;
}

.category-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  transition: left 0.5s;
}

.category-card:hover::before {
  left: 100%;
}

/* === SCROLL ANIMATIONS === */

/* Fade in when scrolling into view */
.scroll-fade-in {
  opacity: 0;
  transform: translateY(30px);
  transition: all 0.6s ease-out;
}

.scroll-fade-in.in-view {
  opacity: 1;
  transform: translateY(0);
}

/* Scale in when scrolling into view */
.scroll-scale-in {
  opacity: 0;
  transform: scale(0.8);
  transition: all 0.6s ease-out;
}

.scroll-scale-in.in-view {
  opacity: 1;
  transform: scale(1);
}

/* === TOAST/NOTIFICATION ANIMATIONS === */

.toast {
  transform: translateX(100%);
  transition: transform var(--transition-base);
}

.toast.show {
  transform: translateX(0);
}

.toast.hide {
  animation: slideOutRight 0.3s ease-in forwards;
}

/* === MODAL ANIMATIONS === */

.modal {
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
}

.modal.show {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  transform: scale(0.7);
  transition: transform var(--transition-base);
}

.modal.show .modal-content {
  transform: scale(1);
}

/* === ACCORDION ANIMATIONS === */

.accordion-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--transition-slow) ease-out;
}

.accordion-item.active .accordion-content {
  max-height: 500px; /* Adjust based on content */
}

.accordion-toggle {
  transition: transform var(--transition-base);
}

.accordion-item.active .accordion-toggle {
  transform: rotate(180deg);
}

/* === HOVER EFFECTS === */

/* Image hover zoom */
.hover-zoom {
  overflow: hidden;
}

.hover-zoom img {
  transition: transform var(--transition-slow);
}

.hover-zoom:hover img {
  transform: scale(1.05);
}

/* Text hover underline animation */
.hover-underline {
  position: relative;
}

.hover-underline::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background-color: var(--color-accent-red);
  transition: width var(--transition-base);
}

.hover-underline:hover::after {
  width: 100%;
}

/* === MOBILE OPTIMIZATIONS === */

/* Reduce animations on mobile for performance */
@media (max-width: 768px) {
  .animate-float,
  .animate-glow,
  .animate-scale-pulse {
    animation: none;
  }
  
  /* Faster animations on mobile */
  .animate-fade-in,
  .animate-fade-in-up,
  .animate-fade-in-down,
  .animate-fade-in-left,
  .animate-fade-in-right {
    animation-duration: 0.4s;
  }
}

/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .animate-float,
  .animate-glow,
  .animate-pulse,
  .animate-spin,
  .animate-scale-pulse {
    animation: none !important;
  }
}

/* === PERFORMANCE-FRIENDLY ANIMATIONS === */

/* Use transform and opacity for better performance */
.will-change-transform {
  will-change: transform;
}

.will-change-opacity {
  will-change: opacity;
}

/* Remove will-change after animation completes */
.animation-complete {
  will-change: auto;
}