/* Lato autoalojada: en sala no se puede depender de que haya red buena.
   Es la misma tipografía que llevan pegada los bloques de la instalación. */
@font-face {
  font-family: 'Lato'; font-style: normal; font-weight: 300; font-display: swap;
  src: url('fuentes/lato-latin-300-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Lato'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('fuentes/lato-latin-400-normal.woff2') format('woff2');
}

/* GREY SPACES · AR — superposición
   Gris de la pieza, cobre de los tubos, frío de la señal. */

:root {
  --fondo: #0b0d0f;
  --gris: #babfc4;
  --gris-tenue: rgba(186, 191, 196, 0.55);
  --cobre: #d08b4f;
  --campo: #00ff21;   /* el verde de IRIDIA */
  --claiming: #ff4d3d;
  --linea: rgba(186, 191, 196, 0.16);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--fondo);
  color: var(--gris);
  font-family: Lato, "Helvetica Neue", Arial, sans-serif;
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  touch-action: manipulation;
}

#ar {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  overflow: hidden;
}
#ar video, #ar canvas { object-fit: cover; }

/* ---------- Portada ----------
   Una cartela: cabecera, imagen, texto. Sin brillos ni degradados; el único
   movimiento es el de la señal. */
#portada {
  position: fixed; inset: 0; z-index: 40;
  display: grid; grid-template-rows: auto 1fr auto;
  padding: calc(16px + var(--safe-t)) 20px calc(16px + var(--safe-b));
  background: #07090b;
  overflow: hidden;
  transition: opacity .6s ease, visibility .6s;
}
#portada.fuera { opacity: 0; visibility: hidden; pointer-events: none; }
#cielo { display: block; width: 100%; height: 100%; min-height: 0; }

.cabecera {
  display: grid; gap: 3px;
  padding-bottom: 12px; border-bottom: 1px solid var(--linea);
  font-size: 11px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--gris-tenue);
}
.cabecera .kicker { color: #e6e9eb; }

.marco { width: 100%; max-width: 440px; justify-self: center; animation: aparecer 1s .2s ease both; }

/* Las barras del Tratado, sin letras. */
.barras { display: grid; gap: 4px; margin: 14px 0 14px; width: 40%; }
.barras i { display: block; height: 4px; width: var(--w); background: var(--gris); opacity: .28; }
.barras i:nth-child(4) { background: var(--claiming); opacity: .85; }

h1 {
  margin: 0 0 2px; font-size: clamp(26px, 7.6vw, 36px); font-weight: 300;
  letter-spacing: .2em; color: #fff; line-height: 1.1; white-space: nowrap;
}
#subtitulo {
  margin: 0 0 12px; font-size: 11.5px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--gris-tenue);
}

