/* ============================================================
   SANCTUARY — THE DESCENT
   Scroll-as-fall journey: High Heavens -> Burning Hells.
   Builds on styles.css (cursor, nav, loader, vars).
   ============================================================ */

html { scroll-behavior: auto; }   /* let the fall feel continuous */
body { background: #05040a; }

/* ---------- fixed environment layers ---------- */
.sky {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  /* two CSS vars drive the vertical mood; JS lerps them with depth */
  background:
    radial-gradient(120% 70% at 50% -10%, var(--sky-top, #e9e4d0), transparent 70%),
    linear-gradient(180deg, var(--sky-top, #cdd2e6) 0%, var(--sky-bot, #1a1730) 100%);
  transition: background .15s linear;
}
.sky-glow {
  position: fixed; left: 50%; bottom: -25vh; transform: translateX(-50%);
  width: 130vw; height: 70vh; z-index: 0; pointer-events: none;
  background: radial-gradient(closest-side, rgba(255,60,20, var(--hell, 0)), transparent 70%);
  filter: blur(30px);
}
.particles { position: fixed; inset: 0; z-index: 1; pointer-events: none; }
.fog {
  position: fixed; inset: 0; z-index: 2; pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 35%, transparent 40%, rgba(3,2,6,.6) 100%),
    linear-gradient(180deg, transparent 60%, rgba(3,1,1, var(--hell, 0)) 100%);
  opacity: calc(.4 + var(--depth, 0) * .5);
  transition: opacity .2s linear;
}

/* ---------- progress bar (molten) ---------- */
.descent-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 100%; z-index: 130;
  background: rgba(255,255,255,.04);
}
.descent-progress span {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, #cdb978, var(--accent, #c1121f), #ff3b1f);
  box-shadow: 0 0 14px var(--accent, #c1121f);
}

/* ---------- depth gauge ---------- */
.gauge {
  position: fixed; right: clamp(.8rem, 2.5vw, 2rem); top: 50%; transform: translateY(-50%);
  z-index: 60; display: flex; flex-direction: column; align-items: center; gap: .8rem;
  pointer-events: none;
}
.gauge__cap { font-family: var(--display); letter-spacing: .3em; font-size: .55rem; color: var(--bone-dim); text-transform: uppercase; }
.gauge__track {
  position: relative; width: 2px; height: 38vh; background: rgba(216,203,184,.12);
}
.gauge__fill {
  position: absolute; top: 0; left: 0; width: 100%; height: 0;
  background: linear-gradient(180deg, #cdb978, var(--accent, #c1121f));
  box-shadow: 0 0 10px var(--accent, #c1121f);
}
.gauge__marker {
  position: absolute; left: 50%; top: 0; width: 11px; height: 11px; margin: -5px 0 0 -5px;
  border-radius: 50%; background: var(--accent, #c1121f);
  box-shadow: 0 0 16px var(--accent, #c1121f), 0 0 4px #fff inset;
}
.gauge__fathoms { font-family: var(--decor); font-weight: 900; font-size: 1rem; color: var(--bone); line-height: 1; }
.gauge__fathoms small { display: block; font-family: var(--display); font-weight: 400; font-size: .5rem; letter-spacing: .25em; color: var(--bone-dim); margin-top: .25rem; }
.gauge__name {
  writing-mode: vertical-rl; text-orientation: mixed;
  font-family: var(--display); letter-spacing: .25em; font-size: .62rem; text-transform: uppercase;
  color: var(--accent); height: 14ch; text-align: center;
  transition: color .5s var(--ease);
}
@media (max-width: 760px) { .gauge__track { height: 26vh; } .gauge__name { display: none; } }

/* ---------- the shaft & strata ---------- */
.shaft { position: relative; z-index: 5; }

.intro {
  position: relative; z-index: 5;
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 6rem clamp(1.2rem,6vw,6rem) 4rem;
}
.intro__eyebrow { font-family: var(--display); letter-spacing: .5em; font-size: clamp(.6rem,1.4vw,.8rem); text-transform: uppercase; color: #6b6f8a; }
.intro__title {
  font-family: var(--decor); font-weight: 900; font-size: clamp(3rem,11vw,8rem); line-height: .9; margin: 1rem 0;
  color: transparent; background: linear-gradient(180deg, #e9e4d0, #9aa0c0);
  -webkit-background-clip: text; background-clip: text; filter: drop-shadow(0 4px 30px rgba(180,190,230,.3));
}
.intro__sub { max-width: 50ch; color: #b9bdd0; font-weight: 300; font-size: clamp(1rem,1.6vw,1.25rem); }
.intro__scroll { margin-top: 3rem; font-family: var(--display); letter-spacing: .3em; font-size: .72rem; text-transform: uppercase; color: var(--bone); display: flex; flex-direction: column; align-items: center; gap: .8rem; }
.intro__chev { font-size: 1.2rem; animation: fall 1.8s ease-in-out infinite; }
@keyframes fall { 0%,100% { transform: translateY(0); opacity: .5; } 50% { transform: translateY(10px); opacity: 1; } }

.stratum {
  position: relative; z-index: 5;
  min-height: 100vh; display: grid; align-items: center;
  padding: clamp(4rem,12vh,9rem) clamp(1.4rem,7vw,7rem);
  --accent: #c1121f;
}
.stratum__num {
  position: absolute; z-index: -1; pointer-events: none;
  font-family: var(--decor); font-weight: 900; line-height: .7;
  font-size: clamp(10rem, 34vw, 34rem);
  color: transparent; -webkit-text-stroke: 1px rgba(var(--accent-rgb,193,18,31), .16);
  top: 50%; transform: translateY(-50%);
}
.stratum--left { justify-items: start; text-align: left; }
.stratum--right { justify-items: end; text-align: right; }
.stratum--left .stratum__num { right: -2vw; }
.stratum--right .stratum__num { left: -2vw; }
.stratum--center { justify-items: center; text-align: center; }
.stratum--center .stratum__num { left: 50%; transform: translate(-50%,-50%); }

.stratum__inner { max-width: 56ch; }
.stratum__label {
  font-family: var(--display); letter-spacing: .4em; font-size: .72rem; text-transform: uppercase;
  color: var(--accent); display: block; margin-bottom: .8rem;
}
.stratum__title {
  font-family: var(--decor); font-weight: 900; font-size: clamp(2.4rem,6.5vw,5rem); line-height: .98;
  color: var(--bone); margin-bottom: 1.4rem;
}
.stratum__lore { color: var(--bone-dim); font-weight: 300; font-size: clamp(1.05rem,1.7vw,1.3rem); line-height: 1.8; }
.stratum__lore .drop {
  float: left; font-family: var(--decor); font-weight: 900; font-size: 3.4em; line-height: .68;
  padding: .05em .12em 0 0; color: var(--accent);
}

.dive {
  margin-top: 2rem; cursor: none; background: none;
  display: inline-flex; align-items: center; gap: .7rem;
  font-family: var(--display); letter-spacing: .25em; font-size: .74rem; text-transform: uppercase;
  color: var(--bone); padding: .85rem 1.5rem;
  border: 1px solid rgba(var(--accent-rgb,193,18,31), .5); position: relative; overflow: hidden;
  transition: color .3s, border-color .3s;
}
.dive span { position: relative; z-index: 1; }
.dive::before { content: ""; position: absolute; inset: 0; background: var(--accent); transform: scaleY(0); transform-origin: bottom; transition: transform .4s var(--ease); }
.dive:hover { color: #fff; border-color: transparent; }
.dive:hover::before { transform: scaleY(1); }
.dive__chev { position: relative; z-index: 1; transition: transform .3s; }
.dive:hover .dive__chev { transform: translateY(3px); }

/* scroll reveals (local so this page doesn't depend on script.js) */
[data-rise] { opacity: 0; transform: translateY(48px); transition: opacity 1s var(--ease), transform 1s var(--ease); }
[data-rise].in { opacity: 1; transform: none; }

/* ---------- the abyss (bottom) ---------- */
.abyss {
  position: relative; z-index: 5; min-height: 100vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  padding: 6rem clamp(1.2rem,6vw,6rem);
  background: linear-gradient(180deg, transparent, #0a0202 60%, #000);
}
.abyss__title { font-family: var(--decor); font-weight: 900; font-size: clamp(2.6rem,8vw,6rem); color: transparent;
  background: linear-gradient(180deg, #ff3b1f, #5c0907); -webkit-background-clip: text; background-clip: text;
  filter: drop-shadow(0 0 40px rgba(255,60,20,.5)); line-height: .95; }
.abyss__sub { max-width: 48ch; color: var(--bone-dim); font-weight: 300; margin-top: 1.2rem; }
.abyss__links { margin-top: 2.6rem; display: flex; gap: 1.4rem; flex-wrap: wrap; justify-content: center; }
.abyss__links a {
  font-family: var(--display); letter-spacing: .2em; font-size: .74rem; text-transform: uppercase;
  color: var(--bone); text-decoration: none; padding: .85rem 1.5rem; cursor: none;
  border: 1px solid rgba(255,90,31,.4); transition: background .3s, color .3s;
}
.abyss__links a:hover { background: var(--ember); color: #1a0301; border-color: transparent; }

/* ---------- "dive deeper" plunge overlay ---------- */
.plunge {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center;
  padding: clamp(1.2rem,5vw,4rem);
  background: rgba(3,1,1,.0); backdrop-filter: blur(0px);
  opacity: 0; visibility: hidden;
  transition: opacity .5s var(--ease), visibility .5s, background .5s, backdrop-filter .5s;
}
.plunge.is-open { opacity: 1; visibility: visible; background: rgba(3,1,1,.78); backdrop-filter: blur(8px); }
.plunge__inner {
  position: relative; max-width: 64ch; width: 100%;
  border: 1px solid rgba(var(--accent-rgb,193,18,31), .5);
  background: linear-gradient(180deg, rgba(20,8,8,.96), rgba(8,3,3,.98));
  box-shadow: 0 40px 120px rgba(0,0,0,.8), 0 0 60px rgba(var(--accent-rgb,193,18,31), .22);
  padding: clamp(2rem,5vw,3.5rem);
  transform: translateY(40px) scale(.96); transition: transform .55s var(--ease);
}
.plunge.is-open .plunge__inner { transform: none; }
.plunge__label { font-family: var(--display); letter-spacing: .35em; font-size: .68rem; text-transform: uppercase; color: var(--accent); }
.plunge__title { font-family: var(--decor); font-weight: 900; font-size: clamp(1.8rem,4vw,3rem); color: var(--bone); margin: .5rem 0 1.4rem; line-height: 1; }
.plunge__body p { color: var(--bone-dim); font-weight: 300; font-size: 1.05rem; line-height: 1.8; margin-bottom: 1rem; }
.plunge__body p:last-child { margin-bottom: 0; }
.plunge__close {
  margin-top: 2rem; cursor: none; background: none;
  font-family: var(--display); letter-spacing: .25em; font-size: .72rem; text-transform: uppercase;
  color: var(--bone); padding: .8rem 1.4rem; border: 1px solid rgba(216,203,184,.3);
  transition: color .3s, border-color .3s;
}
.plunge__close:hover { color: var(--accent); border-color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  [data-rise] { opacity: 1; transform: none; }
  .intro__chev { animation: none; }
}

/* ---------- floating sound toggle (ambient drone) ---------- */
.soundtoggle {
  position: fixed; right: clamp(1rem,3vw,2.2rem); bottom: clamp(1rem,3vw,2.2rem); z-index: 130; cursor: none;
  display: flex; align-items: center; gap: .7rem; padding: .65rem 1rem;
  background: rgba(7,6,10,.55); backdrop-filter: blur(8px);
  border: 1px solid rgba(255,90,31,.3); border-radius: 999px; color: var(--bone-dim);
  font-family: var(--display); letter-spacing: .18em; font-size: .6rem; text-transform: uppercase;
  transition: color .3s, border-color .3s, box-shadow .3s;
}
.soundtoggle:hover { color: var(--bone); border-color: var(--ember); }
.soundtoggle.is-on { color: var(--bone); border-color: var(--ember); box-shadow: 0 0 22px rgba(255,90,31,.35); }
.soundtoggle__wave { display: flex; align-items: center; gap: 2px; height: 14px; }
.soundtoggle__wave i { width: 2px; height: 4px; background: var(--ember-soft); border-radius: 1px; }
.soundtoggle.is-on .soundtoggle__wave i { animation: eq 1s ease-in-out infinite; }
.soundtoggle.is-on .soundtoggle__wave i:nth-child(2){ animation-delay:.15s; }
.soundtoggle.is-on .soundtoggle__wave i:nth-child(3){ animation-delay:.3s; }
.soundtoggle.is-on .soundtoggle__wave i:nth-child(4){ animation-delay:.45s; }
@keyframes eq { 0%,100%{ height:4px; } 50%{ height:13px; } }
@media (prefers-reduced-motion: reduce){ .soundtoggle.is-on .soundtoggle__wave i { animation: none; height: 9px; } }
