/* Lazy Loading Image Styles */

/* Initial state - hidden until loaded */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.4s ease-in-out;
}

/* Loaded state - fade in */
img[loading="lazy"].loaded,
img[loading="lazy"][src] {
    opacity: 1;
}

/* Blur-up placeholder effect */
img.blur-up {
    filter: blur(8px);
    transform: scale(1.05);
    transition: filter 0.4s ease-in-out, transform 0.4s ease-in-out;
}

img.blur-up.loaded {
    filter: blur(0);
    transform: scale(1);
}

/* Picture element styling */
picture {
    display: inline-block;
    line-height: 0;
}

picture img {
    display: block;
    width: 100%;
    height: auto;
}

/* Prevent layout shift during image load */
img[width][height] {
    height: auto;
}

/* Aspect ratio boxes for preventing layout shift */
.img-wrapper {
    position: relative;
    overflow: hidden;
}

.img-wrapper::before {
    content: '';
    display: block;
    padding-top: 56.25%;
    /* 16:9 aspect ratio, adjust as needed */
}

.img-wrapper img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Loading spinner (optional) */
.img-loading {
    position: relative;
}

.img-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 3px solid rgba(255, 215, 0, 0.3);
    border-top-color: #ffd700;
    border-radius: 50%;
    animation: img-spinner 0.8s linear infinite;
}

.img-loading.loaded::after {
    display: none;
}

@keyframes img-spinner {
    to {
        transform: rotate(360deg);
    }
}

/* Responsive image utilities */
.img-responsive {
    max-width: 100%;
    height: auto;
}

.img-fluid {
    max-width: 100%;
    height: auto;
    display: block;
}

/* WebP support detection fallback */
.no-webp picture source[type="image/webp"] {
    display: none;
}