/**
 * Reels de Instagram (funciones/videos.php): la tira que se desliza, los Reels de un juego (página del juego, artículo,
 * ficha del jugador y Videoteca) y el visor a pantalla completa tipo historias (js/reels.js).
 * Los clips horizontales de la transmisión se ven enteros sobre su propia imagen difuminada.
 * @author Aris Mota <soy@aris.do>
 * @version 1.0
 * @date 2026-10-25
 */

/* ------------------------------------------------------------------ Tira */
.reels-tira { position: relative; }
.reels-pista { display: flex; gap: 12px; overflow-x: auto; padding: 4px 2px 10px; scroll-snap-type: x mandatory; scroll-behavior: smooth; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.reels-pista::-webkit-scrollbar { display: none; }
.reel { flex: 0 0 166px; display: flex; flex-direction: column; gap: 8px; min-width: 0; color: #1d1d1b; text-decoration: none !important; scroll-snap-align: start; }
.reel-foto {
    position: relative;
    display: block;
    overflow: hidden;
    aspect-ratio: 9 / 16;
    border-radius: 12px;
    background: var(--reel-img, none) center / cover, linear-gradient(160deg, #fd3f00, #1d1d1b);
    box-shadow: 0 8px 20px rgba(0, 0, 0, .18);
    transition: transform .25s, box-shadow .25s;
}
.reel-foto img { position: relative; width: 100%; height: 100%; object-fit: cover; transition: transform .5s ease; }
.reel-foto::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0, 0, 0, .25) 0%, transparent 25%, transparent 60%, rgba(0, 0, 0, .55) 100%); pointer-events: none; }
/* Horizontal: entero en el centro, sobre su imagen difuminada */
.reel-horizontal .reel-foto::before { content: ""; position: absolute; inset: 0; background: rgba(0, 0, 0, .3); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.reel-horizontal .reel-foto img { position: absolute; left: 0; top: 50%; height: auto; transform: translateY(-50%); object-fit: contain; box-shadow: 0 0 22px rgba(0, 0, 0, .55); }
.reel-sinfoto .reel-foto::before { content: ""; position: absolute; inset: 30% 25%; background: url("../api/icons/toros.png") center / contain no-repeat; opacity: .9; }
.reel-play { position: absolute; left: 10px; top: 10px; z-index: 1; display: flex; align-items: center; justify-content: center; width: 30px; height: 30px; padding-left: 2px; border-radius: 50%; background: rgba(0, 0, 0, .45); color: #fff; font-size: 11px; transition: background-color .2s, transform .2s; -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.reel-texto { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 13px; font-weight: 600; line-height: 1.3; }
.reel:hover .reel-foto, .reel:focus .reel-foto { transform: translateY(-4px); box-shadow: 0 0 0 3px #fd3f00, 0 14px 28px rgba(0, 0, 0, .25); }
.reel:hover .reel-foto img { transform: scale(1.05); }
.reel-horizontal:hover .reel-foto img { transform: translateY(-50%) scale(1.05); }
.reel:hover .reel-play { background: #fd3f00; transform: scale(1.15); }
.reels-tira-oscura .reel { color: #fff; }
.reels-tira-oscura .reel-foto { box-shadow: 0 0 0 1px rgba(255, 255, 255, .1), 0 10px 24px rgba(0, 0, 0, .5); }

.reels-flecha { position: absolute; top: calc(50% - 40px); z-index: 2; display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; border: 0; border-radius: 50%; background: #fff; color: #1d1d1b; font-size: 14px; box-shadow: 0 6px 18px rgba(0, 0, 0, .25); transition: background-color .2s, color .2s, transform .2s; }
.reels-flecha-ant { left: -10px; }
.reels-flecha-sig { right: -10px; }
.reels-flecha:hover { background: #fd3f00; color: #fff; transform: scale(1.08); }

/* ------------------------------------------------------------------ Los videos de un juego (juego, artículo, ficha) */
.reels-juego { margin: 0; }
.reels-juego-cabeza { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 14px; margin-bottom: 12px; }
.reels-juego-cabeza h2 { margin: 0; padding: 0; border: 0; color: #1d1d1b; font-family: var(--fuente-widget, sans-serif); font-weight: 700; font-size: 19px; letter-spacing: .08em; text-transform: uppercase; }
.reels-juego-cabeza h2 i { color: #fd3f00; }
.reels-juego-cabeza h2 small { margin-left: 6px; color: #777; font-family: var(--fuente-texto, sans-serif); font-size: 12px; font-weight: 600; letter-spacing: .06em; }
.reels-todos { display: inline-flex; align-items: center; gap: 7px; padding: .55em 1.2em; border: 0; border-radius: 2em; background: #fd3f00; color: #fff; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; box-shadow: 0 6px 16px rgba(253, 63, 0, .35); transition: background-color .2s, transform .2s; }
.reels-todos:hover, .reels-todos:focus { background: #e13901; transform: translateY(-2px); }
.reels-ocultos { display: none !important; }

/* ------------------------------------------------------------------ Visor tipo historias */
html.rv-abierto, html.rv-abierto body { overflow: hidden; }
.rv { position: fixed; inset: 0; z-index: 100000; display: flex; align-items: center; justify-content: center; gap: 22px; background: rgba(0, 0, 0, .94); color: #fff; font-family: var(--fuente-texto, Inter, Arial, sans-serif); animation: rv-entra .25s ease both; }
.rv[hidden] { display: none; }
.rv-fondo { position: absolute; inset: -40px; background: var(--rv-img, none) center / cover; filter: blur(40px) brightness(.45) saturate(1.3); transition: background-image .3s; }
.rv-marco { position: relative; display: flex; flex-direction: column; justify-content: center; height: min(92vh, 860px); aspect-ratio: 9 / 16; max-width: calc(100vw - 32px); overflow: hidden; border-radius: 16px; background: #000; box-shadow: 0 30px 80px rgba(0, 0, 0, .7); touch-action: pan-y; user-select: none; }
.rv-media { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--rv-img, none) center / cover; }
.rv-media::before { content: ""; position: absolute; inset: 0; background: rgba(0, 0, 0, .55); -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px); }
.rv-media video, .rv-media img { position: relative; width: 100%; height: 100%; object-fit: cover; }
.rv-horizontal .rv-media video, .rv-horizontal .rv-media img { height: auto; max-height: 100%; object-fit: contain; }
.rv-media iframe { position: relative; width: 100%; height: 100%; border: 0; background: #fff; }
/* Con el reproductor de Instagram (el MP4 ya caducó): entre la cabecera y el pie, para no taparlo */
.rv-iframe .rv-media { top: 92px; bottom: 96px; background: #000; }
.rv-iframe .rv-media::before { display: none; }
.rv-iframe .rv-arriba, .rv-iframe .rv-abajo { background: #000; }
.rv-iframe .rv-abajo { padding-top: 14px; }
.rv-iframe .rv-texto { -webkit-line-clamp: 1; }
.rv-cargando .rv-media::after { content: ""; position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px; border: 3px solid rgba(255, 255, 255, .25); border-top-color: #fd3f00; border-radius: 50%; animation: rv-gira .8s linear infinite; }

.rv-arriba { position: absolute; left: 0; right: 0; top: 0; z-index: 3; padding: 10px 12px 30px; background: linear-gradient(180deg, rgba(0, 0, 0, .6), transparent); }
.rv-barras { display: flex; gap: 4px; }
.rv-barras span { flex: 1; height: 3px; overflow: hidden; border-radius: 3px; background: rgba(255, 255, 255, .3); }
.rv-barras i { display: block; width: 0; height: 100%; background: #fff; }
.rv-barras .rv-vista i { width: 100%; }
.rv-cabeza { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.rv-cabeza img { width: 34px; height: 34px; border-radius: 50%; background: #fff; object-fit: contain; box-shadow: 0 0 0 2px #fd3f00; }
.rv-quien { flex: 1; min-width: 0; line-height: 1.2; }
.rv-quien strong { display: block; font-size: 14px; }
.rv-quien small { display: block; overflow: hidden; color: rgba(255, 255, 255, .75); font-size: 12px; white-space: nowrap; text-overflow: ellipsis; }
.rv-boton { flex: 0 0 auto; display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; background: rgba(0, 0, 0, .35); color: #fff; font-size: 15px; transition: background-color .2s; }
.rv-boton:hover, .rv-boton:focus { background: #fd3f00; outline: 0; }
.rv-boton[hidden] { display: none; }

.rv-abajo { position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; padding: 50px 16px 16px; background: linear-gradient(0deg, rgba(0, 0, 0, .8), transparent); }
.rv-texto { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; margin: 0 0 10px; font-size: 14px; line-height: 1.45; white-space: pre-line; cursor: pointer; }
.rv-texto.rv-largo { display: block; max-height: 40vh; overflow-y: auto; }
.rv-acciones { display: flex; align-items: center; gap: 8px; }
.rv-ig { display: inline-flex; align-items: center; gap: 7px; padding: .5em 1em; border-radius: 2em; background: rgba(255, 255, 255, .16); color: #fff !important; font-size: 12px; font-weight: 700; text-decoration: none !important; transition: background-color .2s; }
.rv-ig:hover { background: #fd3f00; }
.rv-contador { margin-left: auto; color: rgba(255, 255, 255, .7); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Zonas para tocar: izquierda, el anterior; derecha, el siguiente; mantener, pausa */
.rv-zona { position: absolute; top: 90px; bottom: 120px; z-index: 2; width: 34%; padding: 0; border: 0; background: transparent; cursor: pointer; }
.rv-zona:focus { outline: 0; }
.rv-zona-ant { left: 0; }
.rv-zona-sig { right: 0; width: 66%; }
.rv-iframe .rv-zona { width: 14%; }
.rv-iframe .rv-zona-ant { left: 0; }
.rv-pausa { position: absolute; left: 50%; top: 50%; z-index: 2; display: none; align-items: center; justify-content: center; width: 70px; height: 70px; margin: -35px 0 0 -35px; border-radius: 50%; background: rgba(0, 0, 0, .5); font-size: 26px; pointer-events: none; }
.rv-pausado .rv-pausa { display: flex; }
.rv-sonido { position: absolute; left: 50%; top: 96px; z-index: 3; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 8px; padding: .55em 1.1em; border: 0; border-radius: 2em; background: rgba(0, 0, 0, .6); color: #fff; font-size: 13px; font-weight: 700; animation: cal-latido 1.6s ease-in-out infinite; }
.rv-sonido[hidden] { display: none; }

.rv-flecha { position: relative; z-index: 2; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; width: 52px; height: 52px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .14); color: #fff; font-size: 18px; transition: background-color .2s, transform .2s, opacity .2s; }
.rv-flecha:hover:not(:disabled) { background: #fd3f00; transform: scale(1.08); }
.rv-flecha:disabled { opacity: .2; cursor: default; }
.rv-aviso { position: absolute; left: 50%; bottom: 30px; z-index: 5; transform: translateX(-50%); padding: .6em 1.2em; border-radius: 2em; background: #fff; color: #1d1d1b; font-size: 13px; font-weight: 700; box-shadow: 0 10px 30px rgba(0, 0, 0, .4); animation: rv-entra .2s ease both; }

@keyframes rv-entra { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }
@keyframes rv-gira { to { transform: rotate(360deg); } }
.rv-aviso { animation-name: rv-sube; }
@keyframes rv-sube { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

@media (prefers-reduced-motion: reduce) {
    .rv, .rv-aviso { animation: none; }
    .reels-pista { scroll-behavior: auto; }
}

@media (max-width: 767px) {
    .reels-flecha { display: none !important; }
    .reel { flex-basis: 140px; }
}

/* En pantallas anchas, el clip horizontal en un marco horizontal */
@media (min-width: 901px) and (min-height: 521px) {
    .rv-horizontal .rv-marco { width: min(1100px, calc(100vw - 200px)); height: auto; aspect-ratio: 16 / 9; max-height: 90vh; }
    .rv-horizontal .rv-media video, .rv-horizontal .rv-media img { height: 100%; object-fit: contain; }
    .rv-horizontal .rv-zona { top: 80px; bottom: 90px; }
}

/* En el teléfono, a pantalla completa */
@media (max-width: 600px), (max-height: 520px) and (max-width: 900px) {
    .rv { gap: 0; background: #000; }
    .rv-flecha { display: none; }
    .rv-marco { width: 100%; height: 100%; max-width: none; aspect-ratio: auto; border-radius: 0; }
}
.rv-iframe [data-rv="silencio"] { display: none; }
.reels-articulo { margin: 25px 0; padding: 20px 22px 12px; border: 1px solid #e1e1e1; border-radius: 14px; background: #fff; box-shadow: 0 8px 24px rgba(0, 0, 0, .06); }
