/* PULSAR — señales al futuro
   Sistema visual: precisión de instrumento óptico + solemnidad de observatorio.
   B&N absoluto (#000 real). Cuatro niveles de blanco y ni uno más.
   Tres voces Geist: Pixel Triangle (display sagrada), Mono (instrumento),
   Sans (cuerpo). Self-hosted, sin CDNs. Espaciado en múltiplos de 8px.
   UN SOLO EJE: todo (hero, esquinas, secciones, footer) alinea a --mx. */

/* ── fuentes ─────────────────────────────────────────────────────────── */
@font-face {
  font-family: 'Geist Pixel Triangle';
  font-style: normal; font-weight: 400; font-display: swap;
  src: url('assets/fonts/GeistPixel-Triangle.woff2') format('woff2');
}
@font-face {
  font-family: 'Geist Mono';
  font-style: normal; font-weight: 400; font-display: swap;
  src: url('assets/fonts/GeistMono-Regular.woff2') format('woff2');
}
@font-face {
  font-family: 'Geist';
  font-style: normal; font-weight: 300; font-display: swap;
  src: url('assets/fonts/Geist-Light.woff2') format('woff2');
}
@font-face {
  font-family: 'Geist';
  font-style: normal; font-weight: 400; font-display: swap;
  src: url('assets/fonts/Geist-Regular.woff2') format('woff2');
}
@font-face {
  font-family: 'Geist';
  font-style: normal; font-weight: 500; font-display: swap;
  src: url('assets/fonts/Geist-Medium.woff2') format('woff2');
}

/* ── tokens ──────────────────────────────────────────────────────────── */
:root {
  --pixel: 'Geist Pixel Triangle', 'Geist Mono', monospace;
  --mono: 'Geist Mono', ui-monospace, Menlo, Consolas, monospace;
  --sans: 'Geist', system-ui, -apple-system, sans-serif;

  /* Los ÚNICOS cuatro blancos de la página. */
  --w-100: #ffffff;                    /* protagonista */
  --w-85: rgba(255, 255, 255, 0.85);   /* secundario  */
  --w-50: rgba(255, 255, 255, 0.5);    /* instrumento */
  --w-25: rgba(255, 255, 255, 0.25);   /* estructura  */

  --mx: clamp(24px, 5vw, 96px);        /* margen lateral = EL eje */
  --gutter: 24px;
  --col: calc((100vw - 2 * var(--mx) - 11 * var(--gutter)) / 12);

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  /* la elegancia vive en cómo las cosas VUELVEN: salida > entrada */
  --t-in: 0.2s;
  --t-out: 0.4s;
}

* { box-sizing: border-box; }

html { background: #000; scroll-behavior: smooth; }
body {
  margin: 0; background: #000; color: var(--w-100);
  font-family: var(--sans); font-weight: 300;
  overflow-x: hidden;
}

::selection { background: #fff; color: #000; }

/* scrollbar de instrumento */
html { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.25) #000; }
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #000; }
::-webkit-scrollbar-thumb { background: var(--w-25); }
::-webkit-scrollbar-thumb:hover { background: var(--w-50); }

.mono {
  font-family: var(--mono); text-transform: uppercase;
  letter-spacing: 0.14em; font-weight: 400;
}
.num, #freqRead, #clock, #panel .val {
  font-feature-settings: 'tnum';
  font-variant-numeric: tabular-nums;
}

a { color: inherit; text-decoration: none; }
a:focus-visible, button:focus-visible, input:focus-visible, .k:focus-visible {
  outline: 1px solid var(--w-100); outline-offset: 3px;
}

/* ── capas de fondo globales ─────────────────────────────────────────── */
/* Grano de película */
#grain {
  position: fixed; inset: -50%; width: 200%; height: 200%;
  pointer-events: none; z-index: 90;
  opacity: 0.035; background-repeat: repeat;
  animation: grain-jump 0.6s steps(4) infinite;
}
@keyframes grain-jump {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-3%, 2%); }
  50% { transform: translate(2%, -3%); }
  75% { transform: translate(-1%, -2%); }
  100% { transform: translate(3%, 1%); }
}

/* Campo de anillos: la firma de la membrana continúa detrás de toda la
   página — anillos concéntricos de 1px, tenues, centrados donde vive el
   disco en el hero. Parallax leve por scroll (transform-only, en JS). */
