/* ======================================================================
   DESIGN TOKENS — marca "TV Premium"
   Negro profundo + dorado metálico, tomados directo del logo (medalla
   dorada con corona sobre fondo negro). El dorado es el único acento;
   todo lo demás se mantiene sobrio para que ese acento se note.
   Tipografía: stack de sistema (máxima compatibilidad en motores de TV).
   Escala: basada en vw sobre referencia 1920px para que se vea igual
   en 1080p y 4K.
   ====================================================================== */
html {
  font-size: 1.0417vw; /* 1rem = 20px @1920px de ancho */
}
@media (max-width: 960px) { html { font-size: 16px; } } /* fallback testing en desktop */

:root {
  --bg: #0A0908;
  --surface: #18120A;
  --surface-2: #241B0E;
  --accent: #E0A93D;
  --accent-bright: #F4CB6E;
  --accent-soft: rgba(224, 169, 61, 0.18);
  --text: #F5F1E8;
  --text-dim: #9C9080;
  --live: #E5484D;
  --radius: 0.6rem;
  --safe: 3.2vw; /* margen de seguridad para overscan de TVs */
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
}

.screen {
  display: none;
  position: absolute;
  inset: 0;
  padding: var(--safe);
}
.screen.active { display: block; }

.status-text { color: var(--text-dim); font-size: 1.1rem; }
.status-text.error { color: var(--live); }
.status-text.small { font-size: 0.9rem; }

/* ---------- Foco (elemento de marca de la app) ----------
   Un resplandor dorado que crece desde abajo, como una bombilla
   de marquesina encendiéndose detrás del ítem seleccionado. */
[data-focusable] {
  outline: none;
  transition: transform 150ms ease, box-shadow 150ms ease;
}
.focused {
  transform: scale(1.08);
  box-shadow: 0 0 0 0.18rem var(--accent), 0 0.6rem 1.4rem var(--accent-soft);
  z-index: 2;
  position: relative;
}

/* ---------- LOGIN ---------- */
#login-screen {
  display: none;
  align-items: center;
  justify-content: center;
}
#login-screen.active { display: flex; }
.login-box {
  width: 30rem;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2.4rem;
  text-align: center;
}
.login-box h1 { font-size: 1.6rem; margin: 0 0 0.3rem; }
.login-box p.subtitle { color: var(--text-dim); margin: 0 0 1.6rem; font-size: 1rem; }

/* ---------- MARCA: TV PREMIUM ---------- */
.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.brand-mark .crown { font-size: 0.95em; line-height: 1; filter: drop-shadow(0 0 0.3rem var(--accent-soft)); }
.brand-mark .word-tv { color: var(--text); }
.brand-mark .word-premium {
  background: linear-gradient(135deg, var(--accent-bright), var(--accent) 60%, #9C7222);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.login-field {
  width: 100%;
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
  border-radius: 0.4rem;
  border: 0.06rem solid var(--surface-2);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1.1rem;
}
.login-field::placeholder { color: var(--text-dim); }
.login-btn {
  width: 100%;
  padding: 0.9rem;
  border: none;
  border-radius: 0.4rem;
  background: var(--accent);
  color: #1A1304;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
}
#login-error { color: var(--live); margin-top: 1rem; font-size: 0.95rem; }
.hidden { display: none !important; }

/* ---------- MENÚ PRINCIPAL ---------- */
.menu-header { margin-bottom: 3rem; }
.menu-header h1 { font-size: 1.6rem; margin: 0; letter-spacing: 0.02em; }
.browse-title span { color: var(--accent); }

.menu-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.4rem;
  max-width: 70rem;
}
.menu-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  height: 9rem;
  border: none;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
}
.menu-icon { font-size: 2.4rem; }

/* ---------- BROWSE (Live / Movies / Series) ---------- */
#browse-screen, #detail-screen, #settings-screen { overflow: hidden; }
.browse-title { font-size: 1.4rem; margin: 0 0 1.4rem; letter-spacing: 0.02em; }

.browse-layout { display: flex; gap: 1.6rem; height: calc(100vh - 8rem); }

.browse-sidebar {
  flex: 0 0 14rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
  padding-right: 0.4rem;
}
.sidebar-item {
  text-align: left;
  padding: 0.7rem 0.9rem;
  border: none;
  border-radius: 0.4rem;
  background: var(--surface);
  color: var(--text-dim);
  font-size: 0.95rem;
  cursor: pointer;
}
.sidebar-item.active { background: var(--surface-2); color: var(--text); font-weight: 600; }

.browse-content { flex: 1; overflow-y: auto; padding: 0.4rem 0.2rem; }

/* Live TV: lista de canales + reproducción incrustada en la misma pantalla */
.browse-content.is-live { display: flex; gap: 1.2rem; overflow: hidden; padding: 0; }
.live-channel-list {
  flex: 0 0 22rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
  padding: 0.4rem 0.3rem 0.4rem 0.2rem;
}
.channel-row.active { box-shadow: inset 0 0 0 0.14rem var(--accent); background: var(--surface-2); }
.channel-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1rem;
  border: none;
  border-radius: 0.4rem;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.channel-logo { width: 3rem; height: 3rem; object-fit: contain; background: var(--surface-2); border-radius: 0.3rem; flex-shrink: 0; }
