/* ============================================================
   BlackBox Learning - Custom Video Player
   Reusable module · Dark theme · Glassmorphism · Peach accent
   ============================================================ */

/* ---------- Player Container ---------- */
.bbx-video-player {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: 0;
    overflow: hidden;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    isolation: isolate;
}

.bbx-video-player video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Portrait videos are capped in height and centered by their flex wrapper */
.bbx-video-player.bbx-portrait {
    width: auto;
    max-height: 80vh;
}

/* ---------- Poster / Big-Play Overlay ---------- */
.bbx-player-poster {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(
        180deg,
        rgba(0, 0, 0, 0.15) 0%,
        rgba(0, 0, 0, 0.55) 100%
    );
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.bbx-player-poster.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.bbx-big-play {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: rgba(255, 110, 59, 0.85);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
                background 0.25s ease,
                box-shadow 0.3s ease;
    box-shadow:
        0 0 0 0 rgba(255, 110, 59, 0.4),
        0 8px 30px -6px rgba(0, 0, 0, 0.5);
    animation: bbx-pulse-ring 2.4s ease-out infinite;
}

.bbx-big-play:hover {
    transform: scale(1.12);
    background: rgba(255, 110, 59, 1);
    box-shadow:
        0 0 0 0 rgba(255, 110, 59, 0.5),
        0 12px 40px -8px rgba(0, 0, 0, 0.6);
}

.bbx-big-play svg {
    width: 28px;
    height: 28px;
    fill: #fff;
    margin-left: 3px; /* optical centering */
}

@keyframes bbx-pulse-ring {
    0% {
        box-shadow:
            0 0 0 0 rgba(255, 110, 59, 0.45),
            0 8px 30px -6px rgba(0, 0, 0, 0.5);
    }
    70% {
        box-shadow:
            0 0 0 18px rgba(255, 110, 59, 0),
            0 8px 30px -6px rgba(0, 0, 0, 0.5);
    }
    100% {
        box-shadow:
            0 0 0 0 rgba(255, 110, 59, 0),
            0 8px 30px -6px rgba(0, 0, 0, 0.5);
    }
}

/* ---------- Control Bar ---------- */
.bbx-controls {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    padding: 0 0 0;
    background: linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.82) 0%,
        rgba(0, 0, 0, 0.35) 60%,
        transparent 100%
    );
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    transition: opacity 0.35s ease, visibility 0.35s ease, transform 0.35s ease;
}

/* Show controls on hover / when paused */
.bbx-video-player:hover .bbx-controls,
.bbx-video-player.paused .bbx-controls,
.bbx-video-player.controls-visible .bbx-controls {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* ---------- Progress Bar ---------- */
.bbx-progress-wrap {
    position: relative;
    width: 100%;
    height: 20px;
    display: flex;
    align-items: flex-end;
    padding: 0 12px;
    cursor: pointer;
}

.bbx-progress-track {
    position: relative;
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    overflow: visible;
    transition: height 0.2s ease;
}

.bbx-progress-wrap:hover .bbx-progress-track {
    height: 6px;
}

.bbx-progress-buffered {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: rgba(255, 255, 255, 0.18);
    border-radius: 4px;
    pointer-events: none;
}

.bbx-progress-filled {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: #ff6e3b;
    border-radius: 4px;
    pointer-events: none;
    transition: width 0.05s linear;
}

.bbx-progress-thumb {
    position: absolute;
    top: 50%;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #ff6e3b;
    border: 2px solid #fff;
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.2s ease;
    pointer-events: none;
    box-shadow: 0 0 8px rgba(255, 110, 59, 0.5);
}

.bbx-progress-wrap:hover .bbx-progress-thumb,
.bbx-progress-wrap.dragging .bbx-progress-thumb {
    transform: translate(-50%, -50%) scale(1);
}

/* Time tooltip on hover */
.bbx-time-tooltip {
    position: absolute;
    bottom: 22px;
    padding: 3px 8px;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    font-size: 0.7rem;
    font-family: 'Inter', monospace;
    border-radius: 4px;
    pointer-events: none;
    opacity: 0;
    transform: translateX(-50%);
    transition: opacity 0.15s ease;
    white-space: nowrap;
}

.bbx-progress-wrap:hover .bbx-time-tooltip {
    opacity: 1;
}

/* ---------- Bottom row: buttons + time ---------- */
.bbx-controls-row {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px 8px;
}

/* Generic control button */
.bbx-ctrl-btn {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
}

.bbx-ctrl-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.1);
}

