/* ==========================================================================
   NSSF Custom Video Player - Sleek HTML5 / YouTube Player
   Features:
   - Zero YouTube icons or default branding
   - Custom central play button & poster
   - Fully custom controls (Play, Rewind 10s, Forward 10s, Time, Volume, Fullscreen)
   - Interactive progress scrubber with time tooltip & buffer track
   - Double-tap seek gestures (-10s / +10s) with animated ripples
   - Auto-hides controls during playback
   - Responsive 16:9 ratio on desktop, tablet, and mobile
   ========================================================================== */

.nssf-player-wrapper {
    position: relative !important;
    width: 100% !important;
    aspect-ratio: 16 / 9 !important;
    background: #000000 !important;
    overflow: hidden !important;
    border-top-left-radius: 6px !important;
    border-top-right-radius: 6px !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    font-family: 'Kantumruy', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
    outline: none !important;
}

/* Video element & iframe inside wrapper */
.nssf-player-video-box {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    pointer-events: none !important;
    overflow: hidden !important;
    z-index: 1 !important;
}

.nssf-player-video-box * {
    pointer-events: none !important;
}

/* YouTube Iframe Masking / Overscan Crop
   Pushes YouTube logo, watermark, and title outside visible boundaries */
.nssf-player-video-box.is-youtube iframe,
.nssf-player-video-box iframe {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 128% !important;
    height: 128% !important;
    border: none !important;
    display: block !important;
    pointer-events: none !important;
    user-select: none !important;
    -webkit-user-select: none !important;
}

/* Native HTML5 MP4 Video */
.nssf-player-video-box:not(.is-youtube) video {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 100% !important;
    height: 100% !important;
    border: none !important;
    display: block !important;
    object-fit: contain !important;
    pointer-events: none !important;
}

/* Overlay interceptor for clicks & touch - Prevents mobile touches from reaching the iframe */
.nssf-player-overlay {
    position: absolute !important;
    inset: 0 !important;
    z-index: 5 !important;
    cursor: pointer !important;
    background: rgba(0, 0, 0, 0.001) !important; /* Critical for iOS Safari touch capture */
    touch-action: manipulation !important;
    -webkit-tap-highlight-color: transparent !important;
}

/* Poster cover before playback starts */
.nssf-player-poster {
    position: absolute !important;
    inset: 0 !important;
    z-index: 6 !important;
    background-size: cover !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: opacity 0.3s ease, visibility 0.3s ease !important;
    cursor: pointer !important;
}

.nssf-player-poster.hidden {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

.nssf-player-poster-backdrop {
    position: absolute !important;
    inset: 0 !important;
    background: rgba(0, 0, 0, 0.32) !important;
    backdrop-filter: blur(1px) !important;
}

/* Modern Central Play Button (No Red YouTube Icon!) */
.nssf-player-big-play {
    position: relative !important;
    z-index: 2 !important;
    width: 72px !important;
    height: 72px !important;
    border-radius: 50% !important;
    background: rgba(15, 23, 42, 0.78) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border: 2px solid rgba(255, 255, 255, 0.45) !important;
    color: #ffffff !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45), inset 0 1px 1px rgba(255, 255, 255, 0.4) !important;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.2s ease, box-shadow 0.2s ease !important;
}

.nssf-player-wrapper:hover .nssf-player-big-play,
.nssf-player-big-play:hover {
    transform: scale(1.1) !important;
    background: #1e3a8a !important;
    border-color: rgba(255, 255, 255, 0.8) !important;
    box-shadow: 0 12px 32px rgba(30, 58, 138, 0.6), inset 0 1px 1px rgba(255, 255, 255, 0.6) !important;
}

.nssf-player-big-play svg {
    width: 28px !important;
    height: 28px !important;
    fill: currentColor !important;
    margin-left: 4px !important; /* Visually optical center */
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3)) !important;
}

