/**
 * Vislun Video System
 * Legendas sincronizadas do player MP4.
 *
 * Este arquivo contém somente a apresentação visual
 * do botão, do menu e da camada textual das legendas.
 */

/* =========================================================
   1. CAMADA DE LEGENDAS SINCRONIZADAS
   ========================================================= */

/*
 * A camada fica fora da interface dos controles.
 * Assim, o texto não desaparece durante a reprodução
 * quando a barra inferior é recolhida automaticamente.
 */
.vislun-video-wrapper.vislun-video-controls-tv
.vislun-player-captions {
    position: absolute;
    right: 8%;
    bottom: 66px;
    left: 8%;

    z-index: 69;

    display: flex;
    align-items: flex-end;
    justify-content: center;

    color: var(--vislun-player-white);

    text-align: center;

    opacity: 0;
    visibility: hidden;

    transition:
        bottom var(--vislun-player-transition-normal),
        opacity var(--vislun-player-transition-fast),
        visibility var(--vislun-player-transition-fast);

    pointer-events: none;
}

.vislun-video-wrapper.vislun-video-controls-tv
.vislun-player-captions.is-visible {
    opacity: 1;
    visibility: visible;
}

.vislun-video-wrapper.vislun-video-controls-tv
.vislun-player-captions-text {
    display: inline-block;

    max-width: 100%;

    padding: 6px 10px;

    border: 0;
    border-radius: 4px;

    background:
        linear-gradient(
            to bottom,
            rgba(42, 42, 42, 0.68) 0%,
            rgba(14, 14, 14, 0.54) 100%
        );

    color: var(--vislun-player-white);

    box-shadow:
        0 8px 22px rgba(0, 0, 0, 0.28);

    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);

    font-size: clamp(14px, 2.1vw, 20px);
    font-weight: 500;
    line-height: 1.32;
    text-align: center;
    white-space: pre-line;

    text-shadow:
        0 1px 3px rgba(0, 0, 0, 0.92);

    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;

    overflow-wrap: anywhere;

    box-sizing: border-box;
}

/*
 * Quando os controles saem para baixo, a legenda utiliza
 * o espaço liberado sem encostar na borda do vídeo.
 */
.vislun-video-wrapper.vislun-video-controls-tv
.vislun-player-ui.is-controls-hidden
~ .vislun-player-captions {
    bottom: 16px;
}

/*
 * O painel de compartilhamento ocupa todo o quadro.
 * A fala atual fica temporariamente oculta atrás dele.
 */
.vislun-video-wrapper.vislun-video-controls-tv
.vislun-player-ui.is-share-open
~ .vislun-player-captions {
    opacity: 0;
    visibility: hidden;
}

/*
 * Em tela cheia, o texto ganha presença e mantém
 * distância proporcional da barra inferior.
 */
.vislun-video-wrapper.vislun-video-controls-tv
.vislun-video-frame:is(:fullscreen, :-webkit-full-screen)
.vislun-player-captions {
    right: 12%;
    bottom: 92px;
    left: 12%;
}

.vislun-video-wrapper.vislun-video-controls-tv
.vislun-video-frame:is(:fullscreen, :-webkit-full-screen)
.vislun-player-ui.is-controls-hidden
~ .vislun-player-captions {
    bottom: 26px;
}

.vislun-video-wrapper.vislun-video-controls-tv
.vislun-video-frame:is(:fullscreen, :-webkit-full-screen)
.vislun-player-captions-text {
    padding: 8px 14px;

    font-size: clamp(18px, 2.2vw, 30px);
}

/* =========================================================
   2. BOTÃO DE LEGENDAS
   ========================================================= */

.vislun-video-wrapper.vislun-video-custom-player
.vislun-player-subtitles-control {
    position: relative;

    flex: 0 0 auto;

    width: var(--vislun-player-control-height);
    height: var(--vislun-player-control-height);

    display: flex;
    align-items: center;
    justify-content: center;

    pointer-events: none;
}

.vislun-video-wrapper.vislun-video-custom-player
.vislun-player-ui.is-active.is-interactive
.vislun-player-subtitles-control {
    pointer-events: auto;
}

.vislun-video-wrapper.vislun-video-custom-player
.vislun-player-subtitles-toggle[hidden] {
    display: none !important;
}

.vislun-video-wrapper.vislun-video-custom-player
.vislun-player-subtitles-toggle > span {
    --vislun-player-subtitles-icon:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256'%3E%3Cpath fill='white' d='M224,48H32A16,16,0,0,0,16,64V192a16,16,0,0,0,16,16H224a16,16,0,0,0,16-16V64A16,16,0,0,0,224,48ZM56,128H72a8,8,0,0,1,0,16H56a8,8,0,0,1,0-16Zm96,48H56a8,8,0,0,1,0-16h96a8,8,0,0,1,0,16Zm48,0H184a8,8,0,0,1,0-16h16a8,8,0,0,1,0,16Zm0-32H104a8,8,0,0,1,0-16h96a8,8,0,0,1,0,16Z'/%3E%3C/svg%3E");

    -webkit-mask-image:
        var(--vislun-player-subtitles-icon);

    mask-image:
        var(--vislun-player-subtitles-icon);
}

/*
 * Estado visual do menu de legendas aberto.
 *
 * O ícone fica amarelo somente enquanto o menu
 * estiver visível. Ao fechar o menu, volta ao branco,
 * mesmo que as legendas continuem ativadas.
 */
