/* ==========================================================
   Gate — a gatefold card closed with a wax seal.
   The guest's code breaks the seal; the palace doors swing open.
   ========================================================== */
#gate { position: fixed; inset: 0; z-index: 600; perspective: 2200px; overflow: hidden; }
#gate.gone { display: none; }

/* ---------- doors ---------- */
.gf {
  position: absolute; top: 0; bottom: 0; width: 50%; overflow: hidden;
  background:
    radial-gradient(ellipse 120% 70% at 50% -10%, rgba(255, 255, 255, .6), transparent 60%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64' viewBox='0 0 64 64'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.42' stroke-width='.9'%3E%3Cpath d='M32 4 C40 16 48 24 60 32 C48 40 40 48 32 60 C24 48 16 40 4 32 C16 24 24 16 32 4Z'/%3E%3Cpath d='M32 18 C36 24 40 28 46 32 C40 36 36 40 32 46 C28 40 24 36 18 32 C24 28 28 24 32 18Z'/%3E%3Ccircle cx='32' cy='32' r='2.5'/%3E%3Ccircle cx='0' cy='0' r='4'/%3E%3Ccircle cx='64' cy='0' r='4'/%3E%3Ccircle cx='0' cy='64' r='4'/%3E%3Ccircle cx='64' cy='64' r='4'/%3E%3C/g%3E%3C/svg%3E") center / 64px,
    linear-gradient(165deg, #e8f4ef 0%, #c3e0d4 45%, #9fcbbb 100%);
  transition: transform 2.2s var(--ease-io), filter 2.2s var(--ease-io);
  will-change: transform;
}
.gf-l { left: 0; transform-origin: 0 50%; box-shadow: inset -30px 0 60px -30px rgba(60, 15, 34, .25); }
.gf-r { right: 0; transform-origin: 100% 50%; box-shadow: inset 30px 0 60px -30px rgba(60, 15, 34, .25); }
.gf::before { /* double foil frame */
  content: ''; position: absolute; inset: clamp(10px, 2vw, 22px);
  border: 1px solid rgba(180, 122, 99, .55); outline: 1px solid rgba(180, 122, 99, .3); outline-offset: -7px;
}
.gf-l::before { right: 0; border-right: 0; } .gf-r::before { left: 0; border-left: 0; }
.gf::after { /* foil seam where the doors meet */
  content: ''; position: absolute; top: 0; bottom: 0; width: 3px; background: var(--foil); background-size: 100% 300%;
}
.gf-l::after { right: 0; } .gf-r::after { left: 0; }
.gf-arch { position: absolute; left: 50%; top: 50%; width: min(64%, 300px); height: auto; aspect-ratio: 100 / 160; transform: translate(-50%, -46%); color: rgba(255, 255, 255, .85); }
.gf-lotus { position: absolute; left: 50%; bottom: 7%; width: 70px; height: 44px; transform: translateX(-50%); color: rgba(180, 122, 99, .7); }

#gate.opening .gf-l { transform: rotateY(-108deg); filter: brightness(.82); }
#gate.opening .gf-r { transform: rotateY(108deg); filter: brightness(.82); }

/* ---------- centre UI ---------- */
.gate-ui {
  position: absolute; inset: 0; z-index: 2; overflow-y: auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 28px 16px 64px; text-align: center;
  transition: opacity 1s var(--ease), transform 1.4s var(--ease);
}
#gate.opening .gate-ui { opacity: 0; transform: scale(1.12); pointer-events: none; }
.g-shloka { margin: 0 0 1rem; font-style: italic; font-size: .95rem; letter-spacing: .08em; color: var(--wine); opacity: 0; animation: rise 1.2s .2s var(--ease) forwards; }

.g-medal {
  position: relative; width: min(320px, 74vw); aspect-ratio: 1; flex-shrink: 0;
  filter: drop-shadow(0 26px 40px rgba(60, 15, 34, .22));
  opacity: 0; animation: medalIn 1.6s .35s var(--ease) forwards;
}
@keyframes medalIn { from { opacity: 0; transform: scale(.82) rotate(-8deg); } to { opacity: 1; transform: none; } }
.g-medal-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.g-medal-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.g-name { font-family: var(--script); color: var(--wine); font-size: clamp(2.2rem, 9vw, 3.1rem); line-height: 1.05; }
.g-weds { font-style: italic; font-size: .9rem; color: var(--rosegold); margin: -.1rem 0 .1rem; }
.g-date { margin: 1.4rem 0 1.6rem; font-family: var(--caps); font-size: .68rem; letter-spacing: .38em; text-transform: uppercase; color: var(--wine); opacity: 0; animation: rise 1.2s .7s var(--ease) forwards; }

/* ---------- form + seal ---------- */
.g-form { display: flex; flex-direction: column; align-items: center; opacity: 0; animation: rise 1.2s .9s var(--ease) forwards; }
.g-label { font-style: italic; color: var(--wine); font-size: 1rem; margin-bottom: .6rem; }
.g-input {
  width: min(260px, 80vw); height: 50px; padding: 0 18px; text-align: center;
  font-family: var(--caps); font-size: 1.05rem; letter-spacing: .38em; text-transform: uppercase; color: var(--wine);
  background: rgba(253, 248, 241, .9); border: 1px solid rgba(180, 122, 99, .5); border-radius: 999px;
  box-shadow: 0 14px 30px -18px rgba(60, 15, 34, .45), inset 0 1px 0 #fff;
  transition: border-color .4s, box-shadow .4s;
}
.g-input::placeholder { color: rgba(86, 24, 49, .28); }
.g-input:focus { outline: none; border-color: var(--rosegold); box-shadow: 0 0 0 4px rgba(233, 194, 170, .45), 0 14px 30px -18px rgba(60, 15, 34, .45); }
.g-input.bad { animation: shake .5s; border-color: var(--magenta); }
@keyframes shake { 20%, 60% { transform: translateX(-9px); } 40%, 80% { transform: translateX(9px); } }

.g-seal {
  position: relative; width: 86px; height: 86px; margin-top: 1.3rem; padding: 0; border: 0; background: none; border-radius: 50%;
  transition: transform .7s var(--ease);
}
.g-seal::before { /* uneven wax rim */
  content: ''; position: absolute; inset: -7px; border-radius: 47% 53% 49% 51% / 52% 46% 54% 48%;
  background: radial-gradient(circle at 38% 30%, #8a2d4f, var(--wine) 60%, var(--wine-2));
  box-shadow: 0 10px 20px -6px rgba(60, 15, 34, .6);
}
.seal-half {
  position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle at 36% 28%, #a03a60, var(--wine) 55%, #2f0b1a 100%);
  box-shadow: inset 0 -5px 10px rgba(0, 0, 0, .35), inset 0 3px 7px rgba(255, 255, 255, .2);
  transition: transform 1s var(--ease), opacity 1s var(--ease);
}
.seal-half.l { clip-path: polygon(0 0, 54% 0, 46% 30%, 56% 55%, 44% 78%, 52% 100%, 0 100%); }
.seal-half.r { clip-path: polygon(54% 0, 100% 0, 100% 100%, 52% 100%, 44% 78%, 56% 55%, 46% 30%); }
.seal-mono {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none;
  font-family: var(--script); font-size: 1.9rem; color: #f3d2bd; text-shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 -1px 0 rgba(255, 255, 255, .15);
  transition: opacity .4s;
}
.seal-mono i { font-family: var(--serif); font-size: .5em; opacity: .8; margin: 0 .1em; }
.g-seal::after { content: ''; position: absolute; inset: 8px; border-radius: 50%; border: 1px dashed rgba(243, 210, 189, .45); pointer-events: none; transition: opacity .4s; }
.g-seal:hover { transform: scale(1.07) rotate(-5deg); }
.g-seal.busy { animation: pulse 1s var(--ease-io) infinite; }
@keyframes pulse { 50% { transform: scale(.94); } }

#gate.cracked .seal-half.l { transform: translate(-36px, 14px) rotate(-28deg); opacity: 0; }
#gate.cracked .seal-half.r { transform: translate(36px, 14px) rotate(28deg); opacity: 0; }
#gate.cracked .seal-mono, #gate.cracked .g-seal::after { opacity: 0; }
#gate.cracked .g-seal::before { transition: opacity .6s, transform .8s var(--ease); opacity: 0; transform: scale(1.3); }

.g-hint { margin: .9rem 0 0; font-family: var(--caps); font-size: .58rem; letter-spacing: .34em; text-transform: uppercase; color: var(--rosegold); }
.g-err { min-height: 1.5em; margin: .7rem 0 0; max-width: 320px; font-family: var(--sans); font-size: .8rem; color: var(--magenta); }

.gate-brand {
  position: absolute; z-index: 3; left: 0; right: 0; bottom: 18px; margin: 0;
  display: flex; justify-content: center; align-items: center; gap: 7px;
  font-family: var(--sans); font-size: .68rem; letter-spacing: .1em; color: var(--wine); transition: opacity .6s;
}
.gate-brand b { font-weight: 500; letter-spacing: .16em; }
#gate.opening .gate-brand { opacity: 0; }

@media (max-height: 700px) {
  .g-medal { width: min(240px, 62vw); }
  .g-date { margin: .9rem 0 1rem; }
  .g-seal { width: 72px; height: 72px; margin-top: 1rem; }
}
