/**
 * Infinite Scroll & Skeleton Loader Styles
 * Mobile-first responsive design
 */

/* ===========================================
   SKELETON LOADERS
   =========================================== */

.skeleton-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    width: 100%;
    padding: 0;
    margin: 0;
}

.skeleton-card {
    background: var(--card-bg, #ffffff);
    border-radius: 16px;
    padding: 1.25rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}

/* Dark mode support */
body.dark-mode .skeleton-card {
    background: var(--card-bg-dark, #1e293b);
}

@keyframes skeleton-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

/* Skeleton elements */
.skeleton-header {
    margin-bottom: 1rem;
}

.skeleton-badge {
    width: 80px;
    height: 20px;
    background: linear-gradient(90deg, #e0e0e0 25%, #f0f0f0 50%, #e0e0e0 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: 12px;
    margin-bottom: 0.75rem;
}

body.dark-mode .skeleton-badge {
    background: linear-gradient(90deg, #2d3748 25%, #3d4758 50%, #2d3748 75%);
    background-size: 200% 100%;
}

.skeleton-title {
    width: 70%;
    height: 24px;
    background: linear-gradient(90deg, #e0e0e0 25%, #f0f0f0 50%, #e0e0e0 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: 8px;
}

body.dark-mode .skeleton-title {
    background: linear-gradient(90deg, #2d3748 25%, #3d4758 50%, #2d3748 75%);
    background-size: 200% 100%;
}

.skeleton-image {
    width: 100%;
    height: 200px;
    background: linear-gradient(90deg, #e0e0e0 25%, #f0f0f0 50%, #e0e0e0 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: 12px;
    margin: 1rem 0;
}

body.dark-mode .skeleton-image {
    background: linear-gradient(90deg, #2d3748 25%, #3d4758 50%, #2d3748 75%);
    background-size: 200% 100%;
}

.skeleton-text {
    margin: 1rem 0;
}

.skeleton-line {
    width: 100%;
    height: 14px;
    background: linear-gradient(90deg, #e0e0e0 25%, #f0f0f0 50%, #e0e0e0 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

body.dark-mode .skeleton-line {
    background: linear-gradient(90deg, #2d3748 25%, #3d4758 50%, #2d3748 75%);
    background-size: 200% 100%;
}

.skeleton-line.short {
    width: 60%;
}

.skeleton-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

.skeleton-button {
    flex: 1;
    height: 40px;
    background: linear-gradient(90deg, #e0e0e0 25%, #f0f0f0 50%, #e0e0e0 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: 8px;
}

body.dark-mode .skeleton-button {
    background: linear-gradient(90deg, #2d3748 25%, #3d4758 50%, #2d3748 75%);
    background-size: 200% 100%;
}

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

/* ===========================================
   FADE-IN ANIMATIONS
   =========================================== */

.prompt-card-fade-in {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s ease-out, transform 0.4s ease-out;
}

.prompt-card-fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    .prompt-card-fade-in {
        transform: none;
        transition: opacity 0.2s ease-out;
    }
    
    .skeleton-card {
        animation: none;
        opacity: 0.7;
    }
    
    .skeleton-badge,
    .skeleton-title,
    .skeleton-image,
    .skeleton-line,
    .skeleton-button {
        animation: none;
    }
}

/* ===========================================
   SCROLL SENTINEL
   =========================================== */

.scroll-sentinel {
    position: relative;
    width: 100%;
    height: 1px;
    pointer-events: none;
    visibility: hidden;
}

/* ===========================================
   LOADING STATE IMPROVEMENTS
   =========================================== */

.prompts-grid.loading {
    min-height: 300px;
    position: relative;
}

/* ===========================================
   RESPONSIVE SKELETON ADJUSTMENTS
   =========================================== */

/* Mobile (< 640px) */
@media (max-width: 640px) {
    .skeleton-container {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 0 1rem;
    }
    
    .skeleton-card {
        padding: 1rem;
    }
    
    .skeleton-image {
        height: 180px;
    }
}

/* Tablet (640px - 1024px) */
@media (min-width: 640px) and (max-width: 1024px) {
    .skeleton-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.25rem;
    }
    
    .skeleton-image {
        height: 220px;
    }
}

/* Desktop (> 1024px) */
@media (min-width: 1024px) {
    .skeleton-container {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem;
    }
    
    .skeleton-image {
        height: 240px;
    }
}

/* Large Desktop (> 1440px) */
@media (min-width: 1440px) {
    .skeleton-container {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ===========================================
   PERFORMANCE OPTIMIZATIONS
   =========================================== */

/* Use GPU acceleration for animations */
.prompt-card-fade-in,
.skeleton-card {
    will-change: transform, opacity;
}

/* Remove will-change after animation completes */
.prompt-card-fade-in.visible {
    will-change: auto;
}

/* ===========================================
   NO RESULTS / END OF SCROLL
   =========================================== */

.scroll-end-message {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-secondary, #64748b);
    font-size: 0.95rem;
    grid-column: 1 / -1;
}

body.dark-mode .scroll-end-message {
    color: var(--text-secondary-dark, #94a3b8);
}

.scroll-end-message i {
    display: block;
    font-size: 2rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

/* ===========================================
   SMOOTH SCROLL BEHAVIOR
   =========================================== */

html {
    scroll-behavior: smooth;
}

/* Disable smooth scroll for keyboard navigation */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}

/* ===========================================
   LOADING SPINNER (Alternative/Fallback)
   =========================================== */

.infinite-scroll-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    grid-column: 1 / -1;
}

.infinite-scroll-spinner .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(99, 102, 241, 0.2);
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

body.dark-mode .infinite-scroll-spinner .spinner {
    border-color: rgba(99, 102, 241, 0.3);
    border-top-color: #818cf8;
}
