*, *::before, *::after { box-sizing: border-box; }

:root { --bg: #161012; --bg-2: #221a1c; --text: #f1e8da; --muted: rgba(241,232,218,.66); --gold: #c9a35a; --gold-2: #e6c88a; }
body[data-theme="tower"] {
  --bg: #2a0f14; --bg-2: #4a1520; --text: #f3e7d3; --muted: rgba(243,231,211,.68); --gold: #d1a659; --gold-2: #ecd18f;
  --env: #ecdfc6; --env-dark: #d9c8a8; --env-line: #c9a66a; --seal: #7c1c28; --seal-ink: #ecd18f; --env-ink: #4a1520;
  --paper: #f6eedf; --ink: #3a1118; --ink-muted: rgba(58,17,24,.62); --accent: #7c1c28;
}
body[data-theme="evergreen"] {
  --bg: #0e2a1b; --bg-2: #1c5a37; --text: #f1e9d8; --muted: rgba(241,233,216,.68); --gold: #f2c14e; --gold-2: #ffd96b;
  --env: #1f6b3f; --env-dark: #17552f; --env-line: #ffd34d; --seal: #d62839; --seal-ink: #f1d9a0; --env-ink: #f1e9d8;
  --paper: #fffaf0; --ink: #14532d; --ink-muted: rgba(20,83,45,.62); --accent: #d62839;
}
body[data-theme="joyful"] {
  --bg: #16302a; --bg-2: #24574a; --text: #fbf4e6; --muted: rgba(251,244,230,.7); --gold: #f2a8c4; --gold-2: #ffd1e1;
  --env: #fbf4e6; --env-dark: #eadfc8; --env-line: #e2457a; --seal: #d8352f; --seal-ink: #fbf4e6; --env-ink: #1f3a32;
  --paper: #fbf4e6; --ink: #1f3a32; --ink-muted: rgba(31,58,50,.62); --accent: #d42a72;
}
body[data-theme="midnight"] {
  --bg: #060a14; --bg-2: #141e36; --text: #efe8da; --muted: rgba(239,232,218,.66); --gold: #d0ab5c; --gold-2: #ecd29a;
  --env: #172036; --env-dark: #10182a; --env-line: #d0ab5c; --seal: #c9a24f; --seal-ink: #0d1424; --env-ink: #efe8da;
  --paper: #f3ecdd; --ink: #0d1424; --ink-muted: rgba(13,20,36,.62); --accent: #0d1424;
}

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  color: var(--text);
  background: radial-gradient(120% 80% at 50% 0%, var(--bg-2) 0%, var(--bg) 62%) fixed, var(--bg);
  font-family: "Cormorant Garamond", Georgia, serif; font-size: 19px; line-height: 1.5;
  overflow-x: hidden;
}
body::before { /* grain */
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .5; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .12 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
main { position: relative; z-index: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }
/* Nothing shows until the card design is known (avoids a flash of the wrong colors) */
body:not([data-theme]) main, body:not([data-theme]) .particles { display: none; }

/* ---------- Ambient particles ---------- */
.particles { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.particles i { position: absolute; display: block; border-radius: 50%; }
body[data-theme="tower"] .particles i { bottom: -10px; border: 1px solid var(--gold-2); opacity: 0; animation: p-rise linear infinite; }
body[data-theme="evergreen"] .particles i { top: -10px; background: #fff; opacity: 0; animation: p-fall linear infinite; }
body[data-theme="joyful"] .particles i { background: var(--gold-2); opacity: 0; animation: p-twinkle ease-in-out infinite; }
body[data-theme="midnight"] .particles i { background: var(--gold-2); opacity: 0; animation: p-twinkle ease-in-out infinite; }
@keyframes p-rise { 0% { transform: translate(0,0); opacity: 0; } 10% { opacity: .55; } 100% { transform: translate(14px,-105vh); opacity: 0; } }
@keyframes p-fall { 0% { transform: translate(0,0); opacity: 0; } 10% { opacity: .7; } 100% { transform: translate(-30px,105vh); opacity: .2; } }
@keyframes p-twinkle { 0%,100% { opacity: 0; transform: scale(.5); } 50% { opacity: .9; transform: scale(1); } }

/* ---------- Envelope stage ---------- */
.stage {
  min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px 16px 40px; gap: 34px; transition: opacity .6s ease, transform .6s ease;
}
.stage.is-leaving { opacity: 0; transform: translateY(30px) scale(.96); }
.envelope {
  position: relative; width: min(88vw, 440px); aspect-ratio: 1.46; border: 0; padding: 0; background: none; cursor: pointer;
  perspective: 1400px; filter: drop-shadow(0 30px 40px rgba(0,0,0,.45)); animation: env-in 1s cubic-bezier(.2,.8,.2,1) both;
  -webkit-tap-highlight-color: transparent; color: inherit; font: inherit;
}
.envelope:focus-visible { outline: 2px solid var(--gold); outline-offset: 10px; }
.envelope:not(.is-open):hover { animation: env-wiggle .9s ease-in-out; }
@keyframes env-in { from { opacity: 0; transform: translateY(40px) rotate(-3deg); } to { opacity: 1; transform: none; } }
@keyframes env-wiggle { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-1.4deg); } 75% { transform: rotate(1.4deg); } }
.envelope > span { position: absolute; display: block; }
.envelope__back { inset: 0; background: var(--env-dark); border-radius: 4px; }
.envelope__card {
  left: 6%; right: 6%; top: 5%; height: 92%; background: var(--paper); border-radius: 2px;
  transition: transform .9s cubic-bezier(.3,.7,.2,1) .45s; z-index: 1; overflow: hidden;
  box-shadow: 0 0 0 1px rgba(0,0,0,.04);
}
.envelope__card::before { content: ""; position: absolute; inset: 7%; border: 1px solid var(--gold); }
.envelope__card::after { content: "✦"; position: absolute; left: 0; right: 0; top: 16%; text-align: center; color: var(--gold); font-size: 22px; }
.envelope__pocket {
  inset: 0; z-index: 2; border-radius: 4px; background: var(--env);
  clip-path: polygon(0 0, 50% 54%, 100% 0, 100% 100%, 0 100%);
}
.envelope__pocket::before { /* side folds */
  content: ""; position: absolute; inset: 0; background: linear-gradient(to top right, transparent 49.6%, rgba(0,0,0,.07) 50%, transparent 50.4%), linear-gradient(to top left, transparent 49.6%, rgba(0,0,0,.07) 50%, transparent 50.4%);
}
.envelope__flap {
  left: 0; right: 0; top: 0; height: 60%; z-index: 3; transform-origin: top center;
  background: linear-gradient(to bottom, var(--env), color-mix(in srgb, var(--env) 88%, #000));
  clip-path: polygon(0 0, 100% 0, 50% 100%); transition: transform .7s cubic-bezier(.4,0,.2,1), z-index 0s .35s;
}
.envelope__flap::after { /* liner */
  content: ""; position: absolute; inset: 4% 7% 14%; clip-path: polygon(0 0, 100% 0, 50% 100%);
  background: repeating-linear-gradient(45deg, var(--env-line) 0 2px, transparent 2px 9px); opacity: .35;
}
.envelope__seal {
  z-index: 4; left: 50%; top: 60%; width: 68px; height: 68px; margin: -34px 0 0 -34px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--seal) 70%, #fff) 0%, var(--seal) 45%, color-mix(in srgb, var(--seal) 70%, #000) 100%);
  box-shadow: 0 3px 6px rgba(0,0,0,.35), inset 0 0 0 5px color-mix(in srgb, var(--seal) 85%, #000);
  display: grid !important; place-items: center; color: var(--seal-ink); transition: opacity .3s, transform .4s;
  font-family: "Bodoni Moda", serif; font-style: italic; font-size: 21px; letter-spacing: .02em;
}
.envelope__seal span i { font-family: "Pinyon Script", cursive; font-style: normal; font-size: 24px; margin: 0 2px; line-height: 0; }
.envelope__to {
  z-index: 4; left: 0; right: 0; bottom: 9%; text-align: center; color: var(--env-ink);
  font-family: "Pinyon Script", cursive; font-size: clamp(22px, 6.4vw, 30px); line-height: 1.1; padding: 0 12%;
}
.envelope.is-open .envelope__flap { transform: rotateX(180deg); z-index: 0; }
.envelope.is-open .envelope__seal { opacity: 0; transform: scale(.6); }
.envelope.is-open .envelope__card { transform: translateY(-62%); }
.envelope.is-open { animation: none; }
.stage__hint {
  margin: 0; font-family: "Bodoni Moda", serif; font-size: 12px; letter-spacing: .5em; text-transform: uppercase; color: var(--muted);
  animation: pulse 2.4s ease-in-out infinite; padding-left: .5em;
}
@keyframes pulse { 0%,100% { opacity: .45; } 50% { opacity: 1; } }

/* ---------- Opened invitation ---------- */
.opened {
  max-width: 1120px; margin: 0 auto; padding: 40px 16px 120px;
  display: grid; gap: 48px; grid-template-columns: 1fr; justify-items: center;
}
.opened__card { width: min(100%, 460px); animation: card-in 1.1s cubic-bezier(.2,.8,.2,1) both; }
@keyframes card-in { from { opacity: 0; transform: translateY(60px) rotate(-2deg) scale(.94); } to { opacity: 1; transform: none; } }
.opened__side { width: min(100%, 520px); animation: rise-in .9s cubic-bezier(.2,.8,.2,1) .35s both; }
@keyframes rise-in { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }

/* Desktop: everything on one screen */
@media (min-width: 960px) {
  .opened {
    min-height: 100vh; min-height: 100dvh; padding: 48px 32px;
    grid-template-columns: auto minmax(0, 500px); justify-content: center; align-items: center; column-gap: 80px;
  }
  .opened__card { width: min(460px, calc((100dvh - 96px) * 5 / 7)); }
  .details .detail { padding: 18px 0; }
}

/* RSVP call to action / response summary */
.cta { margin-top: 32px; }
.cta__by { margin: 0 0 14px; color: var(--muted); font-style: italic; text-align: center; }
.cta .btn { background: var(--gold); color: var(--bg); }
.cta .btn:hover { background: var(--gold-2); }
.cta__done { display: flex; align-items: center; gap: 16px; padding: 18px 20px; border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent); }
.cta__done .big { font-family: "Pinyon Script", cursive; font-size: 34px; line-height: 1; color: var(--gold-2); }
.cta__done div { flex: 1; min-width: 0; }
.cta__done p { margin: 2px 0 0; color: var(--muted); font-size: 17px; }
.cta__done button { background: none; border: 0; color: var(--gold-2); font: inherit; font-size: 16px; cursor: pointer; border-bottom: 1px solid color-mix(in srgb, var(--gold-2) 45%, transparent); padding: 2px 0; }

/* Mobile floating RSVP button */
.fab {
  position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 5;
  padding: 17px; border: 0; background: var(--gold); color: var(--bg); cursor: pointer;
  font-family: "Bodoni Moda", serif; font-size: 13px; letter-spacing: .4em; text-transform: uppercase;
  box-shadow: 0 14px 30px -10px rgba(0,0,0,.6); animation: rise-in .6s cubic-bezier(.2,.8,.2,1) 1s both;
}
@media (min-width: 960px) { .fab { display: none !important; } }

/* RSVP sheet: bottom sheet on phones, centered dialog on desktop */
.sheet { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.55); backdrop-filter: blur(3px); animation: fade-in .25s ease both; }
.sheet__panel {
  position: relative; width: 100%; max-width: 520px; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  animation: sheet-up .4s cubic-bezier(.2,.8,.2,1) both;
}
.sheet__close {
  position: absolute; top: 16px; right: 18px; z-index: 2; width: 40px; height: 40px; border: 0; background: none;
  font-size: 30px; line-height: 1; color: var(--ink-muted); cursor: pointer;
}
.sheet__close:hover { color: var(--ink); }
@media (min-width: 640px) {
  .sheet { align-items: center; padding: 24px; }
  .sheet__panel { animation-name: pop-in; }
}
@keyframes fade-in { from { opacity: 0; } }
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes pop-in { from { opacity: 0; transform: translateY(20px) scale(.97); } }
body.sheet-open { overflow: hidden; }

.eyebrow { display: block; font-family: "Bodoni Moda", serif; font-size: 11px; letter-spacing: .42em; text-transform: uppercase; color: var(--gold); }

/* Details */
.details { display: grid; gap: 0; }
.detail { display: grid; grid-template-columns: 92px 1fr; gap: 16px; padding: 22px 0; border-top: 1px solid color-mix(in srgb, var(--gold) 40%, transparent); }
.detail:last-child { border-bottom: 1px solid color-mix(in srgb, var(--gold) 40%, transparent); }
.detail .eyebrow { padding-top: 7px; }
.detail h3 { margin: 0; font-family: "Bodoni Moda", serif; font-weight: 500; font-size: 22px; line-height: 1.25; }
.detail p { margin: 2px 0 0; color: var(--muted); font-size: 19px; }
.detail ul { margin: 0; padding: 0; list-style: none; }
.detail li { font-size: 20px; }
.detail li + li { margin-top: 2px; }
.links { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 10px; }
.links a { color: var(--gold-2); font-size: 16px; letter-spacing: .04em; text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--gold-2) 45%, transparent); padding-bottom: 1px; }
.links a:hover { border-color: var(--gold-2); }