/* Buffering / Loading Spinner */
.nssf-player-spinner {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    z-index: 8 !important;
    width: 48px !important;
    height: 48px !important;
    border: 3.5px solid rgba(255, 255, 255, 0.25) !important;
    border-top-color: #2563eb !important;
    border-radius: 50% !important;
    animation: nssfPlayerSpin 0.75s linear infinite !important;
    pointer-events: none !important;
    display: none !important;
}

.nssf-player-spinner.show {
    display: block !important;
}

@keyframes nssfPlayerSpin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Double Tap / Seek Feedback Ripples */
.nssf-player-seek-ripple {
    position: absolute !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 9 !important;
    width: 100px !important;
    height: 100px !important;
    border-radius: 50% !important;
    background: rgba(255, 255, 255, 0.2) !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    color: #ffffff !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    pointer-events: none !important;
    opacity: 0 !important;
    transition: opacity 0.2s ease, transform 0.2s ease !important;
}

.nssf-player-seek-ripple.left { left: 10% !important; }
.nssf-player-seek-ripple.right { right: 10% !important; }

.nssf-player-seek-ripple.active {
    opacity: 1 !important;
    animation: nssfRipplePulse 0.45s ease-out forwards !important;
}

@keyframes nssfRipplePulse {
    0% { transform: translateY(-50%) scale(0.7); opacity: 0.9; }
    100% { transform: translateY(-50%) scale(1.15); opacity: 0; }
}

/* --------------------------------------------------------------------------
   Custom Bottom Control Bar
   -------------------------------------------------------------------------- */
.nssf-player-controls {
    position: absolute !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 12 !important;
    padding: 18px 14px 10px 14px !important;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.88) 0%, rgba(0, 0, 0, 0.45) 60%, transparent 100%) !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    opacity: 1 !important;
    visibility: visible !important;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
    pointer-events: auto !important;
}

.nssf-player-controls.autohide {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* Scrub Progress Bar */
.nssf-player-progress-wrap {
    position: relative !important;
    width: 100% !important;
    height: 14px !important;
    display: flex !important;
    align-items: center !important;
    cursor: pointer !important;
}

.nssf-player-progress-bg {
    position: relative !important;
    width: 100% !important;
    height: 4px !important;
    background: rgba(255, 255, 255, 0.28) !important;
    border-radius: 3px !important;
    transition: height 0.15s ease !important;
    overflow: hidden !important;
}

.nssf-player-progress-wrap:hover .nssf-player-progress-bg {
    height: 6px !important;
}

.nssf-player-progress-buffer {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    width: 0% !important;
    background: rgba(255, 255, 255, 0.4) !important;
    border-radius: 3px !important;
    transition: width 0.2s ease !important;
}

.nssf-player-progress-fill {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    width: 0% !important;
    background: linear-gradient(90deg, #1d4ed8 0%, #3b82f6 100%) !important;
    border-radius: 3px !important;
}

.nssf-player-progress-thumb {
    position: absolute !important;
    top: 50% !important;
    left: 0% !important;
    transform: translate(-50%, -50%) scale(0) !important;
    width: 13px !important;
    height: 13px !important;
    border-radius: 50% !important;
    background: #ffffff !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5) !important;
    transition: transform 0.15s ease !important;
    pointer-events: none !important;
}

.nssf-player-progress-wrap:hover .nssf-player-progress-thumb,
.nssf-player-progress-wrap.scrubbing .nssf-player-progress-thumb {
    transform: translate(-50%, -50%) scale(1) !important;
}

/* Hover time tooltip */
.nssf-player-time-tooltip {
    position: absolute !important;
    bottom: 22px !important;
    transform: translateX(-50%) !important;
    padding: 3px 7px !important;
    border-radius: 4px !important;
    background: rgba(15, 23, 42, 0.9) !important;
    color: #ffffff !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    pointer-events: none !important;
    display: none !important;
    white-space: nowrap !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3) !important;
}

.nssf-player-progress-wrap:hover .nssf-player-time-tooltip {
    display: block !important;
}

/* Bottom Controls Row */
.nssf-player-btn-row {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
    width: 100% !important;
}

.nssf-player-left-group,
.nssf-player-right-group {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
}

/* Control Buttons */
.nssf-player-btn {
    background: transparent !important;
    border: none !important;
    color: #ffffff !important;
    width: 34px !important;
    height: 34px !important;
    border-radius: 6px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    opacity: 0.9 !important;
    transition: background 0.15s ease, opacity 0.15s ease, transform 0.1s ease !important;
    outline: none !important;
    padding: 0 !important;
}

.nssf-player-btn:hover {
    background: rgba(255, 255, 255, 0.16) !important;
    opacity: 1 !important;
}

.nssf-player-btn:active {
    transform: scale(0.92) !important;
}

.nssf-player-btn svg {
    width: 20px !important;
    height: 20px !important;
    fill: currentColor !important;
}

/* Time Indicator (Current / Duration) */
.nssf-player-time-text {
    color: #ffffff !important;
    font-size: 12.5px !important;
    font-weight: 500 !important;
    letter-spacing: 0.2px !important;
    margin-left: 6px !important;
    white-space: nowrap !important;
    font-variant-numeric: tabular-nums !important;
}

.nssf-player-time-text .duration {
    opacity: 0.75 !important;
}

/* Volume Group with Expandable Slider */
.nssf-player-volume-group {
    display: flex !important;
    align-items: center !important;
    position: relative !important;
}

.nssf-player-volume-slider {
    width: 0 !important;
    opacity: 0 !important;
    overflow: hidden !important;
    height: 4px !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    background: rgba(255, 255, 255, 0.4) !important;
    border-radius: 3px !important;
    cursor: pointer !important;
    transition: width 0.2s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease, margin 0.2s ease !important;
    margin: 0 !important;
}

.nssf-player-volume-group:hover .nssf-player-volume-slider,
.nssf-player-volume-slider:focus {
    width: 65px !important;
    opacity: 1 !important;
    margin-left: 6px !important;
    margin-right: 4px !important;
}

.nssf-player-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none !important;
    width: 12px !important;
    height: 12px !important;
    border-radius: 50% !important;
    background: #ffffff !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4) !important;
}

