/* === Variables globales === */
:root {
  --bg:    #000000;
  --green: #00FF41;
  --white: #FFFFFF;
}

/* === Reset básico === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--green);
  font-family: 'VT323', monospace;
  overflow: hidden;
  user-select: none;
}

.hidden {
  display: none !important;
}

/* === Interfaz principal de TV === */
#tv-interface {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* === Info del canal (arriba izquierda) === */
#channel-info {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 100;
  line-height: 1.3;
  transition: opacity 0.4s;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.85));
}

#channel-number {
  font-size: 1.8rem;
  color: #FFDE21;
  text-shadow: 0 0 10px rgba(255,222,33,0.8);
  letter-spacing: 0.05em;
}

#video-title {
  font-size: 1.3rem;
  color: #FFDE21;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  max-width: 60vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#title-dot {
  color: #FFDE21;
  animation: blink 1s step-end infinite;
  flex-shrink: 0;
}

/* === Contenedor del reproductor === */
/* El tamaño real de #player-wrapper (ancho/alto o aspect-ratio) lo calcula
   applyPlayerAspect() en tv.js según el ratio nativo del vídeo (PC, contain-fit
   dentro de la pantalla) o forzado a 4:3 a sangre (móvil). Los valores de aquí
   son solo el estado inicial antes de que el JS los sobreescriba. */
#player-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#player-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.6s ease;
  /* Aísla este árbol del layout del resto de la página → mejor rendimiento */
  contain: layout style;
}

#player-wrapper.visible {
  opacity: 1;
}

#players-container {
  position: absolute;
  inset: 0;
}

/* Cada canal ocupa todo el contenedor. will-change: transform fuerza
   capa GPU propia → los canales en background siguen reproduciéndose.
   background: #000 impide que el canvas del CH10 (último en el DOM) se
   cuele a través de canales sin vídeo cargado aún. */
.yt-player {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  pointer-events: none;
  z-index: 0;
  will-change: transform;
}

.yt-player.active {
  z-index: 1;
}

/* El <video> (o canvas del CH10) ocupa todo el hueco del canal. */
.yt-player > * {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  border: none !important;
  pointer-events: none !important;
}

.yt-player > video {
  object-fit: contain;
  background: #000;
}

/* Overlay: bloquea el ratón para que YouTube nunca detecte hover.
   .covering se activa durante seekTo del bucle para tapar el frame congelado
   y el spinner de carga — desaparece en cuanto PLAYING vuelve a disparar. */
#player-overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  cursor: default;
  background: transparent;
  transition: background 0.1s ease;
}

#player-overlay.covering {
  background: #000;
}

/* Canvas para efecto estática entre canales */
#static-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
  display: none;
}

/* Overlay de mala señal (fondo) */
#bad-signal {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(255, 255, 255, 0.03) 49%,
    rgba(0, 0, 0, 0.05) 51%,
    transparent 100%
  );
}

/* === Barra de volumen === */
#volume-bar {
  position: fixed;
  bottom: 2rem;
  left: 2rem;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  z-index: 200;
  background: rgba(0, 0, 0, 0.8);
  border: 1px solid rgba(0, 255, 65, 0.35);
  padding: 0.35rem 0.7rem 0.3rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

#volume-bar.visible { opacity: 1; }

#vol-number {
  font-family: 'VT323', monospace;
  font-size: 2rem;
  color: var(--green);
  text-shadow: 0 0 8px var(--green);
  min-width: 2.2rem;
  text-align: right;
  line-height: 1;
}

#vol-segments {
  display: flex;
  align-items: center;
  gap: 2px;
}

.vol-seg {
  width: 3px;
  height: 18px;
  background: rgba(0, 255, 65, 0.12);
  flex-shrink: 0;
}

.vol-seg.lit {
  background: var(--green);
  box-shadow: 0 0 4px var(--green);
}

/* === Mando a distancia — diseño vectorial minimal === */
#remote {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: rgba(15, 15, 15, 0.55);
  border-radius: 12px;
  padding: 0.6rem 0.65rem;
  z-index: 100;
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px);
}

#remote-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.3rem;
}

.remote-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.82);
  font-family: 'VT323', monospace;
  font-size: 1.2rem;
  width: 38px;
  height: 38px;
  border-radius: 7px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, border-color 0.1s, color 0.1s, transform 0.08s;
  line-height: 1;
}

.remote-btn svg {
  width: 18px;
  height: 18px;
}

.remote-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(0, 255, 65, 0.5);
  color: #fff;
}

.remote-btn:active {
  transform: scale(0.90);
  background: rgba(0, 255, 65, 0.12);
  border-color: var(--green);
  color: var(--green);
}

.power-btn {
  color: #ff4444;
  border-color: rgba(255, 68, 68, 0.3);
}

.teletext-btn {
  color: #00ccff;
  border-color: rgba(0, 204, 255, 0.3);
}

.mute-btn .mute-slash { display: none; }
.mute-btn.muted .mute-wave { display: none; }
.mute-btn.muted .mute-slash { display: inline; }
.mute-btn.muted {
  color: #ff4444;
  border-color: rgba(255, 68, 68, 0.3);
}

