/* Reset y contenedor a pantalla completa para Seismic Field */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #030303;
  color: #e0e0e0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#glcanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  z-index: 1;
}

/* ==========================================================================
   FONDO CONMEMORATIVO DE VÍCTIMAS (CONSTELACIÓN INDEPENDIENTE DE NOMBRES)
   ========================================================================== */
.gb-typing-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.gb-memorial-name {
  position: absolute;
  font-family: "Courier New", Courier, "Lucida Console", Monaco, monospace;
  font-size: 11px;
  letter-spacing: 0.6px;
  white-space: nowrap;
  pointer-events: auto;
  image-rendering: pixelated;
  -webkit-font-smoothing: none;
  transition: color 1.2s ease, text-shadow 1.2s ease, opacity 1.5s ease;
  line-height: 1;
  direction: ltr;
}

/* Estado mientras se está mecanografiando (resaltado fosforescente) */
.gb-memorial-name.typing {
  color: rgba(255, 255, 255, 0.70);
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.6);
  opacity: 1.0;
}

/* Estado asentado (fondo testimonial etéreo) */
.gb-memorial-name.settled {
  color: rgba(255, 255, 255, 0.16);
  text-shadow: none;
  opacity: 0.90;
}

/* Microinteracción de respeto: al pasar el ratón por encima se ilumina */
.gb-memorial-name.settled:hover {
  color: rgba(255, 255, 255, 0.95);
  text-shadow: 0 0 12px rgba(255, 255, 255, 0.85);
  opacity: 1.0;
  cursor: default;
}

.gb-name-cursor {
  display: inline-block;
  color: #ffffff;
  animation: gbNameBlink 0.35s infinite steps(2, start);
  margin-left: 2px;
}

/* Efecto de temblor sísmico columpiado lateral y destellos luminosos (de la mitad en adelante) */
.gb-typing-bg.shaking .gb-memorial-name {
  animation: 
    gbSwayLateral 0.21s infinite alternate ease-in-out,
    gbDestello 3.2s infinite ease-in-out;
  will-change: transform, color, opacity, text-shadow;
}
.gb-typing-bg.shaking .gb-memorial-name:nth-child(2n) {
  animation-duration: 0.24s, 2.7s;
  animation-delay: -0.05s, -0.9s;
}
.gb-typing-bg.shaking .gb-memorial-name:nth-child(3n) {
  animation-duration: 0.19s, 4.1s;
  animation-delay: -0.08s, -1.8s;
}
.gb-typing-bg.shaking .gb-memorial-name:nth-child(5n) {
  animation-duration: 0.26s, 3.4s;
  animation-delay: -0.11s, -2.5s;
}
.gb-typing-bg.shaking .gb-memorial-name:nth-child(7n) {
  animation-duration: 0.22s, 4.6s;
  animation-delay: -0.07s, -1.3s;
}
.gb-typing-bg.shaking .gb-memorial-name:nth-child(11n) {
  animation-duration: 0.20s, 2.4s;
  animation-delay: -0.04s, -0.5s;
}

@keyframes gbSwayLateral {
  0% {
    transform: translate3d(-1.8px, 0, 0) rotate(-0.20deg);
  }
  50% {
    transform: translate3d(0.2px, 0, 0) rotate(0.03deg);
  }
  100% {
    transform: translate3d(1.8px, 0, 0) rotate(0.20deg);
  }
}

@keyframes gbDestello {
  0%, 72%, 100% {
    color: rgba(255, 255, 255, 0.16);
    text-shadow: none;
    opacity: 0.90;
  }
  86% {
    color: rgba(255, 255, 255, 0.85);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.70);
    opacity: 1.0;
  }
}

/* Secuencia final de destellos conmemorativos durante el mensaje de cierre (sin movimiento lateral) */
.gb-typing-bg.outro-glow .gb-memorial-name {
  transform: none;
  animation: gbFinalDestello 3.2s infinite ease-in-out;
  will-change: color, text-shadow, opacity;
}
.gb-typing-bg.outro-glow .gb-memorial-name:nth-child(2n) {
  animation-duration: 2.7s;
  animation-delay: -0.8s;
}
.gb-typing-bg.outro-glow .gb-memorial-name:nth-child(3n) {
  animation-duration: 3.8s;
  animation-delay: -1.5s;
}
.gb-typing-bg.outro-glow .gb-memorial-name:nth-child(5n) {
  animation-duration: 3.1s;
  animation-delay: -2.2s;
}
.gb-typing-bg.outro-glow .gb-memorial-name:nth-child(7n) {
  animation-duration: 4.2s;
  animation-delay: -1.0s;
}
.gb-typing-bg.outro-glow .gb-memorial-name:nth-child(11n) {
  animation-duration: 2.4s;
  animation-delay: -0.4s;
}

