/**
 * Video Performance Optimization CSS
 * Styles for optimized video loading and playback
 */

/* Lazy loading video container */
.video-lazy {
    background: #1a1a1a url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="50" cy="50" r="40" fill="none" stroke="%23666" stroke-width="4"/><path d="M 35 25 L 35 75 L 75 50 Z" fill="%23666"/></svg>') center/40px no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    position: relative;
}

.video-lazy.loaded {
    background: none;
}

/* Video loading spinner */
.video-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid #2196F3;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Video element optimization */
video {
    display: block;
    width: 100%;
    height: auto;
    background: #000;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    perspective: 1000;
    -webkit-perspective: 1000;
}

video.optimized {
    will-change: transform;
}

/* Buffer progress bar */
.buffer-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: rgba(33, 150, 243, 0.3);
    width: 0;
    transition: width 0.1s linear;
}

/* Thumbnail placeholder while loading */
.video-thumbnail-placeholder {
    background: linear-gradient(90deg, #1a1a1a 25%, #2a2a2a 50%, #1a1a1a 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Play button on hover */
.video-play-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background: rgba(33, 150, 243, 0.8);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 2;
}

.video-container:hover .video-play-btn {
    opacity: 1;
}

.video-play-btn:hover {
    background: rgba(33, 150, 243, 1);
    transform: translate(-50%, -50%) scale(1.1);
}

/* Video error state */
.video-error {
    background: rgba(244, 67, 54, 0.1);
    border: 2px solid rgba(244, 67, 54, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #f44336;
    font-size: 0.9rem;
    min-height: 300px;
}

.video-error::before {
    content: '⚠ Video failed to load';
    padding: 1rem;
    text-align: center;
}

/* Play-pause feedback */
video.playing {
    box-shadow: inset 0 0 10px rgba(33, 150, 243, 0.2);
}

/* Mobile video optimization */
@media (max-width: 768px) {
    .video-lazy {
        min-height: 200px;
    }

    video {
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }

    /* Fullscreen video on small screens */
    video:fullscreen {
        width: 100vw;
        height: 100vh;
    }

    video:-webkit-full-screen {
        width: 100vw;
        height: 100vh;
    }

    .video-play-btn {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    video,
    .spinner,
    .video-play-btn {
        animation: none;
        transition: none;
    }
}

/* Low performance device optimization */
@media (max-width: 480px) {
    .video-lazy {
        min-height: 150px;
    }

    .spinner {
        width: 30px;
        height: 30px;
        border-width: 3px;
    }

    .video-play-btn {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
}

/* Container for video with controls */
.video-container {
    position: relative;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 16/9;
}

.video-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Slider card video optimization */
.slider-card video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Modal video optimization */
.video-modal video {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 90vh;
}

/* Preload metadata for faster thumbnail display */
video[preload="metadata"] {
    background: linear-gradient(90deg, #1a1a1a 25%, #2a2a2a 50%, #1a1a1a 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

video[preload="metadata"].loaded {
    background: none;
    animation: none;
}

/* High performance - GPU acceleration */
.video-optimized {
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    transform: translate3d(0, 0, 0);
    -webkit-transform: translate3d(0, 0, 0);
}

/* CSS containment for performance */
.video-container,
.slider-card,
.carousel-item {
    contain: layout style paint;
}