.lectura {
  display: grid; grid-template-columns: 1fr auto; gap: 0 12px; align-items: baseline;
  padding: 9px 0; margin-bottom: 12px;
  border-top: 1px solid var(--linea); border-bottom: 1px solid var(--linea);
  font-variant-numeric: tabular-nums;
}
.lectura-eti { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--gris-tenue); }
.lectura-hito { font-size: 11px; letter-spacing: .18em; color: var(--campo); }
.lectura-num { grid-column: 1 / -1; font-size: 24px; letter-spacing: .03em; color: #fff; }
.lectura-num strong { font-weight: 300; color: var(--campo); }

.cuerpo { margin: 0 0 16px; font-size: 14px; line-height: 1.55; color: #cfd4d8; }

#btn-entrar {
  width: 100%; padding: 15px 18px;
  background: transparent; color: #fff;
  border: 1px solid var(--campo);
  font: inherit; font-size: 13px; letter-spacing: .2em; text-transform: uppercase;
  cursor: pointer; transition: background .2s ease, color .2s ease;
}
#btn-entrar:hover:not(:disabled), #btn-entrar:active:not(:disabled) { background: var(--campo); color: #041a08; }
#btn-entrar:disabled { opacity: .55; cursor: default; border-color: var(--linea); }

.pista { margin: 10px 0 0; font-size: 12px; color: var(--gris-tenue); text-align: center; }

#error { margin: 12px 0 0; font-size: 13px; line-height: 1.5; color: var(--claiming); display: none; }
#error.visible { display: block; }

@keyframes aparecer { from { opacity: 0; } to { opacity: 1; } }

/* Móviles bajos (iPhone SE y similares): menos aire, el asteroide manda. */
@media (max-height: 720px) {
  .barras { display: none; }
  .marco { margin-top: 12px; }
  #subtitulo { margin-bottom: 8px; }
  .lectura { padding: 6px 0; margin-bottom: 8px; }
  .lectura-num { font-size: 20px; }
  .cuerpo { font-size: 13px; line-height: 1.45; margin-bottom: 10px; }
  #btn-entrar { padding: 12px 18px; }
  .pista { margin-top: 6px; }
  .enlaces { margin-top: 8px; padding-top: 6px; }
}

/* ---------- Enlaces permanentes ---------- */
.enlaces {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 10px;
  margin-top: 16px; padding-top: 10px; border-top: 1px solid var(--linea);
  font-size: 12px; letter-spacing: .03em;
}
.enlaces a { color: var(--gris-tenue); text-decoration: none; padding: 4px 0; }
.enlaces a:hover, .enlaces a:focus-visible { color: #fff; }
.enlaces a.pdf { color: #e6e9eb; }

/* En la vista AR: barra fina abajo, siempre visible, sin tapar la cámara. */
.enlaces-ar {
  position: fixed; z-index: 20; left: 0; right: 0;
  bottom: calc(4px + var(--safe-b));
  margin: 0; padding: 6px 14px; border-top: 0; justify-content: center; gap: 4px 18px; font-size: 11px;
}
.enlaces-ar a { padding: 6px 2px; text-shadow: 0 1px 8px rgba(0, 0, 0, .9); }
body.previa .enlaces-ar { display: none; }

/* ---------- Estado del anclaje ---------- */
.estado {
  position: fixed; z-index: 20;
  top: calc(14px + var(--safe-t)); left: 14px;
  display: inline-flex; align-items: center; gap: 9px;
  padding: 9px 14px;
  background: rgba(8, 10, 12, .62);
  backdrop-filter: blur(9px); -webkit-backdrop-filter: blur(9px);
  border: 1px solid var(--linea);
  font-size: 12px; letter-spacing: .06em; color: #dfe3e6;
  transition: opacity .4s ease;
}
.estado .punto {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--gris-tenue);
  box-shadow: 0 0 0 0 currentColor;
}
.estado.buscando .punto { background: var(--gris-tenue); animation: latir 1.6s infinite; }
.estado.ok .punto { background: var(--campo); }
.estado.reten .punto { background: var(--cobre); animation: latir 1s infinite; }
@keyframes latir { 0%,100% { opacity: 1 } 50% { opacity: .25 } }

/* ---------- Recolocar (solo modo libre) ---------- */
#btn-recolocar {
  position: fixed; z-index: 20; display: none;
  left: 50%; transform: translateX(-50%);
  bottom: calc(92px + var(--safe-b));
  padding: 10px 16px;
  background: rgba(8, 10, 12, .62);
  backdrop-filter: blur(9px); -webkit-backdrop-filter: blur(9px);
  border: 1px solid var(--linea); color: var(--gris-tenue);
  font: inherit; font-size: 12px; letter-spacing: .12em; text-transform: uppercase;
  cursor: pointer;
}
body.libre #btn-recolocar { display: block; }
.estado.apunta .punto { background: var(--campo); animation: latir 1.1s infinite; }

/* ---------- Capas ---------- */
#btn-capas {
  position: fixed; z-index: 20;
  top: calc(14px + var(--safe-t)); right: 14px;
  padding: 9px 14px;
  background: rgba(8, 10, 12, .62);
  backdrop-filter: blur(9px); -webkit-backdrop-filter: blur(9px);
  border: 1px solid var(--linea); color: #dfe3e6;
  font: inherit; font-size: 12px; letter-spacing: .1em; cursor: pointer;
}
#capas {
  position: fixed; z-index: 20;
  top: calc(56px + var(--safe-t)); right: 14px;
  display: grid; gap: 1px;
  opacity: 0; visibility: hidden; transform: translateY(-6px);
  transition: opacity .25s ease, transform .25s ease, visibility .25s;
}
#capas.abierto { opacity: 1; visibility: visible; transform: none; }
.capa {
  padding: 9px 14px; min-width: 168px; text-align: left;
  background: rgba(8, 10, 12, .72);
  backdrop-filter: blur(9px); -webkit-backdrop-filter: blur(9px);
  border: 1px solid var(--linea); border-bottom: 0;
  color: var(--gris-tenue); font: inherit; font-size: 12px; letter-spacing: .05em;
  cursor: pointer;
}
#capas .capa:last-child { border-bottom: 1px solid var(--linea); }
.capa.on { color: #fff; box-shadow: inset 2px 0 0 var(--campo); }

/* ---------- Pie ---------- */
#pie {
  position: fixed; z-index: 20;
  left: 0; right: 0; bottom: calc(40px + var(--safe-b));
  display: grid; justify-items: center; gap: 3px;
  padding: 0 16px; pointer-events: none;
  opacity: 0; transition: opacity .35s ease;
}
#pie.visible { opacity: 1; }
#pie-frec { font-size: 11px; letter-spacing: .18em; color: var(--gris-tenue); text-transform: uppercase; }
#pie-dato {
  font-weight: 300; font-size: 17px; letter-spacing: .04em; color: #fff;
  text-shadow: 0 1px 14px rgba(0, 0, 0, .75);
}

