/**
 * Campix Animations
 * Keyframe animations and transitions
 */

/* =================================================================
   KEYFRAME ANIMATIONS
   ================================================================= */

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

/* Fade In Up */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Fade In Down */
@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Slide In Right (for RTL) */
@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Slide In Left */
@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Scale In */
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Scale Out */
@keyframes scaleOut {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.8);
  }
}

/* Bounce In */
@keyframes bounceIn {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
  }
  70% {
    transform: scale(0.9);
  }
  100% {
    transform: scale(1);
  }
}

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

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

/* Spin (loading spinner) */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Shimmer (skeleton loading) */
@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

/* Float */
@keyframes float {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-10px);
  }
}

/* Rotate */
@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Wiggle */
@keyframes wiggle {
  0%, 100% {
    transform: rotate(0deg);
  }
  25% {
    transform: rotate(-5deg);
  }
  75% {
    transform: rotate(5deg);
  }
}

/* Glow */
@keyframes glow {
  0%, 100% {
    box-shadow: 0 0 5px var(--color-primary);
  }
  50% {
    box-shadow: 0 0 20px var(--color-primary);
  }
}

/* Slide Down (dropdown) */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

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

/* Typing Indicator */
@keyframes typing {
  0%, 60%, 100% {
    opacity: 0.3;
  }
  30% {
    opacity: 1;
  }
}