/* RSVP reply card */
.rsvp, .thanks {
  background: var(--paper); color: var(--ink); padding: 44px clamp(22px, 6vw, 48px) 40px; position: relative;
}
.rsvp::before, .thanks::before { content: ""; position: absolute; inset: 10px; border: 1px solid var(--gold); pointer-events: none; }
.rsvp__head { text-align: center; margin-bottom: 26px; }
.rsvp__head .eyebrow { color: var(--accent); }
.rsvp__head h2, .thanks h2 { font-family: "Bodoni Moda", serif; font-style: italic; font-weight: 500; font-size: clamp(32px, 7vw, 40px); line-height: 1.1; margin: 10px 0 6px; }
.rsvp__head p { margin: 0; color: var(--ink-muted); font-style: italic; }

.choices { border: 0; padding: 0; margin: 0 0 22px; display: grid; gap: 10px; }
.choice { position: relative; display: block; cursor: pointer; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 15px 18px;
  border: 1px solid color-mix(in srgb, var(--ink) 22%, transparent); transition: background .2s, border-color .2s, color .2s;
}
.choice b { font-family: "Bodoni Moda", serif; font-weight: 500; font-size: 19px; flex: 1; text-align: left; }
.choice em { font-size: 17px; white-space: nowrap; color: var(--ink-muted); }
.choice:hover span { border-color: var(--ink); }
.choice input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 2px; }
.choice input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.choice input:checked + span em { color: color-mix(in srgb, var(--paper) 70%, transparent); }
.choice input:checked + span::before { content: "✦"; color: var(--gold-2); }