/* ---------- Aviso ---------- */
#aviso {
  position: fixed; z-index: 30;
  left: 50%; bottom: calc(104px + var(--safe-b));
  transform: translate(-50%, 8px);
  padding: 11px 18px; max-width: 88vw;
  background: rgba(8, 10, 12, .86);
  border: 1px solid var(--linea);
  font-size: 13px; color: #e7eaec; text-align: center;
  opacity: 0; visibility: hidden;
  transition: opacity .3s ease, transform .3s ease, visibility .3s;
}
#aviso.visible { opacity: 1; visibility: visible; transform: translate(-50%, 0); }

/* ---------- Calibración ---------- */
#calibrar {
  position: fixed; z-index: 35;
  left: 0; right: 0; bottom: 0;
  max-height: 74vh; overflow: auto;
  padding: 16px 16px calc(20px + var(--safe-b));
  background: rgba(8, 10, 12, .93);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--linea);
  transform: translateY(101%);
  transition: transform .35s cubic-bezier(.22, .8, .3, 1);
}
#calibrar.abierto { transform: none; }
#calibrar header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px; font-size: 13px; letter-spacing: .1em; color: #fff;
}
#cal-cerrar {
  background: none; border: 1px solid var(--linea); color: var(--gris-tenue);
  font: inherit; font-size: 11px; padding: 5px 10px; cursor: pointer;
}
#cal-marcador {
  width: 100%; margin-bottom: 14px; padding: 10px;
  background: #12161a; color: #fff; border: 1px solid var(--linea);
  font: inherit; font-size: 13px;
}
.cal-fila {
  display: grid; grid-template-columns: 1fr auto; align-items: center;
  gap: 4px 10px; margin-bottom: 10px; font-size: 12px; color: var(--gris-tenue);
}
.cal-fila input { grid-column: 1 / -1; width: 100%; accent-color: var(--campo); }
.cal-fila output { font-variant-numeric: tabular-nums; color: #fff; }
.cal-nota { font-size: 11px; line-height: 1.5; color: var(--gris-tenue); margin: 4px 0 12px; }
.cal-nota em { color: var(--campo); font-style: normal; }
#cal-copiar {
  width: 100%; padding: 12px; background: transparent; color: #fff;
  border: 1px solid var(--campo); font: inherit; font-size: 12px;
  letter-spacing: .14em; text-transform: uppercase; cursor: pointer;
}

/* En previa no hace falta el indicador de anclaje. */
body.previa .estado { display: none; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
