/**
 * Vaayunim Snacks - Gaming Style Animations
 * Mobile-first, performance optimized
 */

/* ========== GLOBAL ANIMATION SETTINGS ========== */
:root {
    --animation-speed-slow: 0.6s;
    --animation-speed-normal: 0.4s;
    --animation-speed-fast: 0.2s;
    --animation-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --animation-smooth: cubic-bezier(0.4, 0, 0.2, 1);
    --animation-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Reduce animations for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ========== ENTRY ANIMATIONS ========== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ========== GAMING STYLE ANIMATIONS ========== */
@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 0.9;
        transform: scale(1.05);
    }
    80% {
        transform: scale(0.95);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes bounceInUp {
    0% {
        opacity: 0;
        transform: translateY(50px) scale(0.8);
    }
    60% {
        opacity: 1;
        transform: translateY(-10px) scale(1.05);
    }
    80% {
        transform: translateY(5px) scale(0.98);
    }
    100% {
        transform: translateY(0) scale(1);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.9;
    }
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-3px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(3px);
    }
}

@keyframes wiggle {
    0%, 100% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(-5deg);
    }
    75% {
        transform: rotate(5deg);
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes float {
    0% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-8px);
    }
    100% {
        transform: translateY(0px);
    }
}

@keyframes glow {
    0% {
        box-shadow: 0 0 5px rgba(255,107,107,0.3);
    }
    50% {
        box-shadow: 0 0 20px rgba(255,107,107,0.6);
    }
    100% {
        box-shadow: 0 0 5px rgba(255,107,107,0.3);
    }
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

@keyframes confetti {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

@keyframes starPop {
    0% {
        transform: scale(0) rotate(0deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.2) rotate(180deg);
        opacity: 1;
    }
    100% {
        transform: scale(1) rotate(360deg);
        opacity: 0;
    }
}

/* ========== ELEMENT ANIMATIONS ========== */

/* Product Cards - Staggered entry */
.product-card {
    animation: fadeInUp var(--animation-speed-normal) var(--animation-smooth) forwards;
    opacity: 0;
    transform: translateY(30px);
}

/* Stagger delay for product cards */
.product-card:nth-child(1) { animation-delay: 0.05s; }
.product-card:nth-child(2) { animation-delay: 0.1s; }
.product-card:nth-child(3) { animation-delay: 0.15s; }
.product-card:nth-child(4) { animation-delay: 0.2s; }
.product-card:nth-child(5) { animation-delay: 0.25s; }
.product-card:nth-child(6) { animation-delay: 0.3s; }
.product-card:nth-child(7) { animation-delay: 0.35s; }
.product-card:nth-child(8) { animation-delay: 0.4s; }

/* Hover animations for product cards */
.product-card:hover {
    animation: bounce 0.5s var(--animation-bounce);
    transform: translateY(-8px);
}

/* Add to Cart Button - Gaming Style */
.add-to-cart-btn, .add-btn, .add-to-cart {
    position: relative;
    overflow: hidden;
    transition: all 0.3s var(--animation-spring);
}

.add-to-cart-btn:hover, .add-btn:hover, .add-to-cart:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(255,107,107,0.4);
}

.add-to-cart-btn:active, .add-btn:active, .add-to-cart:active {
    transform: scale(0.98);
}

/* Click effect */
.btn-click-effect {
    animation: pulse 0.3s ease-out;
}

/* Cart count badge animation */
.cart-count {
    transition: all 0.3s var(--animation-bounce);
}

.cart-count.update {
    animation: bounceIn 0.4s var(--animation-bounce);
}

/* Hero section animation */
.hero {
    animation: fadeInDown 0.8s var(--animation-smooth);
}

/* Feature items animation */
.feature-item {
    animation: scaleIn 0.5s var(--animation-smooth) forwards;
    opacity: 0;
    transform: scale(0.8);
}

.feature-item:nth-child(1) { animation-delay: 0.1s; }
.feature-item:nth-child(2) { animation-delay: 0.2s; }
.feature-item:nth-child(3) { animation-delay: 0.3s; }
.feature-item:nth-child(4) { animation-delay: 0.4s; }

/* Category items animation */
.category-card, .category-item {
    animation: fadeInUp 0.5s var(--animation-smooth) forwards;
    opacity: 0;
}

/* Page title animation */
.page-title, h1, .category-header h1 {
    animation: fadeInDown 0.6s var(--animation-smooth);
}

/* Section headers animation */
.section-header {
    animation: fadeInLeft 0.5s var(--animation-smooth);
}

/* Testimonial cards animation */
.testimonial-card {
    animation: scaleIn 0.5s var(--animation-smooth) forwards;
    opacity: 0;
}

.testimonial-card:nth-child(1) { animation-delay: 0.1s; }
.testimonial-card:nth-child(2) { animation-delay: 0.2s; }
.testimonial-card:nth-child(3) { animation-delay: 0.3s; }

/* Cart item animation */
.cart-item {
    animation: slideIn 0.4s var(--animation-smooth);
}

/* Order summary animation */
.order-summary, .cart-summary {
    animation: fadeInRight 0.5s var(--animation-smooth);
}

/* Checkout form animation */
.checkout-form {
    animation: fadeInLeft 0.5s var(--animation-smooth);
}

/* Success page animation */
.success-card {
    animation: bounceInUp 0.6s var(--animation-bounce);
}

/* Toast notification animation */
.toast-notification {
    animation: slideIn 0.3s var(--animation-smooth), fadeOut 0.3s var(--animation-smooth) 2.7s forwards;
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* Loading animation */
.loading-spinner {
    animation: spin 1s linear infinite;
}

/* Shimmer loading effect */
.shimmer {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* Price tag animation */
.current-price {
    transition: all 0.3s var(--animation-spring);
}

.current-price:hover {
    transform: scale(1.05);
    color: #ff5252;
}

/* Discount badge animation */
.discount-badge, .product-badge {
    animation: pulse 1s infinite;
}

/* Star rating animation */
.rating-stars i {
    transition: all 0.2s var(--animation-spring);
}

.rating-stars i:hover {
    transform: scale(1.2);
    color: #ffc107;
}

/* Input focus animation */
input:focus, select:focus, textarea:focus {
    animation: glow 0.5s ease-out;
}

/* Checkout button animation */
.place-order-btn, .checkout-btn {
    position: relative;
    overflow: hidden;
    transition: all 0.3s var(--animation-spring);
}

.place-order-btn:hover, .checkout-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(255,107,107,0.4);
}

.place-order-btn:active, .checkout-btn:active {
    transform: translateY(0);
}

/* ========== CONFETTI EFFECT ========== */
.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    background-color: #ff6b6b;
    pointer-events: none;
    z-index: 9999;
    animation: confetti 2s ease-out forwards;
}

/* ========== STAR POP EFFECT ========== */
.star-pop {
    position: fixed;
    font-size: 20px;
    pointer-events: none;
    z-index: 9999;
    animation: starPop 0.6s ease-out forwards;
}

/* ========== MOBILE OPTIMIZATIONS ========== */
@media (max-width: 768px) {
    /* Reduce animations on mobile for performance */
    .product-card,
    .feature-item,
    .testimonial-card,
    .category-card {
        animation-duration: 0.3s;
    }
    
    /* Faster hover effects on mobile */
    .product-card:hover {
        transform: translateY(-4px);
    }
    
    .add-to-cart-btn:hover, .add-btn:hover {
        transform: scale(1.02);
    }
}

/* ========== SCROLL REVEAL ANIMATIONS ========== */
.scroll-reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.6s var(--animation-smooth);
}

