/* style.css — ARCHIVO VIVO (guatebala.com)
   Sin Tailwind, sin CDN, sin fuentes externas: esta página debe cargar sobre
   datos móviles débiles. Paleta canon del régimen: Negro señal #0A0A0D,
   Blanco clínico #F2F4F3. Nada de rojo (reservado a la resistencia). */

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  background: #050507;
  font-family: ui-monospace, "SF Mono", Consolas, "Courier New", monospace;
  color: #f2f4f3;
}

#shell {
  width: 100%;
  max-width: 390px;
  min-height: 100vh;
  min-height: 100dvh;
  background: #0a0a0d;
  position: relative;
}

.hidden { display: none !important; }

/* Pantalla publica antes de la apertura del archivo. */
.standby-screen {
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.standby-static {
  position: absolute;
  z-index: 3;
  inset: 0;
  margin: 0;
  overflow: hidden;
  pointer-events: none;
  color: rgba(242, 244, 243, 0.42);
  background: #0a0a0d;
  font-size: 8px;
  line-height: 1.05;
  letter-spacing: 0;
  white-space: pre;
  opacity: 0;
}

.standby-seal-wrap {
  width: 82px;
  height: 82px;
  margin-bottom: -17px;
  padding: 7px;
  background: #0a0a0d;
  position: relative;
  z-index: 2;
}

.standby-seal {
  width: 68px;
  height: 68px;
  display: block;
  opacity: 0.95;
  filter: invert(1);
}

.standby-frame {
  width: 100%;
  border: 1px solid rgba(242, 244, 243, 0.42);
  padding: 48px 18px;
  position: relative;
  z-index: 1;
  overflow: hidden;
}

.standby-frame::after {
  content: "";
  position: absolute;
  z-index: 2;
  top: -16px;
  left: 0;
  width: 100%;
  height: 12px;
  opacity: 0;
  background: linear-gradient(to bottom, transparent, rgba(242, 244, 243, 0.32), transparent);
  pointer-events: none;
}

/* Reconstrucción breve: hereda la estática y el enfoque de los registros sin
   obligar al visitante a atravesar la introducción completa. */
.standby-entering .standby-static { opacity: 0.58; }

.standby-entering .standby-seal {
  opacity: 0;
  transform: scale(0.9);
  filter: invert(1) blur(8px) contrast(1.8);
}

.standby-entering .standby-frame {
  opacity: 0;
  transform: scale(0.985);
  clip-path: inset(48% 0 48% 0);
  filter: blur(5px) contrast(1.5);
}

.standby-entering .standby-frame > * { opacity: 0; }

.standby-entering.standby-revealed .standby-static {
  opacity: 0;
  transition: opacity 420ms steps(5, end);
}

.standby-entering.standby-revealed .standby-seal {
  opacity: 0.95;
  transform: none;
  filter: invert(1) drop-shadow(0 0 7px rgba(242, 244, 243, 0.16));
  transition: opacity 520ms ease, transform 720ms cubic-bezier(.2,.75,.2,1), filter 620ms ease;
}

.standby-entering.standby-revealed .standby-frame {
  opacity: 1;
  transform: none;
  clip-path: inset(0 0 0 0);
  filter: none;
  transition: opacity 360ms ease, transform 700ms cubic-bezier(.2,.75,.2,1),
              clip-path 650ms cubic-bezier(.2,.75,.2,1), filter 560ms ease;
}

.standby-entering.standby-revealed .standby-frame > * {
  opacity: 1;
  transition: opacity 360ms ease 330ms;
}

.standby-entering.standby-revealed .standby-frame::after {
  animation: standby-scan 760ms cubic-bezier(.25,.6,.35,1) 120ms 1 both;
}

@keyframes standby-scan {
  0% { top: -16px; opacity: 0; }
  14% { opacity: 0.7; }
  82% { opacity: 0.35; }
  100% { top: calc(100% + 8px); opacity: 0; }
}

.standby-title {
  margin: 0;
  font-size: clamp(32px, 12vw, 50px);
  font-weight: 700;
  letter-spacing: 0.16em;
  text-indent: 0.16em;
}

@media (prefers-reduced-motion: reduce) {
  .standby-entering .standby-static { display: none; }
  .standby-entering .standby-frame,
  .standby-entering .standby-frame > * {
    opacity: revert;
    transform: none;
    clip-path: none;
    filter: none;
  }
  .standby-entering .standby-seal {
    opacity: 0.95;
    transform: none;
    filter: invert(1);
  }
  .standby-entering .standby-frame::after { display: none; }
}

/* Solo aparece con ?qa=1. Nunca forma parte de la experiencia publica. */
.qa-panel {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(100%, 390px);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-top: 1px solid rgba(242, 244, 243, 0.35);
  background: rgba(5, 5, 7, 0.97);
  font-size: 9px;
}

.qa-panel label { letter-spacing: 0.08em; color: rgba(242, 244, 243, 0.55); }
.qa-panel select {
  min-width: 0;
  border: 1px solid rgba(242, 244, 243, 0.32);
  border-radius: 0;
  background: #0a0a0d;
  color: #f2f4f3;
  font: inherit;
  padding: 7px 5px;
}
.qa-panel a { color: #f2f4f3; text-decoration: none; white-space: nowrap; }
.qa-active { padding-bottom: 48px; }

#main.hidden {
  display: flex !important;
  visibility: hidden;
  height: 0;
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  contain: content;
}

/* ── Marca de sistema — esquina estampada ─────────────────────────────── */
/* ── Intro: reconstrucción ────────────────────────────────────────────── */
.intro-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  gap: 16px;
}

