/* WP Video Slider Frontend Styles */

/* Main Container */
.wp-video-slider {
    position: relative;
    overflow: hidden;
    margin: 20px auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    /* Ensure no extra padding on mobile */
    padding: 0;
    box-sizing: border-box;
}

/* Slider Container */
.slider-container {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    /* Ensure full width usage on mobile */
    width: 100%;
    box-sizing: border-box;
}

/* Video Track */
.video-track {
    display: flex;
    transition: transform 0.3s ease;
    will-change: transform;
    /* Ensure proper spacing and containment */
    box-sizing: border-box;
}

/* Cloned slides for seamless infinite loop */
.video-item.cloned-slide {
    /* Ensure cloned slides have the same styling as original slides */
    pointer-events: auto;
}

/* Video Item */
.video-item {
    flex: 0 0 auto;
    position: relative;
    transition: transform 0.3s ease;
}

.video-item:hover {
    transform: scale(1.05);
    z-index: 2;
}

/* Video Thumbnail */
.video-thumbnail {
    position: relative;
    cursor: pointer;
    overflow: hidden;
    background: #000;
    transition: all 0.3s ease;
}

.video-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: opacity 0.3s ease;
}

.video-thumbnail:hover img {
    opacity: 0.8;
}

/* Play Overlay */
.play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.video-thumbnail:hover .play-overlay {
    opacity: 1;
}

.play-icon {
    font-size: 48px;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s ease;
}

.play-overlay:hover .play-icon {
    transform: scale(1.1);
}

/* Video Caption */
.video-caption {
    padding: 15px 0;
    text-align: center;
    box-sizing: border-box;
    margin: 0 auto;
}

.video-caption h4 {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    white-space: normal;
    max-height: 3.9em; /* Show up to 3 lines */
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
}

.video-caption p {
    margin: 0;
    font-size: 14px;
    line-height: 1.4;
    opacity: 0.8;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    white-space: normal;
    max-height: 2.8em; /* Show up to 2 lines */
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Thumbnail Size Specific Caption Styles */
/* Small thumbnails (150px) - Smaller text for better fit */
.video-caption.caption-size-small h4 {
    font-size: 13px;
    line-height: 1.2;
    max-height: 3.6em;
}

.video-caption.caption-size-small p {
    font-size: 11px;
    line-height: 1.3;
    max-height: 2.6em;
}

/* Medium thumbnails (200px) - Default styling */
.video-caption.caption-size-medium h4 {
    font-size: 14px;
    line-height: 1.3;
}

.video-caption.caption-size-medium p {
    font-size: 12px;
    line-height: 1.4;
}

/* Large thumbnails (250px) */
.video-caption.caption-size-large h4 {
    font-size: 15px;
    line-height: 1.3;
    max-height: 3.9em;
}

.video-caption.caption-size-large p {
    font-size: 13px;
    line-height: 1.4;
    max-height: 2.8em;
}

/* Extended sizes (300px - 500px) */
.video-caption.caption-size-300 h4,
.video-caption.caption-size-350 h4,
.video-caption.caption-size-400 h4,
.video-caption.caption-size-450 h4,
.video-caption.caption-size-500 h4 {
    font-size: 16px;
    line-height: 1.3;
    max-height: 3.9em;
    padding: 0 5px;
}

.video-caption.caption-size-300 p,
.video-caption.caption-size-350 p,
.video-caption.caption-size-400 p,
.video-caption.caption-size-450 p,
.video-caption.caption-size-500 p {
    font-size: 14px;
    line-height: 1.4;
    max-height: 2.8em;
    padding: 0 5px;
}

/* Large extended sizes (550px - 800px) */
.video-caption.caption-size-550 h4,
.video-caption.caption-size-600 h4,
.video-caption.caption-size-650 h4,
.video-caption.caption-size-700 h4,
.video-caption.caption-size-750 h4,
.video-caption.caption-size-800 h4 {
    font-size: 18px;
    line-height: 1.3;
    max-height: 3.9em;
    padding: 0 10px;
}

.video-caption.caption-size-550 p,
.video-caption.caption-size-600 p,
.video-caption.caption-size-650 p,
.video-caption.caption-size-700 p,
.video-caption.caption-size-750 p,
.video-caption.caption-size-800 p {
    font-size: 15px;
    line-height: 1.4;
    max-height: 2.8em;
    padding: 0 10px;
}

/* Slider Controls */
.slider-controls {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0 10px;
    pointer-events: none;
    z-index: 3;
}

.slider-controls button {
    background: rgba(0, 0, 0, 0.7);
    border: none;
    color: white;
    font-size: 24px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    pointer-events: auto;
    opacity: 0;
}

.wp-video-slider:hover .slider-controls button {
    opacity: 1;
}

.slider-controls button:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

.slider-controls button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.slider-controls .prev {
    left: 10px;
}

.slider-controls .next {
    right: 10px;
}

/* Modal Popup */
.wp-video-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.wp-video-modal .modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    cursor: pointer;
}

.wp-video-modal .modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    animation: slideIn 0.3s ease;
}

.wp-video-modal .modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    color: white;
    font-size: 24px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: background 0.3s ease;
}

