/* ==========================================================================
   AURONIXIA // HERO 3D SCROLLYTELLING INTEGRATION
   Glassmorphism, Three.js WebGL Scrollytelling, Temas Dinámicos & HUD
   ========================================================================== */

/* --------------------------------------------------------------------------
   Variables de Temas para el Hero 3D
   -------------------------------------------------------------------------- */
:root {
  --font-hud: 'Space Grotesk', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-hero-display: 'Outfit', 'Space Grotesk', sans-serif;

  /* Tema por defecto: Auronixia Luxury (adaptado a palette.html) */
  --3d-bg: #140E0B;
  --3d-primary: #8394A6;
  --3d-secondary: #C8D1DA;
  --3d-tertiary: #EEE8DE;
  --3d-glow-primary: rgba(131, 148, 166, 0.45);
  --3d-glow-secondary: rgba(200, 209, 218, 0.4);
  --3d-panel-bg: rgba(30, 22, 18, 0.78);
  --3d-panel-border: rgba(131, 148, 166, 0.28);
  --3d-panel-hover: rgba(200, 209, 218, 0.45);
  --3d-text-primary: #F7F4EF;
  --3d-text-muted: rgba(247, 244, 239, 0.7);
  --3d-text-dim: rgba(247, 244, 239, 0.62);
  --3d-badge-bg: rgba(131, 148, 166, 0.16);
  --3d-card-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 35px rgba(131, 148, 166, 0.15);
}

/* --------------------------------------------------------------------------
   Pista Scrollytelling Pinned del Hero 3D
   -------------------------------------------------------------------------- */
.hero-3d-track {
  position: relative;
  width: 100%;
  height: 480vh; /* Pista de scroll calibrada para el recorrido completo */
  background: var(--3d-bg);
  z-index: 20;
}

.hero-3d-sticky {
  position: sticky;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  overflow: hidden;
  background: var(--3d-bg);
  z-index: 20;
}

/* Canvas Three.js WebGL */
#webgl-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100% !important;
  height: 100% !important;
  z-index: 1;
  outline: none;
}

/* --------------------------------------------------------------------------
   HUD Flotante del Hero 3D
   -------------------------------------------------------------------------- */
.hero-3d-hud-bar {
  position: absolute;
  top: 92px; /* Justo debajo del navbar tradicional */
  left: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 48px;
  z-index: 60;
  pointer-events: none;
}

.hud-brand-pill {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--3d-panel-bg);
  border: 1px solid var(--3d-panel-border);
  padding: 6px 14px;
  border-radius: 999px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.pulse-dot-3d {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--3d-primary);
  box-shadow: 0 0 10px var(--3d-primary);
  animation: pulse-3d 2s infinite ease-in-out;
}

@keyframes pulse-3d {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

.hud-brand-logo-img {
  height: 16px;
  width: auto;
  object-fit: contain;
  display: block;
}

.hud-brand-text {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--3d-primary);
  text-transform: uppercase;
}

.hud-actions-group {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* --------------------------------------------------------------------------
   Navegación Lateral de Waypoints (Hitos del Scrollytelling)
   -------------------------------------------------------------------------- */
.waypoints-nav {
  position: absolute;
  left: 36px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 60;
  pointer-events: auto;
  display: flex;
  align-items: center;
}

.waypoints-track {
  position: absolute;
  left: 9px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: rgba(255, 255, 255, 0.08);
}

.track-indicator {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 0%;
  background: var(--3d-primary);
  box-shadow: 0 0 10px var(--3d-primary);
  transition: height 0.3s ease;
}

.waypoints-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin: 0;
  padding: 0;
}

.waypoint-item {
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px;
  outline: none;
}

.waypoint-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: var(--3d-bg);
  transition: all 0.3s ease;
  z-index: 2;
  box-sizing: border-box;
}

.waypoint-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  opacity: 0.45;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.waypoint-num {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--3d-primary);
  font-weight: 700;
}

.waypoint-label {
  font-family: var(--font-hud);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--3d-text-primary);
  text-transform: uppercase;
  white-space: nowrap;
}

