/* Otimizações para Imagens WebP */

/* Picture element responsivo */
picture {
    display: block;
    width: 100%;
}

picture img {
    display: block;
    width: 100%;
    height: auto;
}

/* Lazy loading placeholder */
img[loading="lazy"] {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s ease-in-out infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Remove animação quando imagem carrega */
img[loading="lazy"].loaded {
    animation: none;
    background: transparent;
}

/* Otimizações de performance */
img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* Suavização de imagens WebP em navegadores antigos */
.webp img {
    image-rendering: auto;
}

/* Estilos para carrossel com background WebP */
.section-bg-img[style*="background-image"] {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    will-change: transform;
}

/* Otimização para portfolio/projetos */
.portfolio-thumb img {
    transition: transform 0.3s ease;
}

.portfolio-thumb:hover img {
    transform: scale(1.05);
}

/* Otimização para thumbnails de serviços */
.service-thumb img {
    object-fit: cover;
    aspect-ratio: 425 / 282;
}

/* Otimização para imagens de blog/posts */
.blog-thumb img {
    object-fit: cover;
    width: 100%;
    height: auto;
}

/* Avatar circular para depoimentos */
.client-image img {
    object-fit: cover;
    border-radius: 50%;
}

/* Prevenção de layout shift */
img[width][height] {
    height: auto;
}

/* Container responsivo para manter proporções */
.img-container {
    position: relative;
    width: 100%;
    padding-bottom: 66.67%; /* 3:2 aspect ratio */
    overflow: hidden;
}

.img-container img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Fade in para imagens lazy loaded */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

img.fade-in {
    animation: fadeIn 0.3s ease-in;
}

/* Suporte para modo escuro (se aplicável) */
@media (prefers-color-scheme: dark) {
    img[loading="lazy"] {
        background: linear-gradient(90deg, #2a2a2a 25%, #1a1a1a 50%, #2a2a2a 75%);
    }
}

/* Otimizações mobile */
@media (max-width: 768px) {
    .service-thumb img,
    .blog-thumb img,
    .portfolio-thumb img {
        max-width: 100%;
        height: auto;
    }
}

/* Print styles - usar versões de alta qualidade */
@media print {
    img {
        image-rendering: high-quality;
        page-break-inside: avoid;
    }
}
