/* The fixed 3D stage, the room behind it, the opening curtain and the chapter rail. */
.stage {
  position: fixed; inset: 0; z-index: 0;
  pointer-events: none;
  contain: strict;
}
.stage__room {
  position: absolute; inset: -4%;
  background:
    radial-gradient(60% 55% at 62% 60%, rgba(46, 96, 78, 0.38), transparent 70%),
    linear-gradient(180deg, rgba(10, 20, 18, 0.72) 0%, rgba(10, 20, 18, 0.55) 45%, rgba(10, 20, 18, 0.95) 100%),
    url("/img/backdrop.webp") center 40% / cover no-repeat,
    var(--bg);
  filter: saturate(0.85);
  transform: translate3d(0, calc(var(--room-y, 0) * 1px), 0) scale(1.04);
}
.stage__gl {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; transition: opacity 1.2s var(--ease);
}
.stage.is-ready .stage__gl { opacity: 1; }
.stage__shade {
  position: absolute; inset: 0;
  background: radial-gradient(120% 90% at 50% 40%, transparent 55%, rgba(5, 10, 9, 0.75) 100%);
}
/* no WebGL: the room and a still of the closed file's light, nothing that moves */
.no-gl .stage__gl { display: none; }
.no-gl .stage__room::after {
  content: ""; position: absolute; left: 50%; top: 52%; width: min(42vw, 520px); aspect-ratio: 1 / 1.36;
  transform: translate(-10%, -50%) rotate(-8deg);
  background: linear-gradient(160deg, #1f3c34, #12251f 70%);
  border-radius: 6px;
  box-shadow: 0 40px 80px rgba(0, 0, 0, 0.55), inset 0 0 0 10px rgba(217, 184, 124, 0.25);
}

/* the opening: two panels part once the scene is ready */
.curtain { position: fixed; inset: 0; z-index: 60; pointer-events: none; display: flex; }
.curtain span {
  flex: 1; background: linear-gradient(90deg, #0b1714, #10201c);
  transition: transform 1.4s var(--ease);
}
.curtain__r { background: linear-gradient(270deg, #0b1714, #10201c) !important; }
.curtain.is-open .curtain__l { transform: translateX(-101%); }
.curtain.is-open .curtain__r { transform: translateX(101%); }
.curtain.is-gone { display: none; }
.no-js .curtain, .no-gl .curtain { display: none; }

/* chapter rail (desktop) */
.rail {
  position: fixed; left: var(--gutter); top: 50%; z-index: 20;
  transform: translateY(-50%);
  display: grid; gap: 14px;
  transition: opacity 0.5s var(--ease);
}
.rail li { display: flex; align-items: center; gap: 12px; color: var(--ink-3); font-size: 0.7rem; letter-spacing: 0.14em; }
.rail li span { width: 28px; position: relative; font-weight: 600; }
.rail li span::after {
  content: ""; position: absolute; left: 22px; top: 50%; width: 0; height: 1px; background: var(--brass);
  transition: width 0.5s var(--ease);
}
.rail li em { font-style: normal; text-transform: uppercase; opacity: 0; transform: translateX(-6px); transition: opacity 0.4s, transform 0.4s var(--ease); }
.rail li.is-on { color: var(--brass); }
.rail li.is-on span::after { width: 14px; }
.rail li.is-on em { opacity: 1; transform: none; color: var(--ink-2); }
.rail.is-hidden { opacity: 0; }
:lang(ka) .rail li em { letter-spacing: 0.04em; }

@media (max-width: 1100px) {
  .rail { display: none; }
  .progress {
    display: block; position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
    background: rgba(236, 229, 212, 0.08);
  }
  .progress span {
    display: block; height: 100%; width: 100%; background: var(--brass);
    transform-origin: 0 50%; transform: scaleX(var(--p, 0));
  }
}

@media (prefers-reduced-motion: reduce) {
  .curtain { display: none; }
  .stage__gl { transition: none; }
}
