/* Trivia Cemento APU — maquetación del tótem.
   Alineada al design system del manual de marca (Brandlab 03.2024), tema Negro.
   Todo color, forma y familia sale de apu_tokens.css. Reglas del manual que
   mandan sobre cualquier decisión de maquetación:
     · Todo es angular: radius 0 en todo. Lo único redondo es un ícono.
     · Sin efectos: ni sombras, ni brillos, ni degradados.
     · Movimiento mínimo y seco: ≤150ms, sin rebotes. "La marca no salta."
     · Nunca texto blanco sobre amarillo.
   Medidas en vh: en el tótem el contenedor ocupa el viewport, así que
   1vh = 19.2 px de la referencia 1080 × 1920 (RNF-08). */

/* ---------- Base y bloqueo de kiosco (RNF-03) ---------- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--surface);
  overflow: hidden;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overscroll-behavior: none;
  cursor: default;
}

.totem {
  position: relative;
  height: 100dvh;
  aspect-ratio: 9 / 16;
  max-width: 100vw;
  margin: 0 auto;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--apu-font-texto);
  overflow: hidden;
}
@media (min-aspect-ratio: 9/16) { body { display: grid; place-items: center; } }

.pantalla {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
  padding: var(--margen-lat);
}
.pantalla.visible { display: flex; }
.pantalla.capa { background: rgba(0,0,0,.88); justify-content: center; align-items: center; }

/* Elemento de soporte del manual: rombo. Se usa para la letra de cada
   opción y para el signo de admiración de la pista. No es decoración
   libre: es el recurso que el manual da para numerar y para advertir. */
.rombo {
  flex: 0 0 auto;
  display: grid; place-items: center;
  background: var(--accent);
  transform: rotate(45deg);
}
.rombo > * { transform: rotate(-45deg); color: var(--on-accent); }

/* Corte a 45° en una esquina: la traducción digital de los cortes
   angulares de la iconografía. Solo en el CTA primario. */
.chaflan {
  clip-path: polygon(0 0, calc(100% - var(--chamfer)) 0, 100% var(--chamfer), 100% 100%, 0 100%);
}

/* ---------- ATRACCIÓN ---------- */
#p-atraccion { justify-content: center; align-items: center; text-align: center; gap: 4vh; }

/* Trama de rombos: el recurso gráfico del manual. Uno por pieza, sin abusar.
   Reemplaza al degradado radial, que el manual prohíbe. */
.atr-fondo {
  position: absolute; inset: -12vh;
  /* Rombo sólido, la forma del logotipo. Es el único lugar del proyecto con
     un hexadecimal escrito a mano: un data URI no admite var(). Si cambia
     --apu-amarillo, hay que cambiarlo acá también. */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cpath d='M60 16 L104 60 L60 104 L16 60 Z' fill='%23FFC709' fill-opacity='0.05'/%3E%3C/svg%3E");
  background-size: var(--trama-rombo) var(--trama-rombo);
  /* Deriva lineal y lenta. Se mueve el recurso gráfico, no la marca:
     sin escalas, sin pulsos, sin rebotes. */
  animation: deriva 30s linear infinite;
}
@keyframes deriva { to { transform: translate(var(--trama-rombo), var(--trama-rombo)); } }

.atr-contenido { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3.4vh; }
.atr-logo { width: 34vh; height: auto; }
.atr-titulo {
  margin: 0; font-family: var(--apu-font-display); font-weight: 900;
  font-size: 6.4vh; line-height: .95; text-transform: uppercase;
  text-wrap: balance;
}
.atr-titulo em { font-style: normal; color: var(--accent); }
.atr-cta {
  margin-top: 2vh;
  background: var(--action); color: var(--on-action);
  font-family: var(--apu-font-display); font-weight: 900; font-size: var(--t-cta);
  text-transform: uppercase; letter-spacing: .01em;
  padding: 2.4vh 5vh; border-radius: var(--radius);
}

/* ---------- INTRO ---------- */
#p-intro { justify-content: space-between; align-items: center; text-align: center; padding-block: 8vh; }
.intro-logo { width: 22vh; height: auto; }
.intro-centro { display: flex; flex-direction: column; gap: 3vh; }
.intro-titulo {
  margin: 0; font-family: var(--apu-font-display); font-weight: 900;
  font-size: 5.6vh; line-height: 1; text-transform: uppercase;
  white-space: pre-line; text-wrap: balance;
}
.intro-detalle { margin: 0; font-size: 2.5vh; line-height: 1.45; color: var(--ink-muted); }

