:root {
  --bg-main: #000000;
  --panel-bg: rgba(22, 22, 26, 0.72);
  --panel-border: rgba(255, 255, 255, 0.1);
  --text-primary: #f5f5f7;
  --text-muted: #86868b;
  --accent: #e0245e;
  --accent-hover: #f0386f;
  --font-main: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Space Grotesk', monospace;
  --nav-h: 52px;
}

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

html {
  background: var(--bg-main);
}

body {
  font-family: var(--font-main);
  background: var(--bg-main);
  color: var(--text-primary);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body.exploring {
  overflow: hidden;
}

/* Barra superior mínima */
.site-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-h);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.nav-brand {
  color: inherit;
  text-decoration: none;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.18em;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: opacity 0.2s ease;
}

.nav-brand:hover { opacity: 0.65; }

/* La flecha es la unica pista de que el nombre lleva de vuelta al
   sitio principal. Se separa un poco para que no se lea como parte
   de la palabra. */
.nav-brand .nav-back {
  font-size: 1.05rem;
  letter-spacing: 0;
  line-height: 1;
  opacity: 0.55;
}

/* El logo es el boton de volver. Se deja a su tamano real, sin
   recuadro ni filtro: es lo unico con color en toda la barra y por
   eso se ve, aunque sea chico. */
.nav-brand .nav-logo {
  height: 32px;
  width: auto;
  display: block;
}

@media (max-width: 600px) {
  .nav-brand .nav-logo { height: 26px; }
}

/* Escena 3D fija detrás de todo */
.stage {
  position: fixed;
  inset: 0;
  z-index: 0;
}

#webgl-canvas {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

body.exploring #webgl-canvas {
  pointer-events: auto;
  touch-action: none;
}

#scroll-track {
  height: 650vh;
}

/* Textos de la historia */
.story-layer {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

.story-block {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(var(--nav-h) + 5vh);
  padding: 0 24px;
  text-align: center;
  opacity: 0;
  will-change: opacity, transform;
}

.eyebrow {
  font-size: clamp(0.95rem, 1.6vw, 1.2rem);
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 6px;
}

.story-block h1 {
  font-size: clamp(2.6rem, 7vw, 5.6rem);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.035em;
}

.story-block h2 {
  font-size: clamp(2.2rem, 6vw, 4.8rem);
  font-weight: 700;
  line-height: 1.04;
  letter-spacing: -0.03em;
  text-shadow: 0 4px 40px rgba(0, 0, 0, 0.6);
}

.lede {
  margin-top: 12px;
  font-size: clamp(1.05rem, 2vw, 1.5rem);
  font-weight: 500;
  color: var(--text-primary);
}

.hero .lede {
  color: #d2d2d7;
}

.cta-row {
  margin-top: 22px;
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}

.finale {
  top: auto;
  bottom: 10vh;
}

/* Botones estilo pill */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 24px;
  border-radius: 999px;
  font-family: var(--font-main);
  font-size: 1.02rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

/* Neón: el color de cada botón sale de --glow (r, g, b) */
.btn-primary,
.btn-secondary {
  --glow: 255, 64, 129;
  color: #ffffff;
  background: rgba(var(--glow), 0.12);
  border: 1.5px solid rgb(var(--glow));
  text-shadow: 0 0 8px rgba(var(--glow), 0.9);
  animation: neon-pulse 4.5s ease-in-out infinite;
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.btn-secondary {
  --glow: 62, 230, 255;
}

.btn-primary:hover,
.btn-secondary:hover {
  background: rgb(var(--glow));
  color: #0a0a0c;
  text-shadow: none;
}

.btn-primary:active,
.btn-secondary:active {
  transform: scale(0.97);
}

@keyframes neon-pulse {
  0%, 100% {
    box-shadow:
      0 0 6px rgba(var(--glow), 0.65),
      0 0 18px rgba(var(--glow), 0.35),
      inset 0 0 8px rgba(var(--glow), 0.25);
  }
  50% {
    box-shadow:
      0 0 7px rgba(var(--glow), 0.75),
      0 0 24px rgba(var(--glow), 0.45),
      inset 0 0 9px rgba(var(--glow), 0.3);
  }
}

.btn-small {
  min-height: 30px;
  padding: 0 14px;
  font-size: 0.82rem;
  animation: none;
  box-shadow: 0 0 10px rgba(var(--glow), 0.45);
}

.btn:focus-visible,
.tab-btn:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

/* Indicador de scroll */
.scroll-cue {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  font-size: 0.8rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
  pointer-events: none;
  transition: opacity 0.4s ease;
  animation: cue 2.2s ease-in-out infinite;
}

@keyframes cue {
  0%, 100% { transform: translate(-50%, 0); }
  50% { transform: translate(-50%, 6px); }
}

body.exploring .story-layer,
body.exploring .scroll-cue {
  opacity: 0 !important;
  visibility: hidden;
}

/* Modo explorar */
.explore-bar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 20px);
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease, transform 0.35s ease, visibility 0.35s;
  width: max-content;
  max-width: calc(100vw - 32px);
}

body.exploring .explore-bar {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

.explore-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
}

.view-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  padding: 6px;
  border-radius: 28px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.tab-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.88rem;
  font-weight: 600;
  min-height: 36px;
  padding: 0 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.tab-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.06);
}

.tab-btn.active {
  color: #ffffff;
  background: #2c2c30;
}

.tab-btn.tab-close {
  color: #ffffff;
  background: rgba(224, 36, 94, 0.22);
}

.tab-btn.tab-close:hover {
  background: var(--accent);
}

/* Pantalla de carga */
.loading-screen {
  position: fixed;
  inset: 0;
  background: var(--bg-main);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 100;
  transition: opacity 0.6s ease;
}

.loading-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

.loader-spinner {
  width: 42px;
  height: 42px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loader-text {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.loader-bar-bg {
  width: 180px;
  height: 3px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
}

.loader-bar-fill {
  width: 0%;
  height: 100%;
  background: var(--accent);
  transition: width 0.2s ease;
}

@media (max-width: 640px) {
  .site-nav { padding: 0 16px; }
  .story-block { padding: 0 16px; }
  .explore-hint { display: none; }
  .tab-btn { padding: 0 12px; font-size: 0.82rem; }
}

@media (prefers-reduced-motion: reduce) {
  .scroll-cue { animation: none; }
  .btn-primary,
  .btn-secondary {
    animation: none;
    box-shadow: 0 0 6px rgba(var(--glow), 0.7), 0 0 20px rgba(var(--glow), 0.4);
  }
}
