/* ═══════════════════════════════════════════════
   RAMSES VII — El Ecosistema · experiencia
   Diseño: el Custodio (server-audit) · jul 2026
   ═══════════════════════════════════════════════ */

:root {
  --bg: #05060a;
  --text: #d6d9e0;
  --text-dim: #8a8fa3;
  --gold: #d9a441;
  --gold-soft: #e8c37a;
  --violet: #8b7ec8;
  --teal: #4fa8a0;
  --rose: #c0657a;
  --line: rgba(140, 148, 175, 0.16);
  --serif: 'Fraunces', Georgia, serif;
  --sans: 'Inter', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.mono { font-family: var(--mono); }
.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }
.container.narrow { max-width: 760px; }

/* ═══════ BOOT ═══════ */

#boot {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #030407;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.9s ease;
}
#boot.done { opacity: 0; pointer-events: none; }

#boot-text {
  font-family: var(--mono);
  font-size: clamp(0.72rem, 2vw, 0.95rem);
  line-height: 2;
  color: #9aa3b8;
  white-space: pre-wrap;
  max-width: 640px;
  padding: 24px;
}
#boot-text .ok { color: var(--teal); }
#boot-text .gold { color: var(--gold); }
#boot-text::after {
  content: '▊';
  color: var(--gold);
  animation: blink 0.8s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

#boot-skip {
  position: fixed;
  bottom: 28px;
  right: 32px;
  background: transparent;
  border: 1px solid rgba(140,148,175,0.3);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 0.75rem;
  padding: 8px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.3s, color 0.3s;
}
#boot-skip:hover { border-color: var(--gold); color: var(--gold-soft); }

/* ═══════ UNIVERSO ═══════ */

#universe {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
}

#vignette {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(3,4,7,0.55) 100%);
}

body.no-webgl #universe, body.no-webgl #vignette { display: none; }
body.no-webgl {
  background:
    radial-gradient(ellipse at 20% 10%, rgba(139,126,200,0.12), transparent 50%),
    radial-gradient(ellipse at 80% 90%, rgba(79,168,160,0.10), transparent 50%),
    var(--bg);
}

/* ═══════ HUD ═══════ */

#hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 28px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1s ease;
}
#hud.on { opacity: 1; }
.hud-brand { font-size: 0.72rem; letter-spacing: 0.35em; color: var(--gold); }
.hud-progress { font-size: 0.68rem; letter-spacing: 0.15em; color: var(--text-dim); }
#hud-era { color: var(--gold-soft); }
#hud-hint {
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  animation: hintpulse 3s ease-in-out infinite;
  transition: opacity 0.6s;
}
#hud-hint.off { opacity: 0; }
@keyframes hintpulse { 50% { color: var(--gold-soft); } }

.hud-right { display: flex; align-items: center; gap: 14px; }

.hud-btn {
  pointer-events: auto;
  background: rgba(12, 14, 22, 0.5);
  border: 1px solid rgba(140, 148, 175, 0.25);
  border-radius: 999px;
  color: var(--text-dim);
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  padding: 6px 14px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: border-color 0.3s, color 0.3s, box-shadow 0.3s;
}
.hud-btn:hover { border-color: var(--gold); color: var(--gold-soft); }
.hud-btn.on {
  border-color: var(--gold);
  color: var(--gold-soft);
  box-shadow: 0 0 18px rgba(217, 164, 65, 0.25);
}

@media (max-width: 640px) {
  #hud-hint { display: none; }
  .hud-btn { padding: 6px 10px; }
  .hud-progress { display: none; }
}

/* ═══════ RELATO DE INCIDENTE ═══════ */

.relato-btn {
  display: inline-block;
  margin-top: 18px;
  background: transparent;
  border: 1px solid rgba(217, 164, 65, 0.35);
  border-radius: 999px;
  color: var(--gold-soft);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  padding: 8px 18px;
  cursor: pointer;
  transition: background 0.3s, border-color 0.3s;
}
.relato-btn:hover { background: rgba(217, 164, 65, 0.12); border-color: var(--gold); }

