/**
 * Gallery Image Fail-safe Styles
 * Provides loading states, error fallbacks, and smooth transitions for gallery images
 */

/* Gallery Thumbnail Container */
.gallery-thumbnail {
    position: relative;
    background-color: #1f2937;
    background-image: linear-gradient(135deg, #374151 25%, transparent 25%), 
                      linear-gradient(225deg, #374151 25%, transparent 25%),
                      linear-gradient(45deg, #374151 25%, transparent 25%),
                      linear-gradient(315deg, #374151 25%, transparent 25%);
    background-position: 10px 0, 10px 0, 0 0, 0 0;
    background-size: 20px 20px;
    overflow: hidden;
}

/* Image States */
.gallery-thumbnail img {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.gallery-thumbnail img.loading {
    opacity: 0;
}

.gallery-thumbnail img.loaded {
    opacity: 1;
}

.gallery-thumbnail img.error {
    display: none;
}

/* Fallback Placeholder */
.gallery-thumbnail .fallback-placeholder {
    display: none;
    position: absolute;
    inset: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1f2937 0%, #374151 100%);
    color: rgba(255, 255, 255, 0.5);
    z-index: 1;
}

.gallery-thumbnail .fallback-placeholder.show {
    display: flex;
}

.gallery-thumbnail .fallback-placeholder svg {
    width: 3rem;
    height: 3rem;
    margin-bottom: 0.5rem;
}

.gallery-thumbnail .fallback-placeholder span {
    font-size: 0.875rem;
}

/* Loading Skeleton Animation */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.gallery-thumbnail.loading-skeleton {
    background: linear-gradient(
        90deg,
        #1f2937 0%,
        #374151 50%,
        #1f2937 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite ease-in-out;
}

/* Gallery Modal Improvements */
.gallery-modal-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    inset: 0;
}

.gallery-modal-spinner {
    width: 3rem;
    height: 3rem;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Image Error State in Modal */
.gallery-modal-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: absolute;
    inset: 0;
    color: rgba(255, 255, 255, 0.7);
}

.gallery-modal-error svg {
    width: 4rem;
    height: 4rem;
    margin-bottom: 1rem;
}

/* Hover Effects */
.gallery-thumbnail:hover img.loaded {
    transform: scale(1.05);
}

/* Mobile Optimizations */
@media (max-width: 640px) {
    .gallery-thumbnail .fallback-placeholder svg {
        width: 2rem;
        height: 2rem;
    }
    
    .gallery-thumbnail .fallback-placeholder span {
        font-size: 0.75rem;
    }
}
