/* ─── Reset ─────────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html,
body {
  height: 100%;
  overflow: hidden;
  background: #f2e7d4;
}
p {
  margin: 0;
}

/* ─── Root / Scroll ─────────────────────────────────────────────────────── */
#invite-root {
  position: fixed;
  inset: 0;
  container-type: size;
  -webkit-font-smoothing: antialiased;
}
#invite-scroll {
  position: absolute;
  inset: 0;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
#invite-scroll::-webkit-scrollbar {
  display: none;
}

/* ─── Hero ──────────────────────────────────────────────────────────────── */
#invite-hero {
  position: relative;
  overflow: hidden;
  height: min(88cqh, 300cqw);
  background: radial-gradient(ellipse at 50% 30%, #fff8e8 0%, #f2e7d4 52%, #e8d5b6 100%);
  isolation: isolate;
}
#invite-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4'%3E%3Cline x1='0' y1='2' x2='4' y2='2' stroke='rgba(255,255,255,.07)' stroke-width='.4'/%3E%3Cline x1='2' y1='0' x2='2' y2='4' stroke='rgba(0,0,0,.05)' stroke-width='.3'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.62' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23g)' opacity='.055'/%3E%3C/svg%3E");
}

/* ─── Stage ─────────────────────────────────────────────────────────────── */
#invite-stage {
  position: absolute;
  inset: 0;
  container-type: size;
  --u: min(0.8cqh, 1.2cqw);
  --rest-y: min(50cqh, calc(var(--u) * 75));
  --env-y: calc(var(--rest-y) + var(--u) * 28);
  --card-y: calc(var(--rest-y) - var(--u) * 64);
  --dur: 3.6s;
}
@container (min-width: 500px) {
  #invite-stage {
    --env-y: calc(var(--rest-y) + var(--u) * 38);
  }
}
@container (max-width: 499px) {
  #invite-stage {
    --card-y: calc(var(--rest-y) - var(--u) * 68);
  }
}

/* ─── Envelope layers ───────────────────────────────────────────────────── */
.vg-env {
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(var(--u) * 98);
  height: calc(var(--u) * 70.5);
  pointer-events: none;
}
.vg-env > svg {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.vg-env.back {
  filter: drop-shadow(
      0 calc(var(--u) * 0.3) calc(var(--u) * 0.5) rgba(10, 10, 10, 0.22)
    )
    drop-shadow(
      0 calc(var(--u) * 1.6) calc(var(--u) * 3) rgba(10, 10, 10, 0.22)
    );
}

/* ── Before animation starts: hide elements so load flash is invisible ──── */
#invite-stage:not(.animating) .vg-env,
#invite-stage:not(.animating) .vg-flap,
#invite-stage:not(.animating) #invite-card {
  opacity: 0;
}

/* ── Animating state: keyframe animations fire ───────────────────────────── */
#invite-stage.animating .vg-env {
  animation: vg-env-move var(--dur) cubic-bezier(0.55, 0, 0.25, 1) both;
}
#invite-stage.animating .vg-env.back {
  z-index: 1;
}
#invite-stage.animating .vg-env.front {
  z-index: 3;
}
#invite-stage.animating .vg-env.flap-layer {
  z-index: 0;
  perspective: calc(var(--u) * 320);
  animation:
    vg-env-move var(--dur) cubic-bezier(0.55, 0, 0.25, 1) both,
    vg-flap-z var(--dur) linear both;
}
#invite-stage.animating .vg-flap {
  animation: vg-flap-open var(--dur) cubic-bezier(0.45, 0, 0.3, 1) both;
}
#invite-stage.animating #invite-card {
  animation: vg-card-move var(--dur) cubic-bezier(0.5, 0, 0.25, 1) both;
}

/* ─── Flap ──────────────────────────────────────────────────────────────── */
.vg-flap {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 70%;
  transform-origin: top center;
  transform: rotateX(180deg);
}
.vg-flap > svg {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.vg-flap > svg.inside {
  transform: rotateX(180deg);
}

/* ─── Save the date card ────────────────────────────────────────────────── */
#invite-card {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 6;
  width: calc(var(--u) * 70.71);
  height: calc(var(--u) * 100);
  container-type: size;
  overflow: hidden;
  border-radius: calc(var(--u) * 0.4);
  box-shadow:
    0 calc(var(--u) * 0.4) calc(var(--u) * 0.8) rgba(10, 10, 10, 0.18),
    0 calc(var(--u) * 2.5) calc(var(--u) * 6) rgba(10, 10, 10, 0.28);
}

