/**
 * Enhanced Video Block - Frontend Styles
 * 
 * @package WebtronDocs
 */

/* ==========================================================================
   Container & Base Styles
   ========================================================================== */

.webtron-enhanced-video {
    /* Re-based onto the theme's shared --wds-* token system (was a hardcoded #0073aa island).
       The PHP still sets --ev-accent-color inline from the block's accentColor attribute; this
       default chain kicks in when that attribute is empty, and pulls light/dark + brand changes
       through automatically. The video-specific accent (cyan) reads well over arbitrary footage. */
    --ev-accent-color: var(--wds-accent, #38bdf8);
    --ev-accent-on: var(--wds-accent-on, #ffffff);
    --ev-controls-bg: rgba(0, 0, 0, 0.7);
    --ev-surface: var(--wds-surface, #ffffff);
    --ev-text: var(--wds-text, #f8fafc);
    --ev-text-muted: var(--wds-text-muted, #9aa4b2);
    --ev-border: var(--wds-border, rgba(255, 255, 255, 0.14));
    --ev-border-radius: var(--wds-radius, 8px);
    --ev-radius-sm: var(--wds-radius-sm, 4px);
    --ev-transition: 0.2s ease;

    position: relative;
    width: 100%;
    max-width: 1920px; /* Max-width for ultrawide displays */
    margin: 0 auto;
}

.webtron-ev-container {
    position: relative;
    width: 100%;
    /* Modern aspect-ratio (var set inline by PHP). Falls back to the legacy padding-bottom hack
       for very old engines via @supports below. */
    aspect-ratio: var(--ev-aspect, 16 / 9);
    overflow: hidden;
    border-radius: var(--ev-border-radius);
    background: #000;
}

/* Legacy fallback: only engines WITHOUT aspect-ratio support consume the PHP-set --ev-aspect-pad
   custom property as a padding-bottom hack. Modern browsers ignore this branch entirely, so the
   padding never stacks on top of the aspect-ratio height (that double-height bug is gone). */
@supports not (aspect-ratio: 1 / 1) {
    .webtron-ev-container {
        height: 0;
        aspect-ratio: auto;
        padding-bottom: var(--ev-aspect-pad, 56.25%);
    }
}

.webtron-ev-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.webtron-ev-gif {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Transient status toast (e.g. an audio track failed to load). Lives in a polite live region so
   screen readers announce it; visually a small pill near the bottom of the player. */
.webtron-ev-status {
    position: absolute;
    left: 50%;
    bottom: 64px;
    transform: translateX(-50%) translateY(6px);
    max-width: 90%;
    padding: 8px 14px;
    border-radius: var(--ev-radius-sm, 4px);
    background: var(--ev-controls-bg, rgba(0, 0, 0, 0.8));
    color: var(--ev-text, #f8fafc);
    font-size: 13px;
    line-height: 1.35;
    text-align: center;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--ev-transition, 0.2s ease), transform var(--ev-transition, 0.2s ease), visibility 0s linear 0.2s;
    z-index: 30;
}

.webtron-ev-status.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
    transition: opacity var(--ev-transition, 0.2s ease), transform var(--ev-transition, 0.2s ease);
}

.webtron-ev-status.is-error {
    border-left: 3px solid var(--wds-danger, #f87171);
}

@media (prefers-reduced-motion: reduce) {
    .webtron-ev-status,
    .webtron-ev-status.is-visible {
        transition: opacity 0.2s ease, visibility 0s;
        transform: translateX(-50%);
    }
}

.webtron-ev-caption {
    text-align: center;
    margin-top: 8px;
    font-size: 14px;
    color: var(--wds-text-muted, #666);
    font-style: italic;
}

/* ==========================================================================
   Big Play Button (center overlay)
   ========================================================================== */

.webtron-ev-big-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 80px;
    border: none;
    border-radius: 50%;
    background: var(--ev-accent-color);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, background-color 0.2s ease;
    z-index: 10;
}

.webtron-ev-big-play:hover {
    transform: translate(-50%, -50%) scale(1.1);
    background: color-mix(in srgb, var(--ev-accent-color) 80%, #000);
}

.webtron-ev-big-play svg {
    width: 36px;
    height: 36px;
    margin-left: 4px; /* Visual center for play icon */
}

.webtron-enhanced-video.is-playing .webtron-ev-big-play {
    display: none;
}

/* ==========================================================================
   Hover Play Mode
   ========================================================================== */

.webtron-enhanced-video.is-hover-play {
    cursor: pointer;
}

.webtron-ev-hover-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
    z-index: 5;
}

.webtron-enhanced-video.is-hover-play.is-playing .webtron-ev-hover-overlay {
    opacity: 0;
    pointer-events: none;
}

.webtron-ev-hover-content {
    text-align: center;
    color: #fff;
}

.webtron-ev-play-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 12px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

.webtron-enhanced-video.is-hover-play:hover .webtron-ev-play-icon {
    transform: scale(1.1);
}

.webtron-ev-play-icon svg {
    width: 32px;
    height: 32px;
    margin-left: 4px;
}

.webtron-ev-hover-text {
    font-size: 14px;
    font-weight: 500;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* ==========================================================================
   Custom Controls Bar
   ========================================================================== */

.webtron-ev-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;            /* dense bar wraps instead of overflowing offscreen */
    gap: 6px 6px;
    /* Two layers: a tall gradient scrim so controls read over any footage, plus a solid blurred
       slab behind the row itself for a more substantial, "panel" feel (was a thin fade). */
    padding: 28px 14px 12px;
    background:
        linear-gradient(transparent, rgba(0, 0, 0, 0.35) 40%, rgba(0, 0, 0, 0.72));
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 20;
}

/* The control row sits on its own solid slab so buttons/sliders never read as floating specks. */
.webtron-ev-controls::before {
    content: "";
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: 8px;
    top: auto;
    height: calc(100% - 24px);
    background: var(--ev-controls-bg, rgba(18, 22, 28, 0.82));
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--ev-border-radius, 8px);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    z-index: -1;
    pointer-events: none;
}

/* Play / skip cluster stays together as one solid group. */
.webtron-ev-playgroup {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

/* Progress bar grows to fill its row; when the bar wraps on narrow widths it keeps a sane min. */
.webtron-ev-progress-container {
    flex: 1 1 140px;
    min-width: 140px;
}

.webtron-ev-controls.is-hidden {
    opacity: 0;
    transform: translateY(100%);
}

/* Control Buttons — fluid size that keeps a 44px touch target (WCAG) on coarse pointers. */
.webtron-ev-btn {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border: none;
    border-radius: var(--ev-radius-sm);
    background: transparent;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--ev-transition), color var(--ev-transition);
}

/* Touch/coarse pointers get full 44px targets without bloating the desktop bar. */
@media (pointer: coarse) {
    .webtron-ev-btn {
        width: 44px;
        height: 44px;
    }
}

.webtron-ev-btn:hover {
    background: rgba(255, 255, 255, 0.14);
}

.webtron-ev-btn:active {
    background: rgba(255, 255, 255, 0.22);
}

/* Primary play/pause reads a touch heavier than the satellite skip buttons. */
.webtron-ev-play-pause {
    color: #fff;
}
.webtron-ev-skip svg {
    width: 22px;
    height: 22px;
}
.webtron-ev-skip:hover {
    color: var(--ev-accent-color, #38bdf8);
}

/* Keyboard focus only (avoid the ring on mouse click); fall back to :focus for old engines. */
.webtron-ev-btn:focus {
    outline: 2px solid var(--ev-accent-color);
    outline-offset: 2px;
}
.webtron-ev-btn:focus:not(:focus-visible) {
    outline: none;
}
.webtron-ev-btn:focus-visible {
    outline: 2px solid var(--ev-accent-color);
    outline-offset: 2px;
}

.webtron-ev-btn svg {
    width: 20px;
    height: 20px;
}

.webtron-ev-btn.is-active {
    color: var(--ev-accent-color);
}

/* ==========================================================================
   Progress Bar
   ========================================================================== */

.webtron-ev-progress-container {
    flex: 1;
    height: 38px;
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 0 6px;
}

.webtron-ev-progress-bar {
    position: relative;
    width: 100%;
    height: 5px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 3px;
    transition: height var(--ev-transition);
    /* no overflow:hidden so the scrubber thumb can sit proud of the track */
}

.webtron-ev-progress-container:hover .webtron-ev-progress-bar,
.webtron-ev-progress-container:focus-visible .webtron-ev-progress-bar {
    height: 7px;
}

.webtron-ev-progress-buffered {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: rgba(255, 255, 255, 0.35);
    width: 0;
    border-radius: 3px;
}

.webtron-ev-progress-played {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: var(--ev-accent-color);
    width: 0;
    border-radius: 3px;
}

/* Scrubber knob at the playhead — appears on hover/focus so the bar feels grabbable. */
.webtron-ev-progress-played::after {
    content: "";
    position: absolute;
    right: 0;
    top: 50%;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 0 2px var(--ev-accent-color), 0 1px 3px rgba(0, 0, 0, 0.5);
    transform: translate(50%, -50%) scale(0);
    transition: transform var(--ev-transition);
}

.webtron-ev-progress-container:hover .webtron-ev-progress-played::after,
.webtron-ev-progress-container:focus-visible .webtron-ev-progress-played::after {
    transform: translate(50%, -50%) scale(1);
}

.webtron-ev-progress-container:focus-visible {
    outline: 2px solid var(--ev-accent-color);
    outline-offset: 4px;
    border-radius: 4px;
}

/* ==========================================================================
   Time Display
   ========================================================================== */

.webtron-ev-time {
    flex-shrink: 0;
    font-size: 13px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #fff;
    white-space: nowrap;
    user-select: none;
}

.webtron-ev-time-separator {
    margin: 0 4px;
    opacity: 0.6;
}

/* ==========================================================================
   Volume Controls
   ========================================================================== */

/* Volume: the slider is now ALWAYS visible at a fixed width inside the flex flow. The old behaviour
   collapsed it to width:0 and expanded on hover, which overlapped neighbouring controls and felt
   flimsy; a fixed-width inline slider can't underlap because it always occupies its own track. */
.webtron-ev-volume {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.webtron-ev-volume-slider-container {
    width: 72px;
    display: flex;
    align-items: center;
}

/* Collapse the slider only on genuinely narrow players (keep the mute button); see media query. */
.webtron-ev-volume-slider {
    width: 72px;
    height: 5px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.28);
    border-radius: 3px;
    cursor: pointer;
    /* Native filled-track tint on supporting browsers (Chrome/Edge/FF). */
    accent-color: var(--ev-accent-color, #38bdf8);
}

.webtron-ev-volume-slider::-webkit-slider-runnable-track {
    height: 5px;
    border-radius: 3px;
}

.webtron-ev-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 13px;
    height: 13px;
    margin-top: -4px;
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.webtron-ev-volume-slider::-moz-range-thumb {
    width: 13px;
    height: 13px;
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.webtron-ev-volume-slider:focus-visible {
    outline: 2px solid var(--ev-accent-color);
    outline-offset: 3px;
}

/* ==========================================================================
   Playback Speed
   ========================================================================== */

.webtron-ev-speed {
    position: relative;
}

.webtron-ev-speed-btn {
    width: auto;
    padding: 0 8px;
    font-size: 12px;
    font-weight: 600;
}

.webtron-ev-speed-menu {
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 10px;
    background: var(--ev-controls-bg, rgba(18, 22, 28, 0.96));
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--ev-radius-sm, 6px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    padding: 4px;
    flex-direction: column;
    min-width: 72px;
    z-index: 25;
}

.webtron-ev-speed-menu button {
    display: block;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: transparent;
    color: #fff;
    font-size: 13px;
    text-align: center;
    cursor: pointer;
    border-radius: 2px;
}

.webtron-ev-speed-menu button:hover {
    background: rgba(255, 255, 255, 0.1);
}

.webtron-ev-speed-menu button.active {
    color: var(--ev-accent-color);
    font-weight: 600;
}

/* ==========================================================================
   Controls Styles Variants
   ========================================================================== */

/* Minimal - only progress bar and essential controls */
.webtron-enhanced-video.controls-minimal .webtron-ev-time,
.webtron-enhanced-video.controls-minimal .webtron-ev-volume,
.webtron-enhanced-video.controls-minimal .webtron-ev-speed {
    display: none;
}

.webtron-enhanced-video.controls-minimal .webtron-ev-controls {
    padding: 8px 12px;
}

/* Full - larger controls with more spacing */
.webtron-enhanced-video.controls-full .webtron-ev-controls {
    padding: 16px 20px;
    gap: 12px;
}

.webtron-enhanced-video.controls-full .webtron-ev-btn {
    width: 44px;
    height: 44px;
}

.webtron-enhanced-video.controls-full .webtron-ev-btn svg {
    width: 24px;
    height: 24px;
}

.webtron-enhanced-video.controls-full .webtron-ev-time {
    font-size: 14px;
}

/* ==========================================================================
   Fullscreen Mode
   ========================================================================== */

.webtron-ev-container:fullscreen {
    background: #000;
}

.webtron-ev-container:fullscreen .webtron-ev-video {
    object-fit: contain;
}

.webtron-ev-container:fullscreen .webtron-ev-controls {
    padding: 16px 24px;
}

/* ==========================================================================
   Focus & Accessibility
   ========================================================================== */

.webtron-enhanced-video:focus {
    outline: 2px solid var(--ev-accent-color);
    outline-offset: 4px;
}

.webtron-enhanced-video:focus:not(:focus-visible) {
    outline: none;
}

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */

@media (max-width: 600px) {
    .webtron-ev-controls {
        padding: 8px 12px;
        gap: 6px;
    }
    
    .webtron-ev-btn {
        width: 32px;
        height: 32px;
    }
    
    .webtron-ev-btn svg {
        width: 18px;
        height: 18px;
    }

    .webtron-ev-skip svg {
        width: 20px;
        height: 20px;
    }

    .webtron-ev-time {
        font-size: 12px;
    }

    /* Solid slab + heavy padding eases off on small players where space is tight. */
    .webtron-ev-controls {
        padding-top: 22px;
    }

    .webtron-ev-volume-slider-container {
        display: none;
    }
    
    .webtron-ev-big-play {
        width: 64px;
        height: 64px;
    }
    
    .webtron-ev-big-play svg {
        width: 28px;
        height: 28px;
    }
    
    /* Hide less important controls on mobile */
    .webtron-ev-speed,
    .webtron-ev-pip {
        display: none;
    }
}

/* ==========================================================================
   Dark Mode Support
   The caption now uses var(--wds-text-muted), which flips automatically with the
   theme tokens — no bespoke [data-theme="dark"] override needed.
   ========================================================================== */

/* ==========================================================================
   Loading State
   ========================================================================== */

.webtron-enhanced-video:not(.webtron-ev-initialized) .webtron-ev-controls {
    display: none;
}

.webtron-enhanced-video:not(.webtron-ev-initialized) .webtron-ev-big-play {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.8;
    }
    50% {
        opacity: 1;
    }
}

/* ==========================================================================
   GIF Fallback Mode
   ========================================================================== */

/* GIF Mode indicator class */
.webtron-enhanced-video.is-gif-mode .webtron-ev-video {
    display: none;
}

.webtron-enhanced-video.is-gif-mode .webtron-ev-gif {
    display: block;
}

/* GIF Toggle Button in Controls */
.webtron-ev-gif-toggle {
    position: relative;
}

.webtron-ev-gif-toggle svg {
    width: 18px;
    height: 18px;
}

/* Floating GIF Toggle Button */
.webtron-ev-gif-toggle-float {
    position: absolute;
    bottom: 16px;
    right: 16px;
    width: 42px;
    height: 42px;
    display: none;
    align-items: center;
    justify-content: center;
    background: var(--ev-controls-bg);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    z-index: 20;
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
}

.webtron-ev-gif-toggle-float:hover {
    background: rgba(0, 0, 0, 0.85);
    border-color: var(--ev-accent-color);
    transform: scale(1.05);
}

.webtron-ev-gif-toggle-float svg {
    width: 20px;
    height: 20px;
}

.webtron-enhanced-video.is-gif-mode .webtron-ev-gif-toggle-float {
    display: flex;
}

/* GIF Mode Badge */
.webtron-ev-gif-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    display: none;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--ev-controls-bg);
    border-radius: 4px;
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    z-index: 15;
    backdrop-filter: blur(4px);
}

.webtron-enhanced-video.is-gif-mode .webtron-ev-gif-badge {
    display: flex;
}

.webtron-ev-gif-badge::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--wds-success, #4ade80);
    border-radius: 50%;
    animation: gif-badge-pulse 2s ease-in-out infinite;
}

@keyframes gif-badge-pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(0.8);
    }
}

.webtron-ev-gif-reason {
    opacity: 0.7;
    font-weight: 400;
    font-size: 11px;
}

/* ==========================================================================
   Reduced motion — honour the user's OS preference (was entirely missing).
   Disables the looping pulse/spin animations and the controls slide.
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
    .webtron-enhanced-video *,
    .webtron-enhanced-video *::before,
    .webtron-enhanced-video *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}

/* Hide controls in GIF mode */
.webtron-enhanced-video.is-gif-mode .webtron-ev-controls {
    display: none;
}

.webtron-enhanced-video.is-gif-mode .webtron-ev-big-play {
    display: none;
}

.webtron-enhanced-video.is-gif-mode .webtron-ev-hover-overlay {
    display: none;
}

/* GIF mode transitions */
.webtron-ev-gif,
.webtron-ev-video {
    transition: opacity 0.3s ease;
}

.webtron-enhanced-video.is-gif-mode .webtron-ev-gif {
    opacity: 1;
}

.webtron-enhanced-video:not(.is-gif-mode) .webtron-ev-gif {
    opacity: 0;
}

/* Mobile adjustments for GIF mode */
@media (max-width: 480px) {
    .webtron-ev-gif-toggle-float {
        width: 36px;
        height: 36px;
        bottom: 12px;
        right: 12px;
    }
    
    .webtron-ev-gif-toggle-float svg {
        width: 18px;
        height: 18px;
    }
    
    .webtron-ev-gif-badge {
        top: 8px;
        left: 8px;
        padding: 4px 8px;
        font-size: 10px;
    }
    
    .webtron-ev-gif-badge::before {
        width: 6px;
        height: 6px;
    }
    
    .webtron-ev-gif-reason {
        display: none;
    }
}

/* ==========================================================================
   Language Selector (Multi-Audio)
   ========================================================================== */

.webtron-ev-language {
    position: relative;
}

.webtron-ev-language-btn {
    width: auto;
    padding: 0 8px;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}

.webtron-ev-language-btn svg {
    width: 16px;
    height: 16px;
}

.webtron-ev-language-label {
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 700;
}

.webtron-ev-language-menu {
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 10px;
    background: var(--ev-controls-bg, rgba(18, 22, 28, 0.96));
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--ev-radius-sm, 6px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
    padding: 6px;
    flex-direction: column;
    min-width: 150px;
    max-height: 240px;
    overflow-y: auto;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 25;
}

.webtron-ev-language-menu button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 12px;
    border: none;
    background: transparent;
    color: #fff;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.15s ease;
}

.webtron-ev-language-menu button:hover {
    background: rgba(255, 255, 255, 0.1);
}

.webtron-ev-language-menu button.active {
    color: var(--ev-accent-color);
    font-weight: 600;
}

.webtron-ev-language-menu button.active::after {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--ev-accent-color);
    border-radius: 50%;
    margin-left: 8px;
    flex-shrink: 0;
}

