/* Custom Premium YouTube Player for NUKI */
.nuki-video-wrapper {
    position: relative;
    width: 100%;
    max-width: 800px;
    margin: 0 auto 2rem;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    font-family: 'Inter', sans-serif;
    user-select: none;
}

.nuki-video-player-container {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
}

.nuki-video-player-container iframe {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    border: none !important;
    pointer-events: none !important; /* Disable native interaction */
}

/* Transparent overlay to block native YouTube clicks/interactions */
.nuki-video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: calc(100% - 60px); /* Leave area for controls */
    z-index: 10;
    cursor: pointer;
    background: transparent;
}

/* Custom Thumbnail Overlay */
.nuki-video-thumb-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    z-index: 12;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.nuki-video-thumb-overlay::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    transition: background 0.3s ease;
}

.nuki-video-thumb-overlay:hover::before {
    background: rgba(0, 0, 0, 0.5);
}

.nuki-play-big-btn {
    position: relative;
    z-index: 2;
    width: 70px;
    height: 70px;
    background: var(--color-primary, #bda87f);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    padding-left: 5px; /* Adjust centering of triangle */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), background-color 0.3s ease;
}

@media (hover: hover) {
    .nuki-video-thumb-overlay:hover .nuki-play-big-btn {
        transform: scale(1.15);
        background: #fff;
        color: #000;
    }
}

/* Custom Controls Bar */
.nuki-video-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 52px;
    background: rgba(15, 15, 15, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    box-sizing: border-box;
    z-index: 20;
    gap: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* Control Buttons */
.nuki-ctrl-btn {
    background: none;
    border: none;
    color: #e0e0e0;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    transition: background 0.2s, color 0.2s;
}

.nuki-ctrl-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* Time Display */
.nuki-time-display {
    color: #b3b3b3;
    font-size: 0.85rem;
    min-width: 85px;
    text-align: center;
}

/* Seek Bar Range Input */
.nuki-seek-bar {
    flex-grow: 1;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.2);
    height: 4px;
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    transition: height 0.1s;
}

.nuki-seek-bar:hover {
    height: 6px;
}

.nuki-seek-bar::-webkit-slider-runnable-track {
    width: 100%;
    height: 100%;
}

.nuki-seek-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--color-primary, #bda87f);
    cursor: pointer;
    margin-top: -4px;
    transition: transform 0.1s;
}

@media (hover: hover) {
    .nuki-seek-bar:hover::-webkit-slider-thumb {
        transform: scale(1.3);
        background: #fff;
    }
}

/* Volume control container */
.nuki-volume-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nuki-volume-slider {
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.2);
    height: 4px;
    width: 60px;
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    transition: width 0.3s ease, opacity 0.3s ease;
}

.nuki-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
}

/* Playback Speed selector */
.nuki-speed-container {
    position: relative;
}

.nuki-speed-btn {
    font-size: 0.85rem;
    font-weight: 700;
    color: #e0e0e0;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    width: auto;
    height: auto;
    padding: 0.25rem 0.6rem;
}

