:root {
  --cream: #f7efd9;
  --paper: #fff8e8;
  --gold: #b8872f;
  --gold-dark: #8d6727;
  --leaf: #365934;
  --ink: #3c3325;
  --mist: #e6f0e7;
  --stage-start: #edf2ec;
  --stage-mid: #f7eedc;
  --stage-end: #c7d8d2;
  --frame-bg: rgba(255, 255, 255, 0.46);
  --shell-bg: radial-gradient(circle at 50% 38%, #f9eed9 0%, #f2e3c8 66%, #ead8b8 100%);
  --heading-color: #785722;
  --heading-subtle: #91703a;
  --envelope-image: url("assets/envelope-light-v2-hq.webp");
  --invite-image: url("assets/invitation-light-option3-mobile-v3-fast.webp");
  --opening-glow: rgba(255, 233, 174, 0.9);
  --opening-halo: rgba(197, 143, 49, 0.42);
  --toggle-bg: rgba(255, 250, 238, 0.86);
  --toggle-color: #765621;
}

html[data-theme="dark"] {
  --stage-start: #07191e;
  --stage-mid: #0a1825;
  --stage-end: #061016;
  --frame-bg: rgba(20, 33, 41, 0.7);
  --shell-bg: #07131c;
  --heading-color: #d8aa56;
  --heading-subtle: #b98b43;
  --envelope-image: url("assets/envelope-dark-v2-hq.webp");
  --invite-image: url("assets/invitation-dark-v2.webp");
  --opening-glow: rgba(255, 218, 127, 0.95);
  --opening-halo: rgba(211, 157, 57, 0.5);
  --toggle-bg: rgba(8, 22, 31, 0.82);
  --toggle-color: #e3ba69;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  color: var(--ink);
  font-family: Inter, system-ui, sans-serif;
  background:
    radial-gradient(circle at 22% 16%, rgba(255, 255, 255, 0.7), transparent 26rem),
    linear-gradient(145deg, var(--stage-start) 0%, var(--stage-mid) 48%, var(--stage-end) 100%);
  transition: background 500ms ease;
}

html[data-theme="dark"] body {
  background:
    radial-gradient(circle at 50% 18%, rgba(45, 66, 76, 0.34), transparent 28rem),
    linear-gradient(145deg, var(--stage-start) 0%, var(--stage-mid) 48%, var(--stage-end) 100%);
}

body.animated-bg {
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.82), transparent 22rem),
    linear-gradient(145deg, #bfd8d5 0%, #f7ecd5 42%, #9fc4c1 100%);
}

body.animated-bg::before,
body.animated-bg::after {
  content: "";
  position: fixed;
  inset: auto -12% -20%;
  height: 46vh;
  pointer-events: none;
  background:
    radial-gradient(70% 48% at 50% 0%, rgba(255, 255, 255, 0.68), transparent 64%),
    repeating-radial-gradient(ellipse at 50% 0%, rgba(255, 255, 255, 0.42) 0 2px, transparent 3px 32px);
  opacity: 0.72;
  transform-origin: center bottom;
  animation: tide 7s ease-in-out infinite alternate;
}

body.animated-bg::after {
  inset: -10% -12% auto;
  height: 100vh;
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 255, 255, 0.88) 0 3px, transparent 4px),
    radial-gradient(circle at 78% 22%, rgba(211, 166, 71, 0.5) 0 2px, transparent 3px),
    radial-gradient(circle at 28% 72%, rgba(255, 255, 255, 0.75) 0 2px, transparent 3px),
    radial-gradient(circle at 66% 66%, rgba(211, 166, 71, 0.42) 0 2px, transparent 3px);
  background-size: 180px 220px, 240px 260px, 210px 240px, 300px 320px;
  opacity: 0.7;
  animation: sparkleDrift 14s linear infinite;
}

button,
input,
select,
textarea {
  font: inherit;
}

.experience {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: hidden;
  position: relative;
}

.theme-toggle {
  position: fixed;
  z-index: 40;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border: 1px solid color-mix(in srgb, var(--toggle-color) 34%, transparent);
  border-radius: 999px;
  color: var(--toggle-color);
  background: var(--toggle-bg);
  box-shadow: 0 8px 24px rgba(20, 29, 25, 0.14);
  backdrop-filter: blur(14px);
  cursor: pointer;
}

.theme-icon {
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-radius: 50%;
  box-shadow: inset -4px -2px 0 currentColor;
}

html[data-theme="dark"] .theme-icon {
  box-shadow: inset 0 0 0 4px currentColor;
}

