/* ============================================================
   MAIN.CSS — Layout general, hero, footer, HUD, utilidades
   ============================================================ */

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

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-body);
  overflow-x: hidden;
  min-height: 100vh;
  cursor: none; /* reemplazado por el cursor personalizado en desktop */
}

/* En touch/mobile no tiene sentido el cursor custom */
@media (hover: none), (pointer: coarse) {
  body {
    cursor: auto;
  }
  #custom-cursor {
    display: none !important;
  }
}

a {
  color: inherit;
  text-decoration: none;
}

img, svg {
  display: block;
  max-width: 100%;
}

/* ---------- Fondo Three.js ---------- */
#bg-canvas {
  position: fixed;
  inset: 0;
  z-index: var(--z-bg);
  pointer-events: none;
}

/* ---------- Nebulosa de fondo (gradiente animado, muy sutil) ---------- */
.nebula {
  position: fixed;
  inset: -10%;
  z-index: var(--z-bg);
  pointer-events: none;
  opacity: 0.5;
  background:
    radial-gradient(circle at 20% 30%, rgba(0, 240, 255, 0.10), transparent 45%),
    radial-gradient(circle at 80% 20%, rgba(123, 47, 255, 0.12), transparent 50%),
    radial-gradient(circle at 50% 80%, rgba(214, 0, 255, 0.08), transparent 55%);
  background-size: 180% 180%;
  animation: nebula-breathe 18s ease-in-out infinite;
  filter: blur(40px);
}

@keyframes nebula-breathe {
  0%   { background-position: 0% 0%, 100% 0%, 50% 100%; }
  50%  { background-position: 20% 20%, 80% 30%, 40% 80%; }
  100% { background-position: 0% 0%, 100% 0%, 50% 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .nebula { animation: none; }
}

/* ---------- Grid HUD sutil superpuesto ---------- */
.hud-grid {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(123, 47, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(123, 47, 255, 0.06) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at center, black 0%, transparent 75%);
}

/* ---------- Cursor personalizado tipo mira ---------- */
#custom-cursor {
  position: fixed;
  top: 0;
  left: 0;
  width: 28px;
  height: 28px;
  border: 1px solid var(--accent-cyan);
  border-radius: 50%;
  pointer-events: none;
  z-index: var(--z-cursor);
  transform: translate(-50%, -50%);
  transition: width 150ms ease, height 150ms ease, border-color 150ms ease;
  mix-blend-mode: screen;
}
#custom-cursor::before,
#custom-cursor::after {
  content: '';
  position: absolute;
  background: var(--accent-cyan);
}
#custom-cursor::before {
  top: 50%; left: -6px;
  width: 6px; height: 1px;
  transform: translateY(-50%);
}
#custom-cursor::after {
  top: -6px; left: 50%;
  width: 1px; height: 6px;
  transform: translateX(-50%);
}
#custom-cursor.hover {
  width: 48px;
  height: 48px;
  border-color: var(--accent-violet-2);
}

/* ---------- Contenedor general ---------- */
.container {
  position: relative;
  z-index: var(--z-content);
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-md);
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-lg) var(--space-md);
}

.hero__logo {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 8vw, 5rem);
  font-weight: 900;
  letter-spacing: 0.15em;
  background: var(--grad-cyan-violet);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 24px rgba(123, 47, 255, 0.5));
  animation: glow-pulse 3.5s ease-in-out infinite;
  position: relative;
}

@keyframes glow-pulse {
  0%, 100% { filter: drop-shadow(0 0 18px rgba(0, 240, 255, 0.35)) drop-shadow(0 0 8px rgba(123, 47, 255, 0.4)); }
  50%      { filter: drop-shadow(0 0 34px rgba(123, 47, 255, 0.65)) drop-shadow(0 0 14px rgba(0, 240, 255, 0.5)); }
}

.hero__logo.glitch {
  animation: glow-pulse 3.5s ease-in-out infinite, glitch 0.35s steps(2, end) 1;
}

@keyframes glitch {
  0%   { clip-path: inset(0 0 0 0); transform: translate(0, 0); }
  20%  { clip-path: inset(20% 0 40% 0); transform: translate(-3px, 1px); }
  40%  { clip-path: inset(60% 0 5% 0); transform: translate(3px, -1px); }
  60%  { clip-path: inset(10% 0 70% 0); transform: translate(-2px, 0); }
  80%  { clip-path: inset(40% 0 20% 0); transform: translate(2px, 1px); }
  100% { clip-path: inset(0 0 0 0); transform: translate(0, 0); }
}

.hero__title {
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 4vw, 2.4rem);
  letter-spacing: 0.08em;
  margin-top: var(--space-md);
  color: var(--text-primary);
}

.hero__subtitle {
  font-family: var(--font-mono);
  font-size: clamp(0.9rem, 2vw, 1.1rem);
  color: var(--text-secondary);
  max-width: 640px;
  margin-top: var(--space-sm);
  min-height: 3em;
  line-height: 1.6;
}

.hero__subtitle .cursor-blink {
  display: inline-block;
  width: 0.55em;
  height: 1em;
  background: var(--accent-cyan);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 1s step-end infinite;
}

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