.channel-name { font-size: 1rem; }

.live-preview {
  flex: 1;
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  min-height: 16rem;
}
.live-preview video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.live-preview.focused { transform: none; box-shadow: inset 0 0 0 0.18rem var(--accent); }
.live-preview-overlay {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.8rem 1rem;
  background: linear-gradient(transparent, rgba(0,0,0,0.85));
}
.live-badge {
  background: var(--live); color: #fff; font-size: 0.65rem; font-weight: 700;
  padding: 0.2rem 0.55rem; border-radius: 0.2rem; letter-spacing: 0.04em;
}
.live-preview-title { font-size: 1rem; font-weight: 600; }
.live-preview-hint {
  position: absolute; top: 0.7rem; right: 0.9rem;
  font-size: 0.75rem; color: var(--text-dim);
  background: rgba(0,0,0,0.55); padding: 0.3rem 0.7rem; border-radius: 0.3rem;
}

/* Movies/Series: grilla de pósters */
.browse-content.is-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 1.1rem;
  align-content: start;
}
.poster-tile {
  border: none;
  border-radius: 0.4rem;
  background: var(--surface);
  padding: 0;
  cursor: pointer;
  overflow: hidden;
}
.poster-img { width: 100%; aspect-ratio: 2/3; object-fit: cover; display: block; background: var(--surface-2); }
.poster-title {
  display: block;
  padding: 0.5rem 0.6rem;
  font-size: 0.85rem;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- DETALLE (Movie / Series) ---------- */
.detail-layout { display: flex; gap: 2.2rem; height: 100%; }
.detail-poster { width: 17rem; aspect-ratio: 2/3; object-fit: cover; border-radius: var(--radius); background: var(--surface); flex-shrink: 0; }
.detail-info { flex: 1; overflow-y: auto; padding-right: 0.4rem; }
.detail-info h1 { font-size: 1.6rem; margin: 0 0 0.4rem; }
.detail-meta { color: var(--text-dim); font-size: 0.95rem; margin: 0 0 1rem; }
.detail-synopsis { font-size: 1rem; line-height: 1.5; max-width: 50rem; margin: 0 0 1.4rem; }
.play-btn {
  padding: 0.8rem 2rem;
  border: none;
  border-radius: 0.4rem;
  background: var(--accent);
  color: #1A1304;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 1.6rem;
}
.season-tabs { display: flex; gap: 0.6rem; margin-bottom: 1rem; flex-wrap: wrap; }
.season-tab {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 0.3rem;
  background: var(--surface);
  color: var(--text-dim);
  font-size: 0.9rem;
  cursor: pointer;
}
.season-tab.active { background: var(--surface-2); color: var(--text); font-weight: 600; }
.episode-list { display: flex; flex-direction: column; gap: 0.5rem; }
.episode-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.6rem 1rem;
  border: none;
  border-radius: 0.4rem;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.episode-num { color: var(--accent); font-weight: 700; width: 1.6rem; }
.episode-title { font-size: 0.95rem; }

/* ---------- SETTINGS ---------- */
.settings-box { max-width: 26rem; }
.settings-row {
  display: flex;
  justify-content: space-between;
  padding: 0.9rem 1rem;
  background: var(--surface);
  border-radius: 0.4rem;
  margin: 0 0 1.4rem;
  font-size: 1rem;
}
.settings-row span { color: var(--text-dim); }
.settings-btn { margin-bottom: 1rem; }
.settings-btn-secondary { background: var(--surface-2); color: var(--text); }

/* ---------- PLAYER ---------- */
#player-screen { display: none; background: #000; padding: 0; }
#player-screen.active { display: block; }
#video-player { width: 100%; height: 100%; object-fit: contain; background: #000; }

#player-buffering {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); font-size: 1.2rem;
}

#player-error {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 0 4rem;
  color: var(--live); font-size: 1.2rem; background: rgba(0,0,0,0.85);
}

#player-controls {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: var(--safe) var(--safe) 1.6rem;
  background: linear-gradient(transparent, rgba(0,0,0,0.92));
  opacity: 0;
  transform: translateY(0.6rem);
  transition: opacity 200ms ease, transform 200ms ease;
  pointer-events: none;
}
#player-controls.visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
#player-title { font-size: 1.3rem; margin: 0 0 0.8rem; }
.progress-row { display: flex; align-items: center; gap: 0.8rem; font-size: 0.9rem; color: var(--text-dim); }
.progress-bar { flex: 1; height: 0.3rem; background: var(--surface-2); border-radius: 0.2rem; overflow: hidden; }
#player-progress-fill { height: 100%; width: 0%; background: var(--accent); }