#bgrings {
  position: fixed; inset: -12% 0; pointer-events: none; z-index: 0;
  background: repeating-radial-gradient(circle at 68% 42%,
    rgba(255, 255, 255, 0.045) 0 1px, transparent 1px 72px);
  will-change: transform;
}
#hero, .section, #cierre, #marquee, footer { position: relative; z-index: 1; }

/* ── HERO ─────────────────────────────────────────────────────────────── */
#hero { position: relative; height: 100vh; height: 100svh; background: #000; }
#stage { position: absolute; inset: 0; }
canvas#c {
  position: absolute; inset: 0; width: 100%; height: 100%;
  display: block; cursor: crosshair; background: #000;
  touch-action: pan-y;
}

/* bloque editorial: columnas 1–5, centrado vertical con corrección óptica */
.hero-copy {
  position: absolute; z-index: 5; pointer-events: none;
  left: var(--mx);
  width: calc(5 * var(--col) + 4 * var(--gutter));
  top: 46%; transform: translateY(-50%);
}
.hero-copy .ctas, .hero-copy a { pointer-events: auto; }

body.preintro .hero-copy,
body.preintro #hud { opacity: 0; }
.hero-copy, #hud { transition: opacity 1.1s var(--ease-out); }
body.panel-open .hero-copy { opacity: 0; pointer-events: none; transition: opacity 0.4s var(--ease-out); }

/* H1: la voz sagrada. Filas de triángulos — un segundo patrón vibratorio. */
#hero h1 {
  margin: 0;
  /* alineación ÓPTICA: la P de Pixel Triangle trae side-bearing propio;
     este margen negativo lleva su borde visible al eje del bloque */
  margin-left: -0.055em;
  font-family: var(--pixel); font-weight: 400;
  font-size: clamp(88px, 12vw, 200px);
  line-height: 0.95;
  letter-spacing: 0.015em;   /* Triangle pide aire entre texturas */
  color: var(--w-100);
}
.hero-copy .sub {
  margin: 20px 0 0;
  font-family: var(--sans); font-weight: 500;
  font-size: clamp(20px, 2vw, 30px); line-height: 1.35;
  color: var(--w-85);
}
.hero-copy .tags {
  margin: 16px 0 0; font-size: 11px; color: var(--w-50);
}

/* ── CTAs ─────────────────────────────────────────────────────────────── */
.ctas { display: flex; gap: 16px; margin-top: 40px; }

.cta {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  height: 52px; padding: 0 32px; border-radius: 0;
  font-family: var(--mono); font-size: 11px; font-weight: 400;
  letter-spacing: 0.14em; text-transform: uppercase;
  cursor: pointer; user-select: none;
  transition: transform var(--t-out) var(--ease-out),
              background-color var(--t-out) var(--ease-out),
              border-color var(--t-out) var(--ease-out),
              color var(--t-out) var(--ease-out);
}
.cta:hover { transition-duration: var(--t-in); }
.cta:active { transform: scale(0.985); transition-duration: 0.08s; }

/* primario: blanco pleno; hover = onda radial negra desde el cursor.
   El borde blanco de 1px es permanente: invisible sobre el fondo blanco,
   y al cubrirse de negro queda idéntico al botón fantasma — coherencia
   estética total y cero filos residuales de rasterizado en los bordes. */
.cta-primary {
  border: 1px solid #fff; background: #fff; color: #000;
}
.cta-primary::after {
  content: ''; position: absolute; inset: 0; z-index: 0;
  background: #000;
  clip-path: circle(0% at var(--wx, 50%) var(--wy, 50%));
  transition: clip-path 0.5s var(--ease-out);
}
.cta-primary:hover::after {
  clip-path: circle(170% at var(--wx, 50%) var(--wy, 50%));
}
.cta-primary > span {
  position: relative; z-index: 1;
  color: #fff; mix-blend-mode: difference;   /* cruza a blanco cuando la onda lo cubre */
}

/* secundario: ghost con recorrido de borde */
.cta-ghost {
  background: transparent; border: 1px solid rgba(255,255,255,0.3);
  color: var(--w-85);
}
.cta-ghost:hover {
  border-color: rgba(255,255,255,0.7);
  background: rgba(255,255,255,0.04);
  color: var(--w-100);
}
.cta-ghost .run {
  position: absolute; inset: -1px; width: calc(100% + 2px); height: calc(100% + 2px);
  pointer-events: none; overflow: visible;
}
.cta-ghost .run rect {
  width: calc(100% - 1px); height: calc(100% - 1px); x: 0.5px; y: 0.5px;
  fill: none; stroke: var(--w-100); stroke-width: 1;
  stroke-dasharray: 0.18 0.82; stroke-dashoffset: 0.18;
  opacity: 0;
}
.cta-ghost:hover .run rect { animation: border-run 0.8s ease forwards; }
@keyframes border-run {
  0% { stroke-dashoffset: 0.18; opacity: 1; }
  100% { stroke-dashoffset: -0.82; opacity: 0; }
}