.field { margin: 0 0 22px; }
.field label { display: block; font-family: "Bodoni Moda", serif; font-size: 11px; letter-spacing: .3em; text-transform: uppercase; margin-bottom: 9px; }
.field label span { letter-spacing: .1em; text-transform: none; font-family: "Cormorant Garamond", serif; font-style: italic; font-size: 15px; color: var(--ink-muted); }
.field input, .field textarea {
  width: 100%; font: inherit; font-size: 19px; color: var(--ink); background: color-mix(in srgb, var(--paper) 70%, #fff);
  border: 1px solid color-mix(in srgb, var(--ink) 22%, transparent); padding: 12px 14px; border-radius: 0; resize: vertical;
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 35%, transparent); }
.field textarea::placeholder { color: var(--ink-muted); font-style: italic; }

.stepper { display: inline-flex; align-items: center; border: 1px solid color-mix(in srgb, var(--ink) 22%, transparent); }
.stepper button { width: 52px; height: 52px; border: 0; background: none; font-size: 26px; color: var(--ink); cursor: pointer; font-family: "Bodoni Moda", serif; }
.stepper button:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.stepper button:disabled { opacity: .25; cursor: default; background: none; }
.stepper output { min-width: 56px; text-align: center; font-family: "Bodoni Moda", serif; font-size: 26px; }

