/* Lazy Loading Styles */
.lazy-loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    min-height: 200px;
    border-radius: 8px;
}

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

.lazy-error {
    background-color: #f8f9fa;
    border: 2px dashed #dee2e6;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    color: #6c757d;
    font-size: 0.875rem;
}

.lazy-error::before {
    content: "⚠️ Image unavailable";
}

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

/* Responsive image optimization */
.img-optimized {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.img-optimized:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

/* Portfolio and gallery specific styles */
.portfolio-image {
    aspect-ratio: 16/9;
    object-fit: cover;
    width: 100%;
}

.blog-image {
    aspect-ratio: 2/1;
    object-fit: cover;
    width: 100%;
    margin: 1rem 0;
}

/* WebP support detection */
.no-webp .webp-image {
    display: none;
}

.webp .fallback-image {
    display: none;
}

/* Loading spinner for critical images */
.critical-image-container {
    position: relative;
    display: inline-block;
}

.critical-image-container::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 1;
}

.critical-image-container img.loaded::before {
    display: none;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Blur-up technique for progressive loading */
.blur-up {
    filter: blur(5px);
    transition: filter 0.3s ease;
}

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

/* Print styles - ensure images load for print */
@media print {
    img[data-src] {
        display: none;
    }
    
    .lazy-loaded,
    .lazy-error {
        display: block !important;
    }
}