:root {
  --bg: #000000;
  --ink: #ECE8E1;
  --ink-dim: rgba(236, 232, 225, 0.52);
  --ink-faint: rgba(236, 232, 225, 0.22);
  --red: #ff1f17;
  --red-soft: #ff5a4d;
  --red-glow: rgba(255, 31, 23, 0.55);
  --edge: rgba(236, 232, 225, 0.16);
  --pad: clamp(1.1rem, 3.2vw, 2.6rem);
  --font-display: "Saira Condensed", "Arial Narrow", sans-serif;
  --font-mono: "Space Mono", ui-monospace, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-mono);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- Stage ---------- */
.stage {
  position: fixed;
  inset: 0;            /* top/right/bottom/left:0 -> rellena el viewport sin depender de vh/dvh */
  overflow: hidden;
  isolation: isolate;
}

/* ---------- Vídeo ---------- */
.video-wrap {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: #000;
}

.video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  /* contain de forma continua: el vídeo escala con el viewport sin saltos
     y el logo del emblema siempre queda entero en pantalla. */
  object-fit: contain;
  object-position: center;
  background: #000;
  /* Fundido de entrada por CSS (sin depender de JS) */
  animation: video-in 1.2s ease both;
  backface-visibility: hidden;
}

/* Resplandor rojo que ancla el espacio negro a los ojos del emblema */
.glow {
  position: absolute;
  left: 50%;
  top: 40%;
  width: min(70vw, 760px);
  aspect-ratio: 1.6 / 1;
  transform: translate(-50%, -50%);
  background: radial-gradient(ellipse at center, var(--red-glow), transparent 68%);
  filter: blur(40px);
  opacity: 0.45;
  z-index: 1;
  pointer-events: none;
  animation: breathe 6.5s ease-in-out infinite;
}

/* ---------- Atmósfera ---------- */
.vignette {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 38%, transparent 42%, rgba(0,0,0,0.55) 78%, #000 100%),
    linear-gradient(to bottom, rgba(0,0,0,0.55) 0%, transparent 22%, transparent 62%, rgba(0,0,0,0.85) 100%);
}

.grain {
  position: absolute;
  inset: -120%;
  z-index: 3;
  pointer-events: none;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  /* Grano ESTÁTICO: textura sin parpadeo (antes saltaba y parecía temblor). */
}

.scanline {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  /* Scanlines muy suaves y más espaciadas para evitar muaré/vibración
     sobre el vídeo en movimiento. */
  opacity: 0.12;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0,0,0,0) 0px,
    rgba(0,0,0,0) 3px,
    rgba(0,0,0,0.14) 4px
  );
  mix-blend-mode: multiply;
}

/* ---------- Marco HUD ---------- */
.frame { position: absolute; inset: var(--pad); z-index: 5; pointer-events: none; }
.corner {
  position: absolute;
  width: 26px;
  height: 26px;
  border: 1px solid var(--edge);
}
.corner.tl { top: 0; left: 0; border-right: 0; border-bottom: 0; }
.corner.tr { top: 0; right: 0; border-left: 0; border-bottom: 0; }
.corner.bl { bottom: 0; left: 0; border-right: 0; border-top: 0; }
.corner.br { bottom: 0; right: 0; border-left: 0; border-top: 0; }

/* ---------- HUD contenido ---------- */
.hud {
  position: absolute;
  left: 0; right: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: calc(var(--pad) + 14px) calc(var(--pad) + 18px);
}
.hud--top { top: 0; }
.hud--bottom { bottom: 0; flex-wrap: wrap; }

.wordmark {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: clamp(0.7rem, 1.4vw, 0.84rem);
  letter-spacing: 0.42em;
  text-transform: uppercase;
  padding-left: 0.2em;
}
.pulse {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 10px 1px var(--red-glow);
  animation: pulse 2.4s ease-in-out infinite;
}