/* ── capa instrumento: esquinas alineadas al eje ─────────────────────── */
#hud {
  position: absolute; inset: 0; z-index: 10; pointer-events: none;
  font-family: var(--mono); font-size: 11px; line-height: 1.7;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--w-50); user-select: none;
}
#hud.hidden { display: none; }

/* Los microtextos habitan los vértices, alineados al MISMO eje --mx que
   el bloque editorial y las secciones. */
.corner { position: absolute; display: flex; flex-direction: column; }
.corner.tl { top: 32px; left: var(--mx); }
.corner.tr { top: 32px; right: var(--mx); text-align: right; }
.corner.bl { bottom: 32px; left: var(--mx); }
.corner.br { bottom: 32px; right: var(--mx); text-align: right; }
.corner .dim { color: var(--w-25); }
.corner a { pointer-events: auto; transition: color var(--t-out) var(--ease-out); }
.corner a:hover { color: var(--w-85); transition-duration: var(--t-in); }

/* entrada de esquinas: último acto del boot, horario desde sup-izq */
.corner { opacity: 0; transition: opacity 0.7s var(--ease-out); }
body.corners-in .corner { opacity: 1; }
body.corners-in .corner.tl { transition-delay: 0ms; }
body.corners-in .corner.tr { transition-delay: 150ms; }
body.corners-in .corner.br { transition-delay: 300ms; }
body.corners-in .corner.bl { transition-delay: 450ms; }

/* guías de mesa de medición que siguen al cursor sobre los ejes del canvas */
#tickX, #tickY {
  position: absolute; background: var(--w-50); pointer-events: none;
  opacity: 0; transition: opacity 0.6s var(--ease-out);
}
#tickX { top: 0; width: 1px; height: 6px; }
#tickY { left: 0; width: 6px; height: 1px; }
#stage.ticks #tickX, #stage.ticks #tickY { opacity: 1; }

#panelBtn {
  pointer-events: auto; background: none; border: 0; padding: 0; margin: 0;
  font: inherit; letter-spacing: inherit; text-transform: inherit;
  color: var(--w-50); cursor: pointer; text-align: left;
  transition: color var(--t-out) var(--ease-out);
}
#panelBtn:hover { color: var(--w-85); transition-duration: var(--t-in); }

/* ── panel de manipulación ────────────────────────────────────────────── */
#labpanel {
  position: absolute; left: var(--mx); bottom: 80px; pointer-events: auto;
  display: none;
}
#labpanel.open { display: block; }

#panel { display: flex; flex-direction: column; }
#panel .row {
  display: grid; grid-template-columns: 88px 136px 64px;
  gap: 16px; align-items: center;
  padding: 8px 0; border-top: 1px solid var(--w-25);
}
#panel .row:first-child { border-top: 0; }
#panel .row .val { text-align: right; }

#labpanel.open #panel .row, #labpanel.open #keys {
  opacity: 0; transform: translateY(4px);
  animation: row-boot 0.45s var(--ease-out) forwards;
}
@keyframes row-boot { to { opacity: 1; transform: none; } }

#keys { padding: 12px 0 0; border-top: 1px solid var(--w-25); margin-top: 8px; }
#hud .k {
  pointer-events: auto; cursor: pointer;
  transition: color var(--t-out) var(--ease-out);
}
#hud .k:hover { color: var(--w-85); transition-duration: var(--t-in); }

#panel input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 16px; margin: 0;
  background: transparent; cursor: ew-resize;
}
#panel input[type="range"]::-webkit-slider-runnable-track {
  height: 1px; background: var(--w-25);
}
#panel input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 7px; height: 7px; margin-top: -3px;
  background: var(--w-85); border-radius: 0;
}
#panel input[type="range"]:hover::-webkit-slider-thumb { background: var(--w-100); }
#panel input[type="range"]::-moz-range-track { height: 1px; background: var(--w-25); }
#panel input[type="range"]::-moz-range-thumb {
  width: 7px; height: 7px; border: none;
  background: var(--w-85); border-radius: 0;
}
#panel input[type="range"]:hover::-moz-range-thumb { background: var(--w-100); }