.btn {
  display: block; width: 100%; padding: 18px; border: 0; cursor: pointer; background: var(--ink); color: var(--paper);
  font-family: "Bodoni Moda", serif; font-size: 13px; letter-spacing: .4em; text-transform: uppercase; transition: transform .15s, box-shadow .2s;
}
.btn:hover { box-shadow: 0 10px 22px -10px rgba(0,0,0,.5); transform: translateY(-1px); }
.btn:disabled { opacity: .6; cursor: progress; transform: none; }
.btn--ghost { background: none; color: var(--ink); border: 1px solid color-mix(in srgb, var(--ink) 30%, transparent); }
.form-error { color: #a3242f; margin: 0 0 12px; min-height: 0; font-style: italic; text-align: center; }
.form-error:empty { display: none; }

.thanks { text-align: center; }
.thanks .big { font-family: "Pinyon Script", cursive; font-size: clamp(44px, 12vw, 60px); line-height: 1; color: var(--accent); margin: 6px 0 4px; }
.thanks p { margin: 0 0 8px; font-size: 20px; }
.thanks .summary { margin: 22px 0 26px; padding: 16px 0; border-top: 1px solid color-mix(in srgb, var(--ink) 15%, transparent); border-bottom: 1px solid color-mix(in srgb, var(--ink) 15%, transparent); color: var(--ink-muted); font-style: italic; }

/* Public landing (no code / bad code) */
.stage--landing { gap: 40px; padding-top: 48px; padding-bottom: 48px; }
.stage--landing .envelope { width: min(72vw, 340px); cursor: default; pointer-events: none; animation: env-in 1s cubic-bezier(.2,.8,.2,1) both, float 6s ease-in-out 1s infinite; }
.stage--landing .stage__hint { display: none; }
@keyframes float { 0%,100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-8px) rotate(1deg); } }
.landing { text-align: center; max-width: 440px; animation: rise-in .9s cubic-bezier(.2,.8,.2,1) .3s both; }
.landing h1 { font-family: "Bodoni Moda", serif; font-style: italic; font-weight: 500; font-size: clamp(32px, 8vw, 44px); line-height: 1.05; margin: 12px 0 14px; }
.landing > p { margin: 0 auto; color: var(--muted); font-size: 20px; line-height: 1.45; max-width: 380px; }
.lookup { margin-top: 30px; padding-top: 26px; border-top: 1px solid color-mix(in srgb, var(--gold) 35%, transparent); }
.lookup label { display: block; font-family: "Bodoni Moda", serif; font-size: 11px; letter-spacing: .32em; text-transform: uppercase; color: var(--gold); margin-bottom: 12px; padding-left: .32em; }
.lookup__row { display: flex; border: 1px solid color-mix(in srgb, var(--gold) 55%, transparent); }
.lookup__row input { flex: 1; min-width: 0; background: transparent; border: 0; color: var(--text); font: inherit; font-size: 18px; padding: 13px 14px; }
.lookup__row input::placeholder { color: var(--muted); font-style: italic; }
.lookup__row input:focus { outline: none; background: rgba(255,255,255,.04); }
.lookup__row button { border: 0; background: var(--gold); color: var(--bg); font-family: "Bodoni Moda", serif; font-size: 11px; letter-spacing: .24em; text-transform: uppercase; padding: 0 16px; cursor: pointer; white-space: nowrap; }
.lookup__row button:hover { background: var(--gold-2); }
.lookup__row button:disabled { opacity: .6; cursor: progress; }
.lookup__msg { margin: 12px 0 0; font-style: italic; color: var(--muted); font-size: 17px; }
.lookup__msg:empty { display: none; }
.lookup__done { animation: rise-in .6s cubic-bezier(.2,.8,.2,1) both; outline: none; }
.lookup__done svg { width: 44px; height: 33px; fill: none; stroke: var(--gold); stroke-width: 1.5; stroke-linejoin: round; }
.lookup__done h2 { font-family: "Bodoni Moda", serif; font-style: italic; font-weight: 500; font-size: 28px; margin: 12px 0 8px; }
.lookup__done p { margin: 0 auto; color: var(--muted); font-size: 19px; line-height: 1.45; max-width: 360px; }
.lookup__done b { color: var(--text); font-weight: 500; word-break: break-all; }
.lookup__again { margin-top: 16px; background: none; border: 0; padding: 4px 0; color: var(--gold-2); font: inherit; font-size: 16px; cursor: pointer; border-bottom: 1px solid color-mix(in srgb, var(--gold-2) 45%, transparent); }
.lookup__again:hover { border-color: var(--gold-2); }

/* Notice (no / bad link) */
.notice { max-width: 520px; margin: 0 auto; padding: 0 16px 96px; text-align: center; color: var(--muted); }
.notice h2 { font-family: "Bodoni Moda", serif; font-style: italic; font-weight: 500; color: var(--text); font-size: 28px; margin: 0 0 8px; }

/* Confetti */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 30; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 8px; height: 14px; animation: confetti 2.8s cubic-bezier(.2,.6,.4,1) forwards; }
/* Raindrops for a decline */
.confetti i.drop {
  top: -30px; width: 9px; height: 13px; background: linear-gradient(to bottom, #b9c7d6, #7f93a8);
  border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%; clip-path: polygon(50% 0, 100% 62%, 100% 100%, 0 100%, 0 62%);
  border-radius: 0 0 50% 50%; opacity: .75; animation: drop-fall ease-in forwards;
}
@keyframes drop-fall { 0% { translate: 0 0; opacity: 0; } 10% { opacity: .8; } 90% { opacity: .6; } 100% { translate: 0 110vh; opacity: 0; } }
@keyframes confetti { to { transform: translate(var(--dx), 110vh) rotate(var(--r)); opacity: .9; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .particles, .confetti { display: none; }
}
