/**
 * Social Media Embeds Optimization Styles
 * - YouTube: Facade styles for lazy loading
 * - X/Twitter: Direct embed styles (no facade)
 * Optimized for performance and user experience
 * Author: Coreiten Performance Team
 * Version: 2.1
 */

/* YouTube Lazy Loading Facade */
.youtube-facade {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    background-color: #000;
    cursor: pointer;
    overflow: hidden;
    border-radius: 8px;
    margin: 16px 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: box-shadow 0.3s ease;
}

.youtube-facade:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.youtube-facade img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.3s ease;
}

.youtube-facade:hover img {
    opacity: 0.8;
}

/* Play button overlay */
.youtube-facade::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 68px;
    height: 48px;
    background: rgba(255,255,255,0.95);
    transform: translate(-50%, -50%);
    border-radius: 12px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    backdrop-filter: blur(2px);
}

.youtube-facade:hover::after {
    background: #ff0000;
    transform: translate(-50%, -50%) scale(1.1);
    box-shadow: 0 6px 20px rgba(255,0,0,0.4);
}

/* Play arrow icon */
.youtube-facade::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-left: 20px solid #333;
    border-top: 12px solid transparent;
    border-bottom: 12px solid transparent;
    transform: translate(-40%, -50%);
    z-index: 1;
    transition: all 0.3s ease;
}

.youtube-facade:hover::before {
    border-left-color: #fff;
    transform: translate(-40%, -50%) scale(1.1);
}

/* Video title overlay */
.youtube-facade .youtube-title {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.8));
    color: white;
    padding: 20px 16px 16px;
    font-size: 14px;
    font-weight: 500;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.youtube-facade:hover .youtube-title {
    opacity: 1;
}

/* Loading state animation */
.youtube-facade.loading::after {
    animation: youtubePulse 1.5s ease-in-out infinite;
    background: #ff0000;
}

.youtube-facade.loading::before {
    border-left-color: #fff;
    animation: youtubeArrowPulse 1.5s ease-in-out infinite;
}

@keyframes youtubePulse {
    0%, 100% { 
        opacity: 0.8; 
        transform: translate(-50%, -50%) scale(1);
    }
    50% { 
        opacity: 0.4; 
        transform: translate(-50%, -50%) scale(1.05);
    }
}

@keyframes youtubeArrowPulse {
    0%, 100% { 
        opacity: 1; 
        transform: translate(-40%, -50%) scale(1);
    }
    50% { 
        opacity: 0.7; 
        transform: translate(-40%, -50%) scale(1.1);
    }
}

/* Focus styles for accessibility */
.youtube-facade:focus {
    outline: 2px solid #ff0000;
    outline-offset: 2px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .youtube-facade {
        border-radius: 4px;
        margin: 12px 0;
    }
    
    .youtube-facade::after {
        width: 60px;
        height: 42px;
    }
    
    .youtube-facade::before {
        border-left-width: 18px;
        border-top-width: 11px;
        border-bottom-width: 11px;
    }
    
    .youtube-facade .youtube-title {
        font-size: 13px;
        padding: 16px 12px 12px;
    }
}

@media (max-width: 576px) {
    .youtube-facade {
        margin: 10px 0;
    }
    
    .youtube-facade::after {
        width: 56px;
        height: 40px;
    }
    
    .youtube-facade::before {
        border-left-width: 16px;
        border-top-width: 10px;
        border-bottom-width: 10px;
    }
    
    .youtube-facade .youtube-title {
        font-size: 12px;
        padding: 14px 10px 10px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .youtube-facade {
        box-shadow: 0 2px 8px rgba(255,255,255,0.1);
    }
    
    .youtube-facade:hover {
        box-shadow: 0 4px 16px rgba(255,255,255,0.2);
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .youtube-facade::after {
        background: #fff;
        border: 2px solid #000;
    }
    
    .youtube-facade:hover::after {
        background: #ff0000;
        border: 2px solid #fff;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .youtube-facade,
    .youtube-facade img,
    .youtube-facade::after,
    .youtube-facade::before,
    .youtube-facade .youtube-title {
        transition: none;
    }
    
    .youtube-facade.loading::after,
    .youtube-facade.loading::before {
        animation: none;
    }
}

/* Print styles */
@media print {
    .youtube-facade {
        display: none;
    }
}

/* X/Twitter Direct Embed Styles */
.twitter-tweet {
    margin: 16px auto !important;
    max-width: 550px !important;
    border-radius: 12px !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1) !important;
}

/* Loading state for Twitter embeds */
.twitter-tweet[data-loading="true"] {
    background: #f7f9fa;
    border: 1px solid #e1e8ed;
    padding: 20px;
    text-align: center;
    font-family: system-ui, -apple-system, sans-serif;
}

.twitter-tweet[data-loading="true"] a {
    color: #1d9bf0 !important;
    text-decoration: none !important;
    font-size: 14px;
}
