/**
 * Lazy Loading Styles for TRemlak360 Homepage
 * These styles enhance the lazy loading experience without affecting existing functionality
 */

/* Lazy loading image styles */
img[data-src] {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    background: #f8f9fa;
    min-height: 200px;
}

img[data-src].lazy-loaded {
    opacity: 1;
}

/* Blog-specific lazy loading styles */
.blog-lazy-image {
    transition: all 0.4s ease-in-out;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
    overflow: hidden;
}

.blog-lazy-image[data-src] {
    opacity: 0.8;
    filter: blur(1px);
    transform: scale(0.98);
}

.blog-lazy-image.lazy-loaded {
    opacity: 1;
    filter: blur(0);
    transform: scale(1);
    background: none;
}

.blog-lazy-image:hover {
    transform: scale(1.02);
    transition: transform 0.2s ease-in-out;
}

/* Blog image skeleton loading */
.blog-lazy-image::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23adb5bd"><path d="M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z"/></svg>') no-repeat center;
    background-size: contain;
    opacity: 0.4;
    z-index: 1;
}

.blog-lazy-image.lazy-loaded::before {
    display: none;
}

/* Placeholder styling for images */
img[src*="placeholder.png"] {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    position: relative;
}

img[src*="placeholder.png"]::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23adb5bd"><path d="M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z"/></svg>') no-repeat center;
    background-size: contain;
    opacity: 0.3;
}

/* Section lazy loading animations */
/* section:not(.home-banner-style4) {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
} */

section.section-loaded {
    opacity: 1;
    transform: translateY(0);
}

/* Smooth transitions for all lazy-loaded content */
.lazy-loading {
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.4s ease-out;
}

.lazy-loaded {
    opacity: 1;
    transform: translateY(0);
}

/* Loading skeleton for images */
.image-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 4px;
    min-height: 200px;
}

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

/* Enhanced hover effects for lazy-loaded images */
img.lazy-loaded:hover {
    transform: scale(1.02);
    transition: transform 0.2s ease-in-out;
}

/* Property listing specific lazy loading styles */
.property-listing-image {
    transition: all 0.3s ease-in-out;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.property-listing-image.lazy-loaded {
    background: none;
}

.property-listing-image[data-src] {
    opacity: 0.8;
    filter: blur(1px);
}

.property-listing-image.lazy-loaded {
    opacity: 1;
    filter: blur(0);
}

/* Property listing section animations */
.lazy-loading-section {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.6s ease-out;
}

.lazy-loading-section.section-loaded {
    opacity: 1;
    transform: translateY(0);
}

/* Loading indicator styles */
.lazy-loading-indicator {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.lazy-loading-indicator .spinner-border {
    width: 1.5rem;
    height: 1.5rem;
}

/* Responsive lazy loading adjustments */
@media (max-width: 768px) {
    img[data-src] {
        min-height: 150px;
    }

    .image-skeleton {
        min-height: 150px;
    }

    .blog-lazy-image {
        min-height: 180px;
    }

    section:not(.home-banner-style4) {
        transform: translateY(15px);
    }
}

/* Print styles - disable lazy loading for printing */
@media print {
    img[data-src] {
        opacity: 1;
        background: none;
    }

    .blog-lazy-image {
        opacity: 1;
        filter: none;
        transform: none;
        background: none;
    }

    section:not(.home-banner-style4) {
        opacity: 1;
        transform: none;
    }

    .lazy-loading,
    .lazy-loaded {
        opacity: 1;
        transform: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    img[data-src] {
        border: 2px solid #000;
    }

    .blog-lazy-image {
        border: 2px solid #000;
    }

    .image-skeleton {
        border: 2px solid #000;
        background: #fff;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    img[data-src],
    .blog-lazy-image,
    section:not(.home-banner-style4),
    .lazy-loading,
    .lazy-loaded {
        transition: none;
        transform: none;
    }

    img.lazy-loaded:hover,
    .blog-lazy-image:hover {
        transform: none;
    }
}

/* Focus styles for accessibility */
img[data-src]:focus,
img.lazy-loaded:focus,
.blog-lazy-image:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    img[data-src] {
        background: #2d3748;
    }

    .blog-lazy-image {
        background: linear-gradient(135deg, #2d3748 0%, #4a5568 100%);
    }

    .image-skeleton {
        background: linear-gradient(90deg, #2d3748 25%, #4a5568 50%, #2d3748 75%);
        background-size: 200% 100%;
    }

    img[src*="placeholder.png"]::before,
    .blog-lazy-image::before {
        filter: invert(1);
        opacity: 0.5;
    }
}