.theme-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.phone-frame {
  width: min(calc(100vw - 28px), 430px);
  aspect-ratio: 9 / 16;
  max-height: calc(100vh - 48px);
  border-radius: 34px;
  padding: 0;
  background: transparent;
  box-shadow: 0 30px 80px rgba(44, 68, 52, 0.32);
  backdrop-filter: blur(18px);
}

.invite-shell {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 34px;
  background: var(--shell-bg);
  transition: background 500ms ease;
}

.invite-card,
.envelope-presentation {
  position: absolute;
  inset: 0;
}

.invite-card {
  border: 0;
  background: #f4ead4;
  opacity: 0;
  transform: translateY(34px) scale(0.97);
  transition: opacity 850ms ease, transform 850ms ease;
}

.art-layer {
  position: absolute;
  inset: 0;
  background-image: var(--invite-image);
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity 420ms ease;
  will-change: opacity;
}

.invite-shell.invite-art-ready .art-layer {
  opacity: 1;
}

.content-layer {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 23.5% 12% 8%;
  text-align: center;
}

.title-block {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.kicker,
.family-line,
.date,
.place {
  color: var(--gold-dark);
  font-family: Cinzel, serif;
  letter-spacing: 0;
  text-transform: uppercase;
}

.family-line {
  margin: 10px 0 0;
  color: #8f6826;
  font-size: clamp(0.68rem, 2.7vw, 0.82rem);
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  text-shadow: 0 1px 10px rgba(255, 250, 236, 0.95);
}

.kicker {
  margin: 0 0 28px;
  width: min(100%, 350px);
  color: #624414;
  font-size: clamp(0.86rem, 3.15vw, 1rem);
  font-weight: 600;
  line-height: 1.24;
  text-shadow:
    0 1px 0 #fff9e8,
    0 -1px 0 #fff9e8,
    1px 0 0 #fff9e8,
    -1px 0 0 #fff9e8,
    0 0 16px rgba(255, 250, 236, 0.96);
}

h1 {
  margin: 0;
  color: #b98529;
  font-family: "Great Vibes", "Cormorant Garamond", cursive;
  font-size: clamp(4.15rem, 15.5vw, 6.15rem);
  font-weight: 400;
  line-height: 0.78;
  text-shadow:
    0 2px 0 rgba(255, 255, 255, 0.62),
    0 10px 24px rgba(120, 83, 24, 0.13);
}

h1 span {
  display: block;
  margin: 0.11em 0 0.2em;
  color: #a87320;
  font-family: "Great Vibes", cursive;
  font-size: 0.56em;
  font-weight: 400;
  line-height: 0.7;
  transform: none;
}

h1 .name-pippa {
  display: inline-block;
  font: inherit;
  font-weight: inherit;
  transform: translateX(-0.16em);
}

.date {
  margin: 15px 0 4px;
  font-size: clamp(0.92rem, 3.7vw, 1.08rem);
  -webkit-text-stroke: 0.35px rgba(255, 253, 246, 0.98);
  paint-order: stroke fill;
  text-shadow:
    -1px -1px 0 rgba(255, 253, 246, 0.94),
    1px -1px 0 rgba(255, 253, 246, 0.94),
    -1px 1px 0 rgba(255, 253, 246, 0.94),
    1px 1px 0 rgba(255, 253, 246, 0.94),
    0 0 10px rgba(255, 250, 236, 0.92);
}

.place {
  margin: 0 0 26px;
  font-size: clamp(0.82rem, 3.25vw, 0.96rem);
}

.details {
  width: 100%;
  display: grid;
  gap: 8px;
  margin-top: auto;
  margin-bottom: 2px;
}

.details div {
  position: relative;
  padding: 14px 15px;
  border: 1px solid rgba(171, 121, 35, 0.6);
  border-radius: 0;
  outline: 0;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.72), transparent 38%),
    rgba(255, 252, 242, 0.92);
  box-shadow: 0 12px 28px rgba(101, 76, 34, 0.12);
  backdrop-filter: blur(9px);
  clip-path: polygon(12px 0, calc(100% - 12px) 0, 100% 12px, 100% calc(100% - 12px), calc(100% - 12px) 100%, 12px 100%, 0 calc(100% - 12px), 0 12px);
}

.details div::after {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(191, 147, 69, 0.34);
  clip-path: polygon(9px 0, calc(100% - 9px) 0, 100% 9px, 100% calc(100% - 9px), calc(100% - 9px) 100%, 9px 100%, 0 calc(100% - 9px), 0 9px);
  pointer-events: none;
}