/* Playback Speed Pill Button */
.nssf-player-speed-btn {
    padding: 2px 7px !important;
    height: 26px !important;
    border-radius: 13px !important;
    background: rgba(255, 255, 255, 0.16) !important;
    color: #ffffff !important;
    font-size: 11.5px !important;
    font-weight: 700 !important;
    border: none !important;
    cursor: pointer !important;
    transition: background 0.15s ease !important;
}

.nssf-player-speed-btn:hover {
    background: rgba(255, 255, 255, 0.28) !important;
}

/* Fullscreen mode styling */
.nssf-player-wrapper:fullscreen,
.nssf-player-wrapper:-webkit-full-screen {
    width: 100vw !important;
    height: 100vh !important;
    aspect-ratio: auto !important;
    border-radius: 0 !important;
}

.nssf-player-wrapper:fullscreen .nssf-player-controls,
.nssf-player-wrapper:-webkit-full-screen .nssf-player-controls {
    padding: 24px 28px 18px 28px !important;
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    /* Push YouTube title and watermark completely out of view on mobile screens */
    .nssf-player-video-box.is-youtube iframe,
    .nssf-player-video-box iframe {
        width: 140% !important;
        height: 140% !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
    }
}

@media (max-width: 600px) {
    .nssf-player-big-play {
        width: 58px !important;
        height: 58px !important;
    }
    .nssf-player-big-play svg {
        width: 24px !important;
        height: 24px !important;
    }
    .nssf-player-controls {
        padding: 12px 10px 8px 10px !important;
    }
    .nssf-player-btn {
        width: 30px !important;
        height: 30px !important;
    }
    .nssf-player-btn svg {
        width: 18px !important;
        height: 18px !important;
    }
    .nssf-player-skip-btn {
        display: none !important; /* Save space on small phones */
    }
    .nssf-player-volume-group .nssf-player-volume-slider {
        display: none !important; /* Only toggle mute on phones */
    }
    .nssf-player-time-text {
        font-size: 11.5px !important;
    }
}