.waypoint-item:hover .waypoint-info,
.waypoint-item.active .waypoint-info {
  opacity: 1;
  transform: translateX(4px);
}

.waypoint-item.active .waypoint-dot {
  border-color: var(--3d-primary);
  background: var(--3d-primary);
  box-shadow: 0 0 14px var(--3d-primary);
}

/* --------------------------------------------------------------------------
   Tarjetas Narrativas (Story Sections)
   -------------------------------------------------------------------------- */
.story-sections-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 55;
  pointer-events: none;
}

.story-section {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 24px 80px 24px;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), 
              visibility 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.story-section.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Todas las fases centradas en la parte inferior */
#sec-1,
#sec-2,
#sec-3,
#sec-4,
#sec-5 {
  justify-content: center;
  align-items: flex-end;
  padding-left: 24px;
  padding-right: 24px;
}

/* Panel Glassmorphism */
.glass-panel {
  background: var(--3d-panel-bg);
  border: 1px solid var(--3d-panel-border);
  border-radius: 20px;
  padding: 26px 36px;
  max-width: 760px;
  width: 100%;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: var(--3d-card-shadow);
  pointer-events: auto;
  position: relative;
  transform: translateY(20px);
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1), 
              border-color 0.4s ease, 
              box-shadow 0.4s ease;
}

.story-section.active .glass-panel {
  transform: translateY(0);
}

.glass-panel:hover {
  border-color: var(--3d-panel-hover);
}

.card-header-3d {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.card-tag-3d {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--3d-primary);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.card-status-indicator-3d {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--3d-badge-bg);
  color: var(--3d-secondary);
  border: 1px solid rgba(255, 255, 255, 0.1);
  text-transform: uppercase;
}

.card-title-3d {
  font-family: var(--font-hero-display);
  font-size: clamp(22px, 2.4vw, 34px);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--3d-text-primary);
  margin-bottom: 12px;
  text-transform: uppercase;
}

.card-desc-3d {
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--3d-text-muted);
  margin-bottom: 18px;
}

/* Grilla de Métricas en Tarjetas */
.stats-grid-3d {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 18px;
}

.stat-item-3d {
  display: flex;
  flex-direction: column;
}

.stat-num-3d {
  font-family: var(--font-hero-display);
  font-size: 26px;
  font-weight: 800;
  color: var(--3d-primary);
  line-height: 1;
}

.stat-unit-3d {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--3d-secondary);
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-top: 2px;
}

.stat-label-3d {
  font-size: 11px;
  color: var(--3d-text-dim);
  margin-top: 4px;
}

.card-actions-3d {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 8px;
}

.glow-btn-3d {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--3d-primary);
  color: #000000;
  font-family: var(--font-hud);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  box-shadow: 0 0 20px var(--3d-glow-primary);
  transition: all 0.25s ease;
}

.glow-btn-3d:hover {
  transform: translateY(-2px);
  filter: brightness(1.15);
}

.action-hint-3d {
  font-size: 12px;
  color: var(--3d-text-dim);
  font-family: var(--font-mono);
}

/* --------------------------------------------------------------------------
   Barra de Telemetría Inferior HUD
   -------------------------------------------------------------------------- */
.hero-3d-hud-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 48px;
  z-index: 60;
  background: linear-gradient(0deg, rgba(20, 14, 11, 0.95) 0%, transparent 100%);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  pointer-events: none;
}

.progress-track-3d {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 16px;
  width: 380px;
  max-width: 40vw;
}

.progress-line-bg {
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
}

.progress-line-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--3d-secondary), var(--3d-primary));
  box-shadow: 0 0 10px var(--3d-primary);
  transition: width 0.1s linear;
}

.progress-percent-lbl {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--3d-text-primary);
  min-width: 40px;
}

/* Responsive */
@media (max-width: 1024px) {
  .hero-3d-hud-bar { padding: 0 20px; }
  .hero-3d-hud-footer { padding: 0 20px; }
  .waypoints-nav { display: none; }
  .story-section,
  #sec-1, #sec-2, #sec-3, #sec-4, #sec-5 {
    justify-content: center;
    padding: 0 20px 80px 20px;
  }
}

