/*
  comunicacion-cabeza.css
  Comunicación con seguimiento de cabeza: modal para el profesional +
  tablero de letras. Todo el color sale de tokens semánticos (tokens.css /
  theme.css), nada hardcodeado, para que el modo oscuro funcione solo.

  Con un puntero de cabeza no se puede hacer scroll, así que el tablero se
  reparte el alto disponible sin desbordar (el JS calcula las columnas; ver
  grilla.js). El modal, en cambio, es para el profesional (mouse y teclado)
  y puede scrollear.
*/

.epe-cc-shell {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--shell-bg);
}

/* `hidden` pierde contra display:flex de una clase: se fuerza. */
.epe-cc-shell [hidden] {
  display: none !important;
}

.epe-cc-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px clamp(16px, 4vw, 40px);
}

.epe-cc-header-der {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Indicador de calidad del seguimiento (visible con el modal cerrado). */
.epe-cc-chip {
  font-size: 12.5px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--tile-border);
  background: var(--tile-bg);
  color: var(--text-dim);
}
.epe-cc-chip[data-calidad='ok'] {
  border-color: var(--grn);
  color: var(--grn);
}
.epe-cc-chip[data-calidad='pausa'],
.epe-cc-chip[data-calidad='sin-cara'],
.epe-cc-chip[data-calidad='sin-senial'] {
  border-color: var(--red);
  color: var(--red);
}

.epe-cc-shell .epe-btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

/* ── Modal ── */
.epe-cc-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 20, 20, 0.55);
}
.epe-cc-modal-overlay[hidden] {
  display: none;
}