.btn-cta {
  width: 100%; min-height: var(--alto-opcion);
  background: var(--action); color: var(--on-action);
  border: 0; border-radius: var(--radius);
  font-family: var(--apu-font-display); font-weight: 900; font-size: var(--t-cta);
  text-transform: uppercase; letter-spacing: .02em;
  cursor: pointer; transition: background var(--mov);
}
.btn-cta:active { background: var(--apu-blanco); }

/* ---------- PREGUNTA ---------- */
#p-pregunta { gap: 2vh; padding-block: 3vh 4vh; }

.preg-header { display: flex; flex-direction: column; gap: 1.2vh; }
/* La frase se construye en casilleros cuadrados, separados por el mismo
   aire que el manual pide alrededor del amarillo. */
.frase-progreso { display: flex; gap: .9vh; align-items: stretch; min-height: 5.4vh; }
.frase-slot {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: .8vh .4vh; border-radius: var(--radius);
  background: var(--surface-alt);
  font-size: 1.7vh; line-height: 1.1; text-align: center; color: var(--ink-muted);
  transition: background var(--mov), color var(--mov);
}
.frase-slot.lleno {
  background: var(--accent); color: var(--on-accent);
  font-family: var(--apu-font-display); font-weight: 900;
  text-transform: uppercase; font-size: 1.9vh;
}
/* Numeral de sección sobre filete de 3px: la grilla del manual. */
.preg-bloque {
  align-self: stretch;
  border-top: var(--rule-width) solid var(--rule);
  padding-top: 1.1vh;
  font-family: var(--apu-font-texto); font-weight: 700; font-size: var(--t-label);
  text-transform: uppercase; letter-spacing: var(--ls-label); color: var(--ink);
}
.preg-bloque b { color: var(--accent); font-weight: 900; }

.preg-imagen {
  flex: 1 1 34vh; min-height: 17vh; max-height: 34vh;
  border-radius: var(--radius); overflow: hidden;
  background: var(--surface-alt); position: relative;
}
.preg-imagen img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.2vh;
  background: var(--surface-alt);
}
.ph-marco { position: absolute; inset: 1.4vh; border: var(--hairline-width) dashed var(--hairline); }
.ph-id { font-family: var(--apu-font-display); font-weight: 900; font-size: 4.6vh; color: var(--accent); }
.ph-txt {
  font-family: var(--apu-font-texto);
  font-size: 1.7vh; color: var(--apu-gris-400);
  letter-spacing: var(--ls-label); text-transform: uppercase; font-weight: 700;
}

.preg-enunciado {
  margin: 0; font-family: var(--apu-font-display); font-weight: 900;
  font-size: var(--t-enunciado); line-height: 1.06; text-transform: uppercase;
  text-align: center; text-wrap: balance;
}

/* Opciones en la mitad inferior (RNF-07), en la tipografía de texto y en
   caja alta y baja: son frases largas y una display en mayúsculas a 1.5 m
   se vuelve un bloque ilegible. */