.details span {
  display: block;
  color: var(--gold-dark);
  font-size: clamp(0.66rem, 2.45vw, 0.78rem);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0;
  line-height: 1.25;
}

.details span::before,
.details span::after {
  content: "—";
  margin: 0 7px;
  color: rgba(174, 127, 43, 0.58);
  font-weight: 400;
}

.details strong {
  display: block;
  margin-top: 3px;
  color: #4d422f;
  font-size: clamp(0.72rem, 2.65vw, 0.84rem);
  font-weight: 500;
  line-height: 1.32;
}

.details em {
  display: block;
  margin-top: 6px;
  color: #876329;
  font-style: normal;
  font-weight: 700;
}

.rsvp-button,
.submit-preview {
  min-height: 46px;
  width: 100%;
  margin-top: 12px;
  position: relative;
  border: 1px solid rgba(166, 116, 31, 0.68);
  border-radius: 12px;
  color: #865f20;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.78), transparent 42%),
    linear-gradient(145deg, rgba(255, 253, 246, 0.97), rgba(244, 228, 193, 0.97));
  font-weight: 700;
  cursor: pointer;
  box-shadow:
    0 12px 28px rgba(121, 83, 24, 0.16),
    inset 0 0 0 3px rgba(255, 255, 255, 0.62),
    inset 0 0 0 4px rgba(174, 126, 40, 0.24);
  overflow: hidden;
}

.rsvp-button:hover,
.submit-preview:hover {
  color: #714c14;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.86), transparent 42%),
    linear-gradient(145deg, #fffef9, #efd9aa);
}

.rsvp-confirmation {
  width: 100%;
  margin-top: 12px;
  padding: 15px 18px;
  border: 1px solid rgba(166, 116, 31, 0.5);
  border-radius: 12px;
  color: #5a482b;
  background: rgba(255, 252, 242, 0.92);
  box-shadow: 0 12px 28px rgba(101, 76, 34, 0.12), inset 0 0 0 3px rgba(255, 255, 255, 0.58);
  text-align: center;
  animation: confirmationReveal 520ms cubic-bezier(0.22, 0.8, 0.22, 1) both;
}

.rsvp-confirmation[hidden] {
  display: none;
}

.rsvp-confirmation strong,
.rsvp-confirmation span {
  display: block;
}

.rsvp-confirmation strong {
  color: #805b20;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.18rem;
  line-height: 1.15;
}

.rsvp-confirmation span {
  margin-top: 5px;
  font-size: 0.78rem;
  line-height: 1.4;
}

.envelope-presentation {
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(22px, 4vh, 38px);
  padding: 5%;
  pointer-events: none;
}

.envelope-presentation::before,
.envelope-presentation::after {
  content: "";
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 58%;
  width: min(72vw, 340px);
  aspect-ratio: 1;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.18);
}

.envelope-presentation::before {
  background: radial-gradient(circle, var(--opening-glow) 0 3%, var(--opening-halo) 14%, transparent 66%);
  filter: blur(7px);
}

.envelope-presentation::after {
  border: 1px solid var(--opening-glow);
  box-shadow: 0 0 35px var(--opening-halo), inset 0 0 35px var(--opening-halo);
}

.envelope-heading {
  position: relative;
  z-index: 5;
  display: grid;
  justify-items: center;
  color: var(--heading-color);
  text-align: center;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.92);
  transition: opacity 420ms ease, transform 500ms ease;
}

.envelope-heading span {
  font-family: "Cormorant Garamond", "Playfair Display", Georgia, serif;
  font-size: clamp(2rem, 5vw, 3.25rem);
  font-weight: 600;
  line-height: 0.95;
}

.envelope-heading i {
  display: inline-block;
  margin: 0 0.24em;
  color: #ad7d29;
  font-family: "Great Vibes", cursive;
  font-size: 1.15em;
  font-weight: 400;
}

