/* ─────────────────────────────────────────────
   Gate + film, in the site's own language.
   The gate is the wine ground with a lotus card as the door: tap, the card lifts
   away as a deep wine comes up over it, and the film (which opens on deep red
   cloth and ends on black) fades in out of it. At the end the black lifts off the site.
   Uses the tokens and the .lotus-card from styles.css.
   ───────────────────────────────────────────── */

html.is-locked, html.is-locked body { overflow: hidden; height: 100%; }
/* while the gate or the film is up, the site is put away (so the first section's rise-in starts when it returns) */
html.is-locked body > :not(.stage):not(script) { display: none !important; }

.stage {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  z-index: 2000; overflow: hidden;
  color: var(--ink);
  background:
    radial-gradient(120% 70% at 50% 0%, var(--ground-lift) 0%, rgba(86, 32, 44, 0) 70%),
    var(--ground);
  opacity: 1; transition: opacity 1.6s ease;   /* after the film: the black lifts slowly off the page */
}
/* opening: a deep wine comes up over it; once it is full the stage itself turns the same wine, so nothing jumps */
.stage::after { content: ""; position: absolute; inset: 0; background: var(--ground-deep); opacity: 0; pointer-events: none; transition: opacity .85s ease .15s; }
.stage.is-opening::after { opacity: 1; }
.stage.is-dark::after { display: none; }
.stage.is-dark { background: var(--ground-deep); }
.stage.is-black { background: #000; }            /* set under the playing film, so its black ending has black behind it */
.stage.is-out { opacity: 0; pointer-events: none; }
.stage[hidden] { display: none; }

.stage-frame { position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0; transition: opacity .6s ease; }
.stage.is-dark .stage-frame { opacity: 1; }
.stage.is-ending .stage-frame { opacity: 0; }
.stage-film { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
/* when the screen's shape forces the whole frame to be shown, its edges are feathered into the black */
.stage-feather { position: absolute; top: -1px; left: -1px; right: -1px; bottom: -1px; pointer-events: none; opacity: 0; box-shadow: inset 0 0 34px 22px #000; }
.stage-frame.is-boxed .stage-feather { opacity: 1; }

/* ── The gate ── */
.gate {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  padding: 32px var(--pad); padding-bottom: max(32px, env(safe-area-inset-bottom));
}
.stage.is-dark .gate { visibility: hidden; }
/* --dw is the card's width, as large as fits: limited by the screen's width, or by the height left once the line
   above and the button below are counted. The card's frame is 77% of that, and the button is made exactly as wide. */
.gate {
  --dw: min(350px, 82vw, max(150px, calc((100vh - 250px) * 400 / 560)));
  --dw: min(350px, 82vw, max(150px, calc((100svh - 250px) * 400 / 560)));
}

.gate-eyebrow { color: var(--brass); padding-left: .3em; margin-bottom: clamp(22px, 4vh, 36px); }

/* the lotus card, used as the door: the date in its arch, the names in the frame */
.gate-door {
  --h: 560;
  width: var(--dw);
  cursor: pointer; flex: none;
  transform-origin: 50% 44%;
  transition: transform 1.05s cubic-bezier(.6, 0, .35, 1), opacity .7s ease .1s;
  animation: gate-rise 1.2s var(--ease) .15s backwards;
}
.gate-door .lotus-hub { animation: gate-fade 1.2s ease .9s backwards; }
.gate-names {
  position: absolute; left: 0; right: 0; top: calc(224 / 560 * 100%); bottom: calc(34 / 560 * 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--fg);
  animation: gate-fade 1.2s ease 1.1s backwards;
}
.gate-names span { font-family: var(--script); font-size: 15.5cqw; line-height: 1.15; padding-inline: .12em; white-space: nowrap; }
.gate-names i { font-family: var(--serif); font-style: italic; font-weight: 400; font-size: 5.8cqw; line-height: 1.3; color: var(--tone); }
/* a guest's own name on the door: "For" and "& Family" in small italics around the name in script */
.gate-names.is-guest { padding-inline: 14cqw; }
.gate-names.is-guest span { line-height: 1.12; text-align: center; text-wrap: balance; margin-block: .08em; }
@keyframes gate-fade { from { opacity: 0; } }

.gate .button { position: relative; box-sizing: border-box; width: calc(var(--dw) * .77); min-width: max-content; padding-inline: calc(10px + .3em) 10px; text-align: center; white-space: nowrap; margin-top: clamp(20px, 3.2vh, 30px); animation: gate-rise 1.2s var(--ease) .45s backwards; }
.gate .button::before, .gate .button::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; }

/* ── The invitation to tap ── */

/* shimmer: light catching brass. A broad soft sheen and a narrow bright glint cross the button together,
   the glint a touch ahead; they fade in, speed up through the middle and fade out. A fainter second pass follows,
   then a rest, and the button's inner brass line brightens as the light goes by — so it never reads as a fixed patch. */
.gate .button {
  overflow: hidden;
  animation: gate-rise 1.2s var(--ease) .45s backwards, gate-glint-line 6.4s ease-in-out 2.6s infinite;
}
.gate .button::before, .gate .button::after {
  inset: -30% auto -30% 0; opacity: 0; will-change: transform, opacity;
  animation-duration: 6.4s; animation-iteration-count: infinite; animation-timing-function: cubic-bezier(.45, 0, .25, 1);
}
.gate .button::before {          /* the broad sheen */
  width: 70%;
  background: linear-gradient(100deg, rgba(210, 179, 124, 0) 0%, rgba(210, 179, 124, .09) 35%, rgba(210, 179, 124, .17) 50%, rgba(210, 179, 124, .09) 65%, rgba(210, 179, 124, 0) 100%);
  animation-name: gate-sheen; animation-delay: 2.6s;
}
.gate .button::after {           /* the bright glint inside it */
  width: 22%;
  background: linear-gradient(100deg, rgba(245, 232, 200, 0) 0%, rgba(245, 232, 200, .14) 30%, rgba(245, 232, 200, .34) 50%, rgba(245, 232, 200, .14) 70%, rgba(245, 232, 200, 0) 100%);
  animation-name: gate-glint; animation-delay: 2.52s;
}
@keyframes gate-sheen {
  0%   { transform: translateX(-115%) skewX(-16deg); opacity: 0; }
  5%   { opacity: 1; }
  19%  { opacity: 1; }
  25%  { transform: translateX(165%) skewX(-16deg); opacity: 0; }
  31%  { transform: translateX(-115%) skewX(-16deg); opacity: 0; }
  35%  { opacity: .55; }
  43%  { opacity: .55; }
  48%, 100% { transform: translateX(165%) skewX(-16deg); opacity: 0; }
}
@keyframes gate-glint {
  0%   { transform: translateX(-150%) skewX(-16deg); opacity: 0; }
  6%   { opacity: 1; }
  18%  { opacity: 1; }
  25%  { transform: translateX(520%) skewX(-16deg); opacity: 0; }
  31%  { transform: translateX(-150%) skewX(-16deg); opacity: 0; }
  36%  { opacity: .5; }
  43%  { opacity: .5; }
  48%, 100% { transform: translateX(520%) skewX(-16deg); opacity: 0; }
}
@keyframes gate-glint-line {
  0%, 26%, 30%, 50%, 100% { box-shadow: inset 0 0 0 3px var(--ground), inset 0 0 0 4px rgba(210, 179, 124, .45), 0 0 0 0 rgba(210, 179, 124, 0); }
  13% { box-shadow: inset 0 0 0 3px var(--ground), inset 0 0 0 4px rgba(210, 179, 124, 1), 0 0 16px 0 rgba(210, 179, 124, .26); }
  40% { box-shadow: inset 0 0 0 3px var(--ground), inset 0 0 0 4px rgba(210, 179, 124, .8), 0 0 10px 0 rgba(210, 179, 124, .15); }
}

.gate-eyebrow { animation: gate-rise 1.2s var(--ease) backwards; }
.gate-eyebrow, .gate .button { transition: opacity .3s ease; }

@keyframes gate-rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

/* opening: the words fade, the card lifts towards the reader and thins away, and the wine comes up */
.stage.is-opening .gate-eyebrow, .stage.is-opening .gate .button { opacity: 0; pointer-events: none; }
.stage.is-opening .gate .button::before, .stage.is-opening .gate .button::after { animation: none; opacity: 0; }
.stage.is-opening .gate-door { transform: scale(1.14); opacity: 0; animation: none; }

/* ── Controls that appear only if the film is stuck or paused ── */
.stage-chip {
  min-height: 52px; padding: 0 28px 0 calc(28px + .26em);
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid rgba(245, 239, 227, .6); border-radius: 999px;
  background: rgba(0, 0, 0, .6); cursor: pointer;
  font-family: var(--deco); font-weight: 700; font-size: .72rem; letter-spacing: .26em; text-transform: uppercase; color: var(--ground);
  white-space: nowrap;
}
.stage-chip[hidden] { display: none; }
.stage-chip:focus-visible { outline: 1.5px solid var(--brass-light); outline-offset: 4px; }
.stage-resume { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); }
.stage-onward { position: absolute; left: 50%; top: calc(50% + 34px); transform: translateX(-50%); }
.stage-loading {
  position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); text-align: center;
  font-style: italic; font-size: 20px; color: rgba(245, 239, 227, .8);
  opacity: 0; transition: opacity .4s ease; pointer-events: none;
}
.stage.is-dark.is-waiting .stage-loading { opacity: 1; transition-delay: .6s; }

