/* Image Optimization and Responsive Handling */

/* Lazy loading and performance optimization */
img {
    max-width: 100%;
    height: auto;
    display: block;
    transition: opacity 0.3s ease;
}

img[loading="lazy"] {
    opacity: 0;
}

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

/* Responsive image containers */
.image-container {
    position: relative;
    overflow: hidden;
}

.image-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, #f0f0f0 25%, transparent 25%), 
                linear-gradient(-45deg, #f0f0f0 25%, transparent 25%), 
                linear-gradient(45deg, transparent 75%, #f0f0f0 75%), 
                linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    opacity: 0.1;
    z-index: 1;
}

/* Logo specific styles */
.pwani-logo img,
.footer-logo img,
.pwani-logo-small img {
    filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.1));
}

/* Brand logos in cards */
.brand-logo img {
    transition: transform 0.3s ease;
}

.brand-card:hover .brand-logo img {
    transform: scale(1.05);
}

/* Certificate images */
.certificate-item img {
    filter: grayscale(20%);
    transition: filter 0.3s ease;
}

.certificate-item:hover img {
    filter: grayscale(0%);
}

/* Card images with overlay effects */
.card-image {
    position: relative;
    overflow: hidden;
}

.card-image img {
    transition: transform 0.5s ease;
}

.glimpse-card:hover .card-image img,
.brand-card:hover .card-image img {
    transform: scale(1.1);
}

/* Background image handling */
.hero-background,
.section-background,
.footer-background {
    background-attachment: scroll;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Commitment section image effects */
.commitment-image {
    position: relative;
}

.commitment-image::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        45deg,
        rgba(65, 148, 211, 0.1) 0%,
        rgba(237, 28, 36, 0.1) 50%,
        rgba(65, 148, 211, 0.1) 100%
    );
    z-index: 1;
    pointer-events: none;
}

.commitment-overlay {
    position: relative;
    z-index: 2;
}

/* Sustainability elements images */
.recycle-bin img,
.product-hand img {
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2));
    transition: transform 0.3s ease;
}

.recycle-bin:hover img,
.product-hand:hover img {
    transform: scale(1.05) rotate(2deg);
}

/* Decorative elements */
.decorative-elements .element {
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    animation: float 6s ease-in-out infinite;
}

.element-1 {
    animation-delay: 0s;
}

.element-2 {
    animation-delay: 3s;
}

@keyframes float {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    25% { transform: translateY(-10px) rotate(5deg); }
    50% { transform: translateY(-5px) rotate(-2deg); }
    75% { transform: translateY(-15px) rotate(3deg); }
}

/* Social icons with image backgrounds */
.social-icon {
    background-size: 60%;
    background-repeat: no-repeat;
    background-position: center;
}

.social-icon i {
    font-size: 16px;
}

@media (min-width: 1024px) {
    .social-icon i {
        font-size: 20px;
    }
}

/* Image loading states */
.image-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; }
}

/* High resolution display optimizations */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .pwani-logo img,
    .footer-logo img,
    .brand-logo img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Print styles for images */
@media print {
    .hero-background,
    .section-background,
    .footer-background {
        background: none !important;
    }
    
    .card-overlay,
    .commitment-overlay {
        background: none !important;
    }
    
    img {
        max-width: 100% !important;
        page-break-inside: avoid;
    }
}

/* Dark mode support (if needed) */
@media (prefers-color-scheme: dark) {
    .certificate-item img {
        filter: grayscale(20%) brightness(0.9);
    }
    
    .certificate-item:hover img {
        filter: grayscale(0%) brightness(1);
    }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    img,
    .card-image img,
    .brand-logo img,
    .recycle-bin img,
    .product-hand img {
        transition: none !important;
    }
    
    .decorative-elements .element {
        animation: none !important;
    }
    
    @keyframes float {
        0%, 100% { transform: none; }
    }
}