@media (max-width: 768px) {
  .story-section,
  #sec-1, #sec-2, #sec-3, #sec-4, #sec-5 {
    padding: 0 14px 74px 14px;
  }
  .glass-panel {
    padding: 20px 18px;
    max-width: 100%;
    border-radius: 16px;
  }
  .card-title-3d {
    font-size: 20px;
    margin-bottom: 8px;
  }
  .card-desc-3d {
    font-size: 13px;
    line-height: 1.45;
    margin-bottom: 14px;
  }
  .stats-grid-3d {
    gap: 10px;
    padding-top: 12px;
    margin-bottom: 14px;
  }
  .stat-num-3d {
    font-size: 20px;
  }
  .card-actions-3d {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .action-hint-3d {
    text-align: center;
    font-size: 11px;
  }
}


/* --------------------------------------------------------------------------
   Plan de mejoras (fase 2): titulares, enlaces y modo estático
   -------------------------------------------------------------------------- */

/* Titulares largos en mayúsculas/minúsculas */
.card-title-3d {
  text-transform: none;
  letter-spacing: -0.015em;
}
#sec-1 .card-title-3d {
  font-size: clamp(24px, 2.6vw, 38px);
  line-height: 1.12;
}

/* CTA secundario fantasma */
.glow-btn-3d--ghost {
  background: rgba(255, 255, 255, 0.08);
  color: var(--3d-text-primary);
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: none;
}
a.glow-btn-3d { text-decoration: none; min-height: 44px; }
.glow-btn-3d { min-height: 44px; }

/* "Saltar el recorrido →" */
.skip-tour-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 4px;
  font-family: var(--font-hud);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--3d-text-primary);
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-color: rgba(247, 244, 239, 0.4);
}
.skip-tour-link:hover { text-decoration-color: var(--3d-secondary); }

.restart-tour-btn {
  background: transparent;
  border: none;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--3d-text-muted);
  cursor: pointer;
  text-decoration: underline;
  min-height: 44px;
  padding: 0 8px;
}

.action-hint-3d.tour-only { margin-top: 10px; }

/* --------------------------------------------------------------------------
   Modo estático: móvil (<768px) o prefers-reduced-motion
   Sin WebGL: fondo estático y las 5 fases como tarjetas en scroll normal.
   -------------------------------------------------------------------------- */
.hero-static .hero-3d-track {
  height: auto;
  background:
    linear-gradient(180deg, rgba(20, 14, 11, 0.35) 0%, rgba(20, 14, 11, 0.85) 45%, var(--3d-bg) 100%),
    url('../assets/hero-static.webp') center top / cover no-repeat,
    var(--3d-bg);
}
.hero-static .hero-3d-sticky {
  position: relative;
  height: auto;
  overflow: visible;
  background: transparent;
  padding: 110px 0 40px;
}
.hero-static .hero-3d-hud-bar,
.hero-static .hero-3d-hud-footer,
.hero-static .waypoints-nav,
.hero-static .tour-only,
.hero-static .skip-tour-link { display: none !important; }

.hero-static .story-sections-container {
  position: relative;
  height: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  pointer-events: auto;
  max-width: 820px;
  margin: 0 auto;
}
.hero-static .story-section,
.hero-static #sec-1, .hero-static #sec-2, .hero-static #sec-3, .hero-static #sec-4, .hero-static #sec-5 {
  position: relative;
  height: auto;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  padding: 0 16px;
  transition: none;
}
.hero-static .glass-panel {
  transform: none;
  transition: none;
}
.hero-static #sec-1 .glass-panel {
  background: rgba(30, 22, 18, 0.9);
}

@media (max-width: 767px) {
  .hero-static .hero-3d-sticky { padding-top: 96px; }
  .hero-static .stats-grid-3d { grid-template-columns: 1fr 1fr 1fr; }
  .hero-static .stat-num-3d { font-size: 17px; overflow-wrap: anywhere; }
  .hero-static #sec-1 .card-title-3d { font-size: 26px; }
  .card-actions-3d .glow-btn-3d { justify-content: center; }
}