@media (min-width: 900px) {
  .gate { --dw: min(400px, max(150px, calc((100vh - 270px) * 400 / 560))); }
}
@media (max-height: 480px) {
  .gate-eyebrow { margin-bottom: 12px; }
  .gate .button { margin-top: 16px; padding-block: 12px 11px; }
}
@media (prefers-reduced-motion: reduce) {
  .stage, .stage::after, .stage-frame, .gate-door { transition-duration: .01ms !important; transition-delay: 0s !important; }
  .gate-door, .gate .button, .gate-eyebrow, .gate-names, .gate-door .lotus-hub { animation: none; }
  .gate .button { animation: none; }
  .gate .button::before, .gate .button::after { animation: none; opacity: 0; }
  .stage.is-opening .gate-door { transform: none; }
}

/* ── The opening card carrying the couple's card (<html data-gate="names">) ──
   It is the names card exactly: the same 400 × 566 card, the same width rule, the same text block, so nothing about it
   differs from where it sits at the top of the site. The button below keeps to the width of its frame. */
html:not([data-gate="names"]) .gate-door .lotus-couple, html[data-gate="names"] .gate-door .lotus:not(.lotus-couple) { display: none; }
html[data-gate="names"] .gate {
  --dw: min(460px, calc(100vw - 2 * var(--pad)), max(250px, calc((100vh - 250px) * 400 / 566)));
  --dw: min(460px, calc(100vw - 2 * var(--pad)), max(250px, calc((100svh - 250px) * 400 / 566)));
}
html[data-gate="names"] .gate-door { --h: 566; }