/* Full-bleed photo */
#std-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
}

/* SAVE THE DATE — top center */
.std-save-date {
  position: absolute;
  top: 5cqh;
  left: 0;
  right: 0;
  text-align: center;
  font-family: "Montserrat", sans-serif;
  font-weight: 800;
  font-size: 3.8cqw;
  letter-spacing: 0.44em;
  text-transform: uppercase;
  color: #34391f;
  text-shadow: 0 1px 6px rgba(255,255,255,0.55), 0 2px 14px rgba(255,255,255,0.35);
}

/* Ornament — below title */
.std-ornament {
  position: absolute;
  top: 12cqh;
  left: 50%;
  transform: translateX(-50%);
  width: 52%;
  height: auto;
  display: block;
}

/* Names block — centered, upper third */
.std-names {
  position: absolute;
  top: 18cqh;
  left: 0;
  right: 0;
  text-align: center;
}
.std-name {
  font-family: "Cormorant Garamond", serif;
  font-weight: 600;
  font-size: 11cqw;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #34391f;
  line-height: 1;
  display: block;
  text-shadow: 0 1px 8px rgba(255,255,255,0.6), 0 2px 18px rgba(255,255,255,0.4);
}
.std-and {
  display: block;
  font-family: "Great Vibes", cursive;
  font-size: 9cqw;
  color: #b08b55;
  line-height: 1.35;
  margin: 0.8cqh 0;
  text-shadow: 0 1px 8px rgba(255,255,255,0.45);
}

/* Bottom details with scoped overlay */
.std-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 2cqh 7cqw 3.5cqh;
  text-align: center;
}
.std-bottom::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0%,
    rgba(0, 0, 0, 0.3) 28%,
    rgba(0, 0, 0, 0.5) 100%
  );
  z-index: 0;
}
.std-bottom > * {
  position: relative;
  z-index: 1;
}
.std-getting-married {
  font-family: "Montserrat", sans-serif;
  font-weight: 800;
  font-size: 2.3cqw;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: rgba(255, 252, 238, 0.88);
  margin-bottom: 1.6cqh;
}
.std-date-row {
  display: flex;
  align-items: center;
  gap: 2.5cqw;
  margin-bottom: 1.3cqh;
}
.std-date-line {
  flex: 1;
  height: 1px;
  background: rgba(176, 139, 85, 0.7);
  display: block;
}
.std-event-date {
  font-family: "Cormorant Garamond", serif;
  font-weight: 500;
  font-size: 6cqw;
  letter-spacing: 0.08em;
  color: #fffcee;
  white-space: nowrap;
}
.std-event-city {
  font-family: "Montserrat", sans-serif;
  font-weight: 800;
  font-size: 2.2cqw;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: rgba(255, 252, 238, 0.82);
  margin-bottom: 1.4cqh;
}
.std-follow {
  font-family: "Cormorant Garamond", serif;
  font-style: italic;
  font-size: 3.5cqw;
  color: #d1b078;
  font-weight: 800;
}

