/**
 * Styles pour Lazy Loading des Images
 * Animations et transitions fluides
 */

/* Image responsive de base */
.responsive-image {
    display: block;
    max-width: 100%;
    height: auto;
    transition: opacity 0.3s ease-in-out, filter 0.3s ease-in-out;
}

/* État de chargement */
img.lazyload,
img.lazyloading {
    opacity: 0;
    filter: blur(10px);
}

/* Image chargée */
img.lazyloaded {
    opacity: 1;
    filter: blur(0);
    animation: fadeIn 0.4s ease-in-out;
}

/* Animation de fondu */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.98);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Erreur de chargement */
img.lazyerror {
    opacity: 0.5;
    filter: grayscale(100%);
}

/* Placeholder avec effet de shimmer */
.image-placeholder {
    background: linear-gradient(
        90deg,
        #f0f0f0 0%,
        #e0e0e0 20%,
        #f0f0f0 40%,
        #f0f0f0 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* Container avec aspect ratio (évite le layout shift) */
.image-container {
    position: relative;
    overflow: hidden;
    background: #f5f5f5;
}

.image-container--1-1 {
    aspect-ratio: 1 / 1;
}

.image-container--4-3 {
    aspect-ratio: 4 / 3;
}

.image-container--16-9 {
    aspect-ratio: 16 / 9;
}

.image-container--3-2 {
    aspect-ratio: 3 / 2;
}

.image-container img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Support navigateurs sans aspect-ratio */
@supports not (aspect-ratio: 1 / 1) {
    .image-container--1-1::before {
        content: '';
        display: block;
        padding-top: 100%;
    }
    
    .image-container--4-3::before {
        padding-top: 75%;
    }
    
    .image-container--16-9::before {
        padding-top: 56.25%;
    }
    
    .image-container--3-2::before {
        padding-top: 66.67%;
    }
}

/* Optimisation pour images de produits */
.product-card__image {
    width: 100%;
    height: auto;
    object-fit: cover;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

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

/* Picture element responsive */
picture {
    display: block;
    width: 100%;
}

picture img {
    display: block;
    width: 100%;
    height: auto;
}

/* Performance: réduire les animations sur connexions lentes */
@media (prefers-reduced-motion: reduce) {
    .responsive-image,
    .product-card__image {
        transition: none;
        animation: none;
    }
    
    img.lazyload,
    img.lazyloading {
        opacity: 1;
        filter: none;
    }
}

/* Optimisation pour print */
@media print {
    img.lazyload,
    img.lazyloading {
        opacity: 1;
        filter: none;
    }
}

/* Loading spinner optionnel */
.image-loading {
    position: relative;
}

.image-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #D4AF37;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

img.lazyloaded + .image-loading::after {
    display: none;
}
