/**
 * Portfolio Image Loading States
 * Provides smooth transitions and loading indicators
 */

/* Loading state for lazy-loaded images */
.gallery-img.loading {
    opacity: 0.5;
    filter: blur(5px);
    transition: opacity 0.3s ease, filter 0.3s ease;
}

/* Loaded state */
.gallery-img.loaded {
    opacity: 1;
    filter: blur(0);
}

/* Error state */
.gallery-img.error {
    opacity: 0.3;
    position: relative;
}

.gallery-img.error::after {
    content: '?';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    color: var(--brand-gold);
}

/* Skeleton loader for images */
.gallery-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        rgba(240, 240, 240, 0.1) 0%,
        rgba(240, 240, 240, 0.3) 50%,
        rgba(240, 240, 240, 0.1) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    z-index: -1;
    border-radius: 8px;
}

.gallery-item.loaded::before {
    display: none;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Ensure images fade in smoothly */
.gallery-img {
    transition: opacity 0.3s ease-in-out;
}

/* Progressive enhancement for browsers that don't support loading="lazy" */
@supports not (loading: lazy) {
    .gallery-img {
        opacity: 1;
    }
}

/* Reduce animation on reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .gallery-img,
    .gallery-item::before {
        animation: none;
        transition: none;
    }
}
