/* Reproductor: base común + ajustes por modo (pl--pc, pl--mobile, pl--tv) */
.pl {
  --pl-accent: #e5383b;
  --pl-text: #fff;
  --pl-muted: rgba(255, 255, 255, .72);
  --pl-btn: 44px;
  --pl-icon: 26px;
  --pl-pad: 24px;
  --pl-font: 15px;
  position: fixed; inset: 0; z-index: 80; background: #000; color: var(--pl-text);
  font-size: var(--pl-font); user-select: none; -webkit-user-select: none; outline: none;
  -webkit-tap-highlight-color: transparent;
}
.pl[hidden] { display: none; }
.pl video { position: absolute; inset: 0; width: 100%; height: 100%; background: #000; object-fit: contain; }

/* Degradados arriba y abajo, solo con los controles visibles */
.pl-shade {
  position: absolute; inset: 0; pointer-events: auto; opacity: 0; transition: opacity .25s;
  background: linear-gradient(180deg, rgba(0,0,0,.65) 0%, transparent 22%, transparent 62%, rgba(0,0,0,.8) 100%);
}
.pl-top, .pl-bottom, .pl-center { position: absolute; left: 0; right: 0; opacity: 0; pointer-events: none; transition: opacity .25s; }
.pl.ui-visible .pl-shade, .pl.ui-visible .pl-top, .pl.ui-visible .pl-bottom, .pl.ui-visible .pl-center { opacity: 1; }
.pl.ui-visible .pl-top, .pl.ui-visible .pl-bottom { pointer-events: auto; }
.pl.ui-visible { cursor: default; }
.pl:not(.ui-visible) { cursor: none; }

.pl-top { top: 0; display: flex; align-items: center; gap: 12px; padding: var(--pl-pad); padding-top: max(var(--pl-pad), env(safe-area-inset-top)); }
.pl-title { font-weight: 700; font-size: 1.15em; text-shadow: 0 1px 4px #000; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-bottom { bottom: 0; padding: 0 var(--pl-pad) var(--pl-pad); padding-bottom: max(var(--pl-pad), env(safe-area-inset-bottom)); }

/* Botones */
.pl-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: var(--pl-btn); height: var(--pl-btn); padding: 0 6px; border: 0; border-radius: 999px;
  background: transparent; color: inherit; cursor: pointer; font: inherit; transition: transform .12s, background .15s;
}
.pl-btn svg { width: var(--pl-icon); height: var(--pl-icon); fill: currentColor; }
.pl-btn svg text { fill: currentColor; font-family: system-ui, sans-serif; }
.pl-btn:hover { background: rgba(255,255,255,.12); }
.pl-btn:active { transform: scale(.92); }
.pl-btn:focus-visible, .pl-menu-item:focus-visible, .pl-btn-text:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.pl-btn-label { font-weight: 600; }
.pl-btn[hidden], .pl-volume input[hidden] { display: none; }

.pl-center { top: 50%; transform: translateY(-50%); display: flex; align-items: center; justify-content: center; gap: 56px; pointer-events: none; }
/* Los botones centrales solo responden con los controles visibles (si no, un toque pausaba sin querer) */
.pl.ui-visible .pl-center .pl-btn { pointer-events: auto; }
.pl-big { --pl-btn: 64px; --pl-icon: 40px; background: rgba(0,0,0,.35); }
.pl-main { --pl-btn: 84px; --pl-icon: 52px; }

/* Barra de progreso */
.pl-progress { position: relative; height: 22px; display: flex; align-items: center; margin-bottom: 6px; }
.pl-track { position: absolute; left: 0; right: 0; height: 4px; border-radius: 4px; background: rgba(255,255,255,.25); overflow: hidden; transition: height .15s; }
.pl-buffered { position: absolute; inset: 0 auto 0 0; background: rgba(255,255,255,.4); }
.pl-played { position: absolute; inset: 0 auto 0 0; background: var(--pl-accent); }
.pl-progress:hover .pl-track, .pl-seek:focus-visible ~ .pl-track { height: 6px; }
.pl-seek {
  position: relative; width: 100%; height: 22px; margin: 0; background: transparent; cursor: pointer;
  -webkit-appearance: none; appearance: none;
}
.pl-seek::-webkit-slider-runnable-track { background: transparent; height: 22px; }
.pl-seek::-moz-range-track { background: transparent; }
.pl-seek::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: 3px; border-radius: 50%; background: var(--pl-accent); box-shadow: 0 0 0 3px rgba(229,56,59,.3); }
.pl-seek::-moz-range-thumb { width: 16px; height: 16px; border: 0; border-radius: 50%; background: var(--pl-accent); }
.pl-seek:focus-visible { outline: 3px solid #fff; outline-offset: 4px; border-radius: 6px; }
.pl-preview {
  position: absolute; bottom: 28px; transform: translateX(-50%); padding: 4px 8px; border-radius: 4px;
  background: rgba(0,0,0,.85); font-weight: 700; font-variant-numeric: tabular-nums; pointer-events: none;
}

.pl-row { display: flex; align-items: center; gap: 6px; }
.pl-spacer { flex: 1; }
.pl-time { font-variant-numeric: tabular-nums; color: var(--pl-muted); margin-left: 8px; white-space: nowrap; }
.pl-volume { display: flex; align-items: center; }
.pl-vol {
  width: 0; opacity: 0; margin: 0; transition: width .2s, opacity .2s; cursor: pointer; accent-color: #fff;
  -webkit-appearance: none; appearance: none; height: 4px; border-radius: 4px;
  background: linear-gradient(90deg, #fff var(--p, 100%), rgba(255,255,255,.3) var(--p, 100%));
}
.pl-vol::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: #fff; }
.pl-vol::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: #fff; }
.pl-volume:hover .pl-vol, .pl-vol:focus-visible { width: 90px; opacity: 1; margin: 0 8px; }

/* Menú de audio */
.pl-menu {
  position: absolute; z-index: 5; right: var(--pl-pad); bottom: 96px; min-width: 240px; max-height: 60vh; overflow: auto;
  padding: 10px 0; border-radius: 10px; background: rgba(20,20,26,.96); box-shadow: 0 12px 40px rgba(0,0,0,.6);
}
.pl-menu[hidden] { display: none; }
.pl-menu-title { padding: 6px 18px 10px; font-weight: 700; color: var(--pl-muted); font-size: .85em; text-transform: uppercase; letter-spacing: .06em; }
.pl-menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 18px; border: 0; background: none;
  color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.pl-menu-item:hover, .pl-menu-item:focus-visible { background: rgba(255,255,255,.1); }
.pl-menu-item.active { font-weight: 700; }
.pl-check { width: 1.2em; color: var(--pl-accent); font-weight: 800; }

/* Carga y error */
.pl-loading { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; pointer-events: none; }
.pl-loading[hidden] { display: none; }
.pl-spinner { width: 52px; height: 52px; border: 4px solid rgba(255,255,255,.2); border-top-color: var(--pl-accent); border-radius: 50%; animation: pl-spin .8s linear infinite; }
.pl-status { margin: 0; color: var(--pl-muted); text-shadow: 0 1px 3px #000; min-height: 1.2em; }
@keyframes pl-spin { to { transform: rotate(360deg); } }
.pl-error {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(520px, calc(100% - 32px));
  padding: 28px; border-radius: 12px; background: #15151c; text-align: center; z-index: 6;
}
.pl-error[hidden] { display: none; }
.pl-error h3 { margin: 0 0 10px; font-size: 1.3em; }
.pl-error p { color: var(--pl-muted); line-height: 1.5; }
.pl-error-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 18px; }
.pl-btn-text {
  padding: 10px 20px; border: 0; border-radius: 6px; background: #fff; color: #000; font: inherit; font-weight: 700;
  cursor: pointer; text-decoration: none;
}
.pl-btn-text + .pl-btn-text { background: rgba(120,120,135,.55); color: #fff; }
.pl-btn-text[hidden] { display: none; }

/* Ondas del doble toque (celular) */
.pl-ripple {
  position: absolute; top: 0; bottom: 0; width: 38%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; opacity: 0; pointer-events: none; font-weight: 700; background: rgba(255,255,255,.08);
}
.pl-ripple svg { width: 40px; height: 40px; fill: #fff; }
.pl-ripple--left { left: 0; border-radius: 0 50% 50% 0; }
.pl-ripple--right { right: 0; border-radius: 50% 0 0 50%; }
.pl-ripple.show { animation: pl-ripple .6s ease-out; }
@keyframes pl-ripple { 0% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- PC ---------- */
.pl--pc .pl-center { display: none; }
.pl--pc.paused .pl-center { display: flex; }
.pl--pc .pl-center .pl-skip { display: none; }

/* ---------- Celular ---------- */
.pl--mobile { --pl-pad: 14px; --pl-btn: 44px; --pl-icon: 24px; }
.pl--mobile .pl-row .pl-play, .pl--mobile .pl-row [data-act="back10"], .pl--mobile .pl-row [data-act="fwd10"] { display: none; }
.pl--mobile .pl-time { margin-left: 0; font-size: .9em; }
.pl--mobile .pl-cur, .pl--mobile .pl-sep { display: none; }
.pl--mobile .pl-progress { height: 30px; }
.pl--mobile .pl-seek, .pl--mobile .pl-seek::-webkit-slider-runnable-track { height: 30px; }
.pl--mobile .pl-seek::-webkit-slider-thumb { width: 20px; height: 20px; margin-top: 5px; }
.pl--mobile .pl-center { gap: 44px; }
.pl--mobile .pl-menu {
  left: 0; right: 0; bottom: 0; min-width: 0; max-height: 70%; border-radius: 16px 16px 0 0;
  padding-bottom: max(14px, env(safe-area-inset-bottom)); animation: pl-sheet .22s ease-out;
}
.pl--mobile .pl-menu-item { padding: 16px 22px; font-size: 1.05em; }
@keyframes pl-sheet { from { transform: translateY(100%); } }
@media (orientation: portrait) {
  /* (solo aplica si el reproductor no está girado) */
  .pl--mobile:not(.pl-rotated) .pl-center { gap: 28px; }
  .pl--mobile:not(.pl-rotated) .pl-big { --pl-btn: 54px; --pl-icon: 32px; }
  .pl--mobile:not(.pl-rotated) .pl-main { --pl-btn: 70px; --pl-icon: 44px; }
}

/* ---------- TV (se ve a 3 metros) ---------- */
.pl--tv { --pl-pad: 48px; --pl-btn: 72px; --pl-icon: 40px; --pl-font: 24px; }
.pl--tv .pl-center { display: none; }
.pl--tv.paused .pl-center { display: flex; }
.pl--tv .pl-center .pl-skip { display: none; }
.pl--tv .pl-btn { background: rgba(255,255,255,.08); }
.pl--tv .pl-btn:focus, .pl--tv .pl-menu-item:focus, .pl--tv .pl-btn-text:focus {
  outline: none; background: #fff; color: #000; transform: scale(1.1); box-shadow: 0 0 0 4px rgba(255,255,255,.35);
}
.pl--tv .pl-btn:focus svg text { fill: #000; }
.pl--tv .pl-progress { height: 40px; margin-bottom: 18px; }
.pl--tv .pl-track { height: 8px; }
.pl--tv .pl-seek { height: 40px; }
.pl--tv .pl-seek:focus { outline: none; }
.pl--tv .pl-seek:focus ~ .pl-track { height: 14px; box-shadow: 0 0 0 4px rgba(255,255,255,.5); }
.pl--tv .pl-seek::-webkit-slider-thumb { width: 28px; height: 28px; margin-top: 6px; }
.pl--tv .pl-row { gap: 18px; }
.pl--tv .pl-menu { right: 48px; bottom: 150px; min-width: 380px; }
.pl--tv .pl-menu-item { padding: 18px 26px; }
.pl--tv .pl-title { font-size: 1.3em; }

/* Celular en vertical: el reproductor se dibuja girado para verse siempre en horizontal */
.pl--mobile.pl-rotated {
  inset: auto; top: 0; left: 0;
  width: 100vh; height: 100vw;
  width: 100dvh; height: 100dvw;
  transform-origin: top left;
  transform: translateX(100vw) rotate(90deg);
  transform: translateX(100dvw) rotate(90deg);
}
.pl--mobile.pl-rotated .pl-center { gap: 56px; }
.pl--mobile.pl-rotated .pl-big { --pl-btn: 64px; --pl-icon: 40px; }
.pl--mobile.pl-rotated .pl-main { --pl-btn: 84px; --pl-icon: 52px; }
.pl--mobile.pl-rotated .pl-menu { max-height: 80%; }

/* Aviso cuando el sistema bloqueó el sonido */
.pl-unmute {
  position: absolute; z-index: 7; left: 50%; top: 18%; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 10px; padding: 12px 20px; border: 0; border-radius: 999px;
  background: #fff; color: #000; font: inherit; font-weight: 700; cursor: pointer; box-shadow: 0 6px 24px rgba(0,0,0,.5);
}
.pl-unmute[hidden] { display: none; }
.pl-unmute svg { width: 22px; height: 22px; fill: currentColor; }

/* Subtítulos (capa propia: mismo aspecto en PC, celular y TV) */
.pl-subs {
  position: absolute; left: 5%; right: 5%; bottom: 7%; z-index: 1; display: flex; justify-content: center;
  pointer-events: none; transition: bottom .25s;
}
.pl-subs span {
  display: none; max-width: 100%; padding: .15em .5em; border-radius: 4px; background: rgba(0,0,0,.6);
  color: #fff; text-align: center; white-space: pre-line; line-height: 1.3; font-weight: 600;
  font-size: clamp(16px, 3.6vh, 34px); text-shadow: 0 1px 2px #000;
}
.pl-subs.on span { display: inline-block; }
.pl.ui-visible .pl-subs { bottom: 120px; }
.pl--tv .pl-subs span { font-size: clamp(24px, 4.2vh, 48px); }
.pl--tv.ui-visible .pl-subs { bottom: 200px; }
.pl--mobile.pl-rotated .pl-subs span { font-size: clamp(16px, 3.6vw, 30px); }

/* Menú de audio y subtítulos: dos columnas */
.pl-menu { display: flex; gap: 8px; }
.pl-menu[hidden] { display: none; }
.pl-menu-col { min-width: 200px; }
.pl-menu-col[hidden] { display: none; }
.pl--mobile .pl-menu { flex-direction: row; overflow-x: auto; }
@media (max-width: 520px) { .pl--mobile:not(.pl-rotated) .pl-menu { flex-direction: column; } }
