/* ————————————————————————————————
   HADAL — The Deep Drop
   ———————————————————————————————— */

:root {
  --ink: #01050c;
  --abyss: #020a14;
  --teal: #1f6e7e;
  --foam: #e6f4f3;
  --cyan: #5fe3ff;
  --amber: #ffb15c;
  --text: #dcebed;
  --text-dim: rgba(222, 237, 239, 0.8);
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --serif: "Fraunces", Georgia, serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scrollbar-color: rgba(95, 227, 255, 0.35) rgba(2, 10, 20, 0.9);
}

body {
  background: var(--ink);
  color: var(--text);
  font-family: var(--serif);
  font-optical-sizing: auto;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(95, 227, 255, 0.28); }

/* ——— fixed scene layers ——— */

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 45%, transparent 55%, rgba(1, 4, 10, 0.42) 100%);
}

/* ——— top bar ——— */

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.4rem 2rem;
  pointer-events: none;
}

.wordmark {
  pointer-events: auto;
  font-family: var(--mono);
  font-weight: 500;
  font-size: 0.95rem;
  letter-spacing: 0.42em;
  color: var(--foam);
  text-decoration: none;
}

.hud {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  font-family: var(--mono);
}

.hud-label {
  font-size: 0.62rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.hud-value {
  font-size: 0.95rem;
  min-width: 6.5ch;
  text-align: right;
  color: var(--cyan);
  font-variant-numeric: tabular-nums;
}

/* ——— chapter rail ——— */

.rail {
  position: fixed;
  right: 1.6rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
}

.rail-track {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 42vh;
  min-height: 220px;
  padding: 0 0.4rem;
}

.rail-track::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  background: rgba(220, 235, 237, 0.18);
}

.rail-marker {
  position: absolute;
  left: 50%;
  top: 0;
  width: 9px;
  height: 9px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 12px rgba(95, 227, 255, 0.9);
  transition: top 0.08s linear;
}

.rail-dot {
  position: relative;
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(220, 235, 237, 0.32);
  border: none;
  transition: background 0.3s;
}

.rail-dot.is-active { background: var(--foam); }

.rail-tip {
  position: absolute;
  right: 1.4rem;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-dim);
  opacity: 0;
  white-space: nowrap;
  transition: opacity 0.25s;
  pointer-events: none;
}

.rail-dot:hover .rail-tip,
.rail-dot.is-active .rail-tip { opacity: 1; }

/* ——— chapters ——— */

main { position: relative; z-index: 2; }

.chapter {
  position: relative;
  min-height: 130vh;
  display: flex;
  align-items: center;
  padding: 12vh clamp(1.4rem, 7vw, 7rem);
}

.chapter--hero {
  min-height: 100svh;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding-top: 0;
  padding-bottom: 0;
}

.chapter--right { justify-content: flex-end; }

.content {
  max-width: 34rem;
  opacity: 0;
  transform: translateY(2.2rem);
  transition: opacity 0.9s ease, transform 0.9s ease;
  text-shadow: 0 1px 3px rgba(1, 8, 16, 0.5), 0 2px 30px rgba(1, 8, 16, 0.55);
}

.topbar, .scroll-hint {
  text-shadow: 0 1px 3px rgba(1, 8, 16, 0.55);
}

.content.is-inview {
  opacity: 1;
  transform: none;
}

.chapter--hero .content { max-width: 46rem; }

/* cyan reads poorly on the bright surface teal — use foam in the hero */
.chapter--hero .kicker { color: rgba(240, 250, 250, 0.92); }

.kicker {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--cyan);
  margin-bottom: 1.4rem;
}

.brand {
  font-size: clamp(4.2rem, 15vw, 11rem);
  font-weight: 380;
  font-variation-settings: "opsz" 144;
  letter-spacing: 0.08em;
  line-height: 0.95;
  color: var(--foam);
  margin-bottom: 1.6rem;
}

.headline {
  font-style: italic;
  font-weight: 340;
  font-size: clamp(1.35rem, 3vw, 1.9rem);
  color: var(--foam);
  margin-bottom: 0.7rem;
}

.chapter h2 {
  font-weight: 380;
  font-style: italic;
  font-variation-settings: "opsz" 90;
  font-size: clamp(1.9rem, 4.4vw, 3.1rem);
  line-height: 1.12;
  color: var(--foam);
  margin-bottom: 1.1rem;
  text-wrap: balance;
}

.lede, .body {
  font-family: var(--mono);
  font-size: 0.86rem;
  line-height: 1.75;
  color: var(--text-dim);
  max-width: 30rem;
}

.chapter--hero .lede { margin: 0 auto 2.4rem; }
.body { margin-bottom: 1.8rem; }

.cta {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--foam);
  text-decoration: none;
  padding: 0.95rem 1.9rem;
  border: 1px solid rgba(230, 244, 243, 0.45);
  border-radius: 2rem;
  transition: background 0.3s, color 0.3s, border-color 0.3s;
}

.cta:hover {
  background: var(--foam);
  border-color: var(--foam);
  color: var(--ink);
}

.scroll-hint {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--text-dim);
  animation: hint-bob 3.2s ease-in-out infinite;
}

@keyframes hint-bob {
  0%, 100% { transform: translate(-50%, 0); }
  50%      { transform: translate(-50%, 0.5rem); }
}

/* ——— footer ——— */

.site-footer {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 4rem 2rem 3rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  color: var(--text-dim);
}

.site-footer .fine {
  margin-top: 0.6rem;
  font-size: 0.6rem;
  opacity: 0.6;
}

/* ——— no-WebGL fallback: gradient scenes per chapter ——— */

body.no-webgl #scene { display: none; }

body.no-webgl .chapter--hero { background: linear-gradient(180deg, #3a92a2, #14495c); }
body.no-webgl #twilight      { background: linear-gradient(180deg, #14495c, #082033); }
body.no-webgl #midnight      { background: linear-gradient(180deg, #082033, #010710); }
body.no-webgl #station       { background: linear-gradient(180deg, #010710, #02090f); }
body.no-webgl .site-footer   { background: #02090f; }

/* ——— reduced motion ——— */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .scroll-hint { animation: none; }
  .content {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* ——— mobile ——— */

@media (max-width: 720px) {
  .topbar { padding: 1.1rem 1.2rem; }
  .rail { right: 0.7rem; }
  .rail-tip { display: none; }
  .chapter, .chapter--right { justify-content: center; }
  .content { text-align: center; }
  .lede, .body { margin-left: auto; margin-right: auto; }
}
