/**
 * Styles pour le lazy loading des images
 * Améliore l'expérience utilisateur pendant le chargement
 */

/* Image en cours de chargement */
.lazy-loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: lazy-loading-shimmer 1.5s infinite;
    opacity: 0.7;
    transition: opacity 0.3s ease-in-out;
}

/* Animation de shimmer pendant le chargement */
@keyframes lazy-loading-shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* Image chargée avec succès */
.lazy-loaded {
    opacity: 1;
    transition: opacity 0.3s ease-in-out;
}

/* Image en erreur */
.lazy-error {
    opacity: 0.5;
    filter: grayscale(100%);
    position: relative;
}

.lazy-error::after {
    content: "⚠️";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    opacity: 0.7;
}

/* Placeholder pour les images */
.lazy-placeholder {
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    font-size: 0.875rem;
    min-height: 200px;
}

.lazy-placeholder::before {
    content: "🖼️";
    font-size: 2rem;
    margin-right: 0.5rem;
}

/* Optimisations pour les images */
img[data-lazy] {
    will-change: opacity;
    backface-visibility: hidden;
    transform: translateZ(0);
}

/* Responsive images avec lazy loading */
.lazy-responsive {
    width: 100%;
    height: auto;
    max-width: 100%;
}

/* Images dans les grilles */
.grid img[data-lazy] {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 8px;
}

/* Images dans les articles */
.article-content img[data-lazy] {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Images featured */
.featured-main img[data-lazy],
.featured-small img[data-lazy] {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.featured-main:hover img[data-lazy],
.featured-small:hover img[data-lazy] {
    transform: scale(1.05);
}

/* Indicateur de progression (optionnel) */
.lazy-progress {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px 15px;
    border-radius: 20px;
    font-size: 0.875rem;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lazy-progress.show {
    opacity: 1;
}

/* Mode sombre */
@media (prefers-color-scheme: dark) {
    .lazy-loading {
        background: linear-gradient(90deg, #2d2d2d 25%, #3d3d3d 50%, #2d2d2d 75%);
    }
    
    .lazy-placeholder {
        background: #1a1a1a;
        color: #a0a0a0;
    }
}

/* Animations d'entrée */
@keyframes lazy-fade-in {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.lazy-fade-in {
    animation: lazy-fade-in 0.6s ease-out;
}

/* Optimisations de performance */
.lazy-container {
    contain: layout style paint;
}

/* Support pour les images WebP avec fallback */
.lazy-webp {
    background-image: url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB2aWV3Qm94PSIwIDAgMSAxIiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxyZWN0IHdpZHRoPSIxIiBoZWlnaHQ9IjEiIGZpbGw9IiNmMGYwZjAiLz48L3N2Zz4=');
}

/* Media queries pour différentes tailles d'écran */
@media (max-width: 768px) {
    .lazy-progress {
        top: 10px;
        right: 10px;
        font-size: 0.75rem;
        padding: 8px 12px;
    }
    
    .grid img[data-lazy] {
        height: 150px;
    }
}

@media (max-width: 480px) {
    .grid img[data-lazy] {
        height: 120px;
    }
}
