/*
 * Gatefold invitation intro: a landscape card whose two halves swing open
 * from the centre like doors, revealing the invitation inside.
 *
 * Reuses the #envelope container and its state classes from invite.js:
 *   is-opening  band slides off       is-card    inside card settles forward
 *   is-flap     doors swing open      is-fading  whole intro fades to the site
 *
 * Variant skins set:
 *   --gate-paper  door fronts          --gate-liner  inside of the doors
 *   --gate-inner  inside card          --gate-ink    text colour
 *   --gate-accent accent colour        --gate-edge   fine border colour
 */

.gate {
  position: relative;
  width: min(760px, 92vw);
  aspect-ratio: 1.55;
  perspective: 2200px;
  container-type: inline-size;
  animation: gate-in 1s cubic-bezier(.2,.7,.2,1) both;
}
@keyframes gate-in { from { transform: translateY(26px) scale(0.97); opacity: 0; } to { transform: none; opacity: 1; } }

/* The invitation inside — always there, hidden behind the doors */
.gate-inside {
  position: absolute; inset: 0;
  background: var(--gate-inner); color: var(--gate-ink);
  border-radius: 3px;
  box-shadow: 0 30px 60px rgba(0,0,0,0.22), 0 6px 14px rgba(0,0,0,0.1);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 6cqw 8cqw; overflow: hidden;
  transition: transform 1.2s cubic-bezier(.25,.8,.25,1);
}
.gate-inside::before { content: ""; position: absolute; inset: 2.2cqw; border: 1px solid var(--gate-edge); pointer-events: none; }
/* shadow the doors cast on the inside while they're closing it off */
.gate-inside::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, rgba(0,0,0,0.28), rgba(0,0,0,0) 22%, rgba(0,0,0,0) 78%, rgba(0,0,0,0.28));
  opacity: 0; transition: opacity 1.3s ease;
}
#envelope.is-flap .gate-inside::after { opacity: 1; }
#envelope.is-card .gate-inside::after { opacity: 0.35; }
#envelope.is-card .gate-inside { transform: scale(1.04); }
.gate-inside > * { opacity: 0; transform: translateY(8px); transition: opacity 0.8s ease, transform 0.8s ease; }
#envelope.is-flap .gate-inside > * { opacity: 1; transform: none; }
#envelope.is-flap .gate-inside > :nth-child(2) { transition-delay: 0.45s; }
#envelope.is-flap .gate-inside > :nth-child(3) { transition-delay: 0.6s; }
#envelope.is-flap .gate-inside > :nth-child(4) { transition-delay: 0.75s; }
#envelope.is-flap .gate-inside > :nth-child(5) { transition-delay: 0.9s; }
#envelope.is-flap .gate-inside > :nth-child(6) { transition-delay: 1.05s; }
#envelope.is-flap .gate-inside > :nth-child(7) { transition-delay: 1.2s; }

/* The doors */
.door {
  position: absolute; top: 0; bottom: 0; width: 50%; z-index: 2;
  transform-style: preserve-3d;
  transition: transform 1.5s cubic-bezier(.55,.05,.2,1);
}
.door.l { left: 0; transform-origin: 0 50%; }
.door.r { right: 0; transform-origin: 100% 50%; }
#envelope.is-flap .door.l { transform: rotateY(-112deg); }
#envelope.is-flap .door.r { transform: rotateY(112deg); }

.door .face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; overflow: hidden; }
.door.l .face { border-radius: 3px 0 0 3px; }
.door.r .face { border-radius: 0 3px 3px 0; }
.door .front { background: var(--gate-paper); }
.door .back { background: var(--gate-liner); transform: rotateY(180deg); }
/* light falls across the inside of each door as it swings open */
.door .back::after { content: ""; position: absolute; inset: 0; }
.door.l .back::after { background: linear-gradient(270deg, rgba(0,0,0,0.25), rgba(255,255,255,0.06)); }
.door.r .back::after { background: linear-gradient(90deg, rgba(0,0,0,0.25), rgba(255,255,255,0.06)); }
/* the fold at the seam */
.door.l .front { box-shadow: inset -1px 0 0 rgba(0,0,0,0.08), inset -10px 0 14px -12px rgba(0,0,0,0.25); }
.door.r .front { box-shadow: inset 1px 0 0 rgba(255,255,255,0.5), inset 10px 0 14px -12px rgba(0,0,0,0.18); }

/* Front artwork is one design that spans both doors: each door shows its half. */
.door .art { position: absolute; top: 0; bottom: 0; width: 200%; }
.door.l .art { left: 0; }
.door.r .art { right: 0; }
.art-frame { position: absolute; inset: 2.2cqw; border: 1px solid var(--gate-edge); pointer-events: none; }
.art-center {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; color: var(--gate-ink); padding: 0 10cqw;
}

/* The band that holds it shut */
.gate-band {
  position: absolute; left: -1.5%; right: -1.5%; top: 50%; z-index: 4;
  transform: translateY(-50%);
  border: 0; padding: 0; background: none; cursor: pointer;
  transition: transform 0.6s cubic-bezier(.5,0,.3,1), opacity 0.5s ease;
}
#envelope.is-opening .gate-band { transform: translateY(80%) ; opacity: 0; pointer-events: none; }
.gate-band:focus-visible { outline: 2px solid var(--gate-accent); outline-offset: 4px; }

/* Card-level shadow under the closed doors */
.gate::before {
  content: ""; position: absolute; inset: 0; z-index: 0; border-radius: 3px;
  box-shadow: 0 34px 70px rgba(0,0,0,0.25), 0 6px 16px rgba(0,0,0,0.12);
  transition: opacity 1s;
}
#envelope.is-flap .gate::before { opacity: 0; }

#envelope.is-opening .env-btn, #envelope.is-opening .env-hint { opacity: 0; pointer-events: none; }
.gate-skip { opacity: 0; transition: opacity 0.6s 1.6s; margin: 0; font-size: 0.85rem; }
#envelope.is-flap .gate-skip { opacity: 0.7; }
#envelope .env-stage { position: relative; }
.gate-skip { position: absolute; left: 0; right: 0; bottom: -4px; text-align: center; pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
  .gate { animation: none; }
}

/* Phones: a squarer card so the inside has room to be read. */
@media (max-width: 600px) {
  .gate { aspect-ratio: 0.92; }
  .gate-inside { padding: 8cqw 9cqw; }
}
