/**
 * Epic Key Animations CSS
 * Beautiful scroll animations and micro-interactions
 */

/* ============================
   SCROLL ANIMATIONS
   ============================ */

.fade-in,
.slide-up,
.slide-left,
.slide-right,
.zoom-in,
.rotate-in {
    opacity: 0;
    transition: none;
}

.fade-in.animated {
    animation: fadeIn 0.8s ease-out forwards;
}

.slide-up.animated {
    animation: slideUp 0.8s ease-out forwards;
}

.slide-left.animated {
    animation: slideLeft 0.8s ease-out forwards;
}

.slide-right.animated {
    animation: slideRight 0.8s ease-out forwards;
}

.zoom-in.animated {
    animation: zoomIn 0.8s ease-out forwards;
}

.rotate-in.animated {
    animation: rotateIn 0.8s ease-out forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideLeft {
    from {
        opacity: 0;
        transform: translateX(50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideRight {
    from {
        opacity: 0;
        transform: translateX(-50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes rotateIn {
    from {
        opacity: 0;
        transform: rotate(-180deg) scale(0.5);
    }
    to {
        opacity: 1;
        transform: rotate(0) scale(1);
    }
}

/* ============================
   HOVER EFFECTS
   ============================ */

.product-card {
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-style: preserve-3d;
}

.product-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.product-card img {
    transition: transform 0.4s ease;
}

.product-card:hover img {
    transform: scale(1.1);
}

/* Quick View Button */
.quick-view-btn {
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

.product-card:hover .quick-view-btn {
    opacity: 1;
    transform: translateY(0);
}

.quick-view-btn.bounce {
    animation: bounce 0.6s;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

/* ============================
   BUTTON ANIMATIONS
   ============================ */

.btn-primary,
.btn-success,
.btn-animated {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.btn-primary:hover,
.btn-success:hover,
.btn-animated:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0, 185, 107, 0.3);
}

.btn-primary:active,
.btn-success:active,
.btn-animated:active {
    transform: translateY(0);
}

/* Loading State */
.loading {
    pointer-events: none;
    opacity: 0.7;
}

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Ripple Effect */
button {
    position: relative;
    overflow: hidden;
}

.ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    transform: scale(0);
    animation: ripple-animation 0.6s ease-out;
    pointer-events: none;
}

@keyframes ripple-animation {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* ============================
   CART ANIMATIONS
   ============================ */

.success-checkmark {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: #00b96b;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    animation: checkmarkPop 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes checkmarkPop {
    0% {
        transform: translateY(-50%) scale(0);
    }
    50% {
        transform: translateY(-50%) scale(1.2);
    }
    100% {
        transform: translateY(-50%) scale(1);
    }
}

.flying-product {
    animation: flyToCart 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.flying-product img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.cart-count {
    transition: all 0.3s ease;
}

.bounce-animation {
    animation: bounceScale 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes bounceScale {
    0%, 100% {
        transform: scale(1);
    }
    25% {
        transform: scale(1.3);
    }
    50% {
        transform: scale(0.9);
    }
    75% {
        transform: scale(1.1);
    }
}

/* Cart item removal */
@keyframes slideOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* ============================
   IMAGE ANIMATIONS
   ============================ */

img[data-src] {
    filter: blur(10px);
    transition: filter 0.4s ease;
}

img[data-src].loaded {
    filter: blur(0);
}

/* Image hover zoom */
.image-zoom {
    overflow: hidden;
}

.image-zoom img {
    transition: transform 0.6s ease;
}

.image-zoom:hover img {
    transform: scale(1.15);
}

/* ============================
   PARALLAX EFFECTS
   ============================ */

[data-parallax] {
    will-change: transform;
}

/* ============================
   COUNTER ANIMATIONS
   ============================ */

[data-count] {
    font-feature-settings: 'tnum';
    font-variant-numeric: tabular-nums;
}

/* ============================
   PROGRESS BARS
   ============================ */

.progress-bar {
    transition: width 1.5s cubic-bezier(0.65, 0, 0.35, 1);
}

/* ============================
   ERROR & SUCCESS STATES
   ============================ */

.shake {
    animation: shake 0.6s;
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-10px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(10px);
    }
}

.pulse-success {
    animation: pulseSuccess 1s;
}

@keyframes pulseSuccess {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(0, 185, 107, 0.7);
    }
    50% {
        box-shadow: 0 0 0 20px rgba(0, 185, 107, 0);
    }
}

/* ============================
   NOTIFICATION ANIMATIONS
   ============================ */

.notification {
    animation: slideInRight 0.4s ease-out;
}

.notification.hide {
    animation: slideOutRight 0.4s ease-in;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ============================
   SKELETON LOADING
   ============================ */

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ============================
   TYPING INDICATOR
   ============================ */

.typing-indicator {
    display: inline-flex;
    gap: 4px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #00b96b;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* ============================
   FLOATING ELEMENTS
   ============================ */

.float {
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-20px);
    }
}

/* ============================
   GLOWING EFFECTS
   ============================ */

.glow {
    animation: glow 2s ease-in-out infinite;
}

@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(0, 185, 107, 0.5);
    }
    50% {
        box-shadow: 0 0 20px rgba(0, 185, 107, 0.8);
    }
}

/* ============================
   GRADIENT ANIMATIONS
   ============================ */

.gradient-animate {
    background-size: 200% 200%;
    animation: gradient 3s ease infinite;
}

@keyframes gradient {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* ============================
   TEXT EFFECTS
   ============================ */

.text-shimmer {
    background: linear-gradient(90deg, #2c3e50 25%, #00b96b 50%, #2c3e50 75%);
    background-size: 200% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* Typed cursor */
.typed-cursor {
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 49% {
        opacity: 1;
    }
    50%, 100% {
        opacity: 0;
    }
}

/* ============================
   MOROCCAN-THEMED ANIMATIONS
   ============================ */

.moroccan-pattern-animate {
    animation: moroccanPattern 20s linear infinite;
}

@keyframes moroccanPattern {
    0% {
        background-position: 0 0;
    }
    100% {
        background-position: 100px 100px;
    }
}

/* ============================
   PERFORMANCE OPTIMIZATIONS
   ============================ */

.animated,
[data-parallax],
.product-card,
.flying-product {
    will-change: transform, opacity;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================
   MOBILE OPTIMIZATIONS
   ============================ */

@media (max-width: 768px) {
    .product-card {
        transform: none !important;
    }
    
    .product-card:hover {
        transform: translateY(-5px) !important;
    }
    
    [data-parallax] {
        transform: none !important;
    }
}
