/* Mobile Image Optimization CSS */

/* Base image styles for all devices */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Lazy loading optimization */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

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

/* Hero image optimization */
.hero-image {
    width: 100%;
    height: auto;
    object-fit: cover;
    border-radius: 15px;
}

/* Gallery images responsive grid */
.gallery-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    aspect-ratio: 1;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

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

/* Service card images */
.service-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 8px;
}

/* Team member images */
.team-member img {
    width: 100%;
    height: 250px;
    object-fit: cover;
    border-radius: 12px;
}

/* Certificate images */
.certificate-img {
    width: 100%;
    height: auto;
    max-height: 200px;
    object-fit: contain;
    border-radius: 8px;
    background: white;
    padding: 10px;
}

/* Mobile specific optimizations */
@media (max-width: 768px) {
    /* Reduce image quality on mobile for faster loading */
    .hero-image {
        max-height: 300px;
    }
    
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }
    
    .gallery-item {
        aspect-ratio: 4/3;
    }
    
    .service-card img {
        height: 150px;
    }
    
    .team-member img {
        height: 200px;
    }
    
    .certificate-img {
        max-height: 150px;
    }
}

/* iPhone SE and smaller screens */
@media (max-width: 375px) {
    .gallery-grid {
        grid-template-columns: 1fr;
    }
    
    .hero-image {
        max-height: 250px;
        border-radius: 10px;
    }
    
    .service-card img {
        height: 120px;
    }
    
    .team-member img {
        height: 180px;
    }
}

/* 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: 8px;
}

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

/* Image error handling */
img[src=""], img:not([src]) {
    opacity: 0;
}

img[alt]:after {
    content: attr(alt);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 10px;
    border-radius: 4px;
    font-size: 12px;
    text-align: center;
}

/* Optimize images in cards */
.card img, .service-card img, .testimonial img {
    loading: lazy;
}

/* WebP support detection */
.webp .hero-image {
    /* WebP images will be handled by JavaScript */
}

.no-webp .hero-image {
    /* Fallback for browsers without WebP support */
}

/* Retina display optimization */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .hero-image {
        /* Higher quality images for retina displays */
    }
}

/* Preload critical images */
.preload-image {
    position: absolute;
    top: -9999px;
    left: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
}