.vislun-video-wrapper.vislun-video-custom-player
.vislun-player-subtitles-toggle[aria-expanded="true"] {
    color: var(--vislun-player-accent);
}

/* =========================================================
   3. MENU DE LEGENDAS
   ========================================================= */

.vislun-video-wrapper.vislun-video-custom-player
.vislun-player-subtitles-menu {
    position: absolute;
    left: 50%;
    bottom: calc(
        100%
        + var(--vislun-player-progress-hit-area)
        + 8px
        - var(--vislun-player-control-padding-bottom)
    );

    z-index: 7;

    width: 184px;
    max-width: calc(100vw - 24px);

    padding: 4px;

    border: 0;
    border-radius: 5px;

    background:
        linear-gradient(
            to bottom,
            rgba(42, 42, 42, 0.68) 0%,
            rgba(14, 14, 14, 0.54) 100%
        );

    box-shadow:
        0 8px 22px rgba(0, 0, 0, 0.28);

    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);

    overflow: hidden;

    box-sizing: border-box;

    transform:
        translateX(
            calc(
                -50% +
                var(
                    --vislun-subtitles-menu-shift,
                    0px
                )
            )
        );

    pointer-events: auto;
}

/*
 * Em tela cheia, a base do menu de legendas permanece
 * alinhada à base do menu de velocidade, totalmente
 * acima da linha do tempo.
 */
.vislun-video-wrapper.vislun-video-custom-player
.vislun-video-frame:is(:fullscreen, :-webkit-full-screen)
.vislun-player-subtitles-menu {
    bottom: calc(
        100%
        + var(--vislun-player-progress-hit-area)
        + 8px
        - var(--vislun-player-control-padding-bottom)
    );
}

.vislun-video-wrapper.vislun-video-custom-player
.vislun-player-subtitles-menu-title {
    padding: 6px 8px 7px;

    color: var(--vislun-player-white);

    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.05em;
    line-height: 1;
    text-transform: uppercase;
}

.vislun-video-wrapper.vislun-video-custom-player
.vislun-player-subtitles-option {
    position: relative;

    width: 100%;
    min-height: 32px;

    display: flex;
    align-items: center;

    margin: 0;
    padding: 6px 8px 6px 29px;

    border: 0;
    border-radius: 4px;

    background: transparent;
    color: var(--vislun-player-white);

    font-size: 12px;
    line-height: 1.2;
    text-align: left;

    box-sizing: border-box;

    appearance: none;
    -webkit-appearance: none;

    cursor: pointer;
    pointer-events: auto;
}

.vislun-video-wrapper.vislun-video-custom-player
.vislun-player-subtitles-option::before {
    content: "";

    position: absolute;
    left: 9px;
    top: 50%;

    width: 12px;

    color: currentColor;

    font-size: 15px;
    font-weight: 800;
    line-height: 1;
    text-align: center;

    transform: translateY(-52%);
}

.vislun-video-wrapper.vislun-video-custom-player
.vislun-player-subtitles-option.is-selected {
    background: var(--vislun-player-accent);
    color: var(--vislun-player-black);

    font-weight: 700;
}

.vislun-video-wrapper.vislun-video-custom-player
.vislun-player-subtitles-option.is-selected::before {
    content: "✓";
}

.vislun-video-wrapper.vislun-video-custom-player
.vislun-player-subtitles-option:focus,
.vislun-video-wrapper.vislun-video-custom-player
.vislun-player-subtitles-option:focus-visible {
    outline: 0;
}

.vislun-video-wrapper.vislun-video-custom-player
.vislun-player-subtitles-option:focus-visible {
    box-shadow:
        inset 0 0 0 2px rgba(255, 255, 255, 0.76);
}

/* =========================================================
   4. AJUSTES PARA CELULAR
   ========================================================= */

@media (max-width: 520px) {
    .vislun-video-wrapper.vislun-video-controls-tv
    .vislun-player-captions {
        right: 4%;
        bottom: 54px;
        left: 4%;
    }

    .vislun-video-wrapper.vislun-video-controls-tv
    .vislun-player-ui.is-controls-hidden
    ~ .vislun-player-captions {
        bottom: 10px;
    }

    .vislun-video-wrapper.vislun-video-controls-tv
    .vislun-player-captions-text {
        padding: 5px 8px;

        font-size: 13px;
        line-height: 1.28;
    }

    .vislun-video-wrapper.vislun-video-custom-player
    .vislun-player-subtitles-menu {
        width: 174px;
    }

    .vislun-video-wrapper.vislun-video-custom-player
    .vislun-player-subtitles-option {
        min-height: 34px;

        font-size: 12px;
    }

    .vislun-video-wrapper.vislun-video-controls-tv
    .vislun-video-frame:is(:fullscreen, :-webkit-full-screen)
    .vislun-player-captions {
        right: 6%;
        bottom: 66px;
        left: 6%;
    }

    .vislun-video-wrapper.vislun-video-controls-tv
    .vislun-video-frame:is(:fullscreen, :-webkit-full-screen)
    .vislun-player-ui.is-controls-hidden
    ~ .vislun-player-captions {
        bottom: 14px;
    }

    .vislun-video-wrapper.vislun-video-controls-tv
    .vislun-video-frame:is(:fullscreen, :-webkit-full-screen)
    .vislun-player-captions-text {
        padding: 6px 10px;

        font-size: 16px;
    }
}