.seal {
  width: 72px;
  height: 72px;
  /* asset con fondo transparente, tinta negra — invertido lee como emblema blanco */
  filter: invert(1);
  opacity: 0.95;
}

/* ── Marco de intro — una sola consola; el contenido rota adentro ─────── */
#intro-frame {
  opacity: 0;
  transition: opacity 0.45s ease;
}
#intro-frame.visible { opacity: 1; }

#intro-gate {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
  padding: 10px 4px;
  transition: opacity 0.45s ease;
}
#intro-gate.fade-out { opacity: 0; }

.gate-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 0;
}

.gate-sub {
  font-size: 12px;
  color: rgba(242, 244, 243, 0.55);
  line-height: 1.5;
  margin: 0;
}

#intro-lines {
  width: 100%;
  font-size: 13px;
  line-height: 1.6;
  text-align: left;
}

.term-line { word-break: break-word; }

.cursor {
  display: inline-block;
  width: 7px;
  height: 1em;
  background: #f2f4f3;
  vertical-align: text-bottom;
  margin-left: 2px;
  animation: blink 0.7s step-end infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

.static-pre {
  margin: 0;
  font-size: 9px;
  line-height: 1.15;
  letter-spacing: 1px;
  color: rgba(242, 244, 243, 0.88);
  white-space: pre;
  overflow: hidden;
}

/* ── Marco de consola — borde CSS puro: los marcos dibujados con glifos se
      desfasan según fuente/zoom/densidad de pantalla; una línea CSS nunca ── */
.ascii-frame {
  width: 100%;
  border: 1px solid #f2f4f3;
  font-size: 13px;
  text-align: left;
}
.ascii-frame-content {
  min-width: 0;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* El bloque de lecturas se centra como unidad (texto alineado a la izquierda
   adentro) — sin él, la mitad derecha de la caja queda muerta */
#intro-scan {
  --scan-width: 31ch;
  align-self: center;
  width: min(100%, var(--scan-width));
}

.readout-line {
  font-size: 11px;
  color: rgba(242, 244, 243, 0.6);
  white-space: nowrap;
  overflow: hidden;
}

.scan-bar-wrap { width: 100%; margin-top: 4px; }
.scan-bar-label {
  font-size: 11px;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
  color: rgba(242, 244, 243, 0.6);
}
.scan-ascii {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1ch;
  width: 100%;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.05em;
  white-space: nowrap;
}

.scan-track,
.scan-percent { flex: 0 0 auto; }

#signal-strip {
  width: 100%;
  min-height: 2.7em;
  margin: 8px 0 2px;
  padding: 5px 0;
  border-top: 1px dotted rgba(242, 244, 243, 0.18);
  border-bottom: 1px dotted rgba(242, 244, 243, 0.18);
  color: rgba(242, 244, 243, 0.72);
  font: inherit;
  font-size: 13px;
  line-height: 1.25;
  letter-spacing: 0;
  white-space: pre;
  overflow: hidden;
}

/* ── Registro: la fotografía ──────────────────────────────────────────── */
#main {
  padding: 34px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  transition: opacity 0.5s ease;
}
#main.appearing { opacity: 0; }

#photo-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  border: 1px solid rgba(242, 244, 243, 0.28);
  background: #0a0a0d;
  overflow: hidden;
}

#reg-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.5s ease;
}
#reg-photo.shown { opacity: 1; }

/* La malla de bloques se dibuja YA nítida en el último paso — el fundido de
   salida solo entrega el relevo a la <img> nativa, sin doble transición visible */
#reg-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 1;
  transition: opacity 0.25s ease;
}
#reg-canvas.fading { opacity: 0; }

#idle-canvas {
  position: absolute;
  inset: 0;
  z-index: 4;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 0.18s linear;
  pointer-events: none;
}

#photo-wrap.idle-active #idle-canvas { opacity: 1; }

#idle-hud {
  position: absolute;
  z-index: 5;
  inset: 9px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  opacity: 0;
  color: rgba(242, 244, 243, 0.82);
  font-size: 8px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0.12em;
  text-shadow: 0 1px 0 #0a0a0d, 1px 0 0 #0a0a0d;
  transition: opacity 0.18s linear;
  pointer-events: none;
}

