/* The entrance is the first painted view when the native modal is supported. */
html.at-the-gates,
html.at-the-gates body {
  overflow: hidden;
  overscroll-behavior: none;
}

#arrival {
  --ivory-ink: #fff5dc;
  --brass: #eac08a;
  --travel: 3.25s;
  --set-width: min(max(100vw, 125vh), 170vw, 151vh);
  --set-width: min(max(100vw, 125dvh), 170vw, 151dvh);
  --set-height: calc(var(--set-width) * 1122 / 1402);
  position: fixed;
  inset: 0;
  z-index: 100;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  overscroll-behavior: contain;
  isolation: isolate;
  border: 0;
  color: var(--ivory-ink);
  background: transparent;
}

.gate-scene { position: absolute; inset: 0; overflow: hidden; background: #351e1b; }
#arrival:not([open]) { display: none; }
.at-the-gates #arrival { display: block; }
.at-the-gates .masthead .sound { visibility: hidden; }
#arrival::backdrop { background: transparent; }
.at-the-gates:not(.entering-invitation) .hero * { animation: none; }

.gate-hall,
.gate-stage,
.gate-camera,
.gate-shade,
.gate-rim { position: absolute; }

.gate-hall {
  inset: -18px;
  background: linear-gradient(#2b100c99, #2a1517ad), var(--gate-photo) center / cover;
  filter: blur(10px);
}

.gate-stage {
  top: 50%;
  left: 50%;
  width: var(--set-width);
  height: var(--set-height);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.gate-camera {
  inset: 0;
  transform-origin: 50.14% 59%;
  /* Feather the edge of the photographic set into the surrounding room. */
  mask-image: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent);
}

.gate-facade {
  display: block;
  width: 100%;
  height: 100%;
  user-select: none;
}

/* Measured on the 1402 × 1122 facade: the aperture runs from (331,298)
   to (1069,1011). The meeting stile is at x=703. The arch stays still. */
.gate-doorway {
  position: absolute;
  left: calc(100% * 331 / 1402);
  top: calc(100% * 298 / 1122);
  width: calc(100% * 738 / 1402);
  height: calc(100% * 713 / 1122);
  overflow: hidden;
  perspective: 1400px;
  perspective-origin: 50.4% 49%;
  background: #311e1b;
  visibility: hidden;
}

#arrival.has-door-texture .gate-doorway { visibility: visible; }

.gate-courtyard {
  position: absolute;
  inset: -2%;
  background: #d7bc94 var(--garden-photo) 49% 56% / cover no-repeat;
  filter: brightness(.54);
  transform: scale(1.15);
}

.gate-courtyard::after {
  content: '';
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 4vw 1.4vw #2b150e7d;
  background: radial-gradient(ellipse at 54% 48%, #f6c77a0c 35%, #3316092a 100%);
}

.gate-leaf {
  position: absolute;
  top: 0;
  bottom: 0;
  background-image: var(--gate-photo);
  background-repeat: no-repeat;
  backface-visibility: hidden;
  transform: rotateY(0deg);
}

.left-leaf {
  left: 0;
  width: calc(100% * 372 / 738);
  transform-origin: left center;
  background-size: calc(100% * 1402 / 372) calc(100% * 1122 / 713);
  background-position: calc(100% * 331 / 1030) calc(100% * 298 / 409);
}

.right-leaf {
  right: 0;
  width: calc(100% * 366 / 738);
  transform-origin: right center;
  background-size: calc(100% * 1402 / 366) calc(100% * 1122 / 713);
  background-position: calc(100% * 703 / 1036) calc(100% * 298 / 409);
}

.gate-leaf::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to right, #1c0b0696, #210e08f0);
  opacity: 0;
}
.right-leaf::after { transform: scaleX(-1); }

.gate-shade {
  inset: 0;
  background: linear-gradient(180deg, #220e12d6 0%, #260e1575 15%, transparent 38%, transparent 72%, #2c111137 82%, #210e13d9 100%), radial-gradient(ellipse at 50% 52%, transparent 35%, #3b182233 78%, #260e1a8c);
  pointer-events: none;
}

.gate-rim {
  --frame-inset: clamp(9px, 1.45vw, 24px);
  inset: var(--frame-inset);
  border: 1px solid #f4d4aa69;
  pointer-events: none;
}
.gate-rim::before,
.gate-rim::after {
  content: '';
  position: absolute;
  width: clamp(25px, 4vw, 58px);
  height: clamp(25px, 4vw, 58px);
  border: solid #f6d4a5a6;
}
.gate-rim::before { top: 5px; left: 5px; border-width: 1px 0 0 1px; }
.gate-rim::after { right: 5px; bottom: 5px; border-width: 0 1px 1px 0; }

.gate-heading {
  position: absolute;
  top: max(env(safe-area-inset-top), clamp(28px, 5.5vh, 80px));
  left: 4%;
  right: 4%;
  text-align: center;
  text-shadow: 0 2px 16px #2c100e;
  pointer-events: none;
}

.gate-invocation {
  margin: 0 0 .65rem;
  color: var(--brass);
  font: 400 clamp(1.05rem, 1.45vw, 1.3rem)/1.4 'Tiro Devanagari Hindi', 'Nirmala UI', 'Kohinoor Devanagari', serif;
  letter-spacing: .06em;
}
.gate-dedication {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: .85rem;
  margin: 0 0 .22em;
  color: #fff0d3;
  font: 600 .7rem/1.6 var(--sans);
  letter-spacing: .25em;
  text-transform: uppercase;
}
.gate-dedication span { width: 2rem; height: 1px; background: var(--brass); }
#arrival-title {
  margin: 0;
  color: var(--ivory-ink);
  font: 400 clamp(3.25rem, 6.6vw, 7rem)/1.07 var(--serif);
  letter-spacing: -.045em;
  outline: none;
}
#arrival-title i { font-size: .75em; font-weight: 400; color: #f1d1a1; }

.gate-latch {
  position: absolute;
  /* Pin the seal to the photographed handles even when the stage is cropped. */
  top: calc(50% + var(--set-height) * .066);
  left: 50.14%;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  padding: 0;
  width: clamp(68px, 7.7vw, 106px);
  aspect-ratio: 1;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--ivory-ink);
  -webkit-tap-highlight-color: transparent;
}
.gate-latch:focus-visible { outline: 2px solid #ffedb8; outline-offset: 10px; }
.gate-wax { position: relative; display: grid; width: 100%; height: 100%; place-items: center; }
.gate-wax img {
  position: relative;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 3px 3px #260a07a8) brightness(1.14);
  transition: transform .3s ease;
}
.gate-latch:hover .gate-wax img { transform: scale(1.045) rotate(-3deg); }
.gate-wax::before {
  content: '';
  position: absolute;
  inset: 1%;
  border-radius: 50%;
  border: 1px solid #f6dab0a1;
  box-shadow: 0 0 18px #f8d18a42;
  animation: beckon 2.7s ease-out 3;
}
@keyframes beckon {
  0% { transform: scale(.88); opacity: 0; }
  25% { opacity: .8; }
  100% { transform: scale(1.21); opacity: 0; }
}
.gate-prompt {
  position: absolute;
  top: calc(100% + .45rem);
  left: 50%;
  transform: translateX(-50%);
  display: block;
  white-space: nowrap;
  background: #361921e8;
  border: 1px solid #deb783ba;
  box-shadow: 0 2px 12px #250d0c4d;
  padding: .54rem 1.2rem .57rem;
  color: #fff0d5;
  font: italic 1.26rem/1 var(--serif);
}
.gate-dateline {
  position: absolute;
  bottom: max(env(safe-area-inset-bottom), clamp(28px, 5.4vh, 74px));
  left: 3%;
  right: 3%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  color: #fff0d6;
  font: 600 .76rem/1.4 var(--sans);
  letter-spacing: .16em;
  text-transform: uppercase;
  text-shadow: 0 1px 7px #241011;
  pointer-events: none;
}
.gate-dateline svg { width: 15px; height: 15px; fill: currentColor; color: #e7bc84; }

#replay-arrival {
  border: 0;
  border-bottom: 1px solid currentColor;
  padding: .4rem .08rem .2rem;
  background: none;
  color: var(--wine);
  font: inherit;
}
#replay-arrival[hidden] { display: none; }
#names:focus { outline: none; }

/* The timing is one continuous shot: lift the seal, swing each leaf inwards,
   pass through the threshold, then dissolve into the invitation. */
#arrival.opening .gate-scene { animation: arrive var(--travel) linear both; }
#arrival.opening.simple-fade .gate-scene { animation: gate-fade .18s linear both; }
.opening.simple-fade :is(.gate-wax, .gate-leaf, .gate-camera, .gate-courtyard) { animation: none; }
@keyframes gate-fade { to { opacity: 0; } }
.opening .gate-wax { animation: unseal .65s cubic-bezier(.35,0,.72,.3) both; }
.opening .gate-wax::before { display: none; }
.opening .gate-heading,
.opening .gate-prompt,
.opening .gate-rim,
.opening .gate-dateline { opacity: 0; transition: opacity .45s ease; }
.opening .left-leaf { animation: left-door 2.25s .22s cubic-bezier(.42,.02,.18,1) both; }
.opening .right-leaf { animation: right-door 2.25s .33s cubic-bezier(.4,.02,.17,1) both; }
.opening .gate-leaf::after { animation: moving-shadow 2.12s .25s ease-out both; }
.opening .gate-courtyard { animation: courtyard-light 2.45s .22s ease-out both; }
.opening .gate-camera { animation: through-the-door 2.55s .68s cubic-bezier(.58,.05,.71,.98) both; }
.opening .gate-shade { opacity: 0; transition: opacity 1.8s ease-in; }
.opening .gate-latch { pointer-events: none; }

@keyframes unseal {
  0% { transform: scale(1) rotate(0deg); }
  34% { transform: scale(1.1) rotate(-9deg); }
  100% { opacity: 0; transform: translateY(14px) scale(1.36) rotate(-16deg); }
}
@keyframes left-door { to { transform: rotateY(88deg); } }
@keyframes right-door { to { transform: rotateY(-88deg); } }
@keyframes moving-shadow { to { opacity: .85; } }
@keyframes courtyard-light { to { filter: brightness(1.09); transform: scale(1); } }
@keyframes through-the-door {
  0% { transform: scale(1); }
  40% { transform: scale(1.08); }
  100% { transform: scale(3.2); }
}
@keyframes arrive {
  0%, 72% { opacity: 1; }
  100% { opacity: 0; }
}

@media (max-aspect-ratio: 7/10) {
  .gate-camera { mask-image: linear-gradient(180deg, transparent 0%, #000 8%, #000 91%, transparent 100%); }
  .gate-heading { top: max(env(safe-area-inset-top), 7.8vh); }
  #arrival-title { font-size: clamp(3.25rem, 12vw, 4.8rem); }
  .gate-dateline { bottom: max(env(safe-area-inset-bottom), 7.3vh); gap: .65rem; font-size: .68rem; }
  .gate-shade { background: linear-gradient(180deg, #230f16b3, #32161a33 29%, transparent 47%, transparent 66%, #31131c70 86%, #240f17d1); }
}
@media (max-height: 460px) and (orientation: landscape) {
  .gate-heading { top: 1.1rem; }
  .gate-invocation { margin-bottom: .15rem; font-size: .85rem; }
  #arrival-title { font-size: clamp(2.2rem, 10vh, 3.2rem); }
  .gate-latch { width: 54px; }
  .gate-dateline { bottom: 1rem; }
  .gate-prompt { font-size: 1.05rem; padding: .3rem .9rem; }
}
@media (prefers-reduced-motion: reduce) {
  #arrival.opening .gate-scene { animation: gate-fade .18s linear both !important; }
  .gate-wax::before { display: none; }
}
