/* Reproductor de cgm.soy/videos: capítulos, pantalla completa y móvil. */
:root {
  /* Página clara con la paleta de Kreademy; el reproductor redefine sus colores (oscuro) más abajo. */
  color-scheme: light;
  --fondo: #FAF9FF;
  --panel: #ffffff;
  --panel-2: #F3EFFF;
  --borde: #E7E2F8;
  --texto: #1E1B4B;
  --suave: #625E87;
  --acento: #986EFF;
  --acento-fuerte: #6B3FE6;
  --acento-tinte: rgba(152, 110, 255, .14);
  --radio: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--fondo); color: var(--texto); }
body { font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------ página */
.pagina { max-width: 1440px; margin: 0 auto; padding: 24px; display: grid; gap: 28px; grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.ficha h1 { font-size: 1.35rem; line-height: 1.3; margin: 18px 0 6px; font-weight: 700; letter-spacing: -.01em; color: var(--texto); }
.ficha .desc { color: var(--suave); margin: 0; max-width: 75ch; }

@media (max-width: 1000px) {
  .pagina { grid-template-columns: 1fr; padding: 16px; gap: 12px; }
}
@media (max-width: 640px) {
  .pagina { padding: 0 0 calc(20px + env(safe-area-inset-bottom)); }
  .rep:not(.pc) { border-radius: 0; box-shadow: none; }
  .ficha, .lateral { padding: 0 16px; }
  .ficha h1 { font-size: 1.15rem; margin-top: 12px; }
}

/* ------------------------------------------------------- reproductor */
.rep {
  --texto: #e8ebf1; --suave: #a3a9b8; --acento-tinte: rgba(152, 110, 255, .22); color: #fff;
  box-shadow: 0 12px 36px rgba(30, 27, 75, .16);
  position: relative; background: #000; aspect-ratio: 16 / 9; width: 100%;
  border-radius: var(--radio); overflow: hidden; container-type: inline-size;
  user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; outline: none;
}
.rep video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
.rep video::cue { opacity: 0; }   /* los subtítulos los pinta .rep-subs */
.rep.pc { aspect-ratio: auto; width: 100%; height: 100%; border-radius: 0; }
.rep:fullscreen { aspect-ratio: auto; border-radius: 0; }
.rep.reposo { cursor: none; }
svg { fill: currentColor; }

/* Botón central */
.rep-centro {
  position: absolute; left: 50%; top: 50%; translate: -50% -50%; width: 76px; height: 76px;
  border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer;
  background: rgba(15, 17, 23, .62); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: opacity .2s, scale .2s; z-index: 3;
}
.rep-centro svg { width: 38px; height: 38px; }
.rep-centro:hover { scale: 1.06; }
.rep.reproduciendo .rep-centro { opacity: 0; pointer-events: none; }
.rep.tactil.reproduciendo:not(.reposo) .rep-centro { opacity: 1; pointer-events: auto; }
.rep.reposo .rep-centro { opacity: 0 !important; pointer-events: none !important; }

/* Cargando */
.rep-carga {
  position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; z-index: 2;
  border-radius: 50%; border: 4px solid rgba(255, 255, 255, .2); border-top-color: #fff; animation: gira .8s linear infinite;
}
@keyframes gira { to { rotate: 360deg; } }

/* Saltos ±10 s (doble toque) */
.rep-salto { position: absolute; top: 0; bottom: 0; width: 38%; display: grid; place-items: center; pointer-events: none; opacity: 0; z-index: 2; }
.rep-salto.izq { left: 0; background: radial-gradient(circle at 0 50%, rgba(255,255,255,.14), transparent 70%); }
.rep-salto.der { right: 0; background: radial-gradient(circle at 100% 50%, rgba(255,255,255,.14), transparent 70%); }
.rep-salto span { font-weight: 650; font-size: 15px; background: rgba(0,0,0,.45); padding: 6px 12px; border-radius: 99px; }
.rep-salto.ve { animation: destello .6s ease-out; }
@keyframes destello { 0% { opacity: 0; } 20% { opacity: 1; } 100% { opacity: 0; } }

/* Aviso (reanudar, etc.) */
.rep-aviso {
  position: absolute; left: 50%; top: 14px; translate: -50% 0; z-index: 5; display: flex; gap: 10px; align-items: center;
  background: rgba(15, 17, 23, .85); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  padding: 7px 8px 7px 14px; border-radius: 99px; font-size: 13.5px; white-space: nowrap; max-width: calc(100% - 24px);
}
.rep-aviso button { border: 0; background: var(--acento); color: #fff; border-radius: 99px; padding: 3px 12px; cursor: pointer; font-weight: 600; }

/* Subtítulos */
.rep-subs {
  position: absolute; left: 5%; right: 5%; bottom: 7%; z-index: 2; text-align: center; pointer-events: none;
  font-size: clamp(14px, 2.7cqw, 34px); line-height: 1.35; transition: bottom .2s;
}
.rep:not(.reposo) .rep-subs.sube { bottom: calc(7% + 64px); }
.rep-subs span {
  background: rgba(0, 0, 0, .78); padding: .1em .45em; border-radius: .2em;
  box-decoration-break: clone; -webkit-box-decoration-break: clone; white-space: pre-line;
}

/* ------------------------------------------------------------ controles */
.rep-controles {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 4;
  padding: 36px 12px max(6px, env(safe-area-inset-bottom)); transition: opacity .25s;
  background: linear-gradient(to top, rgba(0,0,0,.82), rgba(0,0,0,.45) 55%, transparent);
}
.rep.pc .rep-controles { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); padding-bottom: max(10px, env(safe-area-inset-bottom)); }
.rep.reposo .rep-controles { opacity: 0; pointer-events: none; }

.rep-barra { position: relative; height: 22px; display: flex; align-items: center; cursor: pointer; touch-action: none; outline: none; }
.rep-tramos { display: flex; gap: 3px; width: 100%; height: 4px; transition: height .12s; }
.rep-barra:hover .rep-tramos, .rep-barra.arrastra .rep-tramos, .rep-barra:focus-visible .rep-tramos { height: 7px; }
.tramo { position: relative; height: 100%; background: rgba(255, 255, 255, .26); border-radius: 2px; overflow: hidden; }
.tramo .buf, .tramo .hecho { position: absolute; left: 0; top: 0; bottom: 0; width: 0; }
.tramo .buf { background: rgba(255, 255, 255, .35); }
.tramo .hecho { background: var(--acento); }
.tramo.encima { background: rgba(255, 255, 255, .42); }
.rep-bola {
  position: absolute; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%;
  background: var(--acento); box-shadow: 0 0 0 3px rgba(152,110,255,.3); scale: 0; transition: scale .12s; pointer-events: none;
}
.rep-barra:hover .rep-bola, .rep-barra.arrastra .rep-bola, .rep.tactil .rep-bola, .rep-barra:focus-visible .rep-bola { scale: 1; }
.rep-globo {
  position: absolute; bottom: 26px; translate: -50% 0; pointer-events: none; text-align: center; white-space: nowrap;
  background: rgba(15, 17, 23, .92); border-radius: 8px; padding: 5px 10px; font-size: 13px; max-width: 70cqw;
}
.rep-globo b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.rep-globo b:empty { display: none; }
.rep-globo span { color: var(--suave); font-variant-numeric: tabular-nums; }

.rep-fila { display: flex; align-items: center; gap: 2px; height: 44px; }
.b {
  flex: none; width: 42px; height: 42px; border: 0; background: none; border-radius: 10px; cursor: pointer;
  display: grid; place-items: center; padding: 0; color: #fff;
}
.b svg { width: 24px; height: 24px; }
.b:hover, .rep-cap:hover { background: rgba(255, 255, 255, .12); }
.b:focus-visible, .rep-cap:focus-visible, .rep-centro:focus-visible { outline: 2px solid var(--acento); outline-offset: 1px; }
.b[aria-pressed="true"] { color: var(--acento); }
.b-vel { width: auto; min-width: 42px; padding: 0 6px; font-weight: 650; font-size: 14px; font-variant-numeric: tabular-nums; }
.rep-vol { display: flex; align-items: center; }
.rep-vol input { width: 0; opacity: 0; transition: width .2s, opacity .2s; accent-color: #fff; margin: 0; }
.rep-vol:hover input, .rep-vol:focus-within input { width: 72px; opacity: 1; margin: 0 6px 0 2px; }
@media (hover: none) { .rep-vol input { display: none; } }
.rep-tiempo { flex: none; font-size: 13.5px; font-variant-numeric: tabular-nums; padding: 0 8px; color: #dfe3ea; white-space: nowrap; }
.rep-cap {
  flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 2px; height: 36px; border: 0; background: none;
  border-radius: 10px; cursor: pointer; padding: 0 6px 0 10px; color: #fff; font-size: 14px; font-weight: 550; justify-content: flex-start;
}
.rep-cap span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rep-cap span::before { content: "•"; color: var(--suave); margin-right: 8px; }
.rep-cap svg { width: 16px; height: 16px; flex: none; opacity: .7; }
.hueco { flex: 1 1 auto; }

@container (max-width: 560px) {
  .solo-ancho { display: none; }
  .rep-tiempo { font-size: 12.5px; padding: 0 4px; }
  .rep-cap { font-size: 13px; padding-left: 4px; }
  .rep-cap span::before { margin-right: 5px; }
  .b { width: 38px; height: 38px; }
  .b svg { width: 22px; height: 22px; }
  .rep-controles { padding: 30px 6px max(2px, env(safe-area-inset-bottom)); }
  .rep-centro { width: 62px; height: 62px; }
  .rep-centro svg { width: 30px; height: 30px; }
}
@container (max-width: 440px) {
  .rep-controles { padding-top: 22px; }
  .rep.tactil .rep-vol { display: none; }
  .rep-menu { bottom: 62px; max-height: calc(100% - 72px); }
  .rep-menu button { padding: 7px 10px; }
}
@container (max-width: 340px) {
  .rep-tiempo .total, .b-vel { display: none; }
}

/* Menú de capítulos dentro del reproductor (útil a pantalla completa) */
.rep-menu {
  position: absolute; right: 10px; bottom: 76px; z-index: 6; width: min(360px, calc(100% - 20px));
  max-height: calc(100% - 96px); overflow: auto; overscroll-behavior: contain;
  background: rgba(20, 23, 31, .96); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-radius: 12px; padding: 6px; box-shadow: 0 10px 40px rgba(0,0,0,.5);
}
.rep-menu button {
  display: grid; grid-template-columns: 1fr auto; gap: 12px; width: 100%; text-align: left; border: 0; background: none;
  padding: 9px 10px; border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--texto);
}
.rep-menu button:hover { background: rgba(255,255,255,.08); }
.rep-menu button.activo { background: var(--acento-tinte); color: #fff; }
.rep-menu .t { color: var(--suave); font-variant-numeric: tabular-nums; }

/* ------------------------------------------- columna: logo, versiones, capítulos */
.lateral { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 24px; max-height: calc(100dvh - 48px); overflow: auto; }
.logo { padding: 6px 6px 2px; }
.logo img { display: block; width: 100%; max-width: 250px; height: auto; }
.bloque { background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio); padding: 8px; }
.bloque h2 { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--suave); margin: 8px 10px 6px; font-weight: 700; }
.bloque h2 span { background: var(--panel-2); border-radius: 99px; padding: 1px 8px; margin-left: 4px; letter-spacing: 0; }
.bloque ul, .bloque ol { list-style: none; margin: 0; padding: 0; }
a:focus-visible { outline: 2px solid var(--acento-fuerte); outline-offset: 2px; }

.versiones .opcion {
  display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; align-items: center;
  padding: 10px; border-radius: 10px; color: var(--texto); text-decoration: none; font-weight: 550; line-height: 1.3;
}
.versiones .opcion svg { width: 22px; height: 22px; color: var(--suave); }
.versiones a.opcion:hover { background: var(--panel-2); }
.versiones .opcion.activa { background: var(--acento-tinte); color: var(--acento-fuerte); font-weight: 650; }
.versiones .opcion.activa svg { color: var(--acento-fuerte); }
.versiones .opcion.desactivada { color: #9a97b5; cursor: not-allowed; }
.versiones .opcion.desactivada svg { color: #b9b6cf; }
.versiones .pronto { font-size: 11.5px; font-weight: 600; background: var(--panel-2); color: var(--suave); border-radius: 99px; padding: 2px 8px; white-space: nowrap; }

/* ------------------------------------------------- lista de capítulos */
.capitulos a {
  position: relative; display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: baseline;
  padding: 11px 10px; border-radius: 10px; color: var(--texto); text-decoration: none; overflow: hidden;
}
.capitulos a:hover { background: var(--panel-2); }
.capitulos a.activo { background: var(--acento-tinte); }
.capitulos .num { color: var(--suave); font-size: 13px; font-variant-numeric: tabular-nums; text-align: right; }
.capitulos a.activo .num, .capitulos a.visto .num { color: var(--acento-fuerte); font-weight: 700; }
.capitulos .tit { font-weight: 550; }
.capitulos .t { color: var(--suave); font-size: 13px; font-variant-numeric: tabular-nums; }
.capitulos .avance { position: absolute; left: 0; bottom: 0; height: 2px; width: 0; background: var(--acento); }
/* Muchos capítulos (12-11-2026): lista compacta para que quepa sin desplazarse. ver.php pone .compacta con 11 o más
   capítulos y además .densa con 18 o más. El título va en una línea, con puntos suspensivos y el texto entero en title. */
.capitulos.compacta h2 { margin: 6px 10px 4px; }
.capitulos.compacta a { grid-template-columns: 20px 1fr auto; gap: 8px; padding: 5px 10px; border-radius: 8px; font-size: 14.5px; line-height: 1.25; }
.capitulos.compacta .tit { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.capitulos.compacta a.activo .tit { font-weight: 650; }
.capitulos.compacta .num, .capitulos.compacta .t { font-size: 12px; }
.capitulos.densa a { padding: 3px 10px; font-size: 14px; }
@media (max-width: 1000px) {
  .lateral { position: static; max-height: none; overflow: visible; }
  .logo img { max-width: 200px; }
}