.preg-opciones { margin-top: auto; display: flex; flex-direction: column; gap: var(--gap-opcion); }
.opcion {
  display: flex; align-items: center; gap: 2.4vh;
  width: 100%; min-height: var(--alto-opcion);
  padding: 1.8vh 2.6vh;
  background: var(--surface-alt); color: var(--ink);
  border: var(--hairline-width) solid var(--hairline); border-radius: var(--radius);
  font-family: var(--apu-font-texto); font-weight: 400;
  font-size: var(--t-opcion); line-height: 1.22; text-align: left;
  cursor: pointer; transition: background var(--mov), border-color var(--mov);
  flex-shrink: 0;   /* el alto mínimo de 180 px es un piso duro (RNF-06) */
}
.opcion:active:not(:disabled) { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.opcion:active:not(:disabled) .rombo { background: var(--on-accent); }
.opcion:active:not(:disabled) .rombo > * { color: var(--accent); }
.opcion:focus-visible { outline: var(--rule-width) solid var(--focus); outline-offset: 2px; }

.opcion .rombo {
  width: 3.9vh; height: 3.9vh;
  font-family: var(--apu-font-display); font-weight: 900; font-size: 2.1vh;
}

/* Error: la opción se apaga y se deshabilita. No depende del color para
   leerse. El manual además exige que un error lleve siempre ícono y texto,
   nunca solo color. */
.opcion.descartada {
  background: transparent; color: var(--apu-gris-600);
  border-color: var(--hairline); opacity: .45; cursor: not-allowed;
  text-decoration: line-through; text-decoration-color: var(--danger);
  text-decoration-thickness: var(--rule-width);
}
.opcion.descartada .rombo { background: var(--apu-gris-700); }
.opcion.descartada .rombo > * { color: var(--apu-gris-400); }
.opcion.acertada { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.opcion.acertada .rombo { background: var(--on-accent); }
.opcion.acertada .rombo > * { color: var(--accent); }

/* ---------- ACIERTO ----------
   El manual no define un color de éxito, así que no se inventa un verde:
   el acierto se marca con el amarillo de la marca, el check y la palabra
   que se suma a la frase. De paso desaparece el par rojo/verde. */
.acierto-caja { display: flex; flex-direction: column; align-items: center; gap: 2.4vh; animation: aparece var(--mov) linear; }
@keyframes aparece { from { opacity: 0 } to { opacity: 1 } }
.acierto-check {
  width: 15vh; height: 15vh; fill: none;
  stroke: var(--accent); stroke-width: 2.6; stroke-linecap: square; stroke-linejoin: miter;
}
.acierto-titulo {
  font-family: var(--apu-font-display); font-weight: 900; font-size: 6vh;
  text-transform: uppercase; color: var(--ink);
}
.acierto-palabra {
  background: var(--accent); color: var(--on-accent);
  font-family: var(--apu-font-display); font-weight: 900; font-size: 3.4vh;
  text-transform: uppercase; padding: 1.4vh 3.2vh; border-radius: var(--radius);
}

/* ---------- PISTA ----------
   Borde de 3px en danger + rombo con ! + mensaje, como pide el manual. */
.pista-caja {
  width: 100%;
  background: var(--surface-alt); border: var(--rule-width) solid var(--danger);
  border-radius: var(--radius); padding: 4vh 3.6vh;
  display: flex; flex-direction: column; align-items: center; gap: 2vh; text-align: center;
  animation: aparece var(--mov) linear;
}
.pista-rombo {
  width: 6vh; height: 6vh; background: var(--danger);
  font-family: var(--apu-font-display); font-weight: 900; font-size: 3.2vh;
}
.pista-rombo > * { color: var(--apu-negro); }
.pista-etiqueta {
  font-family: var(--apu-font-texto); font-weight: 700; font-size: var(--t-label);
  text-transform: uppercase; letter-spacing: var(--ls-label); color: var(--danger);
}
.pista-texto { font-size: var(--t-pista); line-height: 1.32; color: var(--ink); }
.pista-pie {
  font-family: var(--apu-font-texto);
  font-size: 1.8vh; color: var(--ink-muted); font-weight: 700;
  text-transform: uppercase; letter-spacing: var(--ls-label);
}

/* ---------- CIERRE ---------- */
#p-cierre { justify-content: center; align-items: center; text-align: center; gap: 5.5vh; padding-block: 9vh 12vh; }
.cierre-logo { width: 19vh; height: auto; }
/* Zona reservada: acá se dibuja la frase y, si Dinamo define premio, el
   resultado. Ningún texto va quemado en apu_cierre.webp. */
.cierre-zona { display: flex; flex-direction: column; align-items: center; gap: 3vh; }
.cierre-frase {
  font-family: var(--apu-font-display); font-weight: 900;
  font-size: 5.4vh; line-height: 1; text-transform: uppercase;
  display: flex; flex-wrap: wrap; justify-content: center; gap: .6vh 1.6vh;
  max-width: 46vh;
}
.cierre-frase span { opacity: 0; animation: aparece var(--mov) linear forwards; }
.cierre-frase span:nth-child(1) { animation-delay: .05s }
.cierre-frase span:nth-child(2) { animation-delay: .17s }
.cierre-frase span:nth-child(3) { animation-delay: .29s }
.cierre-frase span:nth-child(4) { animation-delay: .41s }
.cierre-frase span:nth-child(5) { animation-delay: .53s }
.cierre-frase span.acento { color: var(--accent); }
.cierre-resultado {
  font-size: 2.4vh; color: var(--on-accent); background: var(--accent);
  padding: 1.2vh 2.8vh; border-radius: var(--radius);
  font-family: var(--apu-font-display); font-weight: 900; text-transform: uppercase;
}
.cierre-marca { font-size: 2.5vh; color: var(--ink-muted); line-height: 1.45; white-space: pre-line; }
.cierre-pie {
  font-family: var(--apu-font-texto);
  position: absolute; left: 0; right: 0; bottom: 4.5vh;
  font-size: 1.8vh; color: var(--apu-gris-600); font-weight: 700;
  text-transform: uppercase; letter-spacing: var(--ls-label);
}

/* ---------- MENÚ DE TÉCNICO ---------- */
#p-tecnico { justify-content: center; background: var(--surface); }
.tec-caja { display: flex; flex-direction: column; gap: 3vh; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.tec-titulo {
  margin: 0; font-family: var(--apu-font-display); font-weight: 900; font-size: 3.6vh;
  text-transform: uppercase; color: var(--accent);
  border-top: var(--rule-width) solid var(--rule); padding-top: 1.4vh;
}
.tec-label { margin: 0; font-size: 1.8vh; color: var(--ink-muted); text-transform: uppercase; letter-spacing: var(--ls-label); }
.tec-pin-display { font-size: 4vh; letter-spacing: .6em; min-height: 6vh; color: var(--accent); }
.tec-teclado { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.4vh; }
.tec-tecla {
  min-height: 8vh; background: var(--surface-alt); color: var(--ink);
  border: var(--hairline-width) solid var(--hairline); border-radius: var(--radius);
  font-size: 3vh; font-family: inherit; cursor: pointer; transition: background var(--mov);
}
.tec-tecla:active { background: var(--accent); color: var(--on-accent); }
.tec-datos { font-size: 2vh; line-height: 1.9; white-space: pre-wrap; color: var(--ink); }
.tec-datos b { color: var(--accent); }
.tec-botones { display: flex; flex-direction: column; gap: 1.4vh; }
.btn-tec {
  min-height: 8vh; background: transparent; color: var(--accent);
  border: var(--rule-width) solid var(--accent); border-radius: var(--radius);
  font-family: var(--apu-font-display); font-weight: 900; font-size: 2.6vh;
  text-transform: uppercase; cursor: pointer; transition: background var(--mov), color var(--mov);
}
.btn-tec:active { background: var(--accent); color: var(--on-accent); }

.esquina-tecnico { position: absolute; top: 0; left: 0; width: 12vh; height: 12vh; z-index: 50; }

/* ---------- ERROR ---------- */
#p-error { justify-content: center; }
.err-caja { display: flex; flex-direction: column; gap: 2.4vh; }
.err-titulo {
  margin: 0; font-family: var(--apu-font-display); font-weight: 900; font-size: 3.4vh;
  color: var(--danger); text-transform: uppercase;
}
.err-texto, .err-nota { margin: 0; font-size: 2vh; line-height: 1.5; color: var(--ink-muted); }
.err-cmd {
  margin: 0; padding: 2vh; background: var(--surface-alt); border-radius: var(--radius);
  border-left: var(--rule-width) solid var(--accent);
  font-family: ui-monospace, Menlo, monospace; font-size: 1.9vh; color: var(--accent);
  white-space: pre-wrap; word-break: break-all;
}

/* ---------- Marca de prototipo (se quita en producción) ---------- */
.prototipo-tag {
  position: absolute; bottom: 0; right: 0; z-index: 40;
  padding: .7vh 1.4vh; background: var(--surface-alt); color: var(--accent);
  font-family: ui-monospace, Menlo, monospace; font-size: 1.3vh; letter-spacing: .06em;
  pointer-events: none;
}
.totem[data-estado="pregunta"] .prototipo-tag,
.totem[data-estado="acierto"] .prototipo-tag,
.totem[data-estado="pista"] .prototipo-tag { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
