/* ============================================
   OTIMIZAÇÃO DINÂMICA DE IMAGENS
   - Skeleton loading com shimmer animation
   - Fade-in suave ao carregar
   - Performance máxima
   ============================================ */

/* Container da imagem com placeholder */
.img-container {
    position: relative;
    overflow: hidden;
    background: #f5f5f5; /* Fundo neutro sem animação */
}

/* Apenas imagens LAZY têm skeleton animado */
.img-container.lazy-loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* Animação shimmer (efeito de brilho) */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* PRIMEIRAS 3 IMAGENS: carregamento instantâneo (sem fade) */
.img-container img[loading="eager"] {
    opacity: 1 !important; /* Sempre visível */
    transition: none !important; /* Sem animação */
    display: block;
}

/* RESTO (lazy): fade-in apenas */
.img-container img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    display: block;
}

/* Imagem lazy carregada (fade-in) */
.img-container img[loading="lazy"].loaded {
    opacity: 1;
}

/* Remover shimmer quando imagem carregar */
.img-container.img-loaded {
    animation: none;
    background: transparent;
}

/* Placeholder com ícone (antes de carregar) */
.img-container::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23cccccc'%3E%3Cpath d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 3c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3 1.34-3 3-3zm0 14.2c-2.5 0-4.71-1.28-6-3.22.03-1.99 4-3.08 6-3.08 1.99 0 5.97 1.09 6 3.08-1.29 1.94-3.5 3.22-6 3.22z'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    opacity: 0.3;
    z-index: 1;
}

/* Remover ícone quando imagem carregar */
.img-container.img-loaded::before {
    display: none;
}

/* Otimização: reduzir motion em dispositivos com preferência */
@media (prefers-reduced-motion: reduce) {
    .img-container {
        animation: none;
    }
    .img-container img {
        transition: none;
        opacity: 1;
    }
}

/* Skeleton para cards inteiros (opcional) */
.skeleton-card {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}

.skeleton-card.loaded {
    animation: none;
    background: transparent;
}

/* Performance: usar will-change para otimizar animações */
.img-container img {
    will-change: opacity;
}

/* Mobile: otimizações adicionais */
@media (max-width: 576px) {
    .img-container img {
        transition-duration: 0.2s; /* Fade mais rápido em mobile */
    }
}