.bbx-ctrl-btn:active {
    transform: scale(0.95);
}

.bbx-ctrl-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* ---------- Volume ---------- */
.bbx-volume-group {
    display: flex;
    align-items: center;
    gap: 2px;
}

.bbx-volume-slider-wrap {
    width: 0;
    overflow: hidden;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
}

.bbx-volume-group:hover .bbx-volume-slider-wrap {
    width: 80px;
}

.bbx-volume-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 72px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    outline: none;
    cursor: pointer;
    margin: 0 4px;
}

.bbx-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ff6e3b;
    border: 2px solid #fff;
    cursor: pointer;
    box-shadow: 0 0 6px rgba(255, 110, 59, 0.5);
}

.bbx-volume-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ff6e3b;
    border: 2px solid #fff;
    cursor: pointer;
    box-shadow: 0 0 6px rgba(255, 110, 59, 0.5);
}

/* ---------- Time Display ---------- */
.bbx-time-display {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.75);
    font-family: 'Inter', monospace;
    letter-spacing: 0.03em;
    white-space: nowrap;
    padding: 0 4px;
}

/* ---------- Spacer ---------- */
.bbx-spacer {
    flex: 1;
}

/* ---------- Picture-in-Picture ---------- */
.bbx-video-player.pip-active video {
    opacity: 0.25;
}

.bbx-video-player.pip-active::after {
    content: 'Playing in picture-in-picture';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.85rem;
    font-family: 'Inter', sans-serif;
    pointer-events: none;
    z-index: 5;
}

/* ---------- Playback Speed ---------- */
.bbx-speed-group {
    position: relative;
    display: flex;
    align-items: center;
}

.bbx-speed-btn {
    font-size: 0.75rem;
    font-family: 'Inter', monospace;
    font-weight: 600;
    letter-spacing: 0.02em;
    min-width: 36px;
}

.bbx-speed-btn svg { display: none; }

.bbx-speed-label {
    color: #fff;
    pointer-events: none;
}

.bbx-speed-menu {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    background: rgba(18, 18, 18, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 4px;
    display: none;
    flex-direction: column;
    gap: 2px;
    min-width: 80px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    z-index: 30;
}

.bbx-speed-menu.open {
    display: flex;
}

.bbx-speed-option {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.75);
    font-size: 0.8rem;
    font-family: 'Inter', monospace;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    text-align: center;
    transition: background 0.15s, color 0.15s;
}

.bbx-speed-option:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.bbx-speed-option.bbx-speed-active {
    color: #ff6e3b;
    font-weight: 600;
}

/* ---------- Fullscreen ---------- */
.bbx-video-player.fullscreen {
    border-radius: 0;
}

/* ---------- Loading Spinner ---------- */
.bbx-loading {
    position: absolute;
    inset: 0;
    z-index: 15;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
}

.bbx-video-player.loading .bbx-loading {
    display: flex;
}

.bbx-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: #ff6e3b;
    border-radius: 50%;
    animation: bbx-spin 0.75s linear infinite;
}

@keyframes bbx-spin {
    to { transform: rotate(360deg); }
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
    .bbx-big-play {
        width: 52px;
        height: 52px;
    }

    .bbx-big-play svg {
        width: 22px;
        height: 22px;
    }

    .bbx-ctrl-btn svg {
        width: 18px;
        height: 18px;
    }

    .bbx-time-display {
        font-size: 0.65rem;
    }

    .bbx-controls-row {
        padding: 2px 6px 6px;
    }

    .bbx-volume-group:hover .bbx-volume-slider-wrap {
        width: 56px;
    }
}
