/**
 * Image Optimization Styles for Zouhal Creations
 * Handles loading states, progressive loading, and responsive images
 */

/* Image loading states */
img {
    opacity: 1;
    transition: opacity 0.3s ease-in-out;
}

img.loading {
    opacity: 1;
    transition: opacity 0.3s ease-in-out;
    /* Remove grey background for regular images */
    /* background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading-shimmer 1.5s infinite; */
}

img.loaded {
    opacity: 1;
    transition: opacity 0.3s ease-in-out;
}

img.error {
    opacity: 0.5;
    filter: grayscale(100%);
}

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

/* Progressive loading */
img.progressive {
    filter: blur(5px);
    transition: filter 0.3s ease-out;
}

img.progressive-loaded {
    filter: blur(0);
}

/* Responsive image containers */
.responsive-image {
    position: relative;
    overflow: hidden;
    background-color: #f5f5f5;
}

.responsive-image img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease;
}

.responsive-image:hover img {
    transform: scale(1.05);
}

/* Picture element fallbacks */
picture {
    display: block;
    width: 100%;
    height: auto;
}

picture img {
    width: 100%;
    height: auto;
    display: block;
}

/* Gallery image optimizations */
.gallery-item img {
    transition: all 0.3s ease;
    will-change: transform, opacity;
}

.gallery-item:hover img {
    transform: scale(1.02);
}

/* Hero image optimizations */
.hero-slideshow img,
.slide {
    object-fit: cover;
    object-position: center;
    will-change: transform, opacity;
}

/* Portfolio image optimizations */
.image-container_port img {
    transition: all 0.3s ease;
    will-change: transform, filter;
}

.image-container_port:hover img {
    transform: scale(1.05);
    filter: brightness(1.1);
}

/* Logo optimizations */
.logo img {
    transition: opacity 0.3s ease;
    will-change: opacity;
}

.logo img:hover {
    opacity: 0.8;
}

/* Background image optimizations */
[style*="background-image"] {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    will-change: transform;
}

/* Image aspect ratio containers */
.aspect-ratio-container {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    overflow: hidden;
}

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

/* Square aspect ratio */
.aspect-ratio-square {
    padding-bottom: 100%;
}

/* Fashion aspect ratio */
.aspect-ratio-fashion {
    padding-bottom: 133.33%; /* 3:4 aspect ratio */
}

/* Landscape aspect ratio */
.aspect-ratio-landscape {
    padding-bottom: 66.67%; /* 3:2 aspect ratio */
}

/* Image loading placeholder */
.image-placeholder {
    background: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 0.875rem;
    min-height: 200px;
}

/* WebP support indicator */
.webp .image-optimized {
    background-color: #e8f5e8;
}

.no-webp .image-optimized {
    background-color: #fff3cd;
}

/* Image error state */
.image-error {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
    padding: 1rem;
    text-align: center;
    border-radius: 4px;
}

/* Responsive image sizes */
@media (max-width: 480px) {
    .responsive-image img {
        max-width: 100%;
        height: auto;
    }
    
    .aspect-ratio-container {
        padding-bottom: 75%; /* Taller on mobile */
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .responsive-image img {
        max-width: 100%;
        height: auto;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .responsive-image img {
        max-width: 100%;
        height: auto;
    }
}

@media (min-width: 1025px) {
    .responsive-image img {
        max-width: 100%;
        height: auto;
    }
}

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

/* Print styles */
@media print {
    img {
        max-width: 100% !important;
        height: auto !important;
        page-break-inside: avoid;
    }
    
    .responsive-image {
        break-inside: avoid;
    }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    img,
    .responsive-image img,
    .gallery-item img {
        transition: none;
        animation: none;
    }
    
    .loading {
        animation: none;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .image-placeholder {
        background: linear-gradient(135deg, #2d2d2d 0%, #1a1a1a 100%);
        color: #ccc;
    }
    
    .loading {
        background: linear-gradient(90deg, #2d2d2d 25%, #1a1a1a 50%, #2d2d2d 75%);
    }
} 