/*=====================================================
EIFI Image Loading Effects
Optimisation du chargement des images avec effets visuels
======================================================*/

/* Container pour les images avec effet de chargement */
.image-loading-container {
    position: relative;
    width: 100%;
    overflow: hidden;
    background-color: #f0f0f0;
}

/* Skeleton loader - effet de base */
.image-skeleton {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        #f0f0f0 0%,
        #e0e0e0 50%,
        #f0f0f0 100%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    z-index: 1;
}

/* Animation shimmer pour le skeleton */
@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Image avec transition de fade-in */
.lazy-image {
    opacity: 0;
    transition: opacity 0.4s ease-in-out;
    width: 100%;
    height: auto;
    display: block;
}

.lazy-image.loaded {
    opacity: 1;
}

/* Spinner de chargement */
.image-loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid rgba(26, 43, 74, 0.1);
    border-top-color: var(--eifi-blue-dark, #1a2b4a);
    border-radius: 50%;
    animation: spinner-rotate 0.8s linear infinite;
    z-index: 2;
}

@keyframes spinner-rotate {
    0% {
        transform: translate(-50%, -50%) rotate(0deg);
    }
    100% {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* Placeholder avec gradient animé */
.image-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        135deg,
        rgba(26, 43, 74, 0.05) 0%,
        rgba(0, 0, 0, 0.05) 100%
    );
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.image-placeholder::before {
    content: '';
    width: 60px;
    height: 60px;
    border: 3px solid rgba(26, 43, 74, 0.1);
    border-top-color: var(--eifi-blue-dark, #1a2b4a);
    border-radius: 50%;
    animation: spinner-rotate 0.8s linear infinite;
}

/* Effet de blur-up (progressive loading) */
.image-blur-up {
    filter: blur(10px);
    transform: scale(1.1);
    transition: filter 0.3s ease-out, transform 0.3s ease-out;
}

.image-blur-up.loaded {
    filter: blur(0);
    transform: scale(1);
}

/* Container pour les images de galerie */
.gallery-img,
.course-img,
.team-img,
.blog-item-img,
.event-img {
    position: relative;
    overflow: hidden;
    background-color: #f5f5f5;
}

.gallery-img img,
.course-img img,
.team-img img,
.blog-item-img img,
.event-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.4s ease-in-out;
}

/* Image de fond avec effet de chargement */
.hero-single,
.video-content {
    position: relative;
    background-size: cover;
    background-position: center;
}

.hero-single::after,
.video-content::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        rgba(26, 43, 74, 0.1) 0%,
        rgba(0, 0, 0, 0.1) 50%,
        rgba(26, 43, 74, 0.1) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    z-index: 0;
    opacity: 0.3;
}

.hero-single.loaded::after,
.video-content.loaded::after {
    display: none;
}

/* Amélioration des performances avec will-change */
.image-loading-container,
.lazy-image {
    will-change: opacity;
}

.image-skeleton {
    will-change: background-position;
}

/* Réduction du mouvement pour les connexions lentes */
@media (prefers-reduced-motion: reduce) {
    .image-skeleton,
    .image-loading-spinner,
    .image-placeholder::before,
    .hero-single::after,
    .video-content::after {
        animation: none;
    }
    
    .lazy-image {
        transition: none;
        opacity: 1;
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .image-loading-spinner {
        width: 30px;
        height: 30px;
        border-width: 3px;
    }
    
    .image-placeholder::before {
        width: 40px;
        height: 40px;
        border-width: 2px;
    }
    
    /* Réduire les animations sur mobile pour économiser la batterie */
    .image-skeleton {
        animation-duration: 2s;
    }
}

/* Optimisation pour les connexions lentes */
@media (prefers-reduced-motion: reduce) {
    .image-skeleton,
    .image-loading-spinner,
    .image-placeholder::before,
    .hero-single::after,
    .video-content::after {
        animation: none;
    }
    
    .lazy-image {
        transition: none;
    }
}

/* Mode sombre (si nécessaire) */
@media (prefers-color-scheme: dark) {
    .image-loading-container,
    .gallery-img,
    .course-img,
    .team-img,
    .blog-item-img,
    .event-img {
        background-color: #1a1a1a;
    }
    
    .image-skeleton {
        background: linear-gradient(
            90deg,
            #1a1a1a 0%,
            #2a2a2a 50%,
            #1a1a1a 100%
        );
        background-size: 200% 100%;
    }
}

/* Amélioration de l'accessibilité */
.image-error {
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #999;
    background: #f5f5f5;
    border-radius: 4px;
}

/* Optimisation pour les images critiques (above the fold) */
img[fetchpriority="high"] {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* Amélioration du contraste pour les placeholders */
.image-skeleton {
    background-color: #e8e8e8;
}

/* Transition douce pour les images chargées */
.lazy-image.loaded {
    animation: fadeInImage 0.4s ease-in-out;
}

@keyframes fadeInImage {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

