/* ==========================================================================
   VIDEO PEEK — previsualizador pequeño 9:16 de un Short (banco común, 20/11/2026)
   --------------------------------------------------------------------------
   Componente reutilizable: js/video-peek.js + este CSS. Marcado mínimo:

     <div style="position:relative">                      (cualquier caja con position)
       <button type="button" class="vpeek" data-vpeek
               data-yt="<id de YouTube>" data-url="https://youtube.com/shorts/<id>"
               data-clip="/images/.../<x>-preview.mp4"    (opcional: clip mudo al pasar el ratón)
               data-title="AAPL · título" data-close="Dismiss"
               aria-haspopup="dialog" aria-label="Watch the analysis: AAPL">
         <img class="vpeek-poster" src="/images/.../<x>-poster.webp" width="180" height="320" alt="" loading="lazy" decoding="async">
         <span class="vpeek-play" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="M8 5.5v13l11-6.5z"/></svg></span>
         <span class="vpeek-bar" aria-hidden="true"></span>
       </button>
     </div>

   Colores FIJOS (va sobre una imagen, no sobre la página): teal #8FD0DE + ámbar #F2BE63.
   Tamaño: --vpeek-w (60px por defecto). Variante grande: clase .vpeek--lg.
   ========================================================================== */
.vpeek {
    --vpeek-w: 60px;
    --vpeek-grow: 1.5;
    position: absolute; right: 10px; bottom: 10px; z-index: 4;
    inline-size: var(--vpeek-w); aspect-ratio: 9 / 16;
    padding: 0; margin: 0; border: 0; border-radius: 9px; overflow: hidden;
    background: #0B0F13; color: #fff; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 0 0 1.5px rgba(255,255,255,.86), 0 10px 22px -8px rgba(0,0,0,.7);
    transform-origin: 100% 100%;
    transition: transform .26s cubic-bezier(.22,.61,.36,1), box-shadow .26s ease;
}
[dir="rtl"] .vpeek { right: auto; left: 10px; transform-origin: 0 100%; }
.vpeek--lg { --vpeek-w: 84px; --vpeek-grow: 1.4; right: 14px; bottom: 14px; border-radius: 11px; }
[dir="rtl"] .vpeek--lg { right: auto; left: 14px; }

.vpeek-poster, .vpeek video {
    position: absolute; inset: 0; width: 100%; height: 100%;
    object-fit: cover; display: block;
}
.vpeek video { opacity: 0; transition: opacity .22s ease; pointer-events: none; }
.vpeek.is-playing video { opacity: 1; }

/* Botón de play: cristal oscuro, triángulo claro. Se retira mientras corre la vista previa. */
.vpeek-play {
    position: absolute; left: 50%; top: 50%; z-index: 2;
    width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: rgba(10,14,18,.62);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.55);
    backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
    transition: opacity .2s ease, transform .2s ease, background-color .2s ease;
}
.vpeek-play svg { width: 13px; height: 13px; fill: currentColor; margin-left: 1px; }
.vpeek--lg .vpeek-play { width: 32px; height: 32px; margin: -16px 0 0 -16px; }
.vpeek--lg .vpeek-play svg { width: 16px; height: 16px; }
.vpeek.is-playing .vpeek-play { opacity: 0; transform: scale(.8); }