/* Hide language controls when not available */
.webtron-enhanced-video:not(.has-language-selector) .webtron-ev-language {
    display: none;
}

/* ==========================================================================
   Transcript Panel
   ========================================================================== */

.webtron-ev-transcript-toggle {
    width: auto;
    padding: 0 8px;
}

.webtron-ev-transcript-toggle svg {
    width: 18px;
    height: 18px;
}

.webtron-ev-transcript-toggle.active {
    color: var(--ev-accent-color);
    background: rgba(0, 115, 170, 0.2);
}

.webtron-ev-transcript-panel {
    background: var(--ev-controls-bg);
    border-radius: var(--ev-border-radius);
    margin-top: 12px;
    overflow: hidden;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.webtron-ev-transcript-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.webtron-ev-transcript-title {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
}

.webtron-ev-transcript-controls {
    display: flex;
    gap: 8px;
}

.webtron-ev-transcript-controls button {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease;
}

.webtron-ev-transcript-controls button:hover {
    background: rgba(255, 255, 255, 0.2);
}

.webtron-ev-transcript-search {
    padding: 8px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    gap: 8px;
    align-items: center;
}

.webtron-ev-transcript-search-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 13px;
}

.webtron-ev-transcript-search-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.webtron-ev-transcript-search-input:focus {
    outline: none;
    border-color: var(--ev-accent-color);
}

