/* ============================================================================
 * qs-threshold.css — The Chamber's front door (the geodesic super-sphere).
 *
 * A full-bleed dark void. The sphere (WebGL canvas) sits centered, owning the
 * majority of the viewport. A title sits above, an invitation below. The whole
 * thing lifts away when you step inside.
 * ========================================================================== */

#qs-threshold {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* the void — a touch warmer than pure black, with a low radial glow */
  background:
    radial-gradient(ellipse 80% 70% at 50% 52%, rgba(40, 36, 64, 0.45) 0%, rgba(10, 10, 18, 0) 60%),
    #06060c;
  overflow: hidden;
  opacity: 1;
  transition: opacity 1.1s cubic-bezier(0.4, 0, 0.2, 1);
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

#qs-threshold.is-grabbing { cursor: grabbing; }
#qs-threshold:not(.is-grabbing):not(.is-entering) { cursor: grab; }

/* the WebGL canvas fills the whole overlay; the camera frames the sphere */
.qs-th-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ── soft vignette so the sphere melts into the void at the edges ── */
#qs-threshold::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 70% 65% at 50% 50%, rgba(0, 0, 0, 0) 55%, rgba(6, 6, 12, 0.92) 100%);
  z-index: 2;
}

/* ── overlaid text — above the canvas, never blocks the drag ──
   The box is width-capped but MUST stay horizontally centered: left:0 + right:0 +
   margin:auto is the absolute-centering trick. Without the auto margins the capped
   box pins to the left edge on any viewport wider than its max-width (i.e. every
   landscape iPad), which strands the copy left of the centered sphere. */
.qs-th-text {
  position: relative;
  z-index: 3;
  pointer-events: none;
  text-align: center;
  width: 100%;
  max-width: 680px;
  margin-left: auto;
  margin-right: auto;
  padding: 0 24px;
}

.qs-th-top {
  position: absolute;
  top: clamp(30px, 8vh, 88px);
  left: 0;
  right: 0;
}
.qs-th-bottom {
  position: absolute;
  bottom: clamp(34px, 9vh, 104px);
  left: 0;
  right: 0;
}

.qs-th-kicker {
  font-family: 'Space Mono', monospace;
  font-size: 0.62rem;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: rgba(214, 179, 92, 0.62);
  margin: 0 0 0.9rem;
  padding-left: 0.42em;
  opacity: 0;
  animation: qs-th-fade 1.6s ease 0.3s forwards;
}

.qs-th-title {
  font-family: 'Cinzel', serif;
  font-weight: 500;
  font-size: clamp(2.1rem, 6.4vw, 3.6rem);
  letter-spacing: 0.16em;
  color: #ece4d2;
  margin: 0;
  text-shadow: 0 0 38px rgba(120, 110, 180, 0.35);
  opacity: 0;
  animation: qs-th-fade 1.8s ease 0.5s forwards;
}

.qs-th-sub {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: clamp(1rem, 2.4vw, 1.32rem);
  color: rgba(233, 226, 212, 0.78);
  margin: 1.4rem auto 0;
  max-width: 30ch;
  line-height: 1.5;
  opacity: 0;
  animation: qs-th-fade 2s ease 1.4s forwards;
}

/* ── the invitation to step inside ── */
.qs-th-enter {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  margin-top: 0.2rem;
  padding: 0.85rem 1.9rem;
  background: rgba(214, 179, 92, 0.05);
  border: 1px solid rgba(214, 179, 92, 0.32);
  border-radius: 100px;
  color: #ecd9a8;
  font-family: 'Space Mono', monospace;
  font-size: 0.74rem;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  cursor: pointer;
  opacity: 0;
  animation: qs-th-fade 2s ease 2s forwards, qs-th-breathe 4.2s ease-in-out 2.6s infinite;
  transition: background 0.4s ease, border-color 0.4s ease, transform 0.3s ease, box-shadow 0.4s ease;
  backdrop-filter: blur(2px);
}
.qs-th-enter:hover {
  background: rgba(214, 179, 92, 0.13);
  border-color: rgba(214, 179, 92, 0.7);
  box-shadow: 0 0 34px rgba(214, 179, 92, 0.22);
  transform: translateY(-1px);
}
.qs-th-enter .qs-th-enter-glyph {
  font-size: 0.9rem;
  line-height: 1;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.qs-th-enter:hover .qs-th-enter-glyph { transform: translateX(3px); }

.qs-th-hint {
  display: block;
  margin-top: 1.4rem;
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 0.92rem;
  color: rgba(180, 176, 200, 0.5);
  opacity: 0;
  animation: qs-th-fade 2s ease 2.6s forwards;
}

/* ── entering: text recedes, whole curtain holds until JS dive completes ── */
#qs-threshold.is-entering .qs-th-text { transition: opacity 0.7s ease; opacity: 0; }
#qs-threshold.is-entering { cursor: default; }
#qs-threshold.is-entering::after { opacity: 0; transition: opacity 0.8s ease; }

/* ── lifted away (JS adds .is-lifted after the dive) ── */
#qs-threshold.is-lifted {
  opacity: 0;
  pointer-events: none;
}

@keyframes qs-th-fade {
  to { opacity: 1; }
}
@keyframes qs-th-breathe {
  0%, 100% { box-shadow: 0 0 0 rgba(214, 179, 92, 0); }
  50%      { box-shadow: 0 0 26px rgba(214, 179, 92, 0.16); }
}

@media (prefers-reduced-motion: reduce) {
  .qs-th-enter { animation: qs-th-fade 0.6s ease forwards; }
  #qs-threshold { transition: opacity 0.4s ease; }
}
