/**
 * Lazy Loading Styles
 * Provides smooth transitions and placeholder effects
 */

/* Base lazy image styles */
img[data-src],
img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s ease-in-out, filter 0.3s ease-in-out, transform 0.3s ease-in-out;
}

/* Loading state */
img.lazy-loading {
    opacity: 0.5;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* Loaded state */
img.lazy-loaded {
    opacity: 1;
    filter: blur(0) !important;
    transform: scale(1) !important;
}

/* Error state */
img.lazy-error {
    opacity: 0.3;
    filter: grayscale(100%);
}

/* Shimmer animation for loading */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* Blur-up effect for placeholders */
img[data-placeholder] {
    filter: blur(20px);
    transform: scale(1.1);
}

/* Aspect ratio containers to prevent layout shift */
.lazy-container {
    position: relative;
    overflow: hidden;
    background-color: #f5f5f5;
}

.lazy-container img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Aspect ratio helpers */
.lazy-container-16-9 {
    padding-bottom: 56.25%; /* 16:9 */
}

.lazy-container-4-3 {
    padding-bottom: 75%; /* 4:3 */
}

.lazy-container-1-1 {
    padding-bottom: 100%; /* 1:1 square */
}

.lazy-container-3-2 {
    padding-bottom: 66.67%; /* 3:2 */
}

/* Progressive enhancement */
@supports (aspect-ratio: 16 / 9) {
    .lazy-container {
        padding-bottom: 0;
    }
    
    .lazy-container-16-9 {
        aspect-ratio: 16 / 9;
    }
    
    .lazy-container-4-3 {
        aspect-ratio: 4 / 3;
    }
    
    .lazy-container-1-1 {
        aspect-ratio: 1 / 1;
    }
    
    .lazy-container-3-2 {
        aspect-ratio: 3 / 2;
    }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    img[data-src],
    img[loading="lazy"],
    img.lazy-loading,
    img.lazy-loaded {
        transition: none;
        animation: none;
    }
}

/* Print styles - load all images */
@media print {
    img[data-src] {
        opacity: 1;
    }
}