/* =============================================================================
   LAZY LOADING & IMAGE OPTIMIZATION
   ============================================================================= */

/* Image Lazy Loading Placeholder */
.img-placeholder {
    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;
    animation: placeholderShimmer 2s infinite linear;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 14px;
    position: relative;
}

.img-placeholder::before {
    content: "Loading...";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.9);
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: 500;
}

@keyframes placeholderShimmer {
    0% {
        background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    }
    100% {
        background-position: 20px 20px, 20px 30px, 30px 10px, 10px 20px;
    }
}

/* Image Loading States */
.img-fluid {
    transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
}

.img-fluid[data-loading="true"] {
    opacity: 0;
    transform: scale(1.05);
}

.img-fluid[data-loading="false"] {
    opacity: 1;
    transform: scale(1);
}

/* Progressive Loading Enhancement */
.progressive-image {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
}

.progressive-image.loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: progressiveLoading 2s infinite;
}

@keyframes progressiveLoading {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.progressive-image img {
    width: 100%;
    height: auto;
    transition: opacity 0.4s ease-out;
}

.progressive-image.loading img {
    opacity: 0;
}

.progressive-image.loaded img {
    opacity: 1;
}

/* Intersection Observer Enhancements */
.fade-in-image {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.fade-in-image.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Portfolio Items Loading Enhancement */
.portfolio-item-enhanced {
    position: relative;
}

.portfolio-item-enhanced.loading::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, 
        rgba(240, 240, 240, 0.8) 25%, 
        rgba(220, 220, 220, 0.8) 50%, 
        rgba(240, 240, 240, 0.8) 75%);
    background-size: 200% 100%;
    animation: portfolioShimmer 2s infinite;
    z-index: 1;
    border-radius: 8px;
}

@keyframes portfolioShimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* Mobile Optimization */
@media (max-width: 768px) {
    .img-placeholder {
        min-height: 150px;
        font-size: 12px;
    }
    
    .progressive-image {
        border-radius: 6px;
    }
}

/* Preload Critical Images */
.preload-critical {
    position: absolute;
    top: -9999px;
    left: -9999px;
    opacity: 0;
    pointer-events: none;
}

/* Loading Spinner for Images */
.image-loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--vixel-primary, #1a4c3e);
    border-radius: 50%;
    animation: imageSpinner 1s linear infinite;
    z-index: 2;
}

@keyframes imageSpinner {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}