/* Optimisation du chargement et affichage des images */

/* Éviter le layout shift en définissant aspect-ratio sur les images */
img {
    max-width: 100%;
    height: auto;
    display: block;
    background-color: #e8e8e8;
}

/* Images responsive avec dimensions natives */
img[width][height] {
    aspect-ratio: attr(width) / attr(height);
}

/* Placeholder skeleton pour les images en loading - léger et performant */
img[loading="lazy"]:not(.loaded) {
    background: linear-gradient(90deg, #e8e8e8 0%, #f0f0f0 50%, #e8e8e8 100%);
    background-size: 100% 100%;
    animation: skeletonShimmer 1.2s ease-in-out infinite;
    color: transparent;
}

img[loading="lazy"].loaded {
    background: none;
    animation: none;
}

/* Animation skeleton ultra-légère sur GPU */
@keyframes skeletonShimmer {
    0%, 100% {
        opacity: 0.6;
    }
    50% {
        opacity: 0.8;
    }
}

/* Images déjà chargées - fade-in rapide */
img.loaded {
    animation: fadeIn 0.3s ease-out forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0.95;
    }
    to {
        opacity: 1;
    }
}

/* Hero images - priorité haute */
.home-hero img,
.baby-hero img,
.insertion-hero img,
.jeux-hero img,
.adults-hero img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    /* Hero images ne doivent pas avoir d'animation skeleton */
}

img[loading="eager"].loaded,
img[loading="eager"] {
    animation: none !important;
}

/* Carousels - images responsives */
.swiper-slide img {
    width: 100%;
    height: auto;
    object-fit: cover;
}

/* Motion cards - hover effect optimisé */
.home-motion-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Images dans le contenu */
.content-section img,
.insertion-text-block img {
    max-width: 100%;
    height: auto;
}

/* Optimisation des images CSS background */
.main-public {
    background-attachment: scroll; /* Plus performant que fixed sur mobile */
    background-size: cover;
    background-position: center;
}

/* Sur les petits écrans, optimiser pour performance mobile */
@media (max-width: 768px) {
    .main-public {
        background-image: none !important;
        background-color: #f9f9f9;
    }
    
    /* Réduire les animations coûteuses sur mobile */
    img[loading="lazy"]:not(.loaded) {
        animation: skeletonShimmer 1.5s ease-in-out infinite;
        background: #f0f0f0;
    }
}

/* Images avec srcset (future utilisation) */
picture img {
    display: block;
    width: 100%;
    height: auto;
}

/* Fallback pour les images qui ne chargent pas */
img[alt] {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    color: #999;
}

/* Optimisation GPU: utiliser will-change avec parcimonie */
img[loading="lazy"]:not(.loaded) {
    will-change: opacity;
}

/* Retirer will-change après chargement */
img.loaded {
    will-change: auto;
}

/* Priorité visuelle d'images préchargées */
img[fetchpriority="high"] {
    content-visibility: auto;
}
