/*
 * AYUDA Y GANA: pantalla del sorteo en vivo (/vivo/<slug>). Se ve en la transmisión.
 * Escenario 16:9 que escala con la ventana: todo se mide en cqw (1cqw = 1 % del ancho del escenario; a 1920 px,
 * 19,2 px), así a 1280, 1920 o 4K se ve igual. Tokens de base.css. La pieza protagonista es la patente: las cifras
 * del ganador ruedan y se frenan de izquierda a derecha (el único movimiento de la pantalla).
 */

html, body.vivo { height: 100%; }
body.vivo {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  overflow: hidden;
  background: var(--noche);
  color: var(--texto);
}
.vivo h1, .vivo h2 { color: var(--texto); }
.vivo :focus-visible { outline: 3px solid var(--boleto); outline-offset: 3px; }

.escenario {
  width: min(100vw, calc(100dvh * 16 / 9));
  aspect-ratio: 16 / 9;
  container-type: size;
}
.escenario__marco {
  position: relative;
  height: 100%;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  padding: 2.4cqw 3.4cqw 1.8cqw;
}

/* Aviso de discrepancia: arriba, a todo el ancho, imposible de no ver. */
.vivo-aviso {
  position: absolute; inset: 0 0 auto 0; z-index: 2;
  padding: 1cqw 3.4cqw;
  background: var(--error);
  color: #FFFFFF;
  font-size: 1.35cqw; font-weight: 700; line-height: 1.3;
}
.vivo-aviso small { display: block; font-size: 1.05cqw; font-weight: 500; margin-top: 0.2cqw; }

/* Cabecera: logo y fecha */
.vivo-cabeza { display: flex; align-items: center; justify-content: space-between; gap: 2cqw; }
.vivo-cabeza__logo { height: 1.55cqw; width: auto; }
.vivo-cabeza__fecha { font-size: 1.1cqw; color: var(--texto-2); font-variant-numeric: tabular-nums; }
.vivo-titulo {
  margin-top: 1.6cqw;
  font-size: 2.6cqw;
  font-stretch: var(--ancho-display);
  font-weight: 750;
  line-height: 1;
}

/* Cuerpo: el premio que se está sorteando a la izquierda, la lista de premios a la derecha */
.vivo-cuerpo {
  display: grid;
  grid-template-columns: minmax(0, 1.72fr) minmax(0, 1fr);
  gap: 3.4cqw;
  min-height: 0;
  padding-block: 1.8cqw;
}

/* Foco */
.foco { display: grid; align-content: center; min-height: 0; }
.foco__premio {
  display: grid;
  grid-template-areas: "texto" "patente" "pie";
  justify-items: start;
  align-content: center;
}
.foco__premio--foto {
  grid-template-columns: minmax(0, 1fr) 22cqw;
  grid-template-areas: "texto foto" "patente patente" "pie pie";
  column-gap: 2.4cqw;
}
.foco__texto { display: contents; }
.foco__orden, .foco__nombre { grid-area: texto; }
.foco__orden {
  align-self: start;
  font-family: var(--fuente-display); font-stretch: var(--ancho-medio);
  font-size: 1.7cqw; font-weight: 700; line-height: 1;
  color: var(--texto-2);
}
.foco__nombre {
  align-self: end;
  padding-top: 2.6cqw;
  font-size: 4.4cqw;
  font-stretch: var(--ancho-display);
  font-weight: 800;
  line-height: 0.98;
  max-width: 26ch;
}
.foco__premio > .patente-vivo, .foco__texto > .patente-vivo { grid-area: patente; margin-top: 2.4cqw; }
.foco__pie { grid-area: pie; margin-top: 1.2cqw; font-size: 1.15cqw; color: var(--texto-2); }
.foco__foto {
  grid-area: foto;
  width: 100%; aspect-ratio: 4 / 3; object-fit: cover;
  border-radius: 0.8cqw;
  background: rgb(255 255 255 / 0.06);
}

/* Entrada del premio nuevo: una sola vez por revelación, corta. */
.foco--entra .foco__orden, .foco--entra .foco__nombre, .foco--entra .foco__foto {
  animation: foco-entra 0.45s var(--ease) both;
}
@keyframes foco-entra { from { opacity: 0; transform: translateY(0.8cqw); } }

/* Espera de la quiniela */
.foco__espera { display: grid; justify-items: start; }
.foco__titulo { font-size: 4.4cqw; font-stretch: var(--ancho-display); font-weight: 800; line-height: 1; }
.foco__cifra {
  margin-top: 3cqw;
  font-family: var(--fuente-display); font-stretch: var(--ancho-display);
  font-size: 10cqw; font-weight: 800; line-height: 0.9;
}
.foco__cifra-rotulo { margin-top: 0.6cqw; font-size: 1.6cqw; color: var(--texto-2); }

