/* Custom YouTube player skin (copied from member/watch.php): the iframe is non-interactive and
   a click zone + custom controls sit on top, so viewers can't click through to YouTube. */
    /* ===== Cinema-Grade Video Player ===== */
    .player-theater {
        position: relative;
        width: 100%;
        background: #000;
        border-radius: 16px;
        overflow: hidden;
        border: 1px solid rgba(255,255,255,0.08);
        box-shadow:
            0 0 0 1px rgba(56,189,248,0.06),
            0 20px 50px -12px rgba(0,0,0,0.85),
            0 0 40px -8px rgba(37,99,235,0.12);
        transition: box-shadow 0.4s ease;
    }
    .player-theater:hover {
        box-shadow:
            0 0 0 1px rgba(56,189,248,0.12),
            0 24px 60px -12px rgba(0,0,0,0.9),
            0 0 50px -6px rgba(37,99,235,0.18);
    }
    .player-theater:fullscreen { border-radius: 0; border: none; }

    .player-aspect {
        position: relative;
        width: 100%;
        padding-top: 56.25%;
    }
    .player-theater:fullscreen .player-aspect {
        padding-top: 0;
        height: 100%;
    }

    #player {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        pointer-events: none;
    }

    /* Click-to-play overlay */
    .player-click-zone {
        position: absolute;
        inset: 0;
        z-index: 5;
        cursor: pointer;
    }

    /* Big center play button (shown on pause) */
    .player-big-play {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%) scale(1);
        z-index: 6;
        width: 72px;
        height: 72px;
        border-radius: 50%;
        background: rgba(37, 99, 235, 0.85);
        backdrop-filter: blur(12px);
        display: flex;
        align-items: center;
        justify-content: center;
        color: #fff;
        font-size: 22px;
        box-shadow: 0 0 40px rgba(37, 99, 235, 0.5), 0 8px 32px rgba(0,0,0,0.4);
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        pointer-events: none;
        opacity: 1;
    }
    .player-big-play.hidden-play { opacity: 0; transform: translate(-50%, -50%) scale(0.6); pointer-events: none; }
    .player-big-play i { margin-left: 3px; }

    /* Controls bar - slides up on hover */
    .player-controls {
        position: absolute;
        left: 0; right: 0; bottom: 0;
        z-index: 10;
        padding: 0 16px 12px;
        background: linear-gradient(to top, rgba(0,0,0,0.92) 0%, rgba(0,0,0,0.6) 50%, transparent 100%);
        transform: translateY(0);
        opacity: 1;
        transition: opacity 0.35s ease, transform 0.35s ease;
    }
    .player-theater.controls-hidden .player-controls {
        opacity: 0;
        transform: translateY(8px);
    }

    /* Progress track */
    .progress-track {
        position: relative;
        width: 100%;
        height: 5px;
        background: rgba(255,255,255,0.15);
        border-radius: 9999px;
        cursor: pointer;
        margin-bottom: 10px;
        transition: height 0.15s ease;
    }
    .player-theater:hover .progress-track,
    .progress-track:hover {
        height: 7px;
    }
    .progress-buffer {
        position: absolute;
        top: 0; left: 0;
        height: 100%;
        border-radius: 9999px;
        background: rgba(255,255,255,0.2);
        pointer-events: none;
        transition: width 0.3s linear;
    }
    .progress-played {
        position: absolute;
        top: 0; left: 0;
        height: 100%;
        border-radius: 9999px;
        background: linear-gradient(90deg, #3b82f6, #06b6d4);
        pointer-events: none;
        transition: width 0.15s linear;
        box-shadow: 0 0 8px rgba(56, 189, 248, 0.5);
    }
    .progress-knob {
        position: absolute;
        top: 50%;
        transform: translate(-50%, -50%) scale(0);
        width: 14px;
        height: 14px;
        border-radius: 50%;
        background: #38bdf8;
        border: 2px solid #fff;
        box-shadow: 0 0 10px rgba(56, 189, 248, 0.6);
        pointer-events: none;
        transition: transform 0.15s ease;
    }
    .progress-track:hover .progress-knob,
    .progress-track.dragging .progress-knob {
        transform: translate(-50%, -50%) scale(1);
    }

    /* Tooltip time preview */
    .progress-tooltip {
        position: absolute;
        top: -32px;
        transform: translateX(-50%);
        background: rgba(15, 23, 42, 0.95);
        color: #f1f5f9;
        font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
        font-size: 11px;
        font-weight: 700;
        padding: 3px 8px;
        border-radius: 6px;
        border: 1px solid rgba(255,255,255,0.1);
        pointer-events: none;
        opacity: 0;
        transition: opacity 0.15s;
        white-space: nowrap;
    }
    .progress-track:hover .progress-tooltip { opacity: 1; }

    /* Control buttons row */
    .controls-row {
        display: flex;
        align-items: center;
        gap: 6px;
    }
    .ctrl-btn {
        background: none;
        border: none;
        color: rgba(255,255,255,0.8);
        font-size: 15px;
        width: 36px;
        height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 8px;
        cursor: pointer;
        transition: all 0.2s ease;
    }
    .ctrl-btn:hover {
        color: #fff;
        background: rgba(255,255,255,0.1);
    }
    .ctrl-btn.active { color: #38bdf8; }

    /* Volume slider */
    .volume-group {
        display: flex;
        align-items: center;
        gap: 4px;
    }
    .volume-slider {
        width: 0;
        opacity: 0;
        transition: width 0.25s ease, opacity 0.25s ease;
        accent-color: #38bdf8;
        cursor: pointer;
        height: 4px;
    }
    .volume-group:hover .volume-slider {
        width: 70px;
        opacity: 1;
    }

    /* Time display */
    .time-display {
        font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
        font-size: 12px;
        color: rgba(255,255,255,0.65);
        white-space: nowrap;
        padding: 0 6px;
        letter-spacing: 0.02em;
    }
    .time-display .time-current { color: #f1f5f9; font-weight: 600; }

    /* Keyboard shortcuts hint */
    .kb-hint {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        background: rgba(0,0,0,0.8);
        backdrop-filter: blur(8px);
        color: #e2e8f0;
        font-size: 15px;
        font-weight: 700;
        padding: 10px 18px;
        border-radius: 10px;
        pointer-events: none;
        opacity: 0;
        transition: opacity 0.2s;
        z-index: 20;
    }
    .kb-hint.show { opacity: 1; }

    /* Speed menu */
    .speed-menu {
        position: absolute;
        right: 12px;
        bottom: 56px;
        background: rgba(15, 23, 42, 0.96);
        border: 1px solid rgba(255,255,255,0.12);
        border-radius: 10px;
        padding: 6px;
        z-index: 30;
        box-shadow: 0 12px 32px rgba(0,0,0,0.6);
        display: none;
    }
    .speed-menu.open { display: block; }
    .speed-option {
        display: block;
        width: 100%;
        background: none;
        border: none;
        color: #94a3b8;
        font-size: 13px;
        font-weight: 600;
        padding: 6px 16px;
        border-radius: 6px;
        cursor: pointer;
        text-align: left;
        transition: all 0.15s;
    }
    .speed-option:hover { background: rgba(255,255,255,0.08); color: #fff; }
    .speed-option.active { color: #38bdf8; background: rgba(56, 189, 248, 0.12); }


/* Preview poster (public course page): loads YouTube only after the first click */
.player-poster {
    position: absolute; inset: 0; z-index: 15; width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    border: 0; padding: 0; cursor: pointer; background: #000;
}
.player-poster img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .8; transition: opacity .2s; }
.player-poster:hover img { opacity: 1; }
.player-poster::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,.7), transparent 55%); }
.player-poster .big { position: relative; z-index: 1; width: 72px; height: 72px; border-radius: 50%; background: rgba(37,99,235,.9);
    display: flex; align-items: center; justify-content: center; color: #fff; font-size: 22px; padding-left: 3px;
    box-shadow: 0 0 40px rgba(37,99,235,.5), 0 8px 32px rgba(0,0,0,.4); transition: transform .25s; }
.player-poster:hover .big { transform: scale(1.1); }
.player-poster .ttl { position: absolute; z-index: 1; left: 16px; right: 16px; bottom: 12px; text-align: left; color: #fff; font-weight: 600; font-size: 14px; }
.player-loading { position: absolute; inset: 0; z-index: 4; display: none; align-items: center; justify-content: center; color: #94a3b8; }
.player-loading.show { display: flex; }

/* Touch-friendly controls on phones */
@media (max-width: 640px) {
    .player-controls { padding: 0 8px 8px; }
    .ctrl-btn { width: 40px; height: 40px; }
    .volume-group { display: none; }
    .progress-track { height: 7px; margin-bottom: 6px; }
    .player-big-play { width: 60px; height: 60px; font-size: 18px; }
}