#relato-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(3, 4, 7, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s ease;
}
#relato-overlay.open { opacity: 1; pointer-events: auto; }

#relato {
  position: relative;
  max-width: 640px;
  max-height: 82vh;
  overflow-y: auto;
  background: rgba(14, 16, 25, 0.92);
  border: 1px solid rgba(217, 164, 65, 0.3);
  border-radius: 20px;
  padding: 44px 42px 34px;
  box-shadow: 0 30px 90px rgba(0,0,0,0.7), 0 0 70px rgba(217,164,65,0.06);
  transform: translateY(18px);
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
#relato-overlay.open #relato { transform: none; }

.relato-close {
  position: absolute;
  top: 16px;
  right: 18px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1rem;
  cursor: pointer;
  padding: 6px;
}
.relato-close:hover { color: var(--gold-soft); }

.relato-fecha { font-size: 0.7rem; letter-spacing: 0.25em; text-transform: uppercase; color: var(--gold); margin-bottom: 10px; }
.relato-titulo { font-family: var(--serif); font-size: 1.9rem; font-weight: 600; color: #f2f3f7; margin-bottom: 22px; }
.relato-cuerpo p { color: #b9bdc9; font-size: 0.98rem; line-height: 1.8; margin-bottom: 18px; }
.relato-firma { margin-top: 8px; font-size: 0.7rem; letter-spacing: 0.15em; color: #565b6e; font-style: italic; text-align: right; }

@media (max-width: 640px) {
  #relato { padding: 34px 24px 26px; }
}

/* ═══════ FICHA DE ESTRELLA ═══════ */

#ficha {
  position: fixed;
  top: 50%;
  right: 28px;
  transform: translateY(-50%) translateX(120%);
  width: min(400px, calc(100vw - 48px));
  z-index: 30;
  background: rgba(12, 14, 22, 0.82);
  border: 1px solid rgba(217, 164, 65, 0.3);
  border-radius: 18px;
  padding: 30px;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 24px 70px rgba(0,0,0,0.6), 0 0 60px rgba(217,164,65,0.06);
  transition: transform 0.55s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.4s;
  opacity: 0;
  pointer-events: none;
}
#ficha.open { transform: translateY(-50%) translateX(0); opacity: 1; pointer-events: auto; }

.ficha-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1rem;
  cursor: pointer;
  padding: 6px;
}
.ficha-close:hover { color: var(--gold-soft); }

.ficha-tipo { font-size: 0.68rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--gold); margin-bottom: 8px; }
.ficha-nombre { font-family: var(--serif); font-size: 1.7rem; font-weight: 600; color: #f2f3f7; margin-bottom: 8px; }
.ficha-rol { font-size: 0.95rem; color: var(--gold-soft); margin-bottom: 14px; }
.ficha-historia { font-size: 0.92rem; color: var(--text-dim); line-height: 1.65; }

.ficha-vinculos { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.vinculos-label { display: block; font-size: 0.65rem; letter-spacing: 0.2em; text-transform: uppercase; color: #565b6e; margin-bottom: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: rgba(26, 29, 41, 0.8);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font-size: 0.72rem;
  padding: 5px 14px;
  cursor: pointer;
  transition: border-color 0.25s, color 0.25s;
}
.chip:hover { border-color: var(--gold); color: var(--gold-soft); }

@media (max-width: 640px) {
  #ficha {
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    transform: translateY(110%);
    border-radius: 18px 18px 0 0;
  }
  #ficha.open { transform: translateY(0); }
}

/* ═══════ CAPÍTULOS ═══════ */

#journey { position: relative; z-index: 10; pointer-events: none; } /* las cards re-habilitan */

.chapter {
  min-height: 135vh;
  display: flex;
  align-items: flex-start;
  padding: 0 6vw;
  pointer-events: none; /* el espacio vacío deja pasar los clicks al universo */
}
.chapter-card { pointer-events: auto; }
body.no-webgl .chapter { min-height: auto; padding: 56px 6vw; }
body.no-webgl .chapter-card { position: static; }
.chapter.right { justify-content: flex-end; }
.chapter.center { justify-content: center; text-align: center; }
.hero-chapter { min-height: 165vh; justify-content: center; text-align: center; }

.chapter-card {
  position: sticky;
  top: 24vh;
  max-width: 520px;
  opacity: 0; /* la opacidad la maneja space.js frame a frame */
  will-change: opacity, transform;
}
.chapter-card.visible, body.no-webgl .chapter-card { opacity: 1; transform: none; visibility: visible; }

.hero-card { top: 16vh; max-width: 900px; }

.kicker {
  font-size: 0.8rem;
  color: var(--gold);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  margin-bottom: 28px;
}

.megatitle {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(4rem, 14vw, 10rem);
  line-height: 0.95;
  letter-spacing: 0.03em;
  background: linear-gradient(160deg, #f7f3e8 20%, var(--gold-soft) 55%, #8a6a2a 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 40px rgba(217,164,65,0.25));
  animation: breathe 7s ease-in-out infinite;
}
.megatitle .vii { font-weight: 300; }
@keyframes breathe {
  0%, 100% { filter: drop-shadow(0 0 30px rgba(217,164,65,0.18)); }
  50% { filter: drop-shadow(0 0 55px rgba(217,164,65,0.4)); }
}

.hero-sub {
  margin-top: 32px;
  font-size: clamp(1.05rem, 2.4vw, 1.4rem);
  color: var(--text-dim);
}

.scroll-hint {
  margin-top: 56px;
  font-size: 0.72rem;
  letter-spacing: 0.25em;
  color: #565b6e;
  animation: floaty 2.4s ease-in-out infinite;
}
@keyframes floaty { 50% { transform: translateY(7px); } }

.ch-date {
  font-size: 0.75rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 14px;
}
.chapter[data-era="hermes"] .ch-date { color: var(--violet); }
.chapter[data-era="expansión"] .ch-date { color: var(--teal); }
.chapter[data-era="hoy"] .ch-date { color: var(--gold-soft); }

.chapter-card h2 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(2rem, 5vw, 3.2rem);
  line-height: 1.1;
  color: #f2f3f7;
  margin-bottom: 18px;
  text-shadow: 0 4px 30px rgba(0,0,0,0.8);
}

.chapter-card p {
  color: #b9bdc9;
  font-size: clamp(0.98rem, 1.6vw, 1.1rem);
  text-shadow: 0 2px 14px rgba(0,0,0,0.9);
}
.chapter-card strong { color: var(--gold-soft); }
.chapter-card em { color: #e6e2d5; }

/* ═══════ AFTER ═══════ */

#after {
  position: relative;
  z-index: 10;
  background: linear-gradient(180deg, transparent 0%, rgba(5,6,10,0.88) 6%, rgba(5,6,10,0.92) 100%);
}

.after-section { padding: 110px 0; }

.after-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(2rem, 4vw, 2.8rem);
  color: #f0f1f5;
  margin-bottom: 12px;
}
.section-num {
  display: block;
  font-size: 0.85rem;
  color: var(--gold);
  letter-spacing: 0.25em;
  margin-bottom: 8px;
}
.section-intro { color: var(--text-dim); font-size: 1.08rem; max-width: 620px; margin-bottom: 52px; }