.envelope-heading small {
  margin-top: 8px;
  color: var(--heading-subtle);
  font-family: Cinzel, serif;
  font-size: clamp(0.65rem, 1.4vw, 0.82rem);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.envelope {
  z-index: 3;
  position: relative;
  inset: auto;
  width: min(90%, 620px);
  height: auto;
  aspect-ratio: 1576 / 998;
  flex: 0 0 auto;
  pointer-events: auto;
  border: 0;
  cursor: pointer;
  overflow: visible;
  background: var(--envelope-image) center 49% / 102.4% 103.6% no-repeat;
  border-radius: 10px;
  clip-path: inset(0.8% 0.55% 0.9% round 10px);
  box-shadow:
    0 35px 70px rgba(53, 63, 49, 0.28),
    0 9px 20px rgba(86, 61, 20, 0.16);
  animation: envelopeFloat 5.2s ease-in-out infinite;
  transition: opacity 620ms ease, transform 760ms cubic-bezier(0.22, 0.8, 0.22, 1), box-shadow 300ms ease;
}

.envelope::before,
.envelope::after {
  display: none;
}

.envelope-flap,
.envelope-liner,
.envelope-border,
.sacred-crest,
.palm-ornament,
.wave-ornament,
.seal,
.seal-ribbon,
.open-label {
  display: none;
}

.envelope:hover {
  box-shadow:
    0 42px 82px rgba(53, 63, 49, 0.34),
    0 12px 24px rgba(134, 94, 24, 0.2);
}

.envelope::before {
  content: "";
  position: absolute;
  z-index: 4;
  inset: 1px;
  border: 1px solid rgba(244, 209, 130, 0.72);
  pointer-events: none;
}

.envelope::after {
  content: "";
  position: absolute;
  z-index: 3;
  inset: 6.5%;
  border: 2px solid #d6a94e;
  outline: 1px solid rgba(240, 205, 127, 0.72);
  outline-offset: 5px;
  pointer-events: none;
}

.envelope-flap {
  position: absolute;
  z-index: 2;
  inset: 0 0 auto;
  height: 59%;
  background:
    radial-gradient(circle at 50% 0, rgba(44, 136, 118, 0.28), transparent 48%),
    repeating-radial-gradient(circle at 0 0, transparent 0 8px, rgba(215, 170, 72, 0.06) 9px 10px),
    linear-gradient(160deg, #0d665d, #084945 58%, #032f30);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top;
  transition: transform 900ms cubic-bezier(0.2, 0.8, 0.2, 1);
  filter: drop-shadow(0 10px 8px rgba(93, 63, 19, 0.25));
}

.envelope-liner {
  position: absolute;
  z-index: 1;
  inset: 5.6% 7.2% auto;
  height: 47%;
  background:
    linear-gradient(135deg, rgba(222, 178, 82, 0.28), rgba(255, 255, 255, 0.04)),
    repeating-linear-gradient(45deg, transparent 0 9px, rgba(218, 174, 80, 0.08) 10px 11px),
    #063b39;
  background-size: auto;
  background-position: center;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  opacity: 0.92;
}

.envelope-border {
  position: absolute;
  z-index: 3;
  inset: 4.5%;
  border: 2px solid #d5a74b;
  pointer-events: none;
  box-shadow:
    inset 0 0 0 5px rgba(5, 48, 46, 0.92),
    inset 0 0 0 7px rgba(224, 181, 87, 0.54),
    inset 0 0 34px rgba(0, 19, 20, 0.44);
}

.sacred-crest {
  position: absolute;
  z-index: 4;
  top: 12%;
  left: 50%;
  transform: translateX(-50%);
  color: #e0b65c;
  font-family: Georgia, serif;
  font-size: clamp(1rem, 3vw, 1.4rem);
  text-shadow: 0 1px 0 #032c2c, 0 0 12px rgba(224, 182, 92, 0.28);
}

.palm-ornament {
  position: absolute;
  z-index: 4;
  top: 12%;
  width: 22%;
  height: 34%;
  opacity: 0.72;
  pointer-events: none;
}

.palm-ornament-left { left: 8%; transform: rotate(-8deg); }
.palm-ornament-right { right: 8%; transform: scaleX(-1) rotate(-8deg); }

.palm-ornament::before {
  content: "";
  position: absolute;
  left: 46%;
  top: 24%;
  width: 3px;
  height: 82%;
  border-radius: 100%;
  background: linear-gradient(#e2bb65, #9f7125);
  transform: rotate(12deg);
  transform-origin: bottom;
}

.palm-ornament i,
.palm-ornament i::before,
.palm-ornament i::after {
  position: absolute;
  content: "";
  left: 46%;
  top: 20%;
  width: 55%;
  height: 5px;
  border-radius: 100% 0;
  border-top: 2px solid #dfb45a;
  transform-origin: left center;
}

.palm-ornament i { transform: rotate(-38deg); }
.palm-ornament i::before { left: 0; top: 0; transform: rotate(48deg); }
.palm-ornament i::after { left: 0; top: 0; transform: rotate(92deg); }

.wave-ornament {
  position: absolute;
  z-index: 4;
  left: 21%;
  right: 21%;
  bottom: 14%;
  height: 16px;
  opacity: 0.72;
  background: radial-gradient(20px 10px at 10px 11px, transparent 8px, #dcb057 9px 10px, transparent 11px) 0 0 / 20px 14px repeat-x;
}

.seal {
  position: absolute;
  z-index: 5;
  top: 51%;
  left: 50%;
  width: clamp(62px, 12.5%, 80px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  transform: translate(-50%, -50%);
  border-radius: 47% 53% 45% 55% / 52% 43% 57% 48%;
  clip-path: polygon(50% 0%, 60% 5%, 70% 2%, 78% 10%, 89% 12%, 92% 23%, 100% 32%, 96% 43%, 99% 55%, 92% 64%, 94% 76%, 82% 82%, 77% 94%, 64% 92%, 53% 100%, 43% 95%, 31% 99%, 24% 88%, 12% 84%, 10% 70%, 0% 61%, 5% 49%, 1% 38%, 10% 29%, 9% 17%, 22% 13%, 28% 3%, 40% 6%);
  border: 1px solid rgba(255, 236, 166, 0.62);
  color: #f9e4ad;
  background:
    radial-gradient(circle at 32% 24%, rgba(255, 248, 204, 0.55), transparent 26%),
    radial-gradient(circle at 63% 72%, rgba(93, 54, 8, 0.22), transparent 40%),
    repeating-radial-gradient(circle, transparent 0 9px, rgba(255, 239, 177, 0.12) 10px 11px),
    linear-gradient(145deg, #b47b2a, #754315 68%, #9f6720);
  font-family: "Playfair Display", Georgia, serif;
  font-size: 1.26rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow:
    inset 2px 3px 5px rgba(255, 241, 186, 0.35),
    inset -3px -4px 7px rgba(82, 47, 7, 0.34),
    0 15px 30px rgba(92, 62, 17, 0.36);
}

.seal::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 2px double rgba(255, 242, 190, 0.62);
  border-radius: 50%;
}

.seal::after {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: inherit;
  background: linear-gradient(112deg, transparent 30%, rgba(255, 249, 211, 0.72) 47%, transparent 62%);
  transform: translateX(-130%);
  animation: sealGlimmer 4.8s ease-in-out 1.1s infinite;
}

.seal-ribbon {
  position: absolute;
  z-index: 4;
  top: calc(51% + 34px);
  left: 50%;
  width: 68px;
  height: 54px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, rgba(150, 102, 28, 0.5), rgba(150, 102, 28, 0));
  clip-path: polygon(0 0, 100% 0, 84% 100%, 50% 72%, 16% 100%);
  opacity: 0.32;
}

.open-label {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: 12%;
  transform: translateX(-50%);
  color: #f0cd7c;
  text-shadow: 0 1px 1px rgba(0, 24, 23, 0.82);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.13em;
}


.magic-dust,
.magic-dust i {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.magic-dust {
  z-index: 6;
}

.magic-dust i {
  inset: auto;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #dfb655;
  box-shadow: 0 0 9px 2px rgba(223, 182, 85, 0.52);
  opacity: 0;
  animation: dustDrift 5.6s ease-in-out infinite;
}

.magic-dust i:nth-child(1) { left: 12%; top: 24%; animation-delay: -1.1s; }
.magic-dust i:nth-child(2) { left: 28%; top: 72%; animation-delay: -3.8s; transform: scale(0.7); }
.magic-dust i:nth-child(3) { left: 75%; top: 18%; animation-delay: -2.4s; transform: scale(0.55); }
.magic-dust i:nth-child(4) { left: 86%; top: 64%; animation-delay: -4.7s; }
.magic-dust i:nth-child(5) { left: 58%; top: 82%; animation-delay: -0.4s; transform: scale(0.65); }
.magic-dust i:nth-child(6) { left: 44%; top: 12%; animation-delay: -3.1s; transform: scale(0.45); }

.invite-shell[data-state="open"] .envelope-flap {
  transform: rotateX(140deg);
}

.invite-shell[data-state="opening"] .envelope-presentation::before {
  animation: openingGlow 1050ms cubic-bezier(0.2, 0.72, 0.18, 1) forwards;
}

.invite-shell[data-state="opening"] .envelope-presentation::after {
  animation: openingRing 900ms cubic-bezier(0.16, 0.8, 0.28, 1) 120ms forwards;
}

.invite-shell[data-state="opening"] .envelope {
  pointer-events: none;
  animation: envelopeReveal 1050ms cubic-bezier(0.2, 0.78, 0.2, 1) forwards;
}

.invite-shell[data-state="opening"] .envelope-heading {
  animation: headingLift 620ms ease forwards;
}

.invite-shell[data-state="opening"] .magic-dust i {
  animation: dustBurst 820ms cubic-bezier(0.18, 0.72, 0.22, 1) forwards;
}

.invite-shell[data-state="opening"] .invite-card {
  opacity: 0.3;
  transform: translateY(18px) scale(0.985);
  transition-duration: 760ms;
  transition-delay: 480ms;
}

.invite-shell[data-state="open"] .envelope {
  animation: none;
  opacity: 0;
  transform: translateY(-26px) scale(1.04) rotateX(3deg);
  pointer-events: none;
  transition-delay: 450ms;
}

.invite-shell[data-state="open"] .envelope-heading {
  opacity: 0;
  transform: translateY(-12px);
}

.invite-shell[data-state="open"] .invite-card {
  opacity: 1;
  transform: translateY(0) scale(1);
  transition-delay: 0ms;
}

html[data-theme="dark"] .invite-card .kicker,
html[data-theme="dark"] .invite-card .family-line,
html[data-theme="dark"] .invite-card .date,
html[data-theme="dark"] .invite-card .place {
  color: #e2bc70;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.72);
}

html[data-theme="dark"] .invite-card h1 {
  color: #d8a64e;
  text-shadow: 0 3px 18px rgba(0, 0, 0, 0.68);
}

html[data-theme="dark"] .invite-card .details div {
  border-color: rgba(215, 171, 86, 0.48);
  background: rgba(4, 28, 27, 0.82);
}

html[data-theme="dark"] .invite-card .details span,
html[data-theme="dark"] .invite-card .details em {
  color: #e4bb6c;
}

html[data-theme="dark"] .invite-card .details strong {
  color: #f5ead4;
}

.rsvp-panel {
  position: fixed;
  left: 50%;
  top: 50%;
  right: auto;
  bottom: auto;
  width: min(430px, calc(100vw - 36px));
  max-height: min(820px, calc(100svh - 36px));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px;
  border: 1px solid rgba(174, 126, 40, 0.24);
  border-radius: 22px;
  color: var(--ink);
  background: rgba(255, 250, 238, 0.96);
  box-shadow: 0 24px 70px rgba(36, 58, 45, 0.28);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate(-50%, calc(-50% + 24px)) scale(0.985);
  transition: opacity 280ms ease, transform 420ms cubic-bezier(0.22, 0.8, 0.22, 1), visibility 0s linear 420ms;
  z-index: 20;
}

.rsvp-panel.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
  transition-delay: 0s;
}

body.rsvp-open {
  overflow: hidden;
}

body.rsvp-open::after {
  content: "";
  position: fixed;
  z-index: 19;
  inset: 0;
  background: rgba(42, 48, 37, 0.34);
  backdrop-filter: blur(4px);
}

html[data-theme="dark"] .rsvp-panel {
  color: #f4ead5;
  background: rgba(8, 22, 31, 0.97);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.48);
}

html[data-theme="dark"] .panel-header,
html[data-theme="dark"] label,
html[data-theme="dark"] .dress-note {
  color: #e2bd73;
}

html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  border-color: rgba(226, 189, 115, 0.28);
  color: #fff8e8;
  background: #0e2530;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  color: var(--gold-dark);
  font-family: Cinzel, serif;
  font-weight: 600;
}

.close-panel {
  width: 36px;
  height: 36px;
  border: 0;
  color: var(--gold-dark);
  background: rgba(184, 135, 47, 0.13);
  cursor: pointer;
  font-size: 1.2rem;
}

form {
  display: grid;
  gap: 10px;
}

label {
  display: grid;
  gap: 5px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #584a35;
}

[data-attending-field][hidden] { display:none !important; }

.side-choice {
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:8px;
  margin:0;
  padding:0;
  border:0;
}

.side-choice legend {
  grid-column:1/-1;
  margin-bottom:5px;
  color:#584a35;
  font-size:.78rem;
  font-weight:700;
}

.side-choice label {
  display:block;
  position:relative;
}

.side-choice input {
  position:absolute;
  opacity:0;
  pointer-events:none;
}

.side-choice span {
  display:block;
  padding:11px 10px;
  border:1px solid rgba(91,75,47,.23);
  border-radius:10px;
  color:#6f5529;
  background:#fffdf5;
  text-align:center;
  cursor:pointer;
}

.side-choice input:checked + span {
  border-color:rgba(166,116,31,.68);
  background:#f3e6ca;
  box-shadow:inset 0 0 0 2px rgba(255,255,255,.72);
}

.side-choice input:focus-visible + span { outline:2px solid #9b6b20; outline-offset:2px; }
html[data-theme="dark"] .side-choice legend { color:#e2bd73; }
html[data-theme="dark"] .side-choice span { color:#f4ead5; border-color:rgba(226,189,115,.28); background:#0e2530; }

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(91, 75, 47, 0.23);
  background: #fffdf5;
  color: var(--ink);
  padding: 11px 12px;
}

textarea {
  min-height: 68px;
  resize: vertical;
}

.dress-note {
  margin: 2px 0 0;
  font-size: 0.82rem;
  line-height: 1.45;
}

.privacy-note {
  margin:0;
  color:#756a58;
  font-size:.68rem;
  line-height:1.4;
}

.form-honeypot {
  position:absolute !important;
  left:-10000px !important;
  width:1px !important;
  height:1px !important;
  overflow:hidden !important;
}

.submit-preview {
  margin-top: 2px;
}

.form-status {
  min-height: 1.25em;
  margin: 0;
  color: #765621;
  font-size: 0.78rem;
  line-height: 1.4;
}

.form-status.is-success { color: #315c42; }
.form-status.is-error { color: #9c3d31; }
.submit-preview:disabled { cursor: wait; opacity: 0.72; }

@keyframes envelopeFloat {
  0%, 100% { transform: translateY(0) rotate(-0.35deg); }
  50% { transform: translateY(-8px) rotate(0.35deg); }
}

@keyframes confirmationReveal {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes envelopeReveal {
  0% { opacity: 1; transform: translateY(0) scale(1) rotateX(0); filter: brightness(1); }
  22% { opacity: 1; transform: translateY(7px) scale(0.975) rotateX(0); filter: brightness(1.08); }
  48% { opacity: 1; transform: translateY(-5px) scale(1.025) rotateX(3deg); filter: brightness(1.22); }
  100% { opacity: 0; transform: translateY(-76px) scale(1.08) rotateX(12deg); filter: brightness(1.35) blur(2px); }
}

@keyframes headingLift {
  to { opacity: 0; transform: translateY(-18px); filter: blur(2px); }
}

@keyframes openingGlow {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.18); }
  38% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.45); }
}

@keyframes openingRing {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.16); }
  30% { opacity: 0.9; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.2); }
}