.wp-video-modal .modal-close:hover {
    background: rgba(0, 0, 0, 0.9);
}

.wp-video-modal .modal-video-container {
    position: relative;
    width: 80vw;
    height: 45vw;
    max-width: 1200px;
    max-height: 675px;
}

.wp-video-modal iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Loading State */
.wp-video-slider.loading .video-track {
    opacity: 0.5;
}

.wp-video-slider.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 10;
}

/* Error State */
.wp-video-slider-error {
    padding: 20px;
    background: #ffebee;
    border: 1px solid #f44336;
    border-radius: 4px;
    color: #c62828;
    text-align: center;
    font-weight: 500;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { 
        opacity: 0;
        transform: scale(0.8);
    }
    to { 
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Responsive Design */
@media screen and (max-width: 768px) {
    .wp-video-slider {
        margin: 15px 10px; /* Reduce side margins but keep some spacing */
    }
    
    .slider-container {
        /* Remove any padding that might cut off slides */
        padding: 0;
        margin: 0;
    }
    
    .video-track {
        /* Ensure proper spacing between items */
        gap: 15px;
        /* Add slight padding to prevent edge cut-off */
        padding: 0 10px;
        /* Account for padding in width calculation */
        box-sizing: border-box;
    }
    
    .video-item {
        min-width: 250px;
        /* Ensure slides don't get cut off */
        flex-shrink: 0;
    }
    
    /* Responsive caption text adjustments for mobile */
    .video-caption h4 {
        font-size: 14px !important;
        max-height: 2.8em !important;
        -webkit-line-clamp: 2 !important;
        line-clamp: 2 !important;
    }
    
    .video-caption p {
        font-size: 12px !important;
        max-height: 2.4em !important;
        -webkit-line-clamp: 2 !important;
        line-clamp: 2 !important;
    }
    
    /* Reduce padding for smaller screens */
    .video-caption.caption-size-550,
    .video-caption.caption-size-600,
    .video-caption.caption-size-650,
    .video-caption.caption-size-700,
    .video-caption.caption-size-750,
    .video-caption.caption-size-800 {
        padding: 10px 5px !important;
    }
    
    .video-caption.caption-size-550 h4,
    .video-caption.caption-size-600 h4,
    .video-caption.caption-size-650 h4,
    .video-caption.caption-size-700 h4,
    .video-caption.caption-size-750 h4,
    .video-caption.caption-size-800 h4,
    .video-caption.caption-size-550 p,
    .video-caption.caption-size-600 p,
    .video-caption.caption-size-650 p,
    .video-caption.caption-size-700 p,
    .video-caption.caption-size-750 p,
    .video-caption.caption-size-800 p {
        padding: 0 5px !important;
    }
    
    .slider-controls button {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    
    .play-icon {
        font-size: 36px;
    }
    
    .wp-video-modal .modal-video-container {
        width: 95vw;
        height: 53.4vw; /* 16:9 aspect ratio */
    }
    
    .wp-video-modal .modal-close {
        top: 10px;
        right: 10px;
        width: 35px;
        height: 35px;
        font-size: 20px;
    }
}

@media screen and (max-width: 480px) {
    .wp-video-slider {
        margin: 10px 5px; /* Minimal side margins for very small screens */
        /* Ensure no horizontal overflow */
        overflow-x: hidden;
    }
    
    .slider-container {
        /* Ensure proper containment on very small screens */
        overflow: hidden;
        width: 100%;
    }
    
    .video-track {
        gap: 10px; /* Smaller gap for very small screens */
        padding: 0 5px; /* Minimal padding */
        /* Ensure track doesn't extend beyond container */
        min-width: 100%;
    }
    
    .video-item {
        min-width: 200px;
        /* Ensure proper sizing for small screens */
        max-width: calc(100vw - 30px); /* Account for padding and margins */
        /* Prevent any unexpected shrinking */
        flex-shrink: 0;
    }
    
    .video-caption {
        padding: 10px 0 !important;
    }
    
    /* Even smaller text for very small screens */
    .video-caption h4 {
        font-size: 12px !important;
        max-height: 2.4em !important;
    }
    
    .video-caption p {
        font-size: 11px !important;
        max-height: 2.2em !important;
    }
    
    .wp-video-slider {
        margin: 15px auto;
    }
    
    .slider-controls {
        padding: 0 5px;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .video-item:hover {
        transform: none;
    }
    
    .play-overlay {
        opacity: 1;
        background: rgba(0, 0, 0, 0.4);
    }
    
    .slider-controls button {
        opacity: 1;
        background: rgba(0, 0, 0, 0.5);
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .video-thumbnail img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Accessibility */
.wp-video-slider button:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.wp-video-slider .video-thumbnail:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .wp-video-slider {
        display: none;
    }
}

/* Custom Thumbnail Sizes */
.wp-video-slider .thumbnail-small .video-thumbnail {
    width: 150px;
}

.wp-video-slider .thumbnail-medium .video-thumbnail {
    width: 200px;
}

.wp-video-slider .thumbnail-large .video-thumbnail {
    width: 250px;
}

/* Shadow Effects */
.wp-video-slider .shadow-enabled .video-thumbnail {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.wp-video-slider .shadow-enabled .video-thumbnail:hover {
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}