@keyframes gbFinalDestello {
  0% {
    color: rgba(255, 255, 255, 0.16);
    text-shadow: none;
    opacity: 0.85;
  }
  38% {
    color: rgba(255, 255, 255, 0.90);
    text-shadow: 0 0 12px rgba(255, 255, 255, 0.80);
    opacity: 1.0;
  }
  75%, 100% {
    color: rgba(255, 255, 255, 0.22);
    text-shadow: none;
    opacity: 0.90;
  }
}

@keyframes gbNameBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

@media (max-width: 768px) {
  .gb-memorial-name {
    font-size: 9px;
    letter-spacing: 0.3px;
  }
}

/* ==========================================================================
   COMPOSICIÓN MULTIVENTANA PROGRESIVA EN DESKTOP (COLUMNAS IZQUIERDA Y DERECHA)
   ========================================================================== */
.gb-desktop-narrative {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  padding: 24px;
  overflow: hidden;
  transition: opacity 1.5s ease, visibility 1.5s ease;
}

.gb-desktop-narrative.gb-fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.gb-col-narrative {
  width: 320px;
  max-width: 26vw;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.gb-col-left {
  align-items: flex-start;
}

.gb-col-right {
  align-items: flex-end;
}

/* Tarjeta individual de fase */
.gb-narrative-card {
  width: 100%;
  pointer-events: auto;
  font-family: "Courier New", Courier, "Lucida Console", Monaco, monospace;
  image-rendering: pixelated;
  -webkit-font-smoothing: none;
  filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.9));
  animation: gbCardSpawn 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: opacity 0.35s ease, transform 0.35s ease, filter 0.35s ease;
}