.hero__scroll-hint {
  position: absolute;
  bottom: var(--space-md);
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  opacity: 0.7;
}
.hero__scroll-hint span {
  display: block;
  width: 1px;
  height: 32px;
  background: linear-gradient(var(--accent-cyan), transparent);
  margin: var(--space-xs) auto 0;
  animation: scroll-line 2s ease-in-out infinite;
}
@keyframes scroll-line {
  0%   { transform: scaleY(0); transform-origin: top; opacity: 1; }
  50%  { transform: scaleY(1); transform-origin: top; opacity: 1; }
  51%  { transform-origin: bottom; }
  100% { transform: scaleY(0); transform-origin: bottom; opacity: 0; }
}

/* ---------- Secciones genéricas ---------- */
.section {
  position: relative;
  padding: var(--space-xl) 0;
}

.section__header {
  text-align: center;
  margin-bottom: var(--space-lg);
}

.section__eyebrow {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--accent-cyan);
  opacity: 0.8;
}

.section__title {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  margin-top: var(--space-xs);
  background: var(--grad-cyan-violet);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Scroll reveal genérico */
.reveal {
  opacity: 0;
  transform: translateY(30px);
}

/* ---------- Footer ---------- */
.footer {
  position: relative;
  padding: var(--space-lg) 0 var(--space-md);
  text-align: center;
  border-top: 1px solid rgba(123, 47, 255, 0.15);
}

.footer__brand {
  font-family: var(--font-display);
  letter-spacing: 0.15em;
  color: var(--text-primary);
  font-size: 1.1rem;
}

.footer__tagline {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: var(--space-xs);
  letter-spacing: 0.1em;
}

.footer__social {
  display: flex;
  justify-content: center;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

.footer__social a {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(232, 236, 241, 0.2);
  border-radius: 50%;
  transition: border-color var(--dur-fast) var(--ease-standard), box-shadow var(--dur-fast) var(--ease-standard), transform var(--dur-fast) var(--ease-standard);
}

.footer__social a:hover {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 16px rgba(0, 240, 255, 0.45);
  transform: translateY(-3px);
}

.footer__social svg {
  width: 18px;
  height: 18px;
  stroke: var(--text-primary);
  fill: none;
}

/* ---------- GLAC container (fixed layer) ---------- */
#glac-container {
  position: fixed;
  z-index: var(--z-glac);
  pointer-events: none;
  width: 160px;
  transition: width var(--dur-med) var(--ease-standard);
}

@media (max-width: 768px) {
  #glac-container {
    width: 96px;
  }
}

/* Canvas Three.js de GLAC (geometría 3D real, ver glac.js) */
#glac-canvas {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  pointer-events: auto;
  cursor: pointer;
  touch-action: manipulation;
}

/* ---------- Vistas (galaxia / nave) ---------- */
.vista {
  display: none;
}

.vista.is-active {
  display: block;
}

/* ---------- Overlay de transición (entrada/salida de la nave) ---------- */
#transition-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: radial-gradient(
    circle at var(--tx, 50%) var(--ty, 50%),
    rgba(123, 47, 255, 0.95),
    rgba(5, 6, 10, 0.99) 65%
  );
  opacity: 0;
  pointer-events: none;
}

/* ---------- Vista nave: contenido ---------- */
/* Pantalla completa: el puente 3D (nave-interior.css/js) es lo único que
   se ve al entrar a la nave — título y botón de volver flotan ENCIMA como
   overlays (position:absolute), no empujan/reducen el layout.

   OJO con el z-index acá: este contenedor NO debe tener uno propio (queda
   z-index:auto a propósito). GLAC (#glac-container) es un contenedor FIJO
   global (--z-glac) que necesita aparecer DELANTE del cuarto 3D (paredes/
   piso — si no, la pared opaca lo tapa por completo, bug real encontrado
   por el usuario) pero DETRÁS del tablero de la consola (para que le tape
   las piernas). Como un z-index no puede "partir" a un mismo ancestro en
   dos — todo lo que cuelgue de un ancestro con z-index propio queda
   atado a esa posición como bloque — la solución es NO elevar este
   contenedor entero, sino que CADA pieza de nave-interior.css compita
   directo por su cuenta: `.nave-console` (paredes/piso/GLAC-spot, sin
   z-index) queda detrás de GLAC por defecto, y `.nave-console__front`
   (tablero + anillos, con SU PROPIO z-index alto) queda delante. */
.nave-view__content {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.btn-hud {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  color: var(--accent-cyan);
  background: rgba(0, 240, 255, 0.06);
  border: 1px solid rgba(0, 240, 255, 0.4);
  border-radius: 4px;
  padding: 0.7em 1.4em;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-standard),
              box-shadow var(--dur-fast) var(--ease-standard),
              transform var(--dur-fast) var(--ease-standard);
}

.btn-hud:hover {
  background: rgba(0, 240, 255, 0.15);
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.35);
  transform: translateY(-2px);
}

/* ---------- Destello de origen (flyTo / teletransporte de GLAC) ---------- */
.glac-flash {
  position: fixed;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.95), rgba(0, 240, 255, 0.85) 30%, rgba(123, 47, 255, 0.6) 55%, transparent 75%);
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: calc(var(--z-glac) - 1);
  mix-blend-mode: screen;
}

/* Estela de propulsión: se mueve CON el astronauta durante el vuelo */
.glac-trail {
  position: fixed;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.9), rgba(0, 240, 255, 0.75) 35%, rgba(123, 47, 255, 0.45) 60%, transparent 75%);
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: calc(var(--z-glac) - 1);
  mix-blend-mode: screen;
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .container { padding: 0 var(--space-sm); }
  .section { padding: var(--space-lg) 0; }
}