/* ─── Keyframes ─────────────────────────────────────────────────────────── */
@keyframes vg-env-move {
  0%,
  44% {
    transform: translate(-50%, -50%) translateY(calc(var(--u) * 12)) scale(0.74);
  }
  57% {
    transform: translate(-50%, -50%) translateY(calc(var(--u) * 30)) scale(0.8);
  }
  100% {
    transform: translate(-50%, -50%) translateY(var(--env-y)) scale(1.05);
  }
}
@keyframes vg-flap-z {
  0%,
  25% {
    z-index: 4;
  }
  26%,
  100% {
    z-index: 0;
  }
}
@keyframes vg-flap-open {
  0%,
  12% {
    transform: rotateX(0deg);
  }
  36%,
  100% {
    transform: rotateX(180deg);
  }
}
@keyframes vg-card-move {
  0%,
  36% {
    z-index: 2;
    transform: translate(-50%, -50%) translateY(calc(var(--u) * 12.7))
      rotate(-90deg) scale(0.62);
  }
  57% {
    z-index: 2;
    transform: translate(-50%, -50%) translateY(calc(var(--u) * -40))
      rotate(-90deg) scale(0.66);
  }
  58% {
    z-index: 6;
    transform: translate(-50%, -50%) translateY(calc(var(--u) * -40))
      rotate(-90deg) scale(0.66);
  }
  100% {
    z-index: 6;
    transform: translate(-50%, -50%) translateY(var(--card-y)) rotate(0deg)
      scale(1);
  }
}
@keyframes vg-peek {
  0% {
    transform: translateY(0);
  }
  42% {
    transform: translateY(-150px);
  }
  54% {
    transform: translateY(-150px);
  }
  100% {
    transform: translateY(0);
  }
}
@media (prefers-reduced-motion: reduce) {
  #invite-stage *,
  #invite-below.peeking {
    animation: none !important;
  }
}

/* ─── Below section ─────────────────────────────────────────────────────── */
#invite-below {
  position: relative;
  z-index: 2;
  background: #f8f4ea;
  font-family: "Montserrat", system-ui, sans-serif;
  color: #2a3d2e;
}
#invite-below.peeking {
  animation: vg-peek 2.8s cubic-bezier(0.4, 0, 0.3, 1) both;
}
.vg-section {
  padding: 52px 24px;
  text-align: center;
  border-top: 1px solid #e0d9c8;
}
.vg-section:first-child {
  border-top: none;
}
.vg-inner {
  max-width: 560px;
  margin: 0 auto;
}
@media (max-width: 519px) {
  .vg-section-2 {
    padding-left: 0;
    padding-right: 0;
  }
}
.vg-sec-label {
  font-family: "Montserrat", system-ui, sans-serif;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #9a8f7a;
  margin-bottom: 10px;
}
.std-headline {
  font-family: "Montserrat", system-ui, sans-serif;
  font-weight: 300;
  font-size: clamp(32px, 7vw, 48px);
  color: #4a3826;
  line-height: 1.2;
  margin-bottom: 18px;
  letter-spacing: 0.04em;
}
.std-tagline {
  font-family: "Montserrat", system-ui, sans-serif;
  font-weight: 300;
  font-size: clamp(13px, 2.4vw, 16px);
  line-height: 1.85;
  color: #6a6050;
}
.vg-details-row {
  display: flex;
  flex-direction: column;
}
.vg-details-col {
  padding: 28px 0;
}
.vg-details-col:first-child {
  padding-top: 0;
}
.vg-details-col:last-child {
  padding-bottom: 0;
}
.vg-details-col + .vg-details-col {
  border-top: 1px solid #e0d9c8;
}
@media (min-width: 520px) {
  .vg-details-row {
    flex-direction: row;
    align-items: stretch;
  }
  .vg-details-col {
    flex: 1;
    padding: 0 0 0 24px;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  .vg-details-col:first-child {
    padding-left: 0;
  }
  .vg-details-col + .vg-details-col {
    border-top: none;
    border-left: 1px solid #e0d9c8;
  }
}
.vg-sec-text {
  font-family: "Montserrat", system-ui, sans-serif;
  font-weight: 400;
  font-size: clamp(14px, 2.4vw, 16px);
  line-height: 1.75;
  color: #3a2a1c;
}
#invite-footer {
  padding: 22px 24px 34px;
  text-align: center;
  font-family: "Montserrat", system-ui, sans-serif;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: #9a8f7a;
  background: #edeae0;
}

/* ─── Replay button — bottom-center, below the card ───────────────────── */
#play-btn {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.88);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.22);
  z-index: 999;
  transition:
    background 0.18s,
    box-shadow 0.18s,
    transform 0.18s;
}
#play-btn:hover {
  background: #fff;
  box-shadow: 0 4px 22px rgba(0, 0, 0, 0.28);
  transform: translateX(-50%) scale(1.08);
}
#play-btn svg {
  fill: #2a2a2a;
}
