/* Optimisation d'images pour American Shop by Toutou */

/* Lazy loading pour toutes les images */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s ease;
}

img[loading="lazy"].loaded {
    opacity: 1;
}

/* Placeholder pendant le chargement */
.image-placeholder {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Optimisation pour les images de produits */
.product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: all 0.3s ease;
}

/* Hero image responsive */
.hero-section {
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
}

/* Logo responsive */
.logo-image,
.custom-logo {
    max-width: 100%;
    height: auto;
    max-height: 50px;
}

/* Images responsive */
img {
    max-width: 100%;
    height: auto;
}

/* Optimisation pour mobiles */
@media (max-width: 768px) {
    .logo-image,
    .custom-logo {
        max-height: 40px;
    }
    
    .product-image {
        height: 200px;
    }
    
    .hero-section {
        min-height: 300px;
        background-attachment: scroll; /* Meilleure performance sur mobile */
    }
}

/* Préchargement des images critiques */
.preload-images {
    position: absolute;
    left: -9999px;
    top: -9999px;
    visibility: hidden;
}

/* Format WebP si supporté */
@supports (background-image: url('image.webp')) {
    .hero-section {
        background-image: url('assets/images/hero-bg.webp'), 
                         linear-gradient(rgba(243, 178, 200, 0.8), rgba(233, 30, 99, 0.8));
    }
}

/* Images avec aspect ratio fixe */
.aspect-ratio-box {
    position: relative;
    overflow: hidden;
}

.aspect-ratio-box::before {
    content: '';
    display: block;
    padding-top: 75%; /* 4:3 ratio */
}

.aspect-ratio-box img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Galerie produit avec aspect ratio */
.product-gallery .aspect-ratio-box::before {
    padding-top: 100%; /* 1:1 ratio pour les images produits */
}

/* Effet de flou pendant le chargement */
.blur-load {
    background-size: cover;
    background-position: center;
}

.blur-load img {
    opacity: 0;
    transition: opacity 0.3s;
}

.blur-load.loaded img {
    opacity: 1;
}

.blur-load::before {
    content: '';
    position: absolute;
    inset: 0;
    background: inherit;
    filter: blur(15px);
    transform: scale(1.1);
}

.blur-load.loaded::before {
    opacity: 0;
}

/* Progressive JPEG support */
.progressive-image {
    filter: blur(5px);
    transition: filter 0.3s;
}

.progressive-image.loaded {
    filter: blur(0);
}