/* Loading states and placeholders */
.image-loading {
    position: relative;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading-shimmer 1.5s infinite;
    border-radius: 8px;
    overflow: hidden;
}

.image-loading::before {
    content: '';
    display: block;
    width: 100%;
    height: 100%;
    background: inherit;
}

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

.image-placeholder {
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    font-size: 0.9rem;
    min-height: 200px;
}

.image-placeholder::before {
    content: '📷';
    font-size: 2rem;
    margin-right: 0.5rem;
}

.image-error {
    background: #f8d7da;
    border: 2px dashed #dc3545;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #721c24;
    font-size: 0.9rem;
    min-height: 200px;
}

.image-error::before {
    content: '⚠️';
    font-size: 2rem;
    margin-right: 0.5rem;
}

.progressive-image {
    position: relative;
    overflow: hidden;
}

.progressive-image img {
    transition: filter 0.3s ease;
}

.progressive-image.loading img {
    filter: blur(10px);
    transform: scale(1.1);
}

.progressive-image.loaded img {
    filter: blur(0);
    transform: scale(1);
}

.image-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: opacity 0.3s ease;
}

.image-loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-text {
    margin-top: 10px;
    font-size: 0.8rem;
    color: #666;
    text-align: center;
}

/* Fade in animation for loaded images */
.image-fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Portfolio image loading states */
.portfolio-image-container {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.portfolio-overlay {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 0;
}

.portfolio-overlay .loading-spinner {
    width: 30px;
    height: 30px;
    border-width: 2px;
}

.portfolio-item .image-error {
    min-height: 100%;
    border-radius: 0;
    font-size: 1.5rem;
}

/* Responsive loading states */
@media (max-width: 768px) {
    .portfolio-overlay .loading-spinner {
        width: 25px;
        height: 25px;
    }
}

/* Modern forced colors mode support (replaces deprecated -ms-high-contrast) */
@media (forced-colors: active) {
    .image-loading {
        background: Canvas;
        border: 1px solid CanvasText;
    }
    
    .image-placeholder {
        background: Canvas;
        border: 2px dashed CanvasText;
        color: CanvasText;
    }
    
    .image-error {
        background: Mark;
        border: 2px dashed MarkText;
        color: MarkText;
    }
    
    .loading-spinner {
        border-color: CanvasText;
        border-top-color: Highlight;
    }
    
    .loading-text {
        color: CanvasText;
    }
}

/* Prevent loading animations for cached images */
.progressive-image.cached img {
    filter: blur(0) !important;
    transform: scale(1) !important;
    animation: none !important;
}

.progressive-image.cached .image-loading-overlay {
    display: none !important;
}

/* Instant loading for cached images */
.progressive-image.cached {
    animation: none !important;
}

.progressive-image.cached img {
    opacity: 1 !important;
    transition: none !important;
}

/* Override fade-in animation for cached images */
.progressive-image.cached img.image-fade-in {
    animation: none !important;
    transform: none !important;
}

/* Ensure cached images never show any motion or transitions */
.progressive-image.cached img {
    animation: none !important;
    transition: none !important;
    transform: none !important;
}

.progressive-image.cached {
    animation: none !important;
    transition: none !important;
}
