/* ============================================
   CUSTOMER ANIMATIONS - QrBiteHub
   60fps optimized animations for mobile-first UX
   ============================================ */

/* ============================================
   KEYFRAME DEFINITIONS
   ============================================ */

/* Fade animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translate3d(0, 20px, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translate3d(0, -20px, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translate3d(-20px, 0, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translate3d(20px, 0, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

/* Slide animations */
@keyframes slideInFromBottom {
    from {
        transform: translate3d(0, 100%, 0);
    }
    to {
        transform: translate3d(0, 0, 0);
    }
}

@keyframes slideOutToBottom {
    from {
        transform: translate3d(0, 0, 0);
    }
    to {
        transform: translate3d(0, 100%, 0);
    }
}

@keyframes slideInFromTop {
    from {
        transform: translate3d(0, -100%, 0);
    }
    to {
        transform: translate3d(0, 0, 0);
    }
}

@keyframes slideInFromLeft {
    from {
        transform: translate3d(-100%, 0, 0);
    }
    to {
        transform: translate3d(0, 0, 0);
    }
}

@keyframes slideInFromRight {
    from {
        transform: translate3d(100%, 0, 0);
    }
    to {
        transform: translate3d(0, 0, 0);
    }
}

/* Scale animations */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale3d(0.9, 0.9, 1);
    }
    to {
        opacity: 1;
        transform: scale3d(1, 1, 1);
    }
}

@keyframes scaleOut {
    from {
        opacity: 1;
        transform: scale3d(1, 1, 1);
    }
    to {
        opacity: 0;
        transform: scale3d(0.9, 0.9, 1);
    }
}

@keyframes popIn {
    0% {
        opacity: 0;
        transform: scale3d(0.8, 0.8, 1);
    }
    50% {
        transform: scale3d(1.05, 1.05, 1);
    }
    100% {
        opacity: 1;
        transform: scale3d(1, 1, 1);
    }
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale3d(0.3, 0.3, 1);
    }
    50% {
        transform: scale3d(1.05, 1.05, 1);
    }
    70% {
        transform: scale3d(0.95, 0.95, 1);
    }
    100% {
        opacity: 1;
        transform: scale3d(1, 1, 1);
    }
}

/* Bounce / Spring animations */
@keyframes bounce {
    0%, 100% {
        transform: translate3d(0, 0, 0);
    }
    50% {
        transform: translate3d(0, -8px, 0);
    }
}

@keyframes bounceSubtle {
    0%, 100% {
        transform: translate3d(0, 0, 0);
    }
    50% {
        transform: translate3d(0, -4px, 0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

@keyframes pulseScale {
    0%, 100% {
        transform: scale3d(1, 1, 1);
    }
    50% {
        transform: scale3d(1.05, 1.05, 1);
    }
}

@keyframes shake {
    0%, 100% {
        transform: translate3d(0, 0, 0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translate3d(-4px, 0, 0);
    }
    20%, 40%, 60%, 80% {
        transform: translate3d(4px, 0, 0);
    }
}

@keyframes wiggle {
    0%, 100% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(-3deg);
    }
    75% {
        transform: rotate(3deg);
    }
}

/* Loading animations */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* Cart / Badge animations */
@keyframes cartBounce {
    0% {
        transform: scale3d(1, 1, 1);
    }
    30% {
        transform: scale3d(1.15, 1.15, 1);
    }
    50% {
        transform: scale3d(0.95, 0.95, 1);
    }
    70% {
        transform: scale3d(1.05, 1.05, 1);
    }
    100% {
        transform: scale3d(1, 1, 1);
    }
}

@keyframes badgePop {
    0% {
        transform: scale3d(0, 0, 1);
    }
    50% {
        transform: scale3d(1.3, 1.3, 1);
    }
    100% {
        transform: scale3d(1, 1, 1);
    }
}

/* Toast animations */
@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translate3d(0, -100%, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes toastSlideOut {
    from {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
    to {
        opacity: 0;
        transform: translate3d(0, -100%, 0);
    }
}

/* Bottom sheet animations */
@keyframes bottomSheetIn {
    from {
        transform: translate3d(0, 100%, 0);
    }
    to {
        transform: translate3d(0, 0, 0);
    }
}

@keyframes bottomSheetOut {
    from {
        transform: translate3d(0, 0, 0);
    }
    to {
        transform: translate3d(0, 100%, 0);
    }
}

@keyframes backdropIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes backdropOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* Skeleton / Content swap */
@keyframes skeletonFadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
        visibility: hidden;
    }
}

@keyframes contentFadeIn {
    from {
        opacity: 0;
        transform: translate3d(0, 10px, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

/* Fade animations */
.animate-fade-in {
    animation: fadeIn var(--duration-normal, 250ms) var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1)) both;
}

.animate-fade-out {
    animation: fadeOut var(--duration-normal, 250ms) var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1)) both;
}

.animate-fade-in-up {
    animation: fadeInUp var(--duration-normal, 250ms) var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1)) both;
}

.animate-fade-in-down {
    animation: fadeInDown var(--duration-normal, 250ms) var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1)) both;
}

.animate-fade-in-left {
    animation: fadeInLeft var(--duration-normal, 250ms) var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1)) both;
}

.animate-fade-in-right {
    animation: fadeInRight var(--duration-normal, 250ms) var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1)) both;
}

/* Slide animations */
.animate-slide-up {
    animation: slideInFromBottom var(--duration-slow, 400ms) cubic-bezier(0.32, 0.72, 0, 1) both;
}

