/**
 * HLS Video Player Styles
 * 
 * @package SwipeTheme
 * @since 1.0.0
 */

/* Video Container */
.video-container {
    position: relative;
    width: 100%;
    height: 100vh;
    background: #000;
    overflow: hidden;
}

.video-container video {
    width: 100%;
    height: 100%;
    object-fit: contain; /* preserve full video inside viewport */
    object-position: center center;
    display: block;
}

/* Mobile Optimization */
@media (max-width: 768px) {
    .video-container {
        height: 100dvh; /* better for mobile browser chrome */
        width: 100vw;
    }
}

/* Single Post/Page: constrain within content flow instead of fullscreen */
.single-post .video-container,
.single-video-container .video-container {
    height: auto;
    width: 100%;
    /* Use measured aspect ratio when available; fallback to 9/16 for portrait feeds */
    aspect-ratio: var(--video-ar, 9/16);
    min-height: 200px;
    max-height: 80vh;
}

@media (max-width: 768px) {
    .single-post .video-container,
    .single-video-container .video-container {
        max-height: 70vh;
    }
}

/* Video States */
.video-container video.hls-ready {
    opacity: 1;
    transition: opacity 0.3s ease;
}

.video-container video:not(.hls-ready) {
    opacity: 1; /* Keep full opacity for regular MP4 videos */
    background: #000;
}

.video-container video.playing {
    cursor: pointer;
}

.video-container video.paused {
    cursor: pointer;
}

/* CSS spinner removed - using HTML element spinner instead */

/* Play/Pause Overlay */
.video-play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none; /* Remove dark background */
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 10;
}

.video-container:hover .video-play-overlay,
.video-container video.paused + .video-play-overlay {
    opacity: 1;
}

.video-play-btn {
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    pointer-events: auto;
}

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

.video-play-btn svg {
    width: 30px;
    height: 30px;
    fill: #000;
    margin-left: 3px; /* Adjust for play icon centering */
}

/* Hide play button when video is playing */
.video-container video.playing + .video-play-overlay .video-play-btn,
.video-container video:not([paused]) + .video-play-overlay .video-play-btn,
.video-container.video-playing .video-play-overlay .video-play-btn {
    display: none;
}

/* Show play button only when paused */
.video-container video[paused] + .video-play-overlay .video-play-btn,
.video-container video.paused + .video-play-overlay .video-play-btn {
    display: flex;
}

/* Error Messages */
.hls-error-message,
.hls-unsupported-message {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hls-error-message > div,
.hls-unsupported-message > div {
    max-width: 300px;
    padding: 20px;
    text-align: center;
}

/* Video Controls Enhancement */
.video-container video {
    outline: none;
}

.video-container video::-webkit-media-controls {
    display: none !important;
}

.video-container video::-webkit-media-controls-enclosure {
    display: none !important;
}

.video-container video::-webkit-media-controls-panel {
    display: none !important;
}

.video-container video::-moz-media-controls {
    display: none !important;
}

.video-container video::--ms-media-controls {
    display: none !important;
}

/* Custom Controls (Optional) */
.custom-video-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    padding: 20px;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    z-index: 3;
}

.video-container:hover .custom-video-controls,
.video-container.show-controls .custom-video-controls {
    transform: translateY(0);
}

.video-progress {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    margin-bottom: 10px;
    cursor: pointer;
}

.video-progress-bar {
    height: 100%;
    background: #fff;
    border-radius: 2px;
    width: 0%;
    transition: width 0.1s linear;
}

.video-info {
    color: white;
    font-size: 14px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .video-play-btn {
        width: 60px;
        height: 60px;
    }
    
    .video-play-btn svg {
        width: 24px;
        height: 24px;
    }
    
    .custom-video-controls {
        padding: 15px;
    }
    
    .video-info {
        font-size: 12px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .video-container {
        background: #000;
    }
    
    .hls-error-message > div,
    .hls-unsupported-message > div {
        background: rgba(0, 0, 0, 0.9);
        color: white;
    }
}

/* High contrast support */
@media (prefers-contrast: high) {
    .video-play-btn {
        background: #fff;
        border: 2px solid #000;
    }
    
    .video-play-btn svg {
        fill: #000;
    }
    
    .video-progress {
        background: #000;
        border: 1px solid #fff;
    }
    
    .video-progress-bar {
        background: #fff;
    }
}


/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .video-container video,
    .video-play-overlay,
    .video-play-btn,
    .custom-video-controls,
    .video-progress-bar {
        transition: none;
    }
    
    .video-container::before {
        animation: none;
    }
}