.glass {
  background: rgba(16, 18, 28, 0.55);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: border-color 0.35s, transform 0.35s, box-shadow 0.35s;
}
.glass:hover {
  border-color: rgba(217,164,65,0.45);
  transform: translateY(-4px);
  box-shadow: 0 18px 50px rgba(0,0,0,0.5), 0 0 40px rgba(217,164,65,0.07);
}

/* agentes */
.agent-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 20px; }
.guardian { border-color: rgba(217,164,65,0.4); box-shadow: 0 0 46px rgba(217,164,65,0.08); }
.agent-icon { font-size: 1.9rem; color: var(--gold); margin-bottom: 14px; line-height: 1; }
.agent-grid h3 { font-family: var(--serif); font-size: 1.25rem; color: #eceef3; margin-bottom: 10px; }
.tag {
  font-size: 0.66rem; font-weight: 400; color: var(--text-dim);
  background: rgba(26,29,41,0.8); border: 1px solid var(--line);
  border-radius: 6px; padding: 2px 8px; vertical-align: middle; margin-left: 6px; white-space: nowrap;
}
.agent-grid p { font-size: 0.94rem; color: var(--text-dim); }
.agent-grid p strong { color: var(--text); }

/* canales */
.canal-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
.canal .badge {
  display: inline-block; font-size: 0.72rem; color: var(--gold);
  border: 1px solid rgba(217,164,65,0.35); border-radius: 999px;
  padding: 4px 14px; letter-spacing: 0.1em; margin-bottom: 16px;
}
.canal h3 { font-family: var(--serif); font-size: 1.2rem; color: #eceef3; margin-bottom: 8px; }
.canal p { font-size: 0.94rem; color: var(--text-dim); }

/* territorio */
.capa-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; }
.capa h3 { font-size: 0.82rem; letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 12px; }
.capa p { font-size: 0.94rem; color: var(--text-dim); }
.c-gold h3 { color: var(--gold-soft); } .c-teal h3 { color: var(--teal); }
.c-violet h3 { color: var(--violet); } .c-rose h3 { color: #d68a9c; }

/* censo */
.censo-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; }
.censo-col h3 {
  font-family: var(--serif); font-size: 1.15rem; color: var(--gold-soft);
  margin-bottom: 16px; padding-bottom: 10px; border-bottom: 1px solid var(--line);
}
.censo-col ul { list-style: none; }
.censo-col li { padding: 8px 0; font-size: 0.9rem; color: var(--text-dim); line-height: 1.55; }
.censo-col li strong { color: var(--text); }

/* principios */
.principios-list { list-style: none; counter-reset: p; }
.principios-list li {
  counter-increment: p; position: relative;
  padding: 24px 0 24px 72px; border-bottom: 1px solid var(--line);
  color: var(--text-dim); font-size: 1rem;
}
.principios-list li strong {
  color: #eceef3; display: block; margin-bottom: 2px;
  font-family: var(--serif); font-size: 1.15rem;
}
.principios-list li::before {
  content: counter(p, decimal-leading-zero);
  position: absolute; left: 0; top: 28px;
  font-family: var(--mono); font-size: 1.4rem; color: var(--gold); opacity: 0.7;
}

/* cifras */
#cifras { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 80px 0; }
.cifras-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 32px; text-align: center; }
.cifra-num {
  display: block; font-size: clamp(2.2rem, 5vw, 3.4rem);
  color: var(--gold); font-weight: 500; line-height: 1.1;
  text-shadow: 0 0 30px rgba(217,164,65,0.35);
}
.cifra-label { display: block; margin-top: 6px; font-size: 0.8rem; color: var(--text-dim); }

