/**
 * Enhanced Lazy Loading Styles
 * Phase 2: Performance Optimization
 * 
 * Features:
 * - Shimmer loading placeholders
 * - Smooth fade-in transitions
 * - YouTube thumbnail styles
 * - Background image placeholders
 */

/* ============================================
   LOADING PLACEHOLDERS - Shimmer Effect
   ============================================ */

.lazy-placeholder {
    position: relative;
    background: linear-gradient(
        90deg,
        #f0f0f0 0%,
        #e0e0e0 20%,
        #f0f0f0 40%,
        #f0f0f0 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    min-height: 100px;
}

/* Darker theme for dark backgrounds */
.bg-dark .lazy-placeholder,
.dark-theme .lazy-placeholder {
    background: linear-gradient(
        90deg,
        #2a2a2a 0%,
        #3a3a3a 20%,
        #2a2a2a 40%,
        #2a2a2a 100%
    );
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* ============================================
   LOADING STATE
   ============================================ */

.lazy-loading {
    opacity: 0.6;
    filter: blur(2px);
    transition: opacity 0.3s ease, filter 0.3s ease;
}

/* ============================================
   LOADED STATE - Smooth Fade In
   ============================================ */

.lazy-loaded {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Remove placeholder animation once loaded */
img.lazy-loaded,
[data-lazy-loaded="true"] {
    background: none !important;
    animation: fadeIn 0.5s ease-in;
}

/* ============================================
   ERROR STATE
   ============================================ */

.lazy-error {
    background: #f0f0f0;
    border: 1px dashed #ccc;
    position: relative;
}

.lazy-error::after {
    content: '📷';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    opacity: 0.3;
}

/* ============================================
   IMAGE PLACEHOLDERS
   ============================================ */

/* Circular images (news thumbnails) */
img.rounded-circle.lazy-placeholder {
    border-radius: 50%;
}

/* Maintain aspect ratio */
img.lazy-placeholder {
    background: linear-gradient(
        90deg,
        #f0f0f0 0%,
        #e0e0e0 20%,
        #f0f0f0 40%,
        #f0f0f0 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

/* ============================================
   YOUTUBE IFRAME PLACEHOLDERS
   ============================================ */

.youtube-placeholder {
    position: relative;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: opacity 0.3s ease;
}

.youtube-placeholder:hover {
    opacity: 0.9;
}

.youtube-placeholder::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    transition: background 0.3s ease;
}

.youtube-placeholder:hover::before {
    background: rgba(0, 0, 0, 0.5);
}

.youtube-play-button {
    position: relative;
    z-index: 1;
    transition: transform 0.3s ease;
}

.youtube-placeholder:hover .youtube-play-button {
    transform: scale(1.1);
}

.youtube-play-button svg {
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
}

/* ============================================
   BACKGROUND IMAGE PLACEHOLDERS
   ============================================ */

[data-bg].lazy-placeholder {
    background: linear-gradient(
        90deg,
        #f0f0f0 0%,
        #e0e0e0 20%,
        #f0f0f0 40%,
        #f0f0f0 100%
    ) !important;
    background-size: 200% 100% !important;
    animation: shimmer 1.5s ease-in-out infinite;
}

/* ============================================
   SKELETON SCREENS (Optional Enhanced)
   ============================================ */

/* News card skeleton */
.news-item.lazy-placeholder .news-title,
.news-item.lazy-placeholder .news-excerpt,
.news-item.lazy-placeholder .news-date {
    background: linear-gradient(
        90deg,
        #f0f0f0 0%,
        #e0e0e0 50%,
        #f0f0f0 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    color: transparent !important;
    border-radius: 4px;
}

/* Event card skeleton */
.event-item.lazy-placeholder .event-title,
.event-item.lazy-placeholder .event-excerpt {
    background: linear-gradient(
        90deg,
        #f0f0f0 0%,
        #e0e0e0 50%,
        #f0f0f0 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    color: transparent !important;
    border-radius: 4px;
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */

@media (max-width: 768px) {
    /* Faster shimmer on mobile */
    .lazy-placeholder {
        animation-duration: 1s;
    }
    
    /* Smaller play button on mobile */
    .youtube-play-button svg {
        width: 48px;
        height: 34px;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .lazy-placeholder,
    img.lazy-placeholder,
    [data-bg].lazy-placeholder {
        animation: none !important;
        background: #f0f0f0 !important;
    }
    
    .lazy-loaded {
        animation: none;
        opacity: 1;
    }
    
    .lazy-loading {
        opacity: 1;
        filter: none;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    /* Remove animations for print */
    .lazy-placeholder {
        animation: none !important;
        background: none !important;
    }
    
    /* Hide YouTube placeholders */
    .youtube-placeholder {
        display: none !important;
    }
}

/* ============================================
   PROGRESSIVE BLUR-UP EFFECT (Optional)
   ============================================ */

.blur-up {
    filter: blur(10px);
    transition: filter 0.5s ease;
}

.blur-up.lazy-loaded {
    filter: blur(0);
}

/* ============================================
   UTILITIES
   ============================================ */

/* Force immediate loading (disable lazy loading) */
.no-lazy {
    animation: none !important;
    background: none !important;
}

/* Hide until loaded */
.hide-until-loaded {
    opacity: 0;
}

.hide-until-loaded.lazy-loaded {
    opacity: 1;
}