@keyframes gbCardSpawn {
  0% {
    opacity: 0;
    transform: translateY(-8px) scale(0.96);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Estado Activo (Fase actual que se está reproduciendo) */
.gb-narrative-card.gb-card-active {
  opacity: 1.0;
  transform: scale(1.0);
}

.gb-narrative-card.gb-card-active .gb-outer-frame {
  border: 2px solid #ffffff;
  box-shadow: 
    inset 1px 1px 0px #ffffff,
    inset -1px -1px 0px #444444,
    0 0 10px rgba(255, 255, 255, 0.35),
    3px 3px 0px #000000;
}

/* Estado Pasado / Histórico (Fases ya narradas que quedan en la composición) */
.gb-narrative-card.gb-card-past {
  opacity: 0.68;
  transform: scale(0.985);
}

.gb-narrative-card.gb-card-past .gb-outer-frame {
  border: 1px solid #777777;
  box-shadow: 
    inset 1px 1px 0px #555555,
    2px 2px 0px #000000;
}

.gb-narrative-card.gb-card-past:hover {
  opacity: 1.0;
  transform: scale(1.0);
  cursor: pointer;
  filter: drop-shadow(0 8px 22px rgba(0, 0, 0, 1.0));
}

/* Marco exterior monocromático con doble borde pixelado en blanco */
.gb-outer-frame {
  background: #000000;
  padding: 2px;
  border: 2px solid #ffffff;
  box-shadow: 
    inset 1px 1px 0px #ffffff,
    inset -1px -1px 0px #444444,
    3px 3px 0px #000000;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Pantalla interior negra de alto contraste */
.gb-inner-screen {
  position: relative;
  background: #050505;
  border: 1px solid #222222;
  padding: 8px 10px 10px 10px;
  min-height: 52px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.8);
}

/* Encabezado / Título */
.gb-header-tag {
  font-size: 10px;
  font-weight: bold;
  letter-spacing: 0.6px;
  color: #ffffff;
  text-transform: uppercase;
  margin-bottom: 4px;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.25);
  padding-bottom: 2px;
}

/* Texto del cuerpo */
.gb-body-text {
  font-size: 11px;
  line-height: 1.35;
  color: #ececec;
  white-space: pre-line;
  word-break: break-word;
  flex-grow: 1;
  font-weight: 500;
}

/* Flechita indicadora monocromática */
.gb-prompt-arrow {
  position: absolute;
  bottom: 3px;
  right: 6px;
  font-size: 9px;
  color: #ffffff;
  opacity: 0;
}

.gb-prompt-arrow.gb-blink {
  animation: gbArrowBlink 0.8s infinite ease-in-out;
}

@keyframes gbArrowBlink {
  0%, 45% {
    opacity: 1;
    transform: translateY(0);
  }
  50%, 95% {
    opacity: 0;
    transform: translateY(2px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================================================
   CUADRO DE INICIO / CIERRE / MÓVIL (#gb-dialogue-box)
   ========================================================================== */
.gb-dialogue-box {
  position: fixed;
  top: 24px;
  left: 24px;
  width: 380px;
  max-width: calc(100vw - 48px);
  z-index: 110;
  cursor: pointer;
  pointer-events: auto;
  font-family: "Courier New", Courier, "Lucida Console", Monaco, monospace;
  image-rendering: pixelated;
  -webkit-font-smoothing: none;
  filter: drop-shadow(0 10px 25px rgba(0, 0, 0, 0.95));
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.gb-dialogue-box.gb-initial-prompt {
  top: 24px;
  left: 24px;
}

.gb-dialogue-box.gb-final-prompt {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 280px;
  max-width: calc(100vw - 48px);
  filter: drop-shadow(0 14px 40px rgba(0, 0, 0, 1.0));
  animation: gbCardSpawn 0.35s ease forwards;
}

/* En Desktop se oculta el cuadro central durante la reproducción de fases */
@media (min-width: 769px) {
  .gb-dialogue-box.gb-hidden-desktop {
    display: none;
  }
}

/* ==========================================================================
   DISPOSICIÓN RESPONSIVA: MOBILE EN LA PARTE INFERIOR
   ========================================================================== */
@media (max-width: 768px) {
  .gb-desktop-narrative {
    display: none;
  }

  .gb-dialogue-box,
  .gb-dialogue-box.gb-initial-prompt,
  .gb-dialogue-box.gb-final-prompt {
    top: auto;
    bottom: 20px;
    left: 16px;
    right: 16px;
    width: auto;
    max-width: none;
    transform: none;
  }

  .gb-dialogue-box.gb-hidden-desktop {
    display: block;
  }

  .gb-inner-screen {
    min-height: 75px;
    padding: 10px 12px 12px 12px;
  }

  .gb-header-tag {
    font-size: 10px;
  }

  .gb-body-text {
    font-size: 11px;
    line-height: 1.35;
  }
}

/* ==========================================================================
   ESTILOS GUI DE DESARROLLO (LADO DERECHO)
   ========================================================================== */
.lil-gui {
  --background-color: rgba(15, 15, 18, 0.88);
  --text-color: #d0d0d8;
  --title-background-color: #1a1a24;
  --widget-color: #242432;
  --hover-color: #323244;
  --focus-color: #484860;
  --number-color: #79a6ff;
  --string-color: #a8d578;
  font-family: "SF Mono", "Fira Code", monospace !important;
  font-size: 11px !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 4px;
  z-index: 9999 !important;
  right: 15px !important;
  left: auto !important;
  top: 15px !important;
}

.lil-gui .title {
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-size: 10px;
}

/* ==========================================================================
   TEXTURA DE PANTALLA CRT (SCANLINES, PHOSPHOR MESH, GLASS REFLECTION & BEAM)
   ========================================================================== */
.crt-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 500;
  overflow: hidden;
}

/* 1. Malla de fósforo RGB y Scanlines horizontales ultra-finas */
.crt-overlay::before {
  content: " ";
  display: block;
  position: absolute;
  inset: 0;
  background: 
    linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.28) 50%),
    linear-gradient(90deg, rgba(255, 0, 0, 0.03), rgba(0, 255, 0, 0.015), rgba(0, 0, 255, 0.03));
  background-size: 100% 3px, 3px 100%;
  pointer-events: none;
  z-index: 501;
}

/* 2. Viñeta de tubo analógico, brillo especular en vidrio y sombreado periférico */
.crt-overlay::after {
  content: " ";
  display: block;
  position: absolute;
  inset: 0;
  background: 
    radial-gradient(ellipse at center, transparent 60%, rgba(0, 0, 0, 0.38) 90%, rgba(0, 0, 0, 0.72) 100%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.03) 0%, rgba(255, 255, 255, 0.008) 25%, transparent 45%);
  pointer-events: none;
  z-index: 502;
  box-shadow: inset 0 0 45px rgba(0, 0, 0, 0.75);
}

/* 3. Haz de barrido sutil que viaja verticalmente emulando el haz catódico */
.crt-scanbeam {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 140px;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(255, 255, 255, 0.015) 50%,
    transparent 100%
  );
  pointer-events: none;
  z-index: 503;
  animation: crtScanlineSweep 8s linear infinite;
}

@keyframes crtScanlineSweep {
  0% { transform: translateY(-140px); }
  100% { transform: translateY(100vh); }
}