/* Ripple Effect */
@keyframes ripple {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

/* Flash */
@keyframes flash {
  0%, 50%, 100% {
    opacity: 1;
  }
  25%, 75% {
    opacity: 0;
  }
}

/* Rubber Band */
@keyframes rubberBand {
  0% {
    transform: scale(1);
  }
  30% {
    transform: scaleX(1.25) scaleY(0.75);
  }
  40% {
    transform: scaleX(0.75) scaleY(1.25);
  }
  50% {
    transform: scaleX(1.15) scaleY(0.85);
  }
  65% {
    transform: scaleX(0.95) scaleY(1.05);
  }
  75% {
    transform: scaleX(1.05) scaleY(0.95);
  }
  100% {
    transform: scale(1);
  }
}

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

/* Fade Animations */
.animate-fade-in {
  animation: fadeIn 0.5s ease-out;
}

.animate-fade-in-up {
  animation: fadeInUp 0.6s ease-out;
}

.animate-fade-in-down {
  animation: fadeInDown 0.6s ease-out;
}

/* Slide Animations */
.animate-slide-in-right {
  animation: slideInRight 0.5s ease-out;
}

.animate-slide-in-left {
  animation: slideInLeft 0.5s ease-out;
}

.animate-slide-down {
  animation: slideDown 0.3s ease-out;
}

.animate-slide-up {
  animation: slideUp 0.3s ease-out;
}

/* Scale Animations */
.animate-scale-in {
  animation: scaleIn 0.3s ease-out;
}

.animate-bounce-in {
  animation: bounceIn 0.5s ease-out;
}

/* Interactive Animations */
.animate-shake {
  animation: shake 0.4s ease-in-out;
}

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

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

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

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

/* Loading Animations */
.animate-spin {
  animation: spin 1s linear infinite;
}

.animate-shimmer {
  background: linear-gradient(
    90deg,
    var(--color-bg-secondary) 0%,
    var(--color-bg-tertiary) 50%,
    var(--color-bg-secondary) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

/* =================================================================
   COMPONENT-SPECIFIC ANIMATIONS
   ================================================================= */

/* Product Card Animation */
.product-card {
  animation: fadeInUp 0.5s ease-out;
  animation-fill-mode: both;
}

.product-card:nth-child(1) { animation-delay: 0s; }
.product-card:nth-child(2) { animation-delay: 0.1s; }
.product-card:nth-child(3) { animation-delay: 0.2s; }
.product-card:nth-child(4) { animation-delay: 0.3s; }
.product-card:nth-child(5) { animation-delay: 0.4s; }
.product-card:nth-child(6) { animation-delay: 0.5s; }
.product-card:nth-child(7) { animation-delay: 0.6s; }
.product-card:nth-child(8) { animation-delay: 0.7s; }

/* Category Card Animation */
.category-card {
  animation: scaleIn 0.4s ease-out;
  animation-fill-mode: both;
}

.category-card:nth-child(1) { animation-delay: 0s; }
.category-card:nth-child(2) { animation-delay: 0.08s; }
.category-card:nth-child(3) { animation-delay: 0.16s; }
.category-card:nth-child(4) { animation-delay: 0.24s; }
.category-card:nth-child(5) { animation-delay: 0.32s; }
.category-card:nth-child(6) { animation-delay: 0.4s; }

/* Toast Notification */
.toast {
  animation: slideInRight 0.3s ease-out;
}

/* Modal Backdrop */
.modal-backdrop {
  animation: fadeIn 0.3s ease-out;
}

.modal-backdrop .modal {
  animation: slideUp 0.3s ease-out;
}

/* Mobile Menu */
.mobile-menu.active {
  animation: slideDown 0.3s ease-out;
}

/* Search Bar */
.search-bar.active {
  animation: slideDown 0.3s ease-out;
}

/* Dropdown Menu */
.dropdown-menu.active {
  animation: slideDown 0.2s ease-out;
}

/* Loading Spinner */
.spinner {
  animation: spin 1s linear infinite;
}

/* Badge Pulse (for notifications) */
.icon-badge {
  animation: pulse 2s ease-in-out infinite;
}

/* Hero Section */
.hero-content {
  animation: fadeInUp 0.8s ease-out;
}

.hero-title {
  animation: fadeInUp 0.8s ease-out 0.2s;
  animation-fill-mode: both;
}

.hero-subtitle {
  animation: fadeInUp 0.8s ease-out 0.4s;
  animation-fill-mode: both;
}

.hero-cta {
  animation: fadeInUp 0.8s ease-out 0.6s;
  animation-fill-mode: both;
}

/* Review Card */
.review-card {
  animation: fadeInUp 0.5s ease-out;
  animation-fill-mode: both;
}

.review-card:nth-child(1) { animation-delay: 0s; }
.review-card:nth-child(2) { animation-delay: 0.15s; }
.review-card:nth-child(3) { animation-delay: 0.3s; }
.review-card:nth-child(4) { animation-delay: 0.45s; }

/* Cart Item */
.cart-item {
  animation: fadeInUp 0.4s ease-out;
}

/* Empty State */
.empty-state {
  animation: fadeIn 0.5s ease-out;
}

.empty-state-icon {
  animation: bounceIn 0.6s ease-out;
}

/* =================================================================
   HOVER ANIMATIONS
   ================================================================= */

/* Product Card Hover */
.product-card {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.product-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.product-card:hover .product-image {
  transform: scale(1.05);
}

/* Button Hover */
.btn {
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
  width: 300px;
  height: 300px;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(200, 149, 108, 0.3);
}

/* Icon Button Hover */
.icon-btn {
  transition: all 0.2s ease;
}

.icon-btn:hover {
  transform: scale(1.1);
}

/* Link Hover */
a {
  position: relative;
  transition: color 0.2s ease;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--color-primary);
  transition: width 0.3s ease;
}

.nav-link:hover::after {
  width: 100%;
}

/* Category Card Hover */
.category-card {
  transition: all 0.3s ease;
}

.category-card:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 8px 20px rgba(200, 149, 108, 0.2);
}

.category-card:hover .category-icon {
  transform: scale(1.2);
  transition: transform 0.3s ease;
}

/* Image Hover */
img {
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Input Focus Animation */
.input {
  transition: all 0.2s ease;
}

.input:focus {
  transform: scale(1.01);
  box-shadow: 0 0 0 3px rgba(200, 149, 108, 0.1);
}

/* =================================================================
   PAGE TRANSITION ANIMATIONS
   ================================================================= */

/* Page Load */
main {
  animation: fadeInUp 0.5s ease-out;
}

/* Section Load */
.section {
  animation: fadeIn 0.6s ease-out;
}

/* Stagger Children */
.stagger-children > * {
  opacity: 0;
  animation: fadeInUp 0.5s ease-out forwards;
}

.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; }

/* =================================================================
   SPECIAL EFFECTS
   ================================================================= */

/* Glowing Button */
.btn-glow {
  animation: glow 2s ease-in-out infinite;
}

/* Heartbeat (for favorite icon) */
@keyframes heartbeat {
  0%, 100% {
    transform: scale(1);
  }
  10%, 30% {
    transform: scale(0.9);
  }
  20%, 40%, 60%, 80% {
    transform: scale(1.1);
  }
  50%, 70% {
    transform: scale(1.05);
  }
}

.product-favorite.active {
  animation: heartbeat 0.8s ease-in-out;
}

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

.success-checkmark {
  stroke-dasharray: 100;
  animation: checkmark 0.6s ease-out forwards;
}

/* Loading Dots */
@keyframes loadingDots {
  0%, 20% {
    opacity: 0.3;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0.3;
  }
}

.loading-dot {
  animation: loadingDots 1.4s infinite;
}

.loading-dot:nth-child(1) { animation-delay: 0s; }
.loading-dot:nth-child(2) { animation-delay: 0.2s; }
.loading-dot:nth-child(3) { animation-delay: 0.4s; }

/* =================================================================
   SCROLL ANIMATIONS (Intersection Observer)
   ================================================================= */

.scroll-animate {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.scroll-animate.in-view {
  opacity: 1;
  transform: translateY(0);
}

/* =================================================================
   REDUCED MOTION OVERRIDE
   ================================================================= */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .product-card,
  .category-card,
  .btn,
  .review-card {
    animation: none !important;
  }
  
  .product-card:hover,
  .btn:hover {
    transform: none;
  }
}
