/* ==========================================================
   player.css — Layout base del reproductor vertical
   Mobile-first. Sin frameworks.
   ========================================================== */

/* ── Wrapper externo (player + traducción) ────────────────── */
/* container-type aquí hace que cqw en los hijos sea relativo
   al ancho del wrapper, no al viewport. */
.vs-wrapper {
    container-type: inline-size;
    display: block;
    width: 100%;
}

/* ── Contenedor principal ─────────────────────────────────── */
.vs-player {
    position: relative;
    width: 100%;
    /* Ratio 9:16, máx 85 del viewport, nunca se desborda */
    aspect-ratio: 9 / 16;
    max-height: 85vh;
    overflow: hidden;
    background: #0a0a0a;
}

/* Pantalla completa (fullscreen API) */
:fullscreen .vs-player, 
:-webkit-full-screen .vs-player {
    max-height: none !important;
    aspect-ratio: auto !important;
    height: 100vh !important;
    width: 100vw !important;
    border-radius: 0 !important;
}

.vs-player {
    display: flex;
    flex-direction: column;
    font-family: var(--vs-font-main, 'Noto Sans JP', sans-serif);
    font-weight: var(--vs-font-weight, 600);
    color: var(--vs-color-text, #ffffff);
    -webkit-font-smoothing: antialiased;
    user-select: none;
    touch-action: pan-y;
}

/* El wrapper Elementor nunca tiene altura fija; crece con su contenido
   (player + bloque de traducción). La altura fija se aplica SOLO al player interno. */
.vs-elementor-wrapper {
    height: auto !important;
    overflow: visible !important;
    display: flex;
    flex-direction: column;
}

/* Cuando Elementor define altura explícita, el aspect-ratio no interfiere */
.vs-elementor-wrapper .vs-player {
    aspect-ratio: unset;
    width: 100%;
    flex-shrink: 0;    /* el player no se encoge */
    max-height: none;
}

/* La traducción siempre se muestra debajo del player, sin recorte */
.vs-elementor-wrapper .vs-story-translation {
    flex-shrink: 0;
    overflow: visible;
}

/* ── Fondos (crossfade) ───────────────────────────────────── */
.vs-backgrounds {
    position: absolute;
    inset: 0;
    z-index: 0;
}

.vs-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    opacity: 0;
    transition: opacity var(--vs-anim-duration, 400ms) ease;
}

.vs-bg--active {
    opacity: 1;
}

/* ── Overlay oscuro ───────────────────────────────────────── */
.vs-overlay {
    position: absolute;
    inset: 0;
    background: var(--vs-color-overlay, rgba(0,0,0,0.40));
    z-index: 1;
    pointer-events: none;
}

/* ── Cabecera ─────────────────────────────────────────────── */
.vs-header {
    position: relative;
    z-index: 10;
    padding: 14px 16px 0;
    text-align: center;
    flex-shrink: 0;
}

.vs-story-title {
    font-size: clamp(16px, 3vw, 22px);
    font-weight: 700;
    opacity: 0.9;
    letter-spacing: 0.04em;
}

/* ── Zona de texto ────────────────────────────────────────── */
.vs-text-area {
    position: relative;
    z-index: 10;
    flex: 1;
    display: flex;
    align-items: flex-start;
    padding: 20px 20px 0;
    cursor: pointer;
    overflow: hidden;
}

.vs-text-block {
    width: 100%;
    font-size: var(--vs-font-size, clamp(22px, 5vw, 36px));
    line-height: var(--vs-line-height, 1.7);
    text-align: var(--vs-text-align, left);
    text-shadow: var(--vs-text-shadow, rgba(0,0,0,0.8) 0 2px 8px);
    word-break: break-word;
}

