/**
 * Media Optimization CSS
 * Optimized styles for images and videos with lazy loading
 */

/* Base Media Optimization */
img, video {
    max-width: 100%;
    height: auto;
    object-fit: cover;
    display: block;
    margin: 0 auto;
}

/* Lazy Loading States */
.media-lazy {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.media-loaded {
    opacity: 1;
}

.media-loading {
    opacity: 0.6;
    filter: blur(2px);
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.media-error {
    opacity: 0.4;
    filter: grayscale(100%);
    background: #f5f5f5;
}

/* Shimmer Loading Animation */
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Fade-in Animation */
@keyframes fadeIn {
    from { 
        opacity: 0; 
        transform: translateY(10px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

/* Responsive Images */
.responsive-image {
    width: 100%;
    height: auto;
    object-fit: cover;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Optimized Room Images */
.room-image {
    width: 100%;
    height: 250px;
    object-fit: cover;
    border-radius: 12px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.room-image:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

/* Optimized Gallery Images */
.gallery-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.gallery-image:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

/* Optimized Hero Images */
.hero-image {
    width: 100%;
    height: 60vh;
    object-fit: cover;
    object-position: center;
    position: relative;
}

.hero-image::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, rgba(0,0,0,0.3), rgba(0,0,0,0.6));
    pointer-events: none;
}

/* Video Optimization */
.optimized-video {
    width: 100%;
    height: auto;
    max-height: 500px;
    object-fit: cover;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.video-container {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    background: #000;
}

.video-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Video Poster Optimization */
.video-poster {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

.video-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    padding: 20px;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.video-container:hover .video-controls {
    opacity: 1;
}

/* Performance Optimizations */
img, video {
    will-change: transform;
    backface-visibility: hidden;
    transform: translateZ(0);
    contain: layout style paint;
}

/* Reduce paint on scroll */
.media-optimized {
    contain: layout style paint;
}

/* Image Compression Placeholder */
.compression-placeholder {
    background: linear-gradient(45deg, #f0f0f0 25%, transparent 25%, transparent 75%, #f0f0f0 75%, #f0f0f0),
                linear-gradient(45deg, #f0f0f0 25%, transparent 25%, transparent 75%, #f0f0f0 75%, #f0f0f0);
    background-size: 20px 20px;
    background-position: 0 0, 10px 10px;
    animation: move 1s linear infinite;
}

@keyframes move {
    0% { background-position: 0 0, 10px 10px; }
    100% { background-position: 20px 20px, 30px 30px; }
}

/* Mobile Optimization */
@media (max-width: 768px) {
    .room-image {
        height: 200px;
    }
    
    .gallery-image {
        height: 150px;
    }
    
    .hero-image {
        height: 40vh;
    }
    
    .optimized-video {
        max-height: 300px;
    }
}

@media (max-width: 480px) {
    .room-image {
        height: 180px;
    }
    
    .gallery-image {
        height: 120px;
    }
    
    .hero-image {
        height: 30vh;
    }
    
    .optimized-video {
        max-height: 250px;
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .room-image,
    .gallery-image,
    .hero-image {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Print Optimization */
@media print {
    img, video {
        max-width: 100% !important;
        height: auto !important;
        page-break-inside: avoid;
    }
    
    .video-controls {
        display: none !important;
    }
}

/* Accessibility */
img:focus, video:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .media-loading {
        animation: none;
    }
    
    .media-lazy,
    .media-loaded,
    .room-image,
    .gallery-image,
    .optimized-video {
        transition: none;
    }
    
    .fade-in {
        animation: none;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .media-error {
        background: #333;
    }
    
    .compression-placeholder {
        background: linear-gradient(45deg, #333 25%, #444 25%, #444 75%, #333 75%, #333),
                    linear-gradient(45deg, #333 25%, #444 25%, #444 75%, #333 75%, #333);
    }
}

/* Critical CSS for Above-the-Fold Content */
.critical-image {
    display: block;
    width: 100%;
    height: auto;
    object-fit: cover;
}

/* Non-Critical CSS for Below-the-Fold Content */
.non-critical-image {
    /* These attributes will be set via JavaScript */
}

/* Image Lazy Loading Support */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

/* Video Lazy Loading Support */
video[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s ease;
}

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