.num-btn {
  font-size: 1.15rem;
  color: rgba(200, 200, 200, 0.75);
}

/* ═══════════════════════════════════════════════════════════
   CH10 — INSTRUCCIONES
   ═══════════════════════════════════════════════════════════ */

#ch10-instructions {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

#ch10-instructions.hidden {
  display: none !important;
}

.ch10-card {
  background: rgba(0, 0, 0, 0.82);
  border: 2px solid rgba(255, 255, 255, 0.12);
  padding: 1.6rem 2.2rem 1.4rem;
  font-family: 'VT323', monospace;
  text-align: center;
  min-width: 22ch;
  backdrop-filter: blur(2px);
}

.ch10-title {
  font-size: 2.6rem;
  color: #FFDE21;
  text-shadow: 0 0 14px rgba(255, 222, 33, 0.7);
  letter-spacing: 0.12em;
  line-height: 1;
  margin-bottom: 0.1rem;
}

.ch10-sub {
  font-size: 1.2rem;
  color: rgba(255, 255, 255, 0.45);
  letter-spacing: 0.08em;
  margin-bottom: 0.6rem;
}

.ch10-sep {
  height: 1px;
  background: rgba(255, 255, 255, 0.15);
  margin: 0.55rem 0;
}

.ch10-row {
  display: flex;
  align-items: baseline;
  gap: 1.2rem;
  font-size: 1.4rem;
  color: #fff;
  line-height: 1.55;
}

.ch10-key {
  min-width: 5ch;
  text-align: left;
  color: #FFDE21;
  flex-shrink: 0;
}

.ch10-desc {
  text-align: left;
  color: rgba(255, 255, 255, 0.85);
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.ch10-mobile {
  font-size: 1.05rem;
  color: rgba(255, 255, 255, 0.4);
  letter-spacing: 0.05em;
  margin-top: 0.1rem;
}

/* Desktop: ocultar nota móvil */
@media (pointer: fine) {
  .ch10-mobile { display: none; }
}

/* Móvil: ocultar fila "1–9", compactar la tarjeta para que quepa en 4:3 */
@media (pointer: coarse) {
  .ch10-row--desktop { display: none; }

  .ch10-card {
    padding: 0.7rem 1.3rem 0.6rem;
    min-width: 0;
  }
  .ch10-title  { font-size: 2rem;  margin-bottom: 0; }
  .ch10-sub    { font-size: 0.95rem; margin-bottom: 0.2rem; }
  .ch10-sep    { margin: 0.25rem 0; }
  .ch10-row    { font-size: 1.15rem; line-height: 1.35; gap: 0.9rem; }
  .ch10-key    { min-width: 4ch; }
  .ch10-mobile { font-size: 0.88rem; margin-top: 0; }
}

/* ═══════════════════════════════════════════════════════════
   BLOQUEO ORIENTACIÓN HORIZONTAL (MÓVIL)
   ═══════════════════════════════════════════════════════════ */

#rotate-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 99999;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.2rem;
  pointer-events: all;
}

#rotate-icon {
  font-size: 5rem;
  color: #FFDE21;
  text-shadow: 0 0 20px rgba(255,222,33,0.6);
  animation: rotate-hint 2s ease-in-out infinite;
}

#rotate-text {
  font-family: 'VT323', monospace;
  font-size: 2.2rem;
  color: #FFDE21;
  letter-spacing: 0.08em;
  opacity: 0.85;
}

@keyframes rotate-hint {
  0%, 100% { transform: rotate(-15deg); }
  50%       { transform: rotate(15deg); }
}

@media (pointer: coarse) and (orientation: landscape) {
  #rotate-overlay { display: flex; }
}

/* ═══════════════════════════════════════════════════════════
   MÓVIL — barra fija en la parte inferior, solo iconos de control
   ═══════════════════════════════════════════════════════════ */

/* En móvil: solo teletext, power, restart, mute, ch-up, ch-down */
@media (pointer: coarse) {
  .num-btn,
  [data-action="fullscreen"],
  [data-action="vol-up"],
  [data-action="vol-down"] { display: none !important; }
}

body[data-touch] .num-btn,
body[data-touch] [data-action="fullscreen"],
body[data-touch] [data-action="vol-up"],
body[data-touch] [data-action="vol-down"] {
  display: none !important;
}

body[data-touch] #player-container {
  padding-bottom: 4.5rem;
}

body[data-touch] #volume-bar {
  bottom: 5.5rem;
  left: 50%;
  transform: translateX(-50%);
}

body[data-touch] #remote {
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.72);
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow: none;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: 0;
  padding: 0.55rem 1rem calc(0.55rem + env(safe-area-inset-bottom, 0px));
  display: flex;
  justify-content: center;
  align-items: center;
}

body[data-touch] #remote-grid {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 0.5rem;
}

body[data-touch] .remote-btn {
  width: 40px;
  height: 40px;
  font-size: 1.2rem;
  border-radius: 8px;
  flex-shrink: 0;
}