.epe-cc-modal {
  width: min(820px, 96vw);
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  background: var(--tile-bg);
  border: 1px solid var(--tile-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.epe-cc-modal h1 {
  font-size: 17px;
  color: var(--text-strong);
}

.epe-cc-modal h2 {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  margin-bottom: 0;
}

.epe-cc-intro {
  font-size: 12.5px;
  line-height: 1.3;
  color: var(--text-dim);
}

.epe-cc-config-fila {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
@media (max-width: 560px) {
  .epe-cc-config-fila {
    grid-template-columns: 1fr;
  }
}

.epe-cc-grupo {
  background: var(--shell-bg-2);
  border: 1px solid var(--tile-border);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12.5px;
  color: var(--text-strong);
}

.epe-cc-grupo label {
  font-size: 12px;
  color: var(--text-dim);
}

.epe-cc-opciones {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.epe-cc-opciones label,
.epe-cc-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--text-strong);
  font-size: 12.5px;
}

.epe-cc-fila-botones {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.epe-cc-estado {
  font-size: 12px;
  line-height: 1.3;
  color: var(--text-dim);
}
.epe-cc-estado.is-alerta {
  color: var(--red);
  font-weight: 700;
}
.epe-cc-estado.is-exito {
  color: var(--grn);
  font-weight: 700;
}

.epe-cc-modal input[type='range'] {
  width: 100%;
  accent-color: var(--teal-600);
}

.epe-cc-modal select {
  width: 100%;
  border: 1px solid var(--tile-border);
  background: var(--shell-bg);
  color: var(--text-strong);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
}

.epe-cc-resumen pre {
  white-space: pre-wrap;
  font: inherit;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-strong);
}

/* ── Vista de cámara y ajustes de Tracky ──
   Se muestra dentro del modal (posición absoluta sobre él no hace falta:
   es un bloque normal debajo del encabezado). Al ocultarla se la saca de
   pantalla en vez de display:none, para no arriesgar que el navegador
   frene el video que Tracky analiza. */
.epe-cc-tracky-host {
  position: fixed;
  z-index: 120; /* por encima de los modales: se acomoda sobre el hueco del modal de cámara */
  right: 16px;
  bottom: 16px;
  width: min(360px, 92vw);
  max-height: 70vh;
  overflow: auto;
  background: var(--tile-bg);
  border: 1px solid var(--tile-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}
.epe-cc-tracky-host:empty {
  display: none;
}
.epe-cc-tracky-host.oculto {
  left: -10000px;
  right: auto;
  opacity: 0;
  pointer-events: none;
}

/* ── Tablero ── */
.epe-cc-body {
  flex: 1;
  min-height: 0;
  display: flex;
  padding: 0 clamp(12px, 3vw, 32px) clamp(12px, 2vw, 24px);
}

.epe-cc-juego {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.epe-cc-panel-texto {
  flex: 0 0 auto;
  background: var(--tile-bg);
  border: 1px solid var(--tile-border);
  border-radius: var(--radius-lg);
  padding: 10px 20px;
}

.epe-cc-panel-texto p {
  margin: 0;
}

.epe-cc-texto {
  font-size: clamp(20px, 3.4vw, 32px);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-strong);
  min-height: 1.3em;
  overflow-wrap: anywhere;
}

.epe-cc-grilla {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: 8px;
}

.epe-cc-celda {
  position: relative;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(16px, 3vw, 30px);
  font-weight: 700;
  color: var(--text-strong);
  background: var(--tile-bg);
  border: 2px solid var(--tile-border);
  border-radius: var(--radius-sm);
  user-select: none;
  transition: background 0.08s ease, border-color 0.08s ease;
}

.epe-cc-celda[data-tipo='accion'] {
  font-size: clamp(12px, 2vw, 20px);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.epe-cc-celda[data-id='a-hablar'] {
  border-color: var(--teal-600);
  color: var(--teal-700);
}

/* Bajo el puntero de cabeza: alto contraste, se nota de un vistazo. */
.epe-cc-celda.is-bajo-puntero {
  border-color: var(--teal-600);
  background: color-mix(in srgb, var(--teal-600) 26%, var(--tile-bg));
}

/* Progreso de permanencia (dwell): relleno que crece de abajo hacia arriba. */
.epe-cc-celda::before {
  content: '';
  position: absolute;
  inset: auto 0 0 0;
  height: calc(var(--p, 0) * 100%);
  background: color-mix(in srgb, var(--teal-600) 40%, transparent);
  pointer-events: none;
}

/* Destello al elegir. */
.epe-cc-celda.is-elegida {
  background: var(--teal-600);
  border-color: var(--teal-700);
  color: #fff;
}

.epe-cc-celda > span {
  position: relative;
}

/* ── Recentrar el puntero ── */
.epe-cc-recentrar {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.epe-cc-tecla {
  min-width: 34px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-strong);
  border: 1px solid var(--tile-border);
  border-radius: 6px;
  padding: 5px 10px;
  background: var(--shell-bg);
}
.epe-cc-tecla.is-capturando {
  border-color: var(--teal-600);
  color: var(--teal-700);
}

/* Aro en el centro de la ventana: es donde Tracky deja el puntero al recentrar. */
.epe-cc-centro {
  position: fixed;
  z-index: 90;
  left: 50%;
  top: 50%;
  width: 96px;
  height: 96px;
  margin: -48px 0 0 -48px;
  border: 4px solid var(--teal-600);
  border-radius: 50%;
  pointer-events: none;
  animation: epe-cc-centro 0.7s ease-out forwards;
}
.epe-cc-centro[hidden] {
  display: none;
}
@keyframes epe-cc-centro {
  from {
    opacity: 1;
    transform: scale(1.6);
  }
  to {
    opacity: 0;
    transform: scale(0.6);
  }
}
@media (prefers-reduced-motion: reduce) {
  .epe-cc-centro {
    animation: none;
    opacity: 0.8;
  }
}

/* Hueco del modal sobre el que se acomoda la vista de cámara (ver acomodarVista()). */
.epe-cc-vista-slot {
  height: min(300px, 42vh);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 12px;
  font-size: 12px;
  color: var(--text-faint);
  border: 1px dashed var(--tile-border);
  border-radius: var(--radius-md);
}

/* ── Compactar: el modal principal no debe scrollear ── */
.epe-cc-inline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 8px;
}
.epe-cc-inline select {
  width: auto;
  flex: 1;
  min-width: 90px;
  padding: 5px 8px;
}
.epe-cc-grupo select {
  padding: 5px 8px;
}
.epe-cc-grupo .epe-cc-estado:empty {
  display: none;
}
.epe-cc-modal .epe-juego-pie {
  margin-top: 2px;
  gap: 8px;
}
.epe-cc-modal .epe-juego-pie .epe-btn-acc,
.epe-cc-modal .epe-juego-pie .epe-btn-ghost {
  padding: 6px 16px;
  font-size: 13px;
}
.epe-cc-modal .epe-cc-estado:empty {
  display: none;
}
.epe-cc-modal .epe-cc-opciones,
.epe-cc-modal .epe-cc-fila-botones {
  gap: 4px 8px;
}

/* ── Modales secundarios (encima del principal) ── */
.epe-cc-modal-2 {
  z-index: 110;
}
.epe-cc-modal-ancho {
  width: min(900px, 96vw);
}
.epe-cc-escala {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--text-faint);
}
.epe-cc-resumen-texto {
  white-space: pre-wrap;
  font: inherit;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-strong);
  max-height: 60vh;
  overflow: auto;
  user-select: text;
}

/* Del panel de Tracky solo se muestra la vista de cámara; los ajustes
   completos aparecen a pedido (los sliders siguen existiendo aunque estén
   ocultos: la sensibilidad se mueve desde nuestro slider). */
.epe-cc-tracky-host:not(.mostrar-ajustes) .tracky-mouse-controls {
  display: none;
}

/* Sin márgenes heredados dentro del modal: el espacio lo da el gap. */
.epe-cc-modal h1,
.epe-cc-modal h2,
.epe-cc-modal p {
  margin: 0;
  line-height: 1.25;
}
.epe-cc-modal .epe-cc-opciones label {
  align-items: center;
}
.epe-cc-modal .epe-cc-inline select {
  padding: 3px 8px;
}

/* Zona de descanso (dwell): hueco del tablero donde el puntero no elige nada. */
.epe-cc-descanso {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  font-size: clamp(12px, 1.6vw, 18px);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  border: 2px dashed var(--tile-border);
  border-radius: var(--radius-sm);
  background: var(--shell-bg-2);
  user-select: none;
}