.scroll-reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* ========== LOADING SCREEN ========== */
.page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease;
}

.page-loader.hide {
    opacity: 0;
    pointer-events: none;
}

.loader-text {
    font-size: 24px;
    font-weight: bold;
    color: #ff6b6b;
    animation: pulse 1s infinite;
}

/* ========== GAMING ELEMENTS ========== */
.level-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, #ff6b6b, #ffc107);
    animation: shimmer 2s infinite;
    background-size: 200% 100%;
    z-index: 10001;
    transition: width 0.3s ease;
}

/* Achievement popup */
.achievement-popup {
    position: fixed;
    bottom: 80px;
    right: 20px;
    background: linear-gradient(135deg, #ff6b6b, #ff8e8e);
    color: white;
    padding: 12px 20px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 1000;
    animation: slideIn 0.3s ease, fadeOutAchievement 0.3s ease 3s forwards;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    font-family: 'Poppins', sans-serif;
}

.achievement-popup i {
    font-size: 20px;
    animation: spin 0.5s ease;
}

@keyframes fadeOutAchievement {
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* Ripple effect */
.ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255,255,255,0.5);
    transform: scale(0);
    animation: rippleEffect 0.6s ease-out;
    pointer-events: none;
}

@keyframes rippleEffect {
    to {
        transform: scale(4);
        opacity: 0;
    }
}