/**
 * Video Player Styles
 * Responsive video embeds for YouTube, Vimeo, and HTML5 videos
 */

/* Video Caption */
.video-caption {
    margin-bottom: 10px;
    color: #333;
    font-size: 14px;
    line-height: 1.4;
}

/* Video Container Base */
.video-container {
    margin: 10px 0;
    max-width: 100%;
}

/* Responsive 16:9 Wrapper for iframes */
.video-wrapper {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
    border-radius: 8px;
    background: #000;
}

.video-wrapper .video-iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 8px;
}

/* HTML5 Video Player */
.video-player {
    width: 100%;
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    background: #000;
    display: block;
    outline: none;
}

.video-player:focus {
    outline: 2px solid #4a9eff;
    outline-offset: 2px;
}

/* Video Error Message */
.video-error {
    padding: 20px;
    background: #ffe6e6;
    border: 1px solid #ffcccc;
    border-radius: 8px;
    color: #cc0000;
    text-align: center;
    font-size: 14px;
}

/* Platform-specific adjustments */
.video-container.youtube {
    /* YouTube specific styles if needed */
}

.video-container.vimeo {
    /* Vimeo specific styles if needed */
}

.video-container.html5 {
    /* HTML5 video specific styles */
}

/* Loading State */
.video-wrapper::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: videoLoading 0.8s linear infinite;
    z-index: 1;
}

.video-wrapper iframe {
    position: relative;
    z-index: 2;
}

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

/* Hide loading spinner once iframe loads */
.video-wrapper iframe[src] ~ ::before {
    display: none;
}

/* Mobile Responsive - Tablets */
@media (max-width: 768px) {
    .video-caption {
        font-size: 13px;
    }

    .video-wrapper {
        border-radius: 6px;
    }

    .video-player {
        border-radius: 6px;
    }
}

/* Mobile Responsive - Phones */
@media (max-width: 480px) {
    .video-container {
        margin: 8px 0;
    }

    .video-caption {
        font-size: 12px;
        margin-bottom: 8px;
    }

    .video-wrapper {
        border-radius: 4px;
    }

    .video-player {
        border-radius: 4px;
    }

    .video-error {
        padding: 15px;
        font-size: 13px;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .video-player {
        /* Ensure controls are touch-friendly */
        min-height: 200px;
    }
}

/* Dark Mode Support (optional) */
@media (prefers-color-scheme: dark) {
    .video-caption {
        color: #e0e0e0;
    }

    .video-error {
        background: #4a2020;
        border-color: #663333;
        color: #ff6666;
    }

    .video-wrapper {
        background: #1a1a1a;
    }
}

/* Accessibility - Focus States */
.video-wrapper:focus-within {
    outline: 2px solid #4a9eff;
    outline-offset: 2px;
    border-radius: 8px;
}

/* Picture-in-Picture Support */
.video-player::-webkit-media-controls-panel {
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
}

/* Custom Controls Styling (if needed) */
.video-player::-webkit-media-controls {
    /* WebKit browsers */
}

.video-player::-moz-media-controls {
    /* Firefox */
}

/* Fullscreen Mode */
.video-player:-webkit-full-screen {
    width: 100%;
    height: 100%;
}

.video-player:-moz-full-screen {
    width: 100%;
    height: 100%;
}

.video-player:-ms-fullscreen {
    width: 100%;
    height: 100%;
}

.video-player:fullscreen {
    width: 100%;
    height: 100%;
}

/* Alternative Aspect Ratios */
.video-wrapper.ratio-4-3 {
    padding-bottom: 75%; /* 4:3 aspect ratio */
}

.video-wrapper.ratio-1-1 {
    padding-bottom: 100%; /* 1:1 square */
}

.video-wrapper.ratio-21-9 {
    padding-bottom: 42.857%; /* 21:9 ultrawide */
}

/* Video Overlay (for thumbnails, play buttons, etc.) */
.video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 3;
    border-radius: 8px;
}

.video-overlay-hidden {
    display: none;
}

.video-play-button {
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, background 0.2s ease;
}

.video-play-button:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 1);
}

.video-play-button i {
    font-size: 32px;
    color: #333;
    margin-left: 4px; /* Adjust play icon centering */
}

/* Video Duration Badge */
.video-duration {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    z-index: 4;
}

/* Video Quality Badge */
.video-quality {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    z-index: 4;
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .video-wrapper::before {
        animation: none;
    }

    .video-play-button {
        transition: none;
    }

    .video-play-button:hover {
        transform: none;
    }
}