@keyframes dustBurst {
  0% { opacity: 0; translate: 0 0; }
  30% { opacity: 1; }
  100% { opacity: 0; translate: 0 -52px; transform: scale(1.8); }
}

@keyframes sealGlimmer {
  0%, 66%, 100% { transform: translateX(-130%); opacity: 0; }
  76% { opacity: 0.85; }
  88% { transform: translateX(130%); opacity: 0; }
}

@keyframes dustDrift {
  0%, 100% { opacity: 0; transform: translate3d(0, 9px, 0) scale(0.55); }
  35% { opacity: 0.75; }
  64% { opacity: 0.28; transform: translate3d(5px, -13px, 0) scale(1); }
}

@keyframes tide {
  from {
    transform: translate3d(-2%, 0, 0) rotate(-1deg) scaleX(1.03);
  }

  to {
    transform: translate3d(2%, -18px, 0) rotate(1deg) scaleX(1.08);
  }
}

@keyframes sparkleDrift {
  from {
    background-position: 0 0, 40px 20px, 80px 60px, 20px 90px;
  }

  to {
    background-position: 80px 240px, 0 300px, 120px 340px, 80px 410px;
  }
}

@media (max-width: 520px) {
  .experience {
    padding:
      max(12px, env(safe-area-inset-top))
      max(12px, env(safe-area-inset-right))
      max(12px, env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left));
  }

  .phone-frame {
    width: min(calc(100vw - 24px), 405px);
    height: min(calc(100svh - 24px), calc((100vw - 24px) * 1.7778));
    max-height: none;
    aspect-ratio: auto;
    border-radius: 28px;
    padding: 0;
  }

  .invite-shell {
    border-radius: 28px;
  }

  .content-layer {
    padding: 29% 10.5% 7.5%;
  }

  .envelope {
    width: 88%;
  }

  .envelope-presentation {
    gap: 24px;
  }

  .envelope-heading span {
    font-size: clamp(2rem, 10vw, 2.5rem);
  }

  .envelope-heading small {
    font-size: 0.64rem;
  }

  .seal {
    top: 53%;
    width: 56px;
    font-size: 0.82rem;
  }

  .seal-ribbon {
    top: calc(53% + 26px);
    width: 52px;
    height: 40px;
  }

  .open-label {
    bottom: 8%;
    font-size: 0.66rem;
  }

  .kicker {
    max-width: 280px;
    margin-bottom: 26px;
    font-size: 0.86rem;
    line-height: 1.3;
  }

  h1 {
    font-size: clamp(3.45rem, 16.2vw, 4.25rem);
    line-height: 0.88;
  }

  .date {
    margin-top: 22px;
    font-size: 0.92rem;
  }

  .place {
    margin-bottom: 18px;
    font-size: 0.8rem;
  }

  .details div {
    padding: 12px 12px;
  }

  .details strong {
    font-size: 0.77rem;
    line-height: 1.34;
  }

  .rsvp-button {
    min-height: 50px;
    margin-top: 10px;
    font-size: 0.86rem;
  }

  body.rsvp-open {
    overflow: hidden;
  }

  body.rsvp-open::after {
    content: "";
    position: fixed;
    z-index: 19;
    inset: 0;
    background: rgba(31, 38, 29, 0.48);
    backdrop-filter: blur(3px);
  }

  .rsvp-panel {
    left: 50%;
    top: 50%;
    right: auto;
    bottom: auto;
    width: calc(100% - 24px);
    max-height: calc(100svh - 24px);
    overflow-y: auto;
    padding: 20px 20px max(20px, env(safe-area-inset-bottom));
    border-radius: 22px;
    box-shadow: 0 24px 70px rgba(30, 40, 31, 0.3);
    transform: translate(-50%, calc(-50% + 20px)) scale(0.985);
  }

  .rsvp-panel.is-open {
    transform: translate(-50%, -50%) scale(1);
  }

  .panel-header {
    position: sticky;
    top: 0;
    z-index: 1;
    padding-bottom: 4px;
    background: rgba(255, 250, 238, 0.98);
  }

  .close-panel {
    width: 44px;
    height: 44px;
  }

  input,
  select,
  textarea {
    min-height: 48px;
    font-size: 16px;
  }

  textarea {
    min-height: 92px;
  }

  .submit-preview {
    min-height: 52px;
  }
}

