/* Cámara de casa — estilos. Pensado para personas mayores: letra grande, contraste alto,
   botones grandes y un foco bien visible para manejarlo con el control remoto de la TV. */

:root {
  --fondo: #15110e;
  --superficie: #221b16;
  --superficie-2: #2e251e;
  --superficie-3: #3b3028;
  --borde: #57473a;
  --texto: #fbf5ec;
  --texto-suave: #d9ccbb;
  --acento: #f2a93b;
  --acento-texto: #1d1408;
  --foco: #ffd23f;
  --error-fondo: #4a1f19;
  --error-texto: #ffc2b8;
  --velo: rgba(0, 0, 0, 0.72);
  --velo-suave: rgba(15, 11, 8, 0.6);
  --radio: 20px;
  --separacion: 12px;

  /* Valores para navegadores viejos de TV (sin clamp). */
  --tam-letra: 20px;
  --tam-boton: 64px;
  --tam-dpad: 88px;
  --tam-dpad-pc: 64px;
  --tam-pie: 14px;
}

@media (min-width: 1100px) {
  :root {
    --tam-letra: 30px;
    --tam-boton: 96px;
    --tam-dpad: 110px;
    --tam-dpad-pc: 80px;
    --tam-pie: 17px;
  }
}

@supports (width: clamp(1px, 2px, 3px)) {
  :root {
    --tam-letra: clamp(20px, 12px + 1.1vw, 34px);
    --tam-boton: clamp(64px, 40px + 3vw, 104px);
    --tam-dpad: clamp(76px, 24vw, 120px);
    --tam-dpad-pc: clamp(48px, 7.5vh, 96px);
    --tam-pie: clamp(13px, 10px + 0.4vw, 18px);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--fondo);
  color: var(--texto);
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: var(--tam-letra);
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

.titulo {
  margin: 0;
  font-size: 1.3em;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.ayuda {
  margin: 0;
  color: var(--texto-suave);
  text-align: center;
}

/* ---------- Botones ---------- */

.boton {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--tam-boton);
  min-height: var(--tam-boton);
  padding: 0.25em 0.9em;
  font: inherit;
  font-weight: 600;
  color: var(--texto);
  background: var(--superficie-2);
  border: 3px solid var(--borde);
  border-radius: var(--radio);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.15s ease, opacity 0.15s ease;
}

.boton:hover { background: var(--superficie-3); }

.boton:active,
.boton.apretado {
  background: var(--acento);
  border-color: var(--acento);
  color: var(--acento-texto);
}

.boton.ocupado { opacity: 0.6; }
.boton[aria-disabled="true"] { opacity: 0.45; }

/* Foco muy visible (control remoto). Los navegadores viejos sin :focus-visible
   ignoran la segunda regla y dejan siempre el anillo, que es lo que queremos. */
.boton:focus,
.boton-salir:focus,
.campo:focus {
  outline: 6px solid var(--foco);
  outline-offset: 4px;
}
.boton:focus:not(:focus-visible),
.boton-salir:focus:not(:focus-visible) {
  outline: none;
}

.boton-primario {
  background: var(--acento);
  border-color: var(--acento);
  color: var(--acento-texto);
}
.boton-primario:hover { background: #f7bd5f; }

.boton-secundario {
  background: transparent;
  font-weight: 500;
}

.boton-ancho { width: 100%; }

.boton-salir {
  -webkit-appearance: none;
  appearance: none;
  min-height: 56px;
  padding: 0.2em 1em;
  font: inherit;
  font-size: 0.85em;
  color: var(--texto-suave);
  background: transparent;
  border: 0;
  border-radius: 12px;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}

/* ---------- Pie ---------- */

.pie {
  padding: 12px 16px 16px;
  font-size: var(--tam-pie);
  text-align: center;
  color: var(--texto-suave);
  opacity: 0.75;
}

/* ---------- Login ---------- */

.login {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.tarjeta {
  width: 100%;
  max-width: 28em;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-gap: 16px;
  gap: 16px;
  padding: 28px 20px;
  background: var(--superficie);
  border: 2px solid var(--borde);
  border-radius: 24px;
  text-align: center;
}

.logo { justify-self: center; width: 3.2em; height: 3.2em; }

.etiqueta-campo {
  margin-top: 4px;
  font-weight: 700;
  text-align: left;
}

.campo {
  width: 100%;
  min-height: var(--tam-boton);
  padding: 0.2em 0.6em;
  font: inherit;
  font-size: 1.2em;
  color: var(--texto);
  background: #0e0b09;
  border: 3px solid var(--borde);
  border-radius: 14px;
}
.campo:focus { border-color: var(--acento); }

.error {
  margin: 0;
  padding: 0.5em 0.8em;
  font-weight: 700;
  color: var(--error-texto);
  background: var(--error-fondo);
  border-radius: 12px;
}

/* ---------- Visor ---------- */

.cabecera {
  display: flex;
  align-items: center;
  padding: 12px 16px;
}
.logo-chico { width: 1.6em; height: 1.6em; margin-right: 0.5em; }

.escenario {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-gap: 16px;
  gap: 16px;
  padding: 0 16px 8px;
}

.zona-video { width: 100%; justify-self: center; }

.marco-video {
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* 16:9 */
  overflow: hidden;
  background: #000;
  border-radius: 16px;
}

.marco-video video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  transform-origin: 50% 50%;
  transition: transform 0.25s ease;
}

.aviso {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  text-align: center;
  background: var(--velo);
}
.aviso-texto { margin: 0 0 16px; font-size: 1.1em; font-weight: 600; }

.indicador-zoom {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 0.15em 0.7em;
  font-weight: 700;
  background: var(--velo);
  border-radius: 999px;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}
.indicador-zoom.visible { opacity: 1; }

.controles {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  align-content: start;
  grid-gap: 16px;
  gap: 16px;
}

.controles > .ayuda,
.controles > .fila-zoom,
.controles > .boton-ancho {
  width: 100%;
  max-width: calc(var(--tam-dpad) * 3 + 24px);
}

.dpad {
  display: grid;
  grid-template-columns: repeat(3, var(--tam-dpad));
  grid-template-rows: repeat(3, var(--tam-dpad));
  grid-gap: 12px;
  gap: 12px;
}
.dpad .arriba { grid-column: 2; grid-row: 1; }
.dpad .izquierda { grid-column: 1; grid-row: 2; }
.dpad .derecha { grid-column: 3; grid-row: 2; }
.dpad .abajo { grid-column: 2; grid-row: 3; }

.boton-flecha {
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  padding: 4px;
  border-radius: 24px;
}
.boton-flecha .icono { width: 1.7em; height: 1.7em; }
.boton-flecha .etiqueta { margin-top: 2px; font-size: 0.68em; line-height: 1.1; }

.fila-zoom {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-gap: 12px;
  gap: 12px;
}
.fila-zoom .boton { padding-left: 0.4em; padding-right: 0.4em; }
.fila-zoom .boton span { margin-left: 0.3em; font-size: 1.3em; line-height: 1; }

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 24px;
  z-index: 60;
  max-width: 24em;
  margin: 0 auto;
  padding: 0.6em 1em;
  font-weight: 700;
  text-align: center;
  color: var(--error-texto);
  background: var(--error-fondo);
  border: 3px solid var(--error-texto);
  border-radius: 16px;
}

/* TV y pantallas anchas (o celular acostado): video a la izquierda, controles a la derecha. */
@media (min-width: 1100px), (min-width: 700px) and (orientation: landscape) {
  @supports (width: clamp(1px, 2px, 3px)) {
    :root { --tam-dpad: clamp(56px, min(6vw, 10.5vh), 124px); }
  }
  .escenario {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
  }
  .zona-video { max-width: calc((100vh - 150px) * 16 / 9); }
  .controles {
    align-content: center;
    max-height: calc(100vh - 140px);
    overflow-x: hidden;
    overflow-y: auto;
    padding: 12px; /* que el anillo de foco no quede cortado */
  }
}

/* Pantallas bajitas (celular acostado): menos espacio en títulos y textos de ayuda. */
@media (orientation: landscape) and (max-height: 500px) {
  .cabecera { padding: 6px 16px; }
  .titulo { font-size: 1.05em; }
  .ayuda { display: none; }
  .fila-zoom .boton { font-size: 0.85em; }
  .zona-video { max-width: calc((100vh - 100px) * 16 / 9); }
  .controles { max-height: calc(100vh - 90px); align-content: start; }
}

/* ---------- Pantalla completa (solo la imagen) ---------- */

.escenario.pantalla-completa {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 50;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  background: #000;
}
.pantalla-completa .zona-video { width: 100%; height: 100%; max-width: none; }
.pantalla-completa .marco-video { height: 100%; padding-top: 0; border-radius: 0; }

/* En pantalla completa solo se ve la imagen: los botones se ocultan.
   Se sale tocando la pantalla, con OK o con Volver del control remoto. */
.pantalla-completa .controles { display: none; }
.pantalla-completa .marco-video { cursor: pointer; }

.aviso-salida {
  position: absolute;
  top: 24px;
  left: 50%;
  z-index: 5;
  padding: 12px 22px;
  color: var(--texto);
  font-size: 1.1em;
  font-weight: 700;
  background: var(--velo-suave);
  border-radius: 999px;
  white-space: nowrap;
  pointer-events: none;
  -webkit-transform: translateX(-50%);
  transform: translateX(-50%);
  opacity: 1;
  -webkit-transition: opacity 0.6s;
  transition: opacity 0.6s;
}
.aviso-salida.oculto { opacity: 0; }
