/* Lazy Loading Styles */

/* Fade-in animation for lazy loaded images */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

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

/* Blur-up effect for lazy loading */
.lazy-image-container {
    position: relative;
    overflow: hidden;
    background-color: #f0f0f0;
}

.lazy-image-container img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}

.lazy-image-container img.loaded {
    opacity: 1;
}

/* Shimmer loading effect */
.image-loading {
    position: relative;
    overflow: hidden;
    background-color: #f0f0f0;
}

.image-loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.4),
        transparent
    );
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* Responsive picture element styles */
picture {
    display: block !important;
    width: 100%;
}

picture img {
    display: block !important;
    width: 100%;
    height: auto;
    max-width: 100%;
}

/* Ensure source elements work properly */
picture source {
    display: none !important; /* Sources are not displayed, browser uses them internally */
}

/* Ensure hero image picture elements work */
picture.hero-image {
    display: block !important;
    width: 100% !important;
}

picture.hero-image img {
    display: block !important;
    width: 100% !important;
    height: auto !important;
}

/* WebP support detection */
.webp picture source[type="image/webp"] {
    display: block;
}

.no-webp picture source[type="image/webp"] {
    display: none;
}

/* Aspect ratio boxes for placeholder */
.aspect-ratio-box {
    position: relative;
    width: 100%;
    background-color: #f0f0f0;
}

.aspect-ratio-box::before {
    content: '';
    display: block;
    padding-bottom: 66.67%; /* 3:2 aspect ratio by default */
}

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

/* Common aspect ratios */
.aspect-ratio-box.ratio-16-9::before {
    padding-bottom: 56.25%;
}

.aspect-ratio-box.ratio-4-3::before {
    padding-bottom: 75%;
}

.aspect-ratio-box.ratio-1-1::before {
    padding-bottom: 100%;
}

/* Error state for failed image loads */
img.error {
    position: relative;
    min-height: 100px;
    background-color: #f5f5f5;
}

img.error::before {
    content: '🖼️';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 48px;
    opacity: 0.3;
}

img.error::after {
    content: 'Image failed to load';
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    color: #999;
}