.animate-slide-down {
    animation: slideInFromTop var(--duration-slow, 400ms) cubic-bezier(0.32, 0.72, 0, 1) both;
}

.animate-slide-left {
    animation: slideInFromRight var(--duration-slow, 400ms) cubic-bezier(0.32, 0.72, 0, 1) both;
}

.animate-slide-right {
    animation: slideInFromLeft var(--duration-slow, 400ms) cubic-bezier(0.32, 0.72, 0, 1) both;
}

/* Scale animations */
.animate-scale-in {
    animation: scaleIn var(--duration-normal, 250ms) var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1)) both;
}

.animate-scale-out {
    animation: scaleOut var(--duration-normal, 250ms) var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1)) both;
}

.animate-pop-in {
    animation: popIn var(--duration-slow, 400ms) var(--ease-spring, cubic-bezier(0.34, 1.56, 0.64, 1)) both;
}

.animate-bounce-in {
    animation: bounceIn var(--duration-slower, 600ms) var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1)) both;
}

/* Interactive animations */
.animate-bounce {
    animation: bounce 0.6s var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1)) infinite;
}

.animate-bounce-once {
    animation: bounceSubtle 0.4s var(--ease-spring, cubic-bezier(0.34, 1.56, 0.64, 1)) both;
}

.animate-pulse {
    animation: pulse 2s ease-in-out infinite;
}

.animate-pulse-scale {
    animation: pulseScale 2s ease-in-out infinite;
}

.animate-shake {
    animation: shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

.animate-wiggle {
    animation: wiggle 0.5s ease-in-out;
}

/* Loading animations */
.animate-spin {
    animation: spin 0.8s linear infinite;
}

.animate-shimmer {
    background: linear-gradient(
        90deg,
        var(--bg-secondary) 0%,
        var(--bg-tertiary) 50%,
        var(--bg-secondary) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

/* Cart animations */
.animate-cart-bounce {
    animation: cartBounce 0.5s var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1)) both;
}

.animate-badge-pop {
    animation: badgePop 0.4s var(--ease-spring, cubic-bezier(0.34, 1.56, 0.64, 1)) both;
}

/* Toast animations */
.animate-toast-in {
    animation: toastSlideIn var(--duration-normal, 250ms) var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1)) both;
}

.animate-toast-out {
    animation: toastSlideOut var(--duration-normal, 250ms) var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1)) both;
}

/* Bottom sheet animations */
.animate-sheet-in {
    animation: bottomSheetIn var(--duration-slow, 400ms) cubic-bezier(0.32, 0.72, 0, 1) both;
}

.animate-sheet-out {
    animation: bottomSheetOut var(--duration-normal, 250ms) var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1)) both;
}

.animate-backdrop-in {
    animation: backdropIn var(--duration-normal, 250ms) ease-out both;
}

.animate-backdrop-out {
    animation: backdropOut var(--duration-fast, 150ms) ease-out both;
}

/* Content swap */
.animate-skeleton-out {
    animation: skeletonFadeOut var(--duration-normal, 250ms) ease-out both;
}

.animate-content-in {
    animation: contentFadeIn var(--duration-normal, 250ms) var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1)) both;
}

/* ============================================
   STAGGER DELAYS
   ============================================ */

.stagger-1 { animation-delay: 50ms; }
.stagger-2 { animation-delay: 100ms; }
.stagger-3 { animation-delay: 150ms; }
.stagger-4 { animation-delay: 200ms; }
.stagger-5 { animation-delay: 250ms; }
.stagger-6 { animation-delay: 300ms; }
.stagger-7 { animation-delay: 350ms; }
.stagger-8 { animation-delay: 400ms; }
.stagger-9 { animation-delay: 450ms; }
.stagger-10 { animation-delay: 500ms; }

/* Faster stagger for list items */
.stagger-fast-1 { animation-delay: 30ms; }
.stagger-fast-2 { animation-delay: 60ms; }
.stagger-fast-3 { animation-delay: 90ms; }
.stagger-fast-4 { animation-delay: 120ms; }
.stagger-fast-5 { animation-delay: 150ms; }
.stagger-fast-6 { animation-delay: 180ms; }

/* ============================================
   ANIMATION MODIFIERS
   ============================================ */

/* Duration modifiers */
.duration-fast { animation-duration: var(--duration-fast, 150ms) !important; }
.duration-normal { animation-duration: var(--duration-normal, 250ms) !important; }
.duration-slow { animation-duration: var(--duration-slow, 400ms) !important; }
.duration-slower { animation-duration: var(--duration-slower, 600ms) !important; }

/* Fill mode */
.fill-both { animation-fill-mode: both; }
.fill-forwards { animation-fill-mode: forwards; }

/* Iteration */
.animate-infinite { animation-iteration-count: infinite; }
.animate-once { animation-iteration-count: 1; }

/* Play state (for pausing) */
.animate-paused { animation-play-state: paused; }
.animate-running { animation-play-state: running; }

/* ============================================
   REDUCED MOTION
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .animate-shimmer {
        animation: none;
        background: var(--bg-secondary);
    }
}

/* ============================================
   GPU OPTIMIZATION HINTS
   ============================================ */

.will-animate {
    will-change: transform, opacity;
}

.will-animate-transform {
    will-change: transform;
}

.will-animate-opacity {
    will-change: opacity;
}

/* Clean up after animation */
.animation-done {
    will-change: auto;
}
