/* ================================================
   IMAGE OPTIMIZATION STYLES
   Styles pour les images optimisées et responsive
   ================================================ */

/* Assurer que les images dans picture sont bien affichées */
picture {
    display: block;
    line-height: 0;
    font-size: 0;
}

picture img {
    display: block;
    width: 100%;
    height: auto;
    margin: 0;
    padding: 0;
    vertical-align: bottom;
}

/* Optimisation pour les images lazy loading */
/* Note: Les images lazy sont visibles par défaut, le navigateur gère le chargement */
img[loading="lazy"] {
    opacity: 1;
    transition: opacity 0.3s;
}

/* Animation optionnelle lors du chargement */
img[loading="lazy"].loading {
    opacity: 0.7;
}

img[loading="lazy"].loaded {
    opacity: 1;
}

/* Prévenir le layout shift avec aspect-ratio */
picture img[width][height] {
    aspect-ratio: attr(width) / attr(height);
}

/* Images critiques (above the fold) */
picture img[fetchpriority="high"] {
    will-change: contents;
}

/* Optimisation pour les images de fond */
.hero-content-wrapper picture,
.hero-content-wrapper img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
}

/* S'assurer que les images dans le hero sont visibles */
.hero-content-wrapper picture img {
    display: block !important;
    opacity: 1 !important;
}

/* Responsive images dans les conteneurs */
.product-image-container picture {
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    display: block;
    visibility: visible;
    opacity: 1;
}

.product-image-container picture img {
    width: 100%;
    max-width: 500px;
    height: 320px;
    max-height: 320px;
    object-fit: contain;
    margin: 0 auto;
    display: block;
    visibility: visible;
    opacity: 1;
    transition: transform 0.3s ease;
}

.about-image-container picture,
.showcase-image-container picture {
    width: 100%;
    height: 100%;
}

.about-image-container picture img,
.showcase-image-container picture img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Images de catégories */
.category-card picture {
    width: 100%;
    overflow: hidden;
}

.category-card picture img {
    width: 100%;
    height: 140px;
    object-fit: cover;
}

/* Performance: réduire les repaints */
picture {
    contain: layout style paint;
}

/* Optimisation pour les images dans les carrousels */
.owl-carousel picture img {
    width: 100%;
    height: auto;
    display: block;
}

/* Fallback pour les navigateurs sans support WebP */
@supports not (image-set()) {
    picture source {
        display: none;
    }
}
