/**
 * Image Optimization Styles
 * Improves image loading performance and user experience
 */

/* Lazy loading image states */
img[loading="lazy"],
img[data-src] {
    opacity: 0;
    transition: opacity 0.3s ease-in;
}

img[loading="lazy"].loaded,
img.loaded {
    opacity: 1;
}

img.loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

img.error {
    opacity: 0.5;
    filter: grayscale(100%);
}

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

/* Prevent layout shift with aspect ratio */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Optimize image rendering */
img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    -ms-interpolation-mode: bicubic;
}

/* Blur-up effect for lazy loaded images */
img[data-src] {
    filter: blur(5px);
    transition: filter 0.3s;
}

img[data-src].loaded {
    filter: blur(0);
}

/* Responsive images */
@media (max-width: 768px) {
    img {
        max-width: 100%;
    }
}

/* Optimize background images */
[style*="background-image"] {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    img {
        transition: none;
    }
    
    img.loading {
        animation: none;
    }
}




