/* Image optimization styles */
.img-lazy {
    opacity: 0;
    transition: opacity 0.3s ease-in;
}

.img-lazy.loaded {
    opacity: 1;
}

/* Responsive images */
.img-fluid {
    max-width: 100%;
    height: auto;
}

/* Blur-up loading effect */
.img-blur-up {
    filter: blur(5px);
    transition: filter 0.3s ease-in;
}

.img-blur-up.loaded {
    filter: blur(0);
}

/* Placeholder background while loading */
.img-placeholder {
    background-color: #f0f0f0;
    position: relative;
    overflow: hidden;
}

.img-placeholder::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(
        to right,
        transparent 0%,
        rgba(255, 255, 255, 0.3) 50%,
        transparent 100%
    );
    animation: loading 1s infinite;
}

@keyframes loading {
    0% {
        left: -100%;
    }
    100% {
        left: 200%;
    }
}

/* Image aspect ratio preservation */
[data-aspect-ratio] {
    position: relative;
    padding-bottom: var(--aspect-ratio);
}

[data-aspect-ratio] > img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Common aspect ratios */
.aspect-16-9 {
    --aspect-ratio: 56.25%;
}

.aspect-4-3 {
    --aspect-ratio: 75%;
}

.aspect-1-1 {
    --aspect-ratio: 100%;
}

/* Responsive image sizing */
@media (max-width: 768px) {
    .img-fluid {
        max-height: 50vh;
        object-fit: cover;
    }
}

/* High-DPI (Retina) image support */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .img-retina {
        transform: scale(0.5);
        transform-origin: 0 0;
    }
}