.webtron-ev-transcript-search-count {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    white-space: nowrap;
}

.webtron-ev-transcript-content {
    max-height: 300px;
    overflow-y: auto;
    padding: 16px;
}

.webtron-ev-transcript-loading {
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
    font-style: italic;
}

.webtron-ev-transcript-text {
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    line-height: 1.7;
}

/* Timestamped transcript cues */
.webtron-ev-transcript-cue {
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.15s ease;
    margin-bottom: 4px;
}

.webtron-ev-transcript-cue:hover {
    background: rgba(255, 255, 255, 0.1);
}

.webtron-ev-transcript-cue.active {
    background: rgba(0, 115, 170, 0.2);
    border-left: 3px solid var(--ev-accent-color);
}

.webtron-ev-cue-time {
    font-size: 12px;
    font-weight: 600;
    color: var(--ev-accent-color);
    margin-right: 8px;
}

.webtron-ev-cue-text {
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    line-height: 1.5;
}

.webtron-ev-transcript-cue.active .webtron-ev-cue-text {
    color: #fff;
}

/* Search highlight */
.webtron-ev-search-highlight {
    background: rgba(255, 220, 0, 0.4);
    color: #fff;
    padding: 1px 2px;
    border-radius: 2px;
}

/* Hide transcript when not available */
.webtron-enhanced-video:not(.has-transcript) .webtron-ev-transcript-toggle,
.webtron-enhanced-video:not(.has-transcript) .webtron-ev-transcript-panel {
    display: none;
}

