/* ─────────────────────────────────────────────────────────────────
   Andromeda — Terminal de fondo (tecnología / Atlas)
   Un terminal real a pantalla completa detrás del hero: una sesión de
   operaciones con comandos y salidas coherentes, que termina en un
   `tail -f` del log de operaciones que no para, como un vídeo de fondo.
   Se monta con terminal.js sobre cualquier [data-term-bg].
   ─────────────────────────────────────────────────────────────── */

/* Fuentes de terminal. Ambas tienen licencia (Monomials: Coastal Type,
   Everson Mono: shareware de Evertype), así que los ficheros no van en el
   repo hasta tener licencia web. Deja los .woff2 en /assets/fonts/ con estos
   nombres; mientras no estén, se usa la fuente instalada (local) o la mono
   del sistema de diseño. */
@font-face {
  font-family: "Monomials";
  src: local("Monomials"), local("Monomials-Regular"),
       url("./assets/fonts/Monomials-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Everson Mono";
  src: local("Everson Mono"), local("EversonMono"),
       url("./assets/fonts/EversonMono.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Monomials para titulares y cifras; Everson Mono para el texto del terminal. */
  --font-term-display: "Monomials", "Everson Mono", var(--font-mono);
  --font-term:         "Everson Mono", "Monomials", var(--font-mono);

  --term-bg:     #07090D;
  --term-fg:     rgba(251,250,247,0.62);
}

/* ── Capa de fondo ──────────────────────────────────────────────── */
.term-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  overflow-anchor: none;
  background-color: var(--term-bg);
  background-image:
    linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
  user-select: none;
}

.term-bg__screen {
  --fs: 13px;
  --lh: 1.55;
  --pad-b: 40px;
  --pad-x: 24px;
  position: absolute;
  top: 0; bottom: 0; right: 0;
  left: var(--term-left, 0);
  margin: 0;
  font-family: var(--font-term);
  font-size: var(--fs);
  line-height: var(--lh);
  color: var(--term-fg);
  white-space: pre;
  overflow: hidden;
  /* Las líneas nuevas no deben arrastrar el scroll de la página */
  overflow-anchor: none;
  contain: strict;
  -webkit-font-smoothing: antialiased;
  /* se funde hacia arriba, como si el scroll viniera de antes */
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 34%);
          mask-image: linear-gradient(180deg, transparent 0, #000 34%);
}
/* Bloque anclado abajo: crece hacia arriba como un terminal real */
.term-bg__lines {
  position: absolute;
  left: var(--pad-x); right: 32px; bottom: var(--pad-b);
}
.term-bg__lines > div { min-height: calc(var(--lh) * 1em); }

/* Legibilidad del copy: oscurece el lado del texto y un poco los bordes */
.term-bg::after {
  content: "";
  position: absolute; inset: 0;
  background:
    linear-gradient(90deg, rgba(7,9,13,0.97) 0%, rgba(7,9,13,0.9) 40%, rgba(7,9,13,0.3) 60%, rgba(7,9,13,0.08) 100%),
    radial-gradient(ellipse 120% 90% at 70% 50%, transparent 55%, rgba(7,9,13,0.6) 100%);
}

/* Tipos de token */
.term-bg .t-p { color: #8FA8C2; }                     /* prompt */
.term-bg .t-c { color: rgba(251,250,247,0.94); }      /* lo que se teclea */
.term-bg .t-h { color: rgba(251,250,247,0.9); }       /* cabeceras */
.term-bg .t-v { color: rgba(251,250,247,0.84); }      /* valores */
.term-bg .t-d { color: rgba(251,250,247,0.34); }      /* atenuado */
.term-bg .t-k { color: rgba(143,168,194,0.72); }      /* claves / módulos */
.term-bg .t-ok { color: #9FC3A8; }                    /* ok / aceptado */
.term-bg .t-w { color: var(--ember); }                /* excepción */
.term-bg .t-bar { color: #8FA8C2; }                   /* barras de progreso */
.term-bg .t-inv { background: rgba(143,168,194,0.22); color: rgba(251,250,247,0.95); } /* fila seleccionada */
.term-bg .t-cur {
  display: inline-block; width: 0.62em; height: 1.1em; vertical-align: -0.2em;
  background: rgba(251,250,247,0.85);
  animation: term-blink 1.05s steps(1) infinite;
}
@keyframes term-blink { 50% { opacity: 0; } }

@media (min-width: 1100px) {
  .term-bg { --term-left: 47%; }
}
@media (max-width: 1099px) {
  .term-bg__screen { opacity: 0.55; }
  .term-bg::after { background: linear-gradient(180deg, rgba(7,9,13,0.92) 0%, rgba(7,9,13,0.84) 60%, rgba(7,9,13,0.6) 100%); }
}
@media (max-width: 640px) {
  .term-bg__screen { --fs: 10.5px; --pad-b: 24px; --pad-x: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .term-bg .t-cur { animation: none; }
}

/* ─────────────────────────────────────────────────────────────────
   Efectos de terminal para las secciones (terminal-fx.js)
   ─────────────────────────────────────────────────────────────── */
.tfx-mono { font-family: var(--font-term); }
.tfx .t-p, .tfx-p { color: #8FA8C2; }
.tfx .t-c { color: rgba(251,250,247,0.94); }
.tfx .t-v { color: rgba(251,250,247,0.86); }
.tfx .t-d { color: rgba(251,250,247,0.4); }
.tfx .t-k { color: rgba(143,168,194,0.8); }
.tfx .t-ok { color: #9FC3A8; }
.tfx .t-w { color: var(--ember); }
.tfx .t-bar { color: #8FA8C2; }
.tfx .t-cur, .tfx-cur {
  display: inline-block; width: 0.6em; height: 1.1em; vertical-align: -0.2em;
  background: rgba(251,250,247,0.85);
  animation: term-blink 1.05s steps(1) infinite;
}

/* Eyebrows que se teclean al entrar en pantalla */
.tfx-type { width: fit-content; max-width: 100%; }
.tfx-type.is-pending { clip-path: inset(0 100% 0 0); }
.tfx-type.is-typing { animation: tfx-type var(--tfx-dur, 700ms) steps(var(--tfx-steps, 24)) both; }
.tfx-type.is-typing::after {
  content: ""; display: inline-block; width: 0.6em; height: 1em; margin-left: 0.3em; vertical-align: -0.12em;
  background: currentColor;
  animation: term-blink 0.5s steps(1) 4 both;
  animation-delay: var(--tfx-dur, 700ms);
}
@keyframes tfx-type { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }

/* Generalista vs Atlas */
.tfx-vs { margin-top: 56px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.tfx-pane {
  background: #07090D; border: 1px solid rgba(255,255,255,0.10); border-radius: var(--r-md);
  overflow: hidden; min-width: 0;
}
.tfx-pane__bar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 16px; border-bottom: 1px solid rgba(255,255,255,0.08);
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--steel-soft);
}
.tfx-pane--atlas { border-color: rgba(143,168,194,0.32); }
.tfx-pane__state { color: rgba(251,250,247,0.4); }
.tfx-pane__state.is-bad { color: var(--ember); }
.tfx-pane__state.is-good { color: #9FC3A8; }
.tfx-pane__body {
  padding: 18px 16px; height: calc(9 * 1.7em + 36px);
  font-family: var(--font-term); font-size: 12.5px; line-height: 1.7;
  color: rgba(251,250,247,0.62); white-space: pre-wrap; overflow: hidden;
}
.tfx-vs__cases {
  grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px 24px;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--mist);
}
.tfx-vs__cases span { transition: color var(--dur-base) var(--ease-out); }
.tfx-vs__cases span::before { content: "○ "; }
.tfx-vs__cases span.is-on { color: var(--paper); }
.tfx-vs__cases span.is-on::before { content: "● "; color: #8FA8C2; }
@media (max-width: 880px) {
  .tfx-vs { grid-template-columns: 1fr; }
  .tfx-pane__body { height: calc(10 * 1.7em + 36px); font-size: 11.5px; }
}

/* Geo: el terminal existente resuelve en directo */
.at-term.tfx-geo.is-pending .at-term__raw,
.at-term.tfx-geo.is-pending .at-term__arrow,
.at-term.tfx-geo.is-pending .at-kv > *,
.at-term.tfx-geo.is-pending .at-term__foot { visibility: hidden; }
.at-term.tfx-geo.is-run .at-term__raw { animation: tfx-type 1400ms steps(48) both; }
.at-term.tfx-geo.is-run .at-term__arrow { animation: tfx-show 1ms 1500ms both; }
.at-term.tfx-geo.is-run .at-term__arrow::after {
  content: " ⠋"; animation: tfx-spin 800ms steps(1) 1500ms 1 both;
}
.at-term.tfx-geo.is-run .at-kv > * { animation: tfx-type 260ms steps(10) both; animation-delay: calc(2400ms + var(--i) * 110ms); }
.at-term.tfx-geo.is-run .at-term__foot { animation: tfx-show 1ms both; animation-delay: calc(2600ms + var(--n) * 110ms); }
@keyframes tfx-show { from { visibility: hidden; } to { visibility: visible; } }
@keyframes tfx-spin {
  0% { content: " ⠋"; } 12% { content: " ⠙"; } 25% { content: " ⠹"; } 37% { content: " ⠸"; }
  50% { content: " ⠼"; } 62% { content: " ⠴"; } 75% { content: " ⠦"; } 87% { content: " ⠧"; } 100% { content: " ✓"; }
}

/* Corpus: barra de ingesta por celda */
.tfx-ingest {
  margin-top: 20px; padding-top: 14px; border-top: 1px dashed rgba(255,255,255,0.10);
  font-family: var(--font-term); font-size: 11px; line-height: 1.5; color: rgba(251,250,247,0.4);
  white-space: pre; overflow: hidden;
}

/* Bucle de excepciones: ticker + beat activo */
.tfx-ticker {
  margin-top: 36px; padding: 14px 16px; min-height: calc(3 * 1.7em + 28px);
  background: #07090D; border: 1px solid rgba(255,255,255,0.10); border-radius: var(--r-sm);
  font-family: var(--font-term); font-size: 12px; line-height: 1.7; color: rgba(251,250,247,0.62);
  white-space: pre-wrap;
}
.tfx-ticker + .at-loop__beats { margin-top: 20px; }
.at-loop__beat { transition: background-color var(--dur-slow) var(--ease-out), box-shadow var(--dur-slow) var(--ease-out); }
.at-loop__beat.is-live { background: rgba(143,168,194,0.08); box-shadow: inset 0 2px 0 #8FA8C2; }
.at-loop__beat.is-live .at-loop__beat-num::after {
  content: ""; display: inline-block; width: 0.6em; height: 1em; margin-left: 6px; vertical-align: -0.15em;
  background: #8FA8C2; animation: term-blink 0.8s steps(1) infinite;
}

/* Cierre: prompt que se teclea */
.tfx-prompt {
  margin-top: 40px; font-family: var(--font-term); font-size: 13px; line-height: 1.6;
  color: rgba(251,250,247,0.9); white-space: pre-wrap; overflow-wrap: anywhere; min-height: 1.6em;
}
@media (max-width: 640px) {
  .tfx-prompt { font-size: 11.5px; min-height: 3.2em; }
  .tfx-ticker { font-size: 11px; min-height: calc(6 * 1.7em + 28px); }
}

@media (prefers-reduced-motion: reduce) {
  .tfx-type.is-typing, .tfx-type.is-typing::after,
  .at-term.tfx-geo.is-run *, .at-term.tfx-geo.is-run .at-term__arrow::after,
  .at-loop__beat.is-live .at-loop__beat-num::after, .tfx .t-cur { animation: none; }
}