#idle-hud span:last-child {
  margin-top: auto;
  color: rgba(242, 244, 243, 0.55);
}

#photo-wrap.idle-active #idle-hud { opacity: 1; }

.photo-static {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 0.4s ease;
  pointer-events: none;
}
.photo-static.faded { opacity: 0; }

/* ── Ficha ministerial ────────────────────────────────────────────────── */
#ficha {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ficha-header {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.1em;
  min-height: 1.3em;
  border-bottom: 1px solid rgba(242, 244, 243, 0.28);
  padding-bottom: 8px;
}

.ficha-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ficha-label {
  font-size: 9px;
  letter-spacing: 0.14em;
  color: rgba(242, 244, 243, 0.45);
}

.ficha-value {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  min-height: 1.3em;
}

/* ── Player forense — bloque administrativo, no Spotify ───────────────── */
#player {
  border: 1px solid rgba(242, 244, 243, 0.28);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.player-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  border-bottom: 1px dotted rgba(242, 244, 243, 0.14);
  padding-bottom: 7px;
}

.p-value {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-align: right;
}

.p-muestra {
  display: flex;
  align-items: baseline;
  gap: 8px;
  overflow: hidden;
}

#player-bar {
  font-size: 11px;
  letter-spacing: 1px;
  white-space: nowrap;
}

#player-time {
  font-size: 10px;
  color: rgba(242, 244, 243, 0.55);
  flex-shrink: 0;
}

#play-btn {
  background: transparent;
  border: 1px solid #f2f4f3;
  color: #f2f4f3;
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 11px 8px;
  cursor: pointer;
  margin-top: 2px;
}
#play-btn:active { background: rgba(242, 244, 243, 0.12); }
#play-btn:disabled { opacity: 0.4; cursor: default; }

.player-aviso {
  margin: 0;
  font-size: 9px;
  letter-spacing: 0.08em;
  line-height: 1.5;
  color: rgba(242, 244, 243, 0.45);
}

/* ── Índice — el archivo sanando ──────────────────────────────────────── */
.indice-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: rgba(242, 244, 243, 0.45);
  margin-bottom: 8px;
}

#indice-rows {
  display: flex;
  flex-direction: column;
}

.indice-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: transparent;
  border: none;
  border-top: 1px solid rgba(242, 244, 243, 0.14);
  color: #f2f4f3;
  font-family: inherit;
  text-align: left;
  padding: 11px 2px;
  cursor: pointer;
}
.indice-row:last-child { border-bottom: 1px solid rgba(242, 244, 243, 0.14); }

.indice-num {
  flex: 0 0 68px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 6px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.15em;
}

.indice-marker { letter-spacing: 0; }

/* Columna media — llena el hueco entre el número y el estado del sistema;
   vacía en las filas bloqueadas (no hay nada que mostrar todavía) */
.indice-estado {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: rgba(242, 244, 243, 0.8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.indice-status {
  flex: 0 0 auto;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: rgba(242, 244, 243, 0.55);
  text-align: right;
}

.indice-row.locked { color: rgba(242, 244, 243, 0.4); cursor: default; }
.indice-row.unlocked:active { background: rgba(242, 244, 243, 0.07); }
.indice-row.active .indice-code { text-decoration: underline; text-underline-offset: 4px; }
.indice-row.denied .indice-status {
  color: #f2f4f3;
  font-weight: 700;
  animation: blink 0.3s step-end 2;
}

/* ── Reconstrucción completa — réplicas externas ──────────────────────── */
#recon-banner {
  border: 1px solid rgba(242, 244, 243, 0.4);
  padding: 14px 12px;
  margin-bottom: 18px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.recon-line {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

#full-archive-btn {
  display: inline-block;
  text-decoration: none;
  background: transparent;
  border: 1px solid #f2f4f3;
  color: #f2f4f3;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 11px 12px;
  cursor: pointer;
}
#full-archive-btn:active { background: rgba(242, 244, 243, 0.12); }

/* ── Acción persistente por fase — la única salida, siempre presente ────── */
#cta-signal {
  padding: 20px 16px 28px;
  border-top: 1px solid rgba(242, 244, 243, 0.14);
}
#cta-signal a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  text-decoration: none;
  color: #f2f4f3;
  border: 1px solid #f2f4f3;
  padding: 13px 12px;
  text-align: center;
}
#cta-signal a:active { background: rgba(242, 244, 243, 0.12); }
#cta-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
}
#cta-sub {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: rgba(242, 244, 243, 0.42);
}

@media (prefers-reduced-motion: reduce) {
  .cursor { animation: none; opacity: 1; }
  #reg-photo, .photo-static, #reg-canvas, #idle-canvas, #idle-hud, #intro-gate, #intro-frame, #main { transition: none; }
  #idle-canvas, #idle-hud { display: none; }
}
