/* gate.css — the sanctum door: a hanging brass bell, one unlit diya, darkness.
 *
 * js/gate.js swings the bell (it owns .gate__bell's transform), spawns the sound rings
 * into .gate__waves, then drives the exit:
 *   .is-opening  copy dims, diya lights, the light bloom rises from the wick
 *   .is-leaving  the whole gate dissolves onto the already-playing darshan video
 * The gate is exactly the column's size; nothing here is ever larger than the frame.
 */

.gate {
  position: fixed;
  z-index: 40;
  top: 0;
  bottom: 0;
  left: 50%;
  width: var(--col);
  transform: translateX(-50%);
  overflow: hidden;
  background: radial-gradient(ellipse 120% 70% at 50% 28%, #3b0c13 0%, var(--garbha) 58%, #120305 100%);
  transition: opacity 1500ms var(--ease-soft);
}

.gate.is-leaving {
  opacity: 0;
  pointer-events: none;
}

.gate[hidden] {
  display: none;
}

.gate__veil {
  position: absolute;
  inset: 0;
  background: url("../assets/video/darshan-poster.jpg") center 30% / cover no-repeat;
  opacity: 0.08;
}

/* ---- the bell -------------------------------------------------------------- */
.gate__rig {
  --bell-h: min(44svh, 390px);
  position: absolute;
  top: calc(var(--bell-h) * -0.1);
  left: 50%;
  transform: translateX(-50%);
}

.gate__bell {
  position: relative;
  display: block;
  height: var(--bell-h);
  aspect-ratio: 374 / 1000;
  padding: 0;
  border: 0;
  background: none;
  cursor: grab;
  touch-action: none;
  transform-origin: 50% 1.5%;
  -webkit-user-select: none;
  user-select: none;
}

.gate__bell:active {
  cursor: grabbing;
}

.gate__bell img {
  width: 100%;
  height: 100%;
  pointer-events: none;
  filter: drop-shadow(0 14px 22px rgba(0, 0, 0, 0.55));
}

.gate__bell:focus-visible {
  outline-offset: -10px;
  border-radius: 40% 40% 12px 12px;
}

/* breathing ring around the bell's mouth: "touch me" */
.gate__cue {
  position: absolute;
  left: 50%;
  top: 76%;
  width: 190%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1.5px solid rgba(246, 196, 69, 0.55);
  transform: translate(-50%, -50%) scale(0.5);
  opacity: 0;
  animation: gate-cue 2.6s var(--ease-out) 1.2s infinite;
  pointer-events: none;
}

.gate.is-rung .gate__cue {
  animation: none;
  opacity: 0;
}

@keyframes gate-cue {
  0%   { transform: translate(-50%, -50%) scale(0.45); opacity: 0; }
  25%  { opacity: 0.9; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}

/* sound rings spawned on every strike */
.gate__waves {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.gate__wave {
  position: absolute;
  left: 50%;
  top: calc(var(--wave-y, 32%));
  width: 78%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(246, 196, 69, 0) 80%, rgba(246, 196, 69, 0.16) 92%, rgba(248, 227, 166, 0.6) 98%, rgba(248, 227, 166, 0) 100%);
  transform: translate(-50%, -50%) scale(0.2);
  opacity: 0;
  animation: gate-wave 1700ms var(--ease-out) forwards;
}

@keyframes gate-wave {
  0%   { transform: translate(-50%, -50%) scale(0.2); opacity: var(--wave-o, 0.8); }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}

/* ---- copy ------------------------------------------------------------------- */
.gate__copy {
  position: absolute;
  left: var(--pad);
  right: var(--pad);
  top: calc(min(44svh, 390px) * 0.93 + 22px);
  text-align: center;
  transition:
    opacity 700ms var(--ease-out),
    transform 700ms var(--ease-out);
}

.gate__title {
  margin: 6px auto 14px;
  max-width: 17ch;
  font: 500 clamp(27px, 7.6vw, 33px) / 1.2 var(--font-display);
  color: var(--ivory);
  text-wrap: balance;
}

.gate__hint {
  margin: 0;
  font: 600 13px/1.4 var(--font-display);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--haldi);
  animation: gate-hint 2.6s var(--ease-soft) infinite alternate;
}

@keyframes gate-hint {
  from { opacity: 0.55; }
  to   { opacity: 1; }
}

.gate.is-opening .gate__copy {
  opacity: 0;
  transform: translateY(-10px);
}

/* ---- the diya + light bloom ------------------------------------------------- */
.gate__diya {
  position: absolute;
  left: 50%;
  bottom: max(6svh, 38px);
  --diya-w: 120px;
  transform: translateX(-50%);
}

/* The light is two nodes, neither larger than the frame: a frame-sized warm wash that
   only fades (so it has no edges to show), and a bounded flare that grows from the wick
   up to scale(1) — the "expanding" comes from the flare, never from scaling the wash. */
.gate__bloom {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% var(--bloom-y, 84%),
    rgba(255, 222, 150, 0.85) 0%,
    rgba(255, 176, 80, 0.5) 20%,
    rgba(214, 80, 34, 0.22) 50%,
    rgba(160, 40, 20, 0.08) 80%,
    rgba(160, 40, 20, 0) 100%);
  opacity: 0;
  pointer-events: none;
}

.gate.is-opening .gate__bloom {
  animation: gate-wash 1900ms var(--ease-out) 300ms forwards;
}

@keyframes gate-wash {
  0%   { opacity: 0; }
  35%  { opacity: 1; }
  100% { opacity: 0.4; }
}

.gate__flare {
  position: absolute;
  left: 50%;
  top: var(--bloom-y, 84%);
  width: min(94%, 440px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(closest-side,
    rgba(255, 250, 226, 1),
    rgba(255, 214, 130, 0.75) 25%,
    rgba(255, 160, 60, 0.3) 55%,
    rgba(255, 140, 40, 0) 100%);
  transform: translate(-50%, -50%) scale(0.05);
  opacity: 0;
  pointer-events: none;
}

.gate.is-opening .gate__flare {
  animation: gate-flare 1500ms var(--ease-out) 250ms forwards;
}

@keyframes gate-flare {
  0%   { transform: translate(-50%, -50%) scale(0.05); opacity: 0; }
  25%  { opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}