.nuki-speed-menu {
    position: absolute;
    bottom: calc(100% + 10px);
    right: 0;
    background: rgba(20, 20, 20, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 0.5rem 0;
    display: none;
    flex-direction: column;
    width: 80px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    z-index: 30;
}

.nuki-speed-menu.show {
    display: flex;
}

.nuki-speed-menu div {
    color: #ccc;
    font-size: 0.85rem;
    padding: 0.4rem 1rem;
    cursor: pointer;
    text-align: center;
    transition: background 0.2s, color 0.2s;
}

.nuki-speed-menu div:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.nuki-speed-menu div.active {
    color: var(--color-primary, #bda87f);
    font-weight: 700;
}

/* Hide control bar when inactive or in play mode */
.nuki-video-wrapper.video-playing.mouse-inactive .nuki-video-controls {
    opacity: 0;
    visibility: hidden;
}

/* Spinner while video is buffering */
.nuki-video-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    border-top-color: var(--color-primary, #bda87f);
    animation: nuki-spin 1s ease-in-out infinite;
    z-index: 15;
    pointer-events: none;
    display: none;
}

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

@media (max-width: 600px) {
    .nuki-volume-slider {
        width: 0;
        opacity: 0;
        pointer-events: none;
    }
    .nuki-volume-container:hover .nuki-volume-slider {
        width: 50px;
        opacity: 1;
        pointer-events: auto;
    }
    .nuki-video-controls {
        padding: 0 0.5rem;
        gap: 0.5rem;
    }
}

/* Fullscreen Custom Player Styles */
.nuki-video-wrapper:fullscreen {
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    border-radius: 0 !important;
    background: #000 !important;
}

.nuki-video-wrapper:-webkit-full-screen {
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    border-radius: 0 !important;
    background: #000 !important;
}

.nuki-video-wrapper:fullscreen .nuki-video-player-container {
    width: 100% !important;
    height: 100% !important;
    padding-bottom: 0 !important;
}

.nuki-video-wrapper:-webkit-full-screen .nuki-video-player-container {
    width: 100% !important;
    height: 100% !important;
    padding-bottom: 0 !important;
}

.nuki-video-wrapper:fullscreen .nuki-video-overlay {
    height: calc(100% - 60px) !important;
}

.nuki-video-wrapper:-webkit-full-screen .nuki-video-overlay {
    height: calc(100% - 60px) !important;
}

/* Vertical Video Layout (9:16 aspect ratio) */
.nuki-video-wrapper.layout-vertical {
    max-width: 360px !important; /* Centered narrow container on desktop */
    aspect-ratio: 9 / 16 !important;
}

.nuki-video-wrapper.layout-vertical .nuki-video-player-container {
    padding-bottom: 177.78% !important; /* 9:16 height ratio */
}

/* Fullscreen reset for vertical layout to prevent cropping */
.nuki-video-wrapper.layout-vertical:fullscreen,
.nuki-video-wrapper.layout-vertical:-webkit-full-screen {
    max-width: none !important;
    aspect-ratio: unset !important;
    width: 100% !important;
    height: 100% !important;
}

.nuki-video-wrapper.layout-vertical:fullscreen .nuki-video-player-container,
.nuki-video-wrapper.layout-vertical:-webkit-full-screen .nuki-video-player-container {
    padding-bottom: 0 !important;
    height: 100% !important;
    width: 100% !important;
}

/* Compact controls for vertical video layout */
.nuki-video-wrapper.layout-vertical .nuki-video-controls {
    padding: 0 0.5rem !important;
    gap: 0.4rem !important;
}

.nuki-video-wrapper.layout-vertical .nuki-volume-slider {
    display: none !important; /* Hide volume slider on vertical layout to prevent horizontal overflow */
}

.nuki-video-wrapper.layout-vertical .nuki-speed-container {
    display: none !important; /* Hide speed settings to save horizontal space */
}

.nuki-video-wrapper.layout-vertical .nuki-time-display {
    min-width: unset !important; /* Allow text container to shrink naturally */
    font-size: 0.75rem !important; /* Slightly smaller for narrow layout compatibility */
    white-space: nowrap !important; /* Prevent text from wrapping to two lines */
}

@media (max-width: 768px) {
    .nuki-video-wrapper.layout-vertical {
        max-width: 320px !important; /* Restricts vertical screen height on mobile */
        margin: 0 auto 2rem !important;
    }
    
    /* Horizontal videos: pull full-bleed to touch screen edges */
    .nuki-video-wrapper:not(.layout-vertical) {
        width: calc(100% + 2.5rem) !important;
        margin-left: -1.25rem !important;
        margin-right: -1.25rem !important;
        max-width: none !important;
        border-radius: 0 !important;
    }
}

/* Pseudo-fullscreen styling for iOS and Mobile browsers */
.nuki-video-wrapper.nuki-pseudo-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: none !important; /* Reset layout constraints in fullscreen */
    aspect-ratio: unset !important;
    z-index: 999999 !important;
    background: #000 !important;
    margin: 0 !important;
    border-radius: 0 !important;
}

.nuki-video-wrapper.nuki-pseudo-fullscreen .nuki-video-player-container {
    width: 100% !important;
    height: 100% !important;
    padding-bottom: 0 !important;
}

/* For horizontal videos in portrait mobile viewports: rotate landscape */
@media screen and (max-width: 768px) and (orientation: portrait) {
    .nuki-video-wrapper.nuki-pseudo-fullscreen:not(.layout-vertical) {
        top: 50% !important;
        left: 50% !important;
        width: 100vh !important;
        height: 100vw !important;
        transform: translate(-50%, -50%) rotate(90deg) !important;
    }
}

/* Close Button for Fullscreen / Pseudo-Fullscreen */
.nuki-video-close-btn {
    display: none;
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 9999999 !important;
    background: rgba(0, 0, 0, 0.65) !important;
    color: #ffffff !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    border-radius: 50% !important;
    width: 40px !important;
    height: 40px !important;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.4rem;
    transition: background-color 0.2s, transform 0.2s;
    padding: 0 !important;
    line-height: 1 !important;
    outline: none !important;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3) !important;
}

.nuki-video-close-btn:hover {
    background: rgba(0, 0, 0, 0.85) !important;
    transform: scale(1.05);
}

.nuki-video-wrapper.nuki-pseudo-fullscreen .nuki-video-close-btn,
.nuki-video-wrapper:fullscreen .nuki-video-close-btn,
.nuki-video-wrapper:-webkit-full-screen .nuki-video-close-btn {
    display: flex !important;
}