/* Patente del vivo: placa blanca con filete de tinta, banda amarilla y seis cifras */
.patente-vivo {
  display: inline-grid;
  padding: 0.28cqw;
  border-radius: 0.7cqw;
  background: var(--placa);
  color: var(--tinta);
  text-align: center;
}
.patente-vivo__banda, .patente-vivo__num { border: 0.2cqw solid var(--tinta); }
.patente-vivo__banda {
  border-bottom: 0;
  border-radius: 0.45cqw 0.45cqw 0 0;
  background: var(--boleto);
  padding: 0.45cqw 1.6cqw 0.4cqw;
  font-size: 1.1cqw; font-weight: 700; letter-spacing: 0.12em; line-height: 1;
  text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.patente-vivo__num {
  border-top: 0;
  border-radius: 0 0 0.45cqw 0.45cqw;
  display: flex; justify-content: center;
  padding: 0.5cqw 2cqw 0.55cqw;
  font-family: var(--fuente-display); font-stretch: var(--ancho-display);
  font-weight: 800; font-size: 10.6cqw; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.patente-vivo__num > * + * { margin-left: 0.07em; }
.patente-vivo--vacia .patente-vivo__banda { background: var(--neutro-suave); color: var(--texto-2); }

/* Casilla vacía: ocupa lo mismo que una cifra (un "0" invisible) con una raya en la base */
.casilla {
  position: relative;
  display: inline-block;
  height: 1em;
}
.casilla::before { content: "0"; visibility: hidden; }
.casilla::after {
  content: "";
  position: absolute; left: 0.06em; right: 0.06em; bottom: 0.1em;
  height: 0.06em;
  background: currentColor;
  opacity: 0.28;
}

/* Rodillo: una tira vertical de cifras que se frena en la del ganador */
.rodillo { display: inline-block; height: 1em; overflow: hidden; }
.rodillo__tira { display: block; }
.rodillo__tira > span { display: block; height: 1em; }
.rodillo--rueda .rodillo__tira {
  animation: rodar var(--duracion, 1s) cubic-bezier(0.16, 0.84, 0.3, 1) both;
}
.rodillo--quieto .rodillo__tira { transform: translateY(var(--fin)); }
@keyframes rodar { from { transform: translateY(0); } to { transform: translateY(var(--fin)); } }

/* Lista de premios */
.premios-vivo {
  list-style: none; padding: 0;
  display: flex; flex-direction: column;
  min-height: 0;
  border-top: 1px solid rgb(255 255 255 / 0.16);
}
.pv {
  flex: 0 1 6.2cqw;
  min-height: 0;
  display: grid;
  grid-template-columns: 3.6cqw minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 1.2cqw;
  padding-inline: 0.8cqw;
  border-bottom: 1px solid rgb(255 255 255 / 0.16);
}
.pv__orden {
  font-family: var(--fuente-display); font-stretch: var(--ancho-medio);
  font-size: 1.5cqw; font-weight: 700; color: var(--texto-2);
}
.pv__nombre {
  font-size: 1.35cqw; font-weight: 600; line-height: 1.2;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.pv--actual { background: rgb(255 255 255 / 0.07); box-shadow: inset 0.25cqw 0 0 var(--texto); }
.pv--actual .pv__orden { color: var(--texto); }

/* Placa chica en la lista: vacía (raya por cifra) o con el ganador */
.placa-vacia, .placa {
  display: inline-flex;
  font-family: var(--fuente-display); font-stretch: var(--ancho-display);
  font-weight: 800; font-size: 2.3cqw; line-height: 1;
  font-variant-numeric: tabular-nums;
  border-radius: 0.35cqw;
}
.placa-vacia {
  padding: 0.35cqw 0.7cqw 0.3cqw;
  border: 1px dashed rgb(255 255 255 / 0.32);
  color: var(--texto-2);
}
.placa-vacia .casilla + .casilla { margin-left: 0.07em; }
.placa {
  padding: 0.55cqw 0.8cqw 0.3cqw;
  background: var(--placa); color: var(--tinta);
  border: 0.15cqw solid var(--tinta);
  box-shadow: inset 0 0.3cqw 0 var(--boleto);
  letter-spacing: 0.07em;
}
.placa--entra { animation: placa-entra 0.3s var(--ease) both; }
@keyframes placa-entra { from { opacity: 0; } }

/* Pie: huella, quiniela y dónde verificar */
.vivo-pie {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 3cqw;
  align-items: start;
  padding-top: 1.3cqw;
  border-top: 1px solid rgb(255 255 255 / 0.16);
}
.dato { display: grid; gap: 0.45cqw; justify-items: start; min-width: 0; }
.dato--verificar { justify-items: end; text-align: right; }
.dato__rotulo { font-size: 1cqw; font-weight: 600; color: var(--texto-2); }
.dato__valor { font-size: 1.15cqw; font-weight: 600; font-variant-numeric: tabular-nums; }
.dato__estado { font-size: 1cqw; color: var(--texto-2); }
.dato__estado--ok { color: var(--ok); }

.huella {
  padding: 0.3cqw 0.6cqw;
  border: 1px solid rgb(255 255 255 / 0.3);
  border-radius: var(--r-1);
  background: transparent;
  color: var(--texto);
  font-size: 1.15cqw; font-weight: 600; line-height: 1.3;
  font-variant-numeric: tabular-nums;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}
.huella:hover { border-color: var(--texto); }
.huella[aria-expanded="true"] {
  max-width: 21cqw;
  font-family: var(--fuente-display); font-stretch: var(--ancho-medio);
  font-size: 1cqw;
  overflow-wrap: anywhere;
}

.quiniela {
  list-style: none; padding: 0;
  display: grid; grid-template-columns: repeat(10, auto); justify-content: start;
  gap: 0.15cqw 1cqw;
  font-size: 1.15cqw; font-weight: 600; line-height: 1.25;
}

@media (prefers-reduced-motion: reduce) {
  .rodillo--rueda .rodillo__tira { animation: none; transform: translateY(var(--fin)); }
}
