/*
 * Chapter player for YouTube videos (assets/js/yt-lightbox.js), ported from
 * salsapal.com. Client deck 12Oct26 slides 4/14/23/24.
 *   .yt-thumb      the thumbnail button in a .video-grid
 *   .yt-box        the full-screen player: stage (video + tap shield),
 *                  control bar, close button, title
 */

/* ---- Thumbnail ---- */

.yt-thumb {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: #000;
    cursor: pointer;
    overflow: hidden;
}

.yt-thumb__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.25s ease;
}

.yt-thumb__shade {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 55%, rgba(0, 0, 0, 0.45));
}

.yt-thumb__play {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 68px;
    height: 68px;
    margin: -34px 0 0 -34px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #FFCC00;
    color: #1a1a1a;
    box-shadow: 0 8px 26px rgba(0, 0, 0, 0.4);
    transition: transform 0.25s ease, background 0.25s ease;
}

.yt-thumb:hover .yt-thumb__img,
.yt-thumb:focus-visible .yt-thumb__img {
    transform: scale(1.04);
}

.yt-thumb:hover .yt-thumb__play,
.yt-thumb:focus-visible .yt-thumb__play {
    transform: scale(1.1);
    background: #FFCC00;
}

.yt-thumb:focus-visible {
    outline: 3px solid #FFCC00;
    outline-offset: 3px;
}

/* ---- Player overlay ---- */

html.has-yt-box {
    overflow: hidden;
}

.yt-box {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    /* full height on phones, below the browser's own bars */
    height: 100dvh;
}

.yt-box[hidden] {
    display: none;
}


.yt-box__stage {
    position: relative;
    height: 100%;
    max-width: 100%;
    aspect-ratio: 9 / 16;
}

.yt-box[data-format='landscape'] .yt-box__stage {
    height: auto;
    width: 100%;
    max-height: 100%;
    aspect-ratio: 16 / 9;
}

.yt-box__video,
.yt-box__frame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* Covers the whole embed: YouTube's links can never be tapped. */
.yt-box__shield {
    position: absolute;
    inset: 0;
    z-index: 2;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Big icon that flashes on play / pause / sound changes */
.yt-box__bump {
    position: absolute;
    left: 50%;
    top: 50%;
    z-index: 3;
    width: 84px;
    height: 84px;
    margin: -42px 0 0 -42px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #ffffff;
    opacity: 0;
    pointer-events: none;
}

.yt-box__bump svg {
    width: 40px;
    height: 40px;
}

.yt-box__bump--on {
    animation: yt-bump 0.6s ease-out;
}

@keyframes yt-bump {
    0% { opacity: 1; transform: scale(0.8); }
    100% { opacity: 0; transform: scale(1.3); }
}

/* Control bar along the bottom */
.yt-box__bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 4;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 24px 16px max(16px, env(safe-area-inset-bottom));
    background: linear-gradient(0deg, rgba(0, 0, 0, 0.8), transparent);
    color: #ffffff;
    transition: opacity 0.3s ease;
}

.yt-box__btn,
.yt-box__close {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    color: #ffffff;
    cursor: pointer;
}

.yt-box__btn:hover,
.yt-box__btn:focus-visible,
.yt-box__close:hover,
.yt-box__close:focus-visible {
    background: #FFCC00;
    color: #1a1a1a;
    outline: none;
}

.yt-box__time {
    flex: 0 0 auto;
    min-width: 3.2em;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

.yt-box__seek {
    flex: 1 1 auto;
    min-width: 40px;
    accent-color: #FFCC00;
    height: 28px;
    cursor: pointer;
}

.yt-box__close {
    position: absolute;
    top: max(16px, env(safe-area-inset-top));
    right: 16px;
    z-index: 4;
    transition: opacity 0.3s ease;
}

.yt-box__title {
    position: absolute;
    top: max(16px, env(safe-area-inset-top));
    left: 16px;
    right: 80px;
    z-index: 4;
    margin: 0;
    padding-top: 12px;
    color: #ffffff;
    font-weight: 700;
    font-size: 14px;
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.7);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.3s ease;
}

/* Controls fade out while playing; any movement or tap brings them back. */
.yt-box--idle .yt-box__bar,
.yt-box--idle .yt-box__close,
.yt-box--idle .yt-box__title {
    opacity: 0;
}

.yt-box--idle {
    cursor: none;
}

@media (max-width: 520px) {
    .yt-box__time {
        min-width: 2.6em;
        font-size: 12px;
    }

    .yt-box__btn {
        width: 44px;
        height: 44px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .yt-box,
    .yt-thumb__img,
    .yt-thumb__play {
        transition: none;
    }

    .yt-box__bump--on {
        animation: none;
    }
}

/* Shown when a phone forced a muted start */
.yt-box__unmute {
    position: absolute;
    left: 50%;
    bottom: 110px;
    z-index: 5;
    transform: translateX(-50%);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border: 0;
    border-radius: 999px;
    background: #FFCC00;
    color: #1a1a1a;
    font-weight: 700;
    font-size: 14px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
    cursor: pointer;
}

.yt-box__unmute[hidden] {
    display: none;
}

/* Previous / next, stacked on the right edge like Shorts */
.yt-box__nav {
    position: absolute;
    right: 16px;
    top: 50%;
    z-index: 4;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    transition: opacity 0.3s ease;
}

.yt-box__nav[hidden] {
    display: none;
}

.yt-box__nav .yt-box__btn {
    width: 52px;
    height: 52px;
    background: rgba(255, 255, 255, 0.18);
}

.yt-box__nav .yt-box__btn:disabled {
    opacity: 0.3;
    cursor: default;
    background: rgba(255, 255, 255, 0.1);
}

.yt-box__count {
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.7);
}

.yt-box--idle .yt-box__nav {
    opacity: 0;
}

@media (max-width: 520px) {
    .yt-box__nav {
        right: 8px;
    }

    .yt-box__nav .yt-box__btn {
        width: 44px;
        height: 44px;
    }
}