/* Hilo de progreso de la vista previa (6 s, lo que dura el clip) */
.vpeek-bar {
    position: absolute; left: 0; right: 0; bottom: 0; height: 2px; z-index: 2;
    background: linear-gradient(90deg, #8FD0DE, #F2BE63);
    transform: scaleX(0); transform-origin: 0 50%;
}
[dir="rtl"] .vpeek-bar { transform-origin: 100% 50%; }
.vpeek.is-playing .vpeek-bar { animation: vpeek-bar 6s linear infinite; }
@keyframes vpeek-bar { from { transform: scaleX(0); } to { transform: scaleX(1); } }

@media (hover: hover) and (pointer: fine) {
    .vpeek:hover, .vpeek.is-playing {
        transform: scale(var(--vpeek-grow));
        box-shadow: 0 0 0 1px #F2BE63, 0 16px 34px -10px rgba(0,0,0,.8);
    }
    .vpeek:hover .vpeek-play { background: rgba(10,14,18,.8); }
}
.vpeek:focus-visible {
    outline: 2px solid #F2BE63; outline-offset: 2px;
    transform: scale(var(--vpeek-grow));
}
.vpeek:active { box-shadow: 0 0 0 1.5px #F2BE63, 0 6px 14px -8px rgba(0,0,0,.7); }

@media (max-width: 600px) {
    .vpeek { --vpeek-w: 56px; }
    .vpeek--lg { --vpeek-w: 68px; right: 10px; bottom: 10px; }
    [dir="rtl"] .vpeek--lg { right: auto; left: 10px; }
}

/* Variante EN FLUJO (.vpeek--flow): no flota sobre la imagen; va dentro del bloque de texto, pegada al borde
   final, y el texto la rodea. El contenedor necesita display: flow-root (no flex). Edu 20/11: «que no tape la portada». */
.vpeek.vpeek--flow {
    position: relative; right: auto; bottom: auto; left: auto;
    float: right; margin: 2px 0 8px 14px;
}
[dir="rtl"] .vpeek.vpeek--flow { left: auto; right: auto; float: left; margin: 2px 14px 8px 0; }

/* Texto solo para lectores de pantalla (nombre accesible traducible con data-i18n dentro del botón) */
.vpeek-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }

/* FICHA DE INDICADOR (21/11/2026): el móvil de la cabecera (.vpeek--hero) va en la esquina final del
   <div class="indicator-detail-header">, que le deja sitio; el del tutorial (.vpeek--tut) flota junto al titular. */
.vpeek.vpeek--hero { top: 4px; bottom: auto; right: auto; left: auto; inset-inline-end: 0; transform-origin: 100% 0; }
[dir="rtl"] .vpeek.vpeek--hero { transform-origin: 0 0; }
.indicator-detail-header:has(> .vpeek--hero) {
    padding-inline-end: calc(84px + 20px);
    min-height: calc(84px * 16 / 9 + 10px);
    align-content: flex-start;
}
@supports not selector(:has(a)) {
    .vpeek.vpeek--hero { position: relative; top: auto; inset-inline-end: auto; order: 3; }
}
.vpeek.vpeek--tut { margin-top: 0; }
.vpeek--tut ~ .indicator-detail-video-embed, .vpeek--tut ~ .indicator-detail-video-placeholder { clear: both; }
@media (max-width: 600px) {
    .indicator-detail-header:has(> .vpeek--hero) { padding-inline-end: calc(68px + 16px); min-height: calc(68px * 16 / 9 + 10px); }
}

/* ---------- Reproductor: <dialog> nativo; el iframe de YouTube solo existe mientras está abierto ---------- */
.vpeek-dialog {
    padding: 0; border: 0; background: transparent; color: #EAF6F9;
    max-width: none; max-height: none; overflow: visible;
    position: fixed; inset: 0; margin: auto;      /* centrado aunque el reset global ponga margin 0 */
    width: -moz-fit-content; width: fit-content; height: -moz-fit-content; height: fit-content;
}
.vpeek-dialog::backdrop {
    background: rgba(5,9,12,.8);
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.vpeek-shell {
    width: min(92vw, 400px, calc((100vh - 136px) * 9 / 16));
    width: min(92vw, 400px, calc((100dvh - 136px) * 9 / 16));
}
.vpeek-top {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    margin: 0 0 10px;
}
.vpeek-title {
    margin: 0; min-width: 0; flex: 1;
    font-family: var(--font-heading, inherit); font-size: .875rem; font-weight: 600; line-height: 1.3;
    color: #EAF6F9;
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
}
.vpeek-close {
    flex: 0 0 auto; width: 40px; height: 40px; padding: 0; border-radius: 50%;
    border: 1px solid rgba(143,208,222,.45); background: rgba(16,24,30,.9); color: #EAF6F9;
    display: flex; align-items: center; justify-content: center; cursor: pointer;
    transition: border-color .2s ease, background-color .2s ease;
}
.vpeek-close svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.vpeek-close:hover { border-color: #F2BE63; background: rgba(28,38,46,.95); }
.vpeek-close:focus-visible, .vpeek-yt:focus-visible { outline: 2px solid #F2BE63; outline-offset: 2px; }
.vpeek-frame {
    aspect-ratio: 9 / 16; border-radius: 16px; overflow: hidden;
    background: #05090C center / cover no-repeat;
    box-shadow: 0 0 0 1px rgba(143,208,222,.35), 0 30px 80px -20px rgba(0,0,0,.85);
}
.vpeek-frame iframe, .vpeek-frame video { display: block; width: 100%; height: 100%; border: 0; }
.vpeek-frame video { object-fit: cover; background: transparent; }
.vpeek-foot[hidden] { display: none; }
.vpeek-foot { margin: 10px 0 0; text-align: center; }
.vpeek-yt {
    display: inline-flex; align-items: center; gap: .4rem; padding: .35rem .6rem;
    font-family: var(--font-heading, inherit); font-size: .8125rem; font-weight: 600;
    color: #8FD0DE; text-decoration: none; border-radius: 8px;
}
.vpeek-yt svg { width: 16px; height: 16px; fill: currentColor; }
.vpeek-yt:hover { color: #F2BE63; }
.vpeek-dialog[open] .vpeek-shell { animation: vpeek-in .24s cubic-bezier(.22,.61,.36,1); }
@keyframes vpeek-in { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
    .vpeek, .vpeek video, .vpeek-play { transition: none; }
    .vpeek:hover, .vpeek.is-playing, .vpeek:focus-visible { transform: none; }
    .vpeek.is-playing .vpeek-bar { animation: none; }
    .vpeek-dialog[open] .vpeek-shell { animation: none; }
}