/* ── Palabras ─────────────────────────────────────────────── */
.vs-word {
    display: inline-block;
    color: var(--vs-color-text, #ffffff);
    transition: color 0.1s ease, transform 0.1s ease;
    transform-origin: bottom center;
    cursor: default;
}

.vs-word.vs-word-break {
    display: inline !important;
}

.vs-word.word-active {
    color: var(--vs-color-active, #FFD400);
    transform: scale(var(--vs-word-scale, 1.08));
}

.vs-word.word-done {
    color: var(--vs-color-after, #ffffff);
}

/* ── Ruby / Furigana ──────────────────────────────────────── */
ruby.vs-ruby {
    ruby-align: center;
    text-align: center;
    color: inherit;
}

.vs-furigana {
    display: ruby-text;
    text-align: center;
    font-size: var(--vs-font-size-furi, clamp(10px, 2.2vw, 16px));
    font-family: var(--vs-font-furigana, inherit);
    font-weight: 400;
    letter-spacing: 0;
    opacity: 0.85;
    color: inherit;
    text-shadow: none !important;
}

.vs-no-furigana .vs-furigana {
    display: none !important;
}

/* ── Score bajo (confianza) ───────────────────────────────── */
.vs-word--low-score { opacity: 0.7; }

/* ── Menú de configuración (Popup) ───────────────────── */
.vs-settings-menu {
    position: absolute;
    bottom: 80px;
    right: 16px;
    background: rgba(20, 20, 20, 0.95);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 16px;
    padding: 16px 12px;
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
    backdrop-filter: blur(8px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}

.vs-settings-menu[hidden] {
    display: none !important;
}

.vs-action-btn {
    background: rgba(0,0,0,0.4);
    border: none;
    border-radius: 50%;
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    cursor: pointer;
    transition: background 0.2s;
}

.vs-action-btn:hover { background: rgba(0,0,0,0.65); }

/* Botón de config (engranaje) dentro de los controles */
.vs-btn-settings {
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.8);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, transform 0.3s;
    flex-shrink: 0;
}

.vs-btn-settings:hover,
.vs-btn-settings.vs-settings-open {
    color: #fff;
    transform: rotate(60deg);
}

.vs-no-furigana .vs-btn-furigana {
    opacity: 0.5;
    text-decoration: line-through;
}

/* ── Barra del narrador ───────────────────────────────────── */
.vs-narrator-bar {
    position: relative;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 16px;
    flex-shrink: 0;
}

.vs-narrator-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.6);
    flex-shrink: 0;
}

.vs-narrator-name {
    font-size: 13px;
    opacity: 0.85;
}

/* ── Controles ────────────────────────────────────────────── */
.vs-controls {
    position: relative;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 10px;
    flex-shrink: 0;
    transition: opacity 0.3s, visibility 0.3s;
}

.vs-ctrl-btn {
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.9;
    transition: opacity 0.2s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}

.vs-ctrl-btn:hover { opacity: 1; }
.vs-ctrl-btn:active { transform: scale(0.92); }

.vs-btn-play {
    opacity: 1 !important;
}

/* Modo ocultar controles */
.vs-controls-hidden .vs-ctrl-btn:not(.vs-btn-toggle-controls) {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.vs-controls-hidden .vs-narrator-bar {
    opacity: 0;
    visibility: hidden;
}
.vs-controls-hidden .vs-side-actions {
    opacity: 0;
    visibility: hidden;
}

/* ── Barra de progreso ────────────────────────────────────── */
.vs-progress-area {
    position: relative;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 16px;
    flex-shrink: 0;
}

.vs-time {
    font-size: 11px;
    opacity: 0.7;
    min-width: 36px;
    font-variant-numeric: tabular-nums;
    font-family: monospace;
}

.vs-progress-bar {
    flex: 1;
    height: 28px; /* Área de toque grande */
    display: flex;
    align-items: center;
    cursor: pointer;
    position: relative;
}

.vs-progress-bar::before {
    /* Pista de la barra */
    content: '';
    position: absolute;
    left: 0; right: 0;
    height: 3px;
    background: rgba(255,255,255,0.25);
    border-radius: 2px;
}

.vs-progress-fill {
    position: absolute;
    left: 0;
    height: 3px;
    background: var(--vs-color-active, #FFD400);
    border-radius: 2px;
    width: 0%;
    pointer-events: none;
}

.vs-progress-thumb {
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    transform: translateX(-50%);
    left: 0%;
    pointer-events: none;
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
    transition: transform 0.1s;
}

.vs-progress-bar:active .vs-progress-thumb {
    transform: translateX(-50%) scale(1.3);
}

/* ── Pantalla final ───────────────────────────────────────── */
.vs-end-screen {
    position: absolute;
    inset: 0;
    z-index: 50;
    background: rgba(0,0,0,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
}

.vs-end-screen[hidden] { display: none; }

.vs-end-inner {
    text-align: center;
    padding: 32px;
}

.vs-end-title {
    font-size: clamp(22px, 5vw, 36px);
    margin-bottom: 24px;
}

.vs-end-btn {
    background: var(--vs-color-active, #FFD400);
    color: #111;
    border: none;
    padding: 14px 28px;
    border-radius: 50px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s;
}

.vs-end-btn:active { transform: scale(0.96); }

/* ── Loading ──────────────────────────────────────────────── */
.vs-loading {
    font-size: 14px;
    opacity: 0.6;
}


/* ── Error ────────────────────────────────────────────────── */
.vs-error {
    color: #ff6b6b;
    padding: 20px;
    text-align: center;
}

/* ── Bloque Traducción al Español ─────────────────────────── */
.vs-story-translation {
    margin-top: 24px;
    padding: 20px 24px;
    background: #f8f9fa;
    border-radius: 10px;
    border-left: 4px solid #cb4b40;
    font-size: 1rem;
    line-height: 1.75;
    color: #1d2327;
}

/* ── Slider de traducción por escenas ─────────────────────── */

/* Track: ocultar todos los slides por defecto */
.vs-translation-track {
    position: relative;
}

/* Cada slide se oculta por defecto */
.vs-translation-slide {
    display: none;
    animation: vs-fade-in 0.35s ease;
}

/* Solo el slide activo es visible */
.vs-translation-slide.vs-translation-active {
    display: block;
}

@keyframes vs-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.vs-story-translation p {
    margin: 0 0 0.8em 0;
    white-space: pre-line; /* respeta saltos de línea del texto plano */
}

.vs-story-translation p:last-child {
    margin-bottom: 0;
}

/* Escenas sin traducción: guión tenue */
.vs-translation-empty {
    color: #aaa;
    font-style: italic;
}