/* Transcript position variants */
.webtron-enhanced-video.transcript-side .webtron-ev-transcript-panel {
    position: absolute;
    right: calc(-100% - 20px);
    top: 0;
    width: 100%;
    max-width: 400px;
    margin-top: 0;
    height: 100%;
    max-height: none;
    border-radius: var(--ev-border-radius);
}

.webtron-enhanced-video.transcript-side .webtron-ev-transcript-content {
    max-height: calc(100% - 60px);
}

.webtron-enhanced-video.transcript-side.transcript-open {
    display: flex;
    gap: 20px;
}

/* Mobile adjustments for language & transcript */
@media (max-width: 768px) {
    .webtron-ev-language-menu {
        right: auto;
        left: 50%;
        transform: translateX(-50%);
    }
    
    .webtron-ev-transcript-panel {
        margin-top: 8px;
    }
    
    .webtron-ev-transcript-content {
        max-height: 200px;
        padding: 12px;
    }
    
    .webtron-ev-transcript-cue {
        padding: 6px 10px;
    }
    
    .webtron-ev-cue-time {
        font-size: 11px;
    }
    
    .webtron-ev-cue-text {
        font-size: 13px;
    }
    
    .webtron-enhanced-video.transcript-side .webtron-ev-transcript-panel {
        position: relative;
        right: auto;
        width: 100%;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .webtron-ev-language-label {
        display: none;
    }
    
    .webtron-ev-transcript-header {
        padding: 10px 12px;
    }
    
    .webtron-ev-transcript-title {
        font-size: 13px;
    }
    
    .webtron-ev-transcript-controls button {
        width: 28px;
        height: 28px;
    }
}

/* ==========================================================================
   Variant Toggle Buttons (Mode Switcher)
   Positioned below the video player to avoid obstructing content
   ========================================================================== */

.webtron-ev-variants {
    display: flex;
    justify-content: center;
    gap: 8px;
}

.webtron-ev-variant-btn {
    --variant-color: #0073aa;
    
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid #000;
    border-radius: 6px;
    background: transparent;
    color: #000;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.webtron-ev-variant-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.webtron-ev-variant-btn.active {
    background: var(--variant-color);
    color: #fff;
    border-color: var(--variant-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.webtron-ev-variant-btn i {
    font-size: 14px;
}

/* Fullscreen variant positioning - move back to overlay */
.webtron-enhanced-video:fullscreen .webtron-ev-variants,
.webtron-enhanced-video:-webkit-full-screen .webtron-ev-variants {
    position: absolute;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    padding: 4px;
    background: rgba(0, 0, 0, 0.8);
    border-radius: 6px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 20;
}

.webtron-enhanced-video:fullscreen .webtron-ev-variant-btn,
.webtron-enhanced-video:-webkit-full-screen .webtron-ev-variant-btn {
    border-color: rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.8);
}

.webtron-enhanced-video:fullscreen .webtron-ev-variant-btn:hover,
.webtron-enhanced-video:-webkit-full-screen .webtron-ev-variant-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.webtron-enhanced-video:fullscreen .webtron-ev-variant-btn.active,
.webtron-enhanced-video:-webkit-full-screen .webtron-ev-variant-btn.active {
    border-color: var(--variant-color);
    color: #fff;
}

@media (max-width: 600px) {
    .webtron-ev-variants {
        gap: 4px;
    }
    
    .webtron-ev-variant-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .webtron-ev-variant-btn i {
        font-size: 12px;
    }
}

/* ============================================================================
   CAPTION / SUBTITLE STYLES
   ============================================================================ */

/* Caption toggle button */
.webtron-ev-captions-btn {
    position: relative;
}

.webtron-ev-captions-btn.active {
    color: var(--ev-accent-color, #0073aa);
}

.webtron-ev-captions-btn.active::after {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    background: var(--ev-accent-color, #0073aa);
    border-radius: 50%;
}

.webtron-ev-captions-btn svg {
    width: 20px;
    height: 20px;
}

/* Video caption styling - enhance default browser captions */
.webtron-enhanced-video video::cue {
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    font-size: 16px;
    line-height: 1.4;
    padding: 4px 8px;
    border-radius: 4px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

/* WebVTT styling customization */
.webtron-enhanced-video.captions-active video::cue {
    background: rgba(0, 0, 0, 0.85);
}

/* Fullscreen caption sizing */
.webtron-enhanced-video:fullscreen video::cue,
.webtron-enhanced-video:-webkit-full-screen video::cue {
    font-size: 24px;
    padding: 8px 16px;
}

@media (max-width: 600px) {
    .webtron-enhanced-video video::cue {
        font-size: 14px;
        padding: 2px 6px;
    }
}
