/* ============================================================
   SCROLLSYSTEM — un ecosistema vertical
   alterlab · laboratorio
   ============================================================ */

:root {
  --ink: #f2efe6;            /* la actualiza JS según el bioma */
  --ink-soft: rgba(242, 239, 230, 0.55);
  --accent: #f2c14e;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  --serif: Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

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

html { scroll-behavior: auto; }

body {
  background: #0b0e14;
  font-family: var(--sans);
  color: var(--ink);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

#scroll-space { width: 1px; }

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

/* ---------- marca ---------- */

#wordmark {
  position: fixed;
  top: 22px;
  left: 26px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 3px;
  pointer-events: none;
  transition: color 1.2s ease;
  color: var(--ink);
}
.wm-a {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.42em;
  font-weight: 600;
}
.wm-b {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.28em;
  opacity: 0.55;
}

/* ---------- tarjeta de bioma ---------- */

#biome-card {
  position: fixed;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%);
  z-index: 9;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.4s ease, color 1.2s ease;
  color: var(--ink);
  max-width: min(82vw, 640px);
}
#biome-card.show { opacity: 1; }
.bc-roman {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.6em;
  opacity: 0.6;
  margin-bottom: 14px;
}
.bc-name {
  font-family: var(--serif);
  font-size: clamp(34px, 6.4vw, 64px);
  letter-spacing: 0.22em;
  font-weight: 400;
}
.bc-caption {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(14px, 2vw, 18px);
  opacity: 0.72;
  margin-top: 16px;
  line-height: 1.6;
}

/* ---------- riel de progreso ---------- */

#rail {
  position: fixed;
  right: 26px;
  top: 50%;
  transform: translateY(-50%);
  height: min(52vh, 420px);
  width: 30px;
  z-index: 10;
  color: var(--ink);
  transition: color 1.2s ease;
}
.rail-line {
  position: absolute;
  right: 14px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: currentColor;
  opacity: 0.28;
}
.rail-mark {
  position: absolute;
  right: 10px;
  width: 9px;
  height: 1px;
  background: currentColor;
  opacity: 0.5;
}
.rail-label {
  position: absolute;
  right: 24px;
  transform: translateY(-50%);
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.18em;
  opacity: 0;
  transition: opacity 0.8s ease;
  white-space: nowrap;
}
.rail-label.on { opacity: 0.75; }
.rail-dot {
  position: absolute;
  right: 11px;
  top: 0;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  transform: translateY(-3px);
  box-shadow: 0 0 12px currentColor;
}

/* ---------- lectura inferior ---------- */

#readout {
  position: fixed;
  left: 26px;
  bottom: 22px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 18px;
  color: var(--ink);
  transition: color 1.2s ease;
  pointer-events: none;
}
#depth {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.3em;
  opacity: 0.75;
}
#pulse-meter {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 14px;
}
#pulse-meter i {
  display: block;
  width: 2px;
  height: 3px;
  background: currentColor;
  opacity: 0.7;
  transition: height 0.12s ease;
}

/* ---------- botón de audio ---------- */

#audio-toggle {
  position: fixed;
  right: 26px;
  bottom: 22px;
  z-index: 11;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 1.2s ease, border-color 1.2s ease, transform 0.2s ease;
  opacity: 0.85;
}
#audio-toggle:hover { transform: scale(1.08); opacity: 1; }
#audio-toggle svg { width: 18px; height: 18px; }

/* ---------- pista de scroll ---------- */

#hint {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 9;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.32em;
  opacity: 0;
  transition: opacity 1.2s ease, color 1.2s ease;
  pointer-events: none;
}
#hint.show { opacity: 0.7; }
#hint svg {
  width: 16px;
  height: 16px;
  animation: hint-bob 1.8s ease-in-out infinite;
}
@keyframes hint-bob {
  0%, 100% { transform: translateY(0); opacity: 0.4; }
  50%      { transform: translateY(5px); opacity: 1; }
}

/* ---------- portada ---------- */

#intro {
  position: fixed;
  inset: 0;
  z-index: 20;
  background:
    radial-gradient(ellipse at 50% 42%, #141a26 0%, #0b0e14 62%, #06080c 100%);
  color: #ece7d8;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  transition: opacity 1.6s ease;
}
#intro.hide { opacity: 0; pointer-events: none; }

.intro-inner {
  max-width: 560px;
  padding: 0 28px;
  position: relative;
}
.intro-orbit {
  color: #f2c14e;
  width: 150px;
  margin: 0 auto 26px;
  animation: orbit-breathe 5s ease-in-out infinite;
}
.intro-orbit svg { width: 100%; height: auto; display: block; }
@keyframes orbit-breathe {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50%      { transform: scale(1.06); opacity: 1; }
}

#intro h1 {
  font-family: var(--mono);
  font-size: clamp(24px, 5vw, 38px);
  letter-spacing: 0.5em;
  font-weight: 600;
  margin-left: 0.5em; /* compensa el tracking */
}
.intro-sub {
  font-family: var(--serif);
  font-style: italic;
  font-size: 17px;
  opacity: 0.75;
  margin-top: 10px;
}
.intro-desc {
  font-family: var(--serif);
  font-size: 14.5px;
  line-height: 1.85;
  opacity: 0.62;
  margin: 26px auto 34px;
  max-width: 460px;
}

#btn-start {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.4em;
  padding: 15px 34px 15px 38px;
  background: transparent;
  color: #ece7d8;
  border: 1px solid rgba(236, 231, 216, 0.6);
  cursor: pointer;
  transition: background 0.3s ease, color 0.3s ease, letter-spacing 0.3s ease;
}
#btn-start:hover {
  background: #ece7d8;
  color: #0b0e14;
  letter-spacing: 0.48em;
}
#btn-mute {
  display: block;
  margin: 18px auto 0;
  background: none;
  border: none;
  color: #ece7d8;
  opacity: 0.4;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.24em;
  cursor: pointer;
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
  transition: opacity 0.3s ease;
}
#btn-mute:hover { opacity: 0.8; border-bottom-color: rgba(236,231,216,0.4); }

/* ---------- final ---------- */

#outro-note {
  position: fixed;
  left: 50%;
  bottom: 12vh;
  transform: translateX(-50%);
  z-index: 9;
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  color: var(--ink);
  opacity: 0;
  transition: opacity 2s ease;
  pointer-events: none;
  text-align: center;
  letter-spacing: 0.06em;
}
#outro-note.show { opacity: 0.65; }

/* ---------- móvil ---------- */

@media (max-width: 640px) {
  #wordmark { top: 16px; left: 18px; }
  #rail { right: 14px; height: 40vh; }
  .rail-label { display: none; }
  #readout { left: 18px; bottom: 16px; }
  #audio-toggle { right: 18px; bottom: 16px; }
  #biome-card { top: 34%; }
  .intro-desc { font-size: 13.5px; }
}