/* footer */
footer { padding: 90px 0 70px; text-align: center; color: var(--text-dim); font-size: 0.95rem; }
.footer-sigil { font-size: 2.2rem; color: var(--gold); margin-bottom: 20px; text-shadow: 0 0 30px rgba(217,164,65,0.5); }
footer strong { color: var(--gold-soft); }
.footer-date { margin-top: 12px; font-size: 0.75rem; color: #565b6e; letter-spacing: 0.12em; }
.footer-note { margin: 30px auto 0; max-width: 560px; font-size: 0.8rem; color: #565b6e; font-style: italic; }
.footer-links { margin-top: 34px; font-size: 0.75rem; }
.footer-links a { color: var(--text-dim); text-decoration: none; border-bottom: 1px dotted #565b6e; }
.footer-links a:hover { color: var(--gold-soft); border-color: var(--gold); }

/* ═══════ RESPONSIVE + MOTION ═══════ */

@media (max-width: 640px) {
  .chapter { padding: 0 20px; min-height: 120vh; }
  .chapter.right { justify-content: flex-start; }
  .chapter-card { top: 18vh; }
  .after-section { padding: 70px 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .chapter-card { opacity: 1; transform: none; transition: none; }
  .megatitle, .scroll-hint { animation: none; }
  #boot { display: none; }
}