/* ── secciones ───────────────────────────────────────────────────────── */
.section {
  padding: clamp(120px, 18vh, 240px) var(--mx);
}

/* regla de eje: overline EN el eje + hairline que corre hasta el margen */
.rule {
  display: flex; align-items: center; gap: 24px;
  margin-bottom: 80px;
}
.rule .overline {
  font-size: 11px; color: var(--w-50); white-space: nowrap;
}
.rule::after {
  content: ''; height: 1px; flex: 1; background: var(--w-25);
}

/* reveals base */
.reveal { opacity: 0; transform: translateY(16px); }
.reveal.in {
  opacity: 1; transform: none;
  transition: opacity 1s var(--ease-out), transform 1s var(--ease-out);
}

/* reveal por líneas enmascaradas (títulos): cada palabra sube desde su
   máscara con stagger — se activa al entrar al viewport */
.mask-w {
  display: inline-block; overflow: hidden;
  vertical-align: bottom; margin-right: 0.28em;
}
.mask-w > span {
  display: inline-block; transform: translateY(115%);
  transition: transform 0.9s var(--ease-out);
  transition-delay: calc(var(--i, 0) * 55ms);
}
.in .mask-w > span, .lines-in .mask-w > span { transform: none; }

/* párrafos: aparición secuencial */
.seq { opacity: 0; transform: translateY(14px); }
.in .seq {
  opacity: 1; transform: none;
  transition: opacity 0.9s var(--ease-out), transform 0.9s var(--ease-out);
  transition-delay: calc(var(--i, 0) * 110ms + 200ms);
}

/* MANIFIESTO */
.section h2 {
  margin: 0 0 56px;
  font-family: var(--sans); font-weight: 300;
  font-size: clamp(40px, 5vw, 72px); line-height: 1.1;
  color: var(--w-100);
  text-wrap: balance;
}
#manifiesto .body { max-width: 62ch; }
#manifiesto .body p {
  margin: 0 0 1.6em;
  font-family: var(--sans); font-weight: 300;
  font-size: 19px; line-height: 1.7; color: var(--w-85);
}
#manifiesto .close-line {
  margin: 80px 0 0; font-size: 11px; color: var(--w-50);
}

/* SEÑALES (oculta por flag; lista para activarse) */
#signals .sig-table { font-size: 12px; max-width: 880px; }
#signals .sig-row {
  display: grid; grid-template-columns: 112px 1fr 136px 64px;
  gap: 16px; padding: 16px 0; align-items: baseline;
  border-top: 1px solid var(--w-25);
  color: var(--w-50); position: relative;
  transition: color var(--t-out) var(--ease-out);
}
#signals .sig-head { color: var(--w-25); border-top: 0; font-size: 10px; }
#signals .sig-row:not(.sig-head):hover,
#signals .sig-row:not(.sig-head):focus-visible {
  color: var(--w-100); transition-duration: var(--t-in);
}
#signals .sig-desc {
  grid-column: 1 / -1; font-size: 11px; color: var(--w-50);
  max-height: 0; overflow: hidden; text-transform: none; letter-spacing: 0.04em;
  transition: max-height var(--t-out) var(--ease-out), padding var(--t-out) var(--ease-out);
}
#signals .sig-row:hover .sig-desc,
#signals .sig-row:focus-visible .sig-desc { max-height: 3em; padding-top: 8px; }
#signals .sig-dead { opacity: 0.4; }
#signals .sig-dead > span:nth-child(2) { text-decoration: line-through; }

/* ── CIERRE ──────────────────────────────────────────────────────────── */
#cierre {
  min-height: 88vh; display: flex; flex-direction: column;
  align-items: flex-start; justify-content: center;
  gap: 56px; padding: clamp(120px, 18vh, 240px) var(--mx);
}
#cierre .statement {
  margin: 0; max-width: 18ch;
  font-family: var(--sans); font-weight: 300;
  font-size: clamp(36px, 5vw, 72px); line-height: 1.15;
  color: var(--w-100);
}
#contact { color: var(--w-85); }

