/* 777 Rummy - Advanced Image Optimization CSS v1.0.0 */

/* Responsive Image Container */
.responsive-image-container {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    overflow: hidden;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

.responsive-image-container img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: transform 0.3s ease;
}

.responsive-image-container:hover img {
    transform: scale(1.05);
}

/* Lazy Loading Placeholder */
.lazy-loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Image Optimization Classes */
.image-optimized {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.image-optimized:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

/* Responsive Image Sizes */
@media (max-width: 480px) {
    .responsive-image-container {
        padding-bottom: 75%; /* 4:3 aspect ratio for mobile */
    }
    
    .image-optimized {
        border-radius: 8px;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .responsive-image-container {
        padding-bottom: 60%; /* Slightly taller for tablets */
    }
}

@media (min-width: 769px) {
    .responsive-image-container {
        padding-bottom: 56.25%; /* 16:9 for desktop */
    }
}

/* WebP Support Detection */
.no-webp .image-optimized {
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1 1"><rect width="1" height="1" fill="%23f0f0f0"/></svg>');
}

.webp .image-optimized {
    background-image: none;
}

/* Progressive Image Loading */
.progressive-image {
    filter: blur(5px);
    transition: filter 0.3s ease;
}

.progressive-image.loaded {
    filter: blur(0);
}

/* Image Compression Indicators */
.image-compressed::after {
    content: "📦 Optimized";
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
}

/* Critical Image Above the Fold */
.critical-image {
    loading: eager;
    fetchpriority: high;
}

/* Non-critical Images */
.non-critical-image {
    loading: lazy;
    fetchpriority: low;
}

/* Image Error Handling */
.image-error {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    text-align: center;
    padding: 4rem 2rem;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    min-height: 450px;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

.image-error h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    font-weight: bold;
}

.image-error p {
    font-size: 1.1rem;
    opacity: 0.9;
    line-height: 1.6;
}

/* Placeholder for missing images */
.image-placeholder {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 4rem 2rem;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    min-height: 450px;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    border: 2px solid rgba(255,255,255,0.2);
}

.image-placeholder h3 {
    font-size: 2rem;
    margin-bottom: 1rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.image-placeholder p {
    font-size: 1.2rem;
    opacity: 0.9;
    max-width: 600px;
    line-height: 1.6;
}

/* Intersection Observer for Lazy Loading */
.lazy-image {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lazy-image.loaded {
    opacity: 1;
}

/* Image Preloading */
.preload-image {
    position: absolute;
    top: -9999px;
    left: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
}

/* High DPI Display Support */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .high-dpi-image {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Print Styles for Images */
@media print {
    .image-optimized {
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    .responsive-image-container {
        height: auto;
        padding-bottom: 0;
    }
    
    .responsive-image-container img {
        position: static;
        width: 100%;
        height: auto;
    }
}

/* Accessibility Improvements */
.image-optimized:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Performance Monitoring */
.image-performance::after {
    content: attr(data-load-time);
    position: absolute;
    bottom: 5px;
    left: 5px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-family: monospace;
}