/* --------------------------------------------------------------------------
   Logo de marca en el hero (fade out con scroll)
   -------------------------------------------------------------------------- */
.hero-brand-logo {
  position: absolute;
  top: calc(76px + 6vh);
  left: 50%;
  transform: translate3d(-50%, var(--logo-shift, 0px), 0) scale(var(--logo-scale, 1));
  z-index: 50;
  width: min(28vw, 380px);
  pointer-events: none;
  opacity: var(--logo-opacity, 1);
  filter: drop-shadow(0 0 28px rgba(131, 148, 166, 0.35)) blur(var(--logo-blur, 0px));
  will-change: opacity, transform;
  animation: hero-logo-in 1.2s var(--ease-editorial, cubic-bezier(0.16, 1, 0.3, 1)) backwards;
}
.hero-brand-logo img { width: 100%; height: auto; display: block; }
.hero-brand-logo.is-hidden { visibility: hidden; }

@keyframes hero-logo-in {
  from { opacity: 0; filter: blur(12px); }
}

/* Móvil / reduced-motion: el logo va en el flujo, sobre las tarjetas */
.hero-static .hero-brand-logo {
  position: relative;
  top: auto;
  left: auto;
  transform: none;
  width: min(62vw, 300px);
  margin: 0 auto 32px;
}
@media (prefers-reduced-motion: reduce) {
  .hero-brand-logo { animation: none; }
}

/* --------------------------------------------------------------------------
   Destello de cambio de fase con los colores del logo (js/hero-3d/ui.js)
   Halo exterior multicolor + borde degradado; entra en ~0,15 s y se apaga antes de 1 s.
   -------------------------------------------------------------------------- */
:root {
  --logo-cyan: #00D8F0;
  --logo-blue: #2E8BFF;
  --logo-violet: #8A4DFF;
  --logo-magenta: #F23BEB;
  --logo-red: #FF3D6B;
  --logo-orange: #FF8A1F;
  --logo-yellow: #FFE01A;
}

.glass-panel::before,
.glass-panel::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
}

/* Halo: sombras de colores alrededor de la tarjeta (izq. cian/azul, arriba magenta, der. naranja, abajo amarillo) */
.glass-panel::after {
  box-shadow:
    -26px 18px 60px -6px rgba(0, 216, 240, 0.55),
    -10px -22px 60px -8px rgba(138, 77, 255, 0.5),
    18px -26px 60px -8px rgba(242, 59, 235, 0.5),
    28px 6px 60px -6px rgba(255, 61, 107, 0.45),
    16px 26px 60px -8px rgba(255, 138, 31, 0.5),
    0 30px 70px -14px rgba(255, 224, 26, 0.4);
}

/* Borde degradado del logo (solo el trazo, con máscara) */
.glass-panel::before {
  padding: 1.5px;
  background: linear-gradient(120deg,
    var(--logo-cyan), var(--logo-blue) 18%, var(--logo-violet) 34%, var(--logo-magenta) 50%,
    var(--logo-red) 66%, var(--logo-orange) 82%, var(--logo-yellow));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}

.glass-panel.phase-glow::after { animation: phase-glow-halo 0.95s cubic-bezier(0.22, 1, 0.36, 1) forwards; }
.glass-panel.phase-glow::before { animation: phase-glow-border 0.95s cubic-bezier(0.22, 1, 0.36, 1) forwards; }

@keyframes phase-glow-halo {
  0%   { opacity: 0; transform: scale(0.985); }
  16%  { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.015); }
}
@keyframes phase-glow-border {
  0%   { opacity: 0; }
  14%  { opacity: 1; }
  100% { opacity: 0; }
}

/* Sin movimiento: solo un destello de opacidad muy breve; en modo estático no aplica */
@media (prefers-reduced-motion: reduce) {
  .glass-panel.phase-glow::after,
  .glass-panel.phase-glow::before { animation-duration: 0.6s; transform: none; }
}
.hero-static .glass-panel::before,
.hero-static .glass-panel::after { display: none; }