/* ── marquee final: la señal corre en Pixel Triangle ─────────────────── */
#marquee {
  overflow: hidden; padding: 64px 0 56px;
  border-top: 1px solid var(--w-25);
}
.mq-track {
  display: flex; white-space: nowrap; width: max-content;
  will-change: transform;
  animation: mq 36s linear infinite;
}
.mq-track span {
  font-family: var(--pixel); font-weight: 400;
  font-size: clamp(56px, 7vw, 112px); line-height: 1;
  letter-spacing: 0.015em;
  color: var(--w-25);
  padding-right: 0.9em;
}
/* de izquierda a derecha: el track (2 mitades idénticas) viaja −50% → 0 */
@keyframes mq {
  from { transform: translateX(-50%); }
  to { transform: translateX(0); }
}

footer {
  padding: 40px var(--mx) 48px;
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px;
  font-size: 10px; color: var(--w-50);
}
footer a {
  position: relative; color: var(--w-50);
  transition: color var(--t-out) var(--ease-out);
}
footer a:hover { color: var(--w-100); transition-duration: var(--t-in); }
footer a::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -4px;
  height: 1px; background: var(--w-100);
  transform: scaleX(0); transform-origin: left;
  transition: transform var(--t-out) var(--ease-out);
}
footer a:hover::after { transform: scaleX(1); transition-duration: var(--t-in); }

/* ── secuencia de entrada ────────────────────────────────────────────── */
#intro {
  position: fixed; inset: 0; z-index: 200; background: #000;
  pointer-events: none; opacity: 1;
  transition: opacity 0.9s var(--ease-out);
}
#intro.gone { opacity: 0; }
#introType {
  position: fixed; left: var(--mx); bottom: 32px; z-index: 210;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--w-100); pointer-events: none;
  transition: opacity 0.5s var(--ease-out);
}
#introType.gone { opacity: 0; }
#introType .cursor { animation: blink 0.9s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
#introType .type-sub { margin-top: 4px; color: var(--w-25); }

/* ── fallback sin WebGL2 ─────────────────────────────────────────────── */
#fallback {
  position: fixed; inset: 0; display: none; place-items: center; background: #000;
  color: var(--w-50); z-index: 300;
  font-family: var(--mono); font-size: 11px; line-height: 2;
  letter-spacing: 0.14em; text-transform: uppercase; text-align: center;
}
#fallback .disc {
  width: 38vmin; height: 38vmin; border-radius: 50%; margin: 0 auto 32px;
  background: radial-gradient(circle at 50% 42%,
    rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.045) 46%, #000 74%);
  box-shadow: inset 0 0 18vmin rgba(255, 255, 255, 0.05);
}

/* ── reduced motion: estados finales correctos, sin coreografías ─────── */
@media (prefers-reduced-motion: reduce) {
  #grain { animation: none; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .mask-w > span { transform: none; transition: none; }
  .seq { opacity: 1; transform: none; transition: none; }
  .corner { transition: none; }
  .cta-primary::after { transition: none; }
  .cta-ghost:hover .run rect { animation: none; }
  .mq-track { animation: none; }
  #labpanel.open #panel .row, #labpanel.open #keys { animation-duration: 0.01s; }
  #introType .cursor { animation: none; }
}

/* ── mobile ──────────────────────────────────────────────────────────── */
@media (max-width: 820px) {
  #hero { height: auto; min-height: 100vh; }
  #stage { position: relative; height: 70vh; }
  .hero-copy {
    position: static; transform: none; width: auto;
    padding: 40px var(--mx) 56px;
  }
  .ctas { flex-direction: column; gap: 16px; margin-top: 40px; }
  .cta { width: 100%; }

  .corner.tl { top: 24px; }
  .corner.tr { top: 24px; }
  /* las esquinas inferiores colapsan en una barra inferior única */
  .corner.bl { bottom: 16px; }
  .corner.br { bottom: 16px; }

  .section { padding: clamp(96px, 14vh, 160px) var(--mx); }
  #cierre .statement { max-width: none; }

  #labpanel {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto;
    background: rgba(0, 0, 0, 0.94);
    border-top: 1px solid var(--w-25);
    padding: 24px var(--mx) calc(24px + env(safe-area-inset-bottom));
    transform: translateY(105%); display: block;
    transition: transform 0.5s var(--ease-out);
    z-index: 60;
  }
  #labpanel.open { transform: translateY(0); }
  #panel .row { grid-template-columns: 88px 1fr 64px; padding: 10px 0; }
  #panel input[type="range"] { height: 32px; }
  #panel input[type="range"]::-webkit-slider-thumb { width: 13px; height: 13px; margin-top: -6px; }
  #panel input[type="range"]::-moz-range-thumb { width: 13px; height: 13px; }
}