@media (min-width: 820px) and (orientation: landscape) {
  .experience {
    padding: 32px;
  }

  .phone-frame {
    width: min(92vw, 1080px);
    height: min(76vh, 680px);
    max-height: none;
    aspect-ratio: auto;
    border-radius: 30px;
  }

  .invite-shell {
    border-radius: 22px;
  }

  .envelope {
    width: min(64%, 650px);
  }

  .invite-card {
    background: var(--shell-bg);
  }

  .art-layer {
    right: 0;
    background-image: url("assets/invitation-light-option3-v3-fast.webp");
    background-size: cover;
    background-position: center 55%;
  }

  .art-layer::after {
    display: none;
  }

  .content-layer {
    display: grid;
    grid-template-columns: 54% 46%;
    grid-template-rows: 1fr auto auto 1fr;
    align-items: center;
    padding: 7% 5% 6%;
  }

  .title-block {
    grid-column: 1;
    grid-row: 1 / -1;
    width: 78%;
    justify-self: center;
    transform: translateY(-24px);
  }

  .kicker {
    margin-bottom: 24px;
    font-size: clamp(0.78rem, 1.25vw, 1rem);
  }

  h1 {
    font-size: clamp(4.6rem, 7.4vw, 6.8rem);
  }

  .date {
    margin-top: 18px;
    font-size: clamp(0.82rem, 1.25vw, 1.02rem);
  }

  .place {
    margin-bottom: 0;
    font-size: clamp(0.76rem, 1.1vw, 0.94rem);
  }

  .details {
    grid-column: 2;
    grid-row: 2;
    width: 88%;
    margin: 0 auto;
  }

  .details div {
    padding: 22px 24px;
  }

  .details strong {
    font-size: 0.9rem;
    line-height: 1.45;
  }

  .rsvp-button {
    grid-column: 2;
    grid-row: 3;
    width: 88%;
    margin: 14px auto 0;
  }

  .rsvp-confirmation {
    grid-column: 2;
    grid-row: 3;
    width: 88%;
    margin: 14px auto 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .envelope,
  .seal::after,
  .magic-dust i,
  body.animated-bg::before,
  body.animated-bg::after {
    animation: none;
  }

  .invite-shell[data-state="opening"] .envelope {
    opacity: 0;
    animation: none;
  }
}

/* The high-resolution envelope artwork includes its own modeled seal. */
.envelope .seal {
  display: none;
}

@media (max-width: 520px) {
  html[data-theme="dark"] .panel-header {
    background: rgba(8, 22, 31, 0.98);
  }
}