.status {
  font-family: var(--font-mono);
  font-size: clamp(0.6rem, 1.1vw, 0.72rem);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

/* ---------- Pie ---------- */
.hud--bottom { align-items: flex-end; }

/* spacer izquierdo: mantiene el titular centrado mientras REC va a la derecha */
.side { flex: 1 1 0; }

.status {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  text-align: right;
}
.rec {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 8px var(--red-glow);
  animation: blink 1.4s steps(1) infinite;
}

.headline {
  flex: 0 0 auto;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}
.kicker {
  font-family: var(--font-mono);
  font-size: clamp(0.62rem, 1.2vw, 0.74rem);
  letter-spacing: 0.36em;
  text-transform: uppercase;
  color: var(--red-soft);
}
.headline h1 {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(2.6rem, 9vw, 6.4rem);
  line-height: 0.86;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink);
  text-shadow: 0 0 36px rgba(0,0,0,0.9), 0 2px 2px rgba(0,0,0,0.6);
}
.headline .sub {
  font-family: var(--font-mono);
  font-size: clamp(0.62rem, 1.2vw, 0.76rem);
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: var(--ink-dim);
  padding-left: 0.4em;
}
.headline .bar {
  margin-top: 0.5rem;
  width: clamp(120px, 22vw, 230px);
  height: 1px;
  background: linear-gradient(to right, transparent, var(--red) 50%, transparent);
  position: relative;
  overflow: hidden;
}
.headline .bar::after {
  content: "";
  position: absolute;
  top: 0; left: -40%;
  width: 40%; height: 100%;
  background: linear-gradient(to right, transparent, #fff, transparent);
  animation: sweep 3.2s ease-in-out infinite;
}

/* ---------- Reveal de entrada ---------- */
/* Visible por defecto: si la animación no llega a ejecutarse, el texto NUNCA
   queda invisible. Solo se oculta+anima cuando se permite movimiento. */
.reveal { opacity: 1; }
@media (prefers-reduced-motion: no-preference) {
  .reveal {
    opacity: 0;
    transform: translateY(12px);
    animation: rise 1s cubic-bezier(0.16, 0.84, 0.36, 1) forwards;
    animation-delay: var(--d, 0s);
  }
}

/* ---------- Keyframes ---------- */
@keyframes rise { to { opacity: 1; transform: translateY(0); } }
@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 10px 1px var(--red-glow); }
  50% { opacity: 0.35; box-shadow: 0 0 4px 0 var(--red-glow); }
}
@keyframes blink { 0%, 60% { opacity: 1; } 61%, 100% { opacity: 0.15; } }
@keyframes breathe { 0%, 100% { opacity: 0.32; } 50% { opacity: 0.55; } }
@keyframes sweep { 0% { left: -45%; } 55%, 100% { left: 110%; } }
@keyframes video-in { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Responsive ----------
   El vídeo usa object-fit: contain en TODO el rango (ver .video), de modo que
   se reduce de forma progresiva y continua al estrechar el viewport, sin saltos
   y manteniendo el emblema completo siempre en pantalla. */

@media (max-width: 640px) {
  /* Sin grano ni scanlines en móvil: imagen limpia. */
  .grain, .scanline { display: none; }

  .hud--bottom { justify-content: center; text-align: center; padding-inline: var(--pad); }
  .side { display: none; }
  .status { flex: 1 1 100%; min-width: 0; justify-content: flex-end; text-align: right; order: 3; opacity: 0.75; }
  .headline { order: 1; flex: 1 1 100%; min-width: 0; margin-bottom: 0.5rem; max-width: 100%; }
  .headline h1 {
    font-size: clamp(1.9rem, 8.4vw, 3rem);
    letter-spacing: 0;
  }
  .headline .sub { letter-spacing: 0.28em; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: opacity 0.4s ease !important;
  }
  .reveal { opacity: 1; transform: none; }
  .video { transform: none; }
}
