/**
 * Lazy Loading Styles
 * Provides smooth loading transitions and skeleton effects
 */

/* Loading state with shimmer effect */
img.lazy-loading {
    background: linear-gradient(
        90deg,
        #1a1a1a 0%,
        #2a2a2a 50%,
        #1a1a1a 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* Shimmer animation */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* Loaded state */
img.lazy-loaded {
    background: none;
}

/* Error state */
img.lazy-error {
    background: #1a1a1a;
    border: 1px solid #ff4444;
}

/* Fade-in animation for loaded images */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Optional: Blur-up effect (for progressive images) */
img.lazy-loading[data-low-res] {
    filter: blur(5px);
    transform: scale(1.05);
    transition: filter 0.3s ease, transform 0.3s ease;
}

img.lazy-loaded[data-low-res] {
    filter: blur(0);
    transform: scale(1);
}

/* Skeleton placeholder for prompt cards */
.prompt-card.loading .prompt-image {
    background: linear-gradient(
        90deg,
        #1a1a1a 0%,
        #2a2a2a 50%,
        #1a1a1a 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* Pulse effect for loading state */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

img.lazy-loading.pulse {
    animation: pulse 1.5s infinite, shimmer 1.5s infinite;
}

/* Prevent layout shift */
img[loading="lazy"] {
    /* Ensure images have dimensions to prevent layout shift */
    min-height: 1px;
}

/* Optional: Add aspect ratio boxes */
.aspect-ratio-box {
    position: relative;
    width: 100%;
    overflow: hidden;
}

.aspect-ratio-box::before {
    content: '';
    display: block;
    padding-top: 75%; /* 4:3 aspect ratio (adjust as needed) */
}

.aspect-ratio-box img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Loading spinner overlay (optional) */
.lazy-loading-spinner {
    position: relative;
}

.lazy-loading-spinner::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #333;
    border-top-color: #5B8DFF;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* Dark mode adjustments */
html.dark img.lazy-loading {
    background: linear-gradient(
        90deg,
        #0a0a0a 0%,
        #1a1a1a 50%,
        #0a0a0a 100%
    );
}

/* Light mode adjustments */
html:not(.dark) img.lazy-loading {
    background: linear-gradient(
        90deg,
        #f0f0f0 0%,
        #e0e0e0 50%,
        #f0f0f0 100%
    );
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    img.lazy-loading {
        animation: none;
        background: #1a1a1a;
    }
    
    img {
        transition: none !important;
    }
}

/* Performance optimization: GPU acceleration */
img.lazy-loading,
img.lazy-loaded {
    transform: translateZ(0);
    will-change: opacity;
}

