/**
 * LivePublicWebcams - Lazy Loading Styles
 * Styles for lazy loaded images and responsive backgrounds
 */

/* Base lazy loading image styles */
img.lazy-placeholder {
    opacity: 0;
    transition: opacity 0.3s ease;
    background-color: #f0f0f0;
    filter: blur(8px);
    transform: scale(1.05);
    will-change: opacity, filter, transform;
}

.dark img.lazy-placeholder {
    background-color: #333;
}

img.loaded {
    opacity: 1;
    filter: blur(0);
    transform: scale(1);
}

img.error {
    opacity: 0.7;
}

/* Low quality image placeholder (LQIP) pattern */
.lqip-wrapper {
    position: relative;
    overflow: hidden;
    background-color: #f0f0f0;
}

.dark .lqip-wrapper {
    background-color: #333;
}

.lqip-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    filter: blur(15px);
    transform: scale(1.1);
    opacity: 1;
    transition: opacity 0.3s ease;
    z-index: 1;
    background-size: cover;
    background-position: center;
}

.lqip-wrapper img {
    position: relative;
    z-index: 2;
}

.lqip-wrapper img.loaded + .lqip-placeholder {
    opacity: 0;
}

/* Responsive background elements */
[data-bg] {
    background-color: #f0f0f0;
    background-size: cover;
    background-position: center;
    position: relative;
    overflow: hidden;
}

.dark [data-bg] {
    background-color: #333;
}

[data-bg]::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: inherit;
    opacity: 1;
    transition: opacity 0.3s ease;
}

[data-bg].bg-loaded::before {
    opacity: 0;
}

/* Aspect ratio containers for responsive images */
.aspect-ratio-box {
    position: relative;
    height: 0;
    overflow: hidden;
}

.aspect-ratio-box[data-ratio="16:9"] {
    padding-top: 56.25%; /* 16:9 */
}

.aspect-ratio-box[data-ratio="4:3"] {
    padding-top: 75%; /* 4:3 */
}

.aspect-ratio-box[data-ratio="1:1"] {
    padding-top: 100%; /* Square */
}

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

/* Blur-up effect animation for progressive loading */
@keyframes blurUp {
    from {
        filter: blur(20px);
        opacity: 0;
    }
    to {
        filter: blur(0);
        opacity: 1;
    }
}

.blur-up {
    animation: blurUp 0.5s ease-out forwards;
}

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

.dark .skeleton-loader {
    background: linear-gradient(90deg, #333 25%, #444 50%, #333 75%);
    background-size: 200% 100%;
}

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

/* Responsive image containers */
.responsive-img-container {
    overflow: hidden;
    position: relative;
}

.responsive-img-container img {
    width: 100%;
    height: auto;
    display: block;
}

/* Optimizations for webp-supporting browsers */
.webp-support [data-webp-bg] {
    background-image: var(--webp-bg-url) !important;
}

/* Prevent content jumping when images load */
.prevent-shift {
    contain: layout style size;
}

/* Media query for responsive image sizing */
@media (max-width: 768px) {
    .aspect-ratio-box[data-ratio-mobile="1:1"] {
        padding-top: 100%; /* Square on mobile */
    }
}

@media (max-width: 480px) {
    img.lazy-placeholder {
        filter: blur(5px); /* Smaller blur for mobile to improve performance */
    }
}