/* ============================================================
   The invitation — shared by "You're Invited" (gifts/invitation) and the
   wedding invitation on the ideas page (ideas/wedding-invitation).
   A sealed envelope; it opens, the card rises out, and turns over.
   Everything on the card is measured in --u, a hundredth of its width.
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
:root {
  --red: #b3262e;
  --red-2: #8e1c25;
  --gold: #d9a441;
  --cream: #f8f1e6;
  --cream-2: #efe4d2;
  --ink: #3b2224;
  --bg: #efe8de;
  --ease: cubic-bezier(0.22, 0.68, 0.16, 1);
  --W: min(330px, 78vw, calc((100svh - 150px) / 1.5));
  --u: calc(var(--W) / 100);
}
body[data-kind="love"] { --bg: #2a1418; }
html, body { margin: 0; height: 100%; }
body {
  min-height: 100svh; overflow: hidden;
  background: radial-gradient(80% 60% at 50% 40%, color-mix(in srgb, var(--bg) 88%, #fff), var(--bg) 70%);
  font-family: "Inter", system-ui, sans-serif; color: var(--ink);
  -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased;
}
body[data-kind="love"] { background: radial-gradient(80% 60% at 50% 42%, #4a1f26, #241014 72%); color: #f6ede4; }
button { font: inherit; color: inherit; }

.petals { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 30; }

/* ---------------- the stage ---------------- */
.stage { position: fixed; inset: 0; display: grid; place-items: center; padding-bottom: 70px; perspective: 1500px; }
.pair { position: relative; width: calc(var(--u) * 106); height: calc(var(--u) * 140); }

/* the envelope */
.env {
  position: absolute; left: 0; right: 0; top: calc(var(--u) * 10); height: calc(var(--u) * 130);
  transform-style: preserve-3d;
  transition: transform 1s var(--ease), opacity 0.8s ease;
  animation: envIn 1.1s var(--ease) backwards;   /* not "both": a held animation would pin it in place when it should drop away */
}
/* two layers with the card between them: the back of the envelope, and its
   pocket and flap in front */
.env--back { z-index: 1; filter: drop-shadow(0 calc(var(--u) * 4) calc(var(--u) * 6) rgba(40, 10, 10, 0.28)); }
.env--front { z-index: 3; cursor: pointer; }
.env--front:focus-visible { outline: 2px solid var(--gold); outline-offset: 8px; border-radius: 6px; }
@keyframes envIn { from { opacity: 0; transform: translateY(30px) rotate(-3deg); } to { opacity: 1; transform: none; } }
.env svg { position: absolute; display: block; }
.env__back, .env__pocket { left: 0; top: 0; width: 100%; height: 100%; }
.env__back { z-index: 1; }
.env__pocket { z-index: 3; pointer-events: none; }
.env__flap {
  left: 0; top: 0; width: 100%; height: calc(var(--u) * 54); z-index: 4;
  transform-origin: 50% 0; transition: transform 0.65s var(--ease);
}
.env__seal {
  position: absolute; left: 50%; top: calc(var(--u) * 52); z-index: 5; width: calc(var(--u) * 20); height: calc(var(--u) * 20);
  transform: translate(-50%, -50%); transition: opacity 0.3s ease, transform 0.4s var(--ease);
  filter: drop-shadow(0 2px 3px rgba(60, 10, 10, 0.35));
}
.env__for {
  position: absolute; left: 0; right: 0; top: calc(var(--u) * 84); z-index: 4; margin: 0; text-align: center; pointer-events: none;
  font-family: "Kalam", "Caveat", cursive; font-weight: 700; font-size: calc(var(--u) * 8); color: var(--env-ink, #fbe9c8);
  transition: opacity 0.4s ease;
}
/* The flap lifts in front of the card, then — once it's up — the same flap
   is shown on the back layer instead, so the card can rise in front of it. */
.env--back .env__flap { transform: rotateX(180deg); opacity: 0; }
.is-opening .env--back .env__flap { opacity: 1; transition: opacity 0s 0.62s; }
.is-opening .env--front .env__flap { transform: rotateX(180deg); visibility: hidden; transition: transform 0.65s var(--ease), visibility 0s 0.62s; }
.is-rising .card { transition-delay: 0.45s; }
/* once it's up, the flap belongs behind the card: it moves to the back layer's height */
.is-opening .env--front { pointer-events: none; }
.is-opening .env__seal { opacity: 0; transform: translate(-50%, -50%) scale(1.4); }
.is-opening .env__for { opacity: 0; }
.is-out .env { transform: translateY(85vh) rotate(4deg); opacity: 0; pointer-events: none; }

/* the card, inside it to begin with */
.card {
  position: absolute; left: 3%; top: 0; width: calc(var(--u) * 100); height: calc(var(--u) * 140);
  /* card is between the envelope's two layers */
  z-index: 2; transform: translateY(calc(var(--u) * 14)) scale(0.88); transform-origin: 50% 50%;
  transition: transform 1s var(--ease); cursor: pointer; outline: none;
  pointer-events: none;
  visibility: hidden;          /* sealed: nothing of it shows through the envelope */
}
.is-opening .card { visibility: visible; }
.is-rising .card { transform: translateY(calc(var(--u) * -64)) scale(0.88); }
.is-out .card { z-index: 6; transform: none; pointer-events: auto; transition-duration: 1.1s; }
.card:focus-visible .face { outline: 2px solid var(--gold); outline-offset: 6px; }

/* ---------------- the card is a folded paper room ----------------
   .cam sits at the card's centre and is turned by invite.js; the walls hinge
   on a shared upright edge through it (the spine), each carrying half the
   floor. Closed, the walls' outsides are the card's front and back. */
.card { perspective: calc(var(--u) * 640); }
.cam { position: absolute; left: 50%; top: 50%; width: 0; height: 0; transform-style: preserve-3d; }
.wall {
  position: absolute; top: calc(var(--u) * -140); width: calc(var(--u) * 100); height: calc(var(--u) * 140);
  transform-style: preserve-3d;
}
.wall--r { left: 0; transform-origin: 0 100%; transform: rotateY(-89deg); }
.wall--l { left: calc(var(--u) * -100); transform-origin: 100% 100%; transform: rotateY(89deg); }
.wall > .in, .wall > .face, .tri { -webkit-backface-visibility: hidden; backface-visibility: hidden; }
.wall > .in { position: absolute; inset: 0; clip-path: polygon(0 21.43%, 50% 0, 100% 21.43%, 100% 100%, 0 100%); }
.wall > .in > svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.wall > .face { position: absolute; inset: 0; transform: rotateY(180deg); }
.flr { position: absolute; left: 0; top: 100%; width: 100%; height: calc(var(--u) * 100); transform-origin: 50% 0; transform: rotateX(179deg); transform-style: preserve-3d; }
.tri { position: absolute; inset: 0; overflow: hidden; }
.wall--r .tri { clip-path: polygon(0 0, 100% 0, 100% 100%); }
.wall--l .tri { clip-path: polygon(0 0, 100% 0, 0 100%); }
.tri > svg { position: absolute; left: 0; top: 0; width: calc(var(--u) * 100); height: calc(var(--u) * 100); display: block; }
.wall--l .tri > svg { transform-origin: 0 0; transform: translateX(calc(var(--u) * 100)) rotate(90deg); }
/* the cut-outs: each stands on its foot, facing the open side of the room */
.prop { position: absolute; transform-origin: 50% 100%; pointer-events: none; }
.prop > svg { display: block; width: 100%; height: 100%; overflow: visible; }
.pshadow {
  position: absolute; left: calc(var(--u) * -85); top: calc(var(--u) * -85); width: calc(var(--u) * 170); height: calc(var(--u) * 170);
  transform: translate3d(0, calc(var(--u) * 0.6), calc(var(--u) * 70.7)) rotateY(45deg) rotateX(90deg);
  background: radial-gradient(closest-side, rgba(60, 20, 20, 0.32), rgba(60, 20, 20, 0.12) 60%, transparent);
  opacity: 0; pointer-events: none;
}
body[data-kind="love"] .pshadow { background: radial-gradient(closest-side, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.2) 60%, transparent); }
/* what the room is for, written on the board on its right-hand wall */
.sign {
  position: absolute; left: 18%; top: 44.29%; width: 64%; height: 32.86%; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  padding: 0 calc(var(--u) * 3); font-family: "Kalam", cursive; color: var(--red);
}
.sign b { font-weight: 700; font-size: calc(var(--u) * 7.4); line-height: 1.05; overflow-wrap: anywhere; }
.sign span { font-size: calc(var(--u) * 3.9); line-height: 1.3; margin-top: calc(var(--u) * 1.4); color: var(--ink); overflow-wrap: anywhere; }
.sign span + span { margin-top: 0; }
.sign--chalk, .sign--chalk span { color: #f6efe2; }
.sign--wood { color: #5a2a14; } .sign--wood span { color: #4a2a1a; }
.sign--marquee { color: #ffd98a; } .sign--marquee span { color: #f6e6d0; }
.is-room .card { cursor: pointer; }
/* the room in three.js (js/invite-3d.js): a canvas over the page that takes
   the card's place while it's open, and hands it back when it's shut */
.room3d { position: fixed; left: 0; top: 0; z-index: 15; pointer-events: none; visibility: hidden; }
.room3d.is-on { visibility: visible; }
.card.is-3d .cam { visibility: hidden; }
.is-room .stage { cursor: grab; }
.face > svg.shape { position: absolute; inset: 0; width: 100%; height: 100%; display: block; filter: drop-shadow(0 calc(var(--u) * 3) calc(var(--u) * 5) rgba(40, 10, 10, 0.3)); }
.garland { position: absolute; left: 6%; right: 6%; top: calc(var(--u) * 27); height: calc(var(--u) * 26); transform-origin: 50% 0; animation: sway 4.6s ease-in-out infinite; }
.garland svg { width: 100%; height: 100%; display: block; overflow: visible; }
@keyframes sway { 0%, 100% { transform: rotate(-1.4deg); } 50% { transform: rotate(1.4deg); } }

/* what's written on it */
.text {
  position: absolute; left: 13%; right: 13%; top: calc(var(--u) * 44); bottom: calc(var(--u) * 16);
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  color: var(--red); overflow: hidden;
}
.text p { margin: 0; overflow-wrap: anywhere; }
.t-kicker { font-family: "Caveat", cursive; font-size: calc(var(--u) * 6.2); line-height: 1.1; color: var(--red-2); }
.t-name { font-family: "Kalam", "Caveat", cursive; font-weight: 700; font-size: calc(var(--u) * 13); line-height: 1.05; white-space: nowrap; margin-top: calc(var(--u) * 1.5) !important; }
.t-amp { font-family: "Kalam", cursive; font-size: calc(var(--u) * 7); line-height: 1; margin: calc(var(--u) * 1) 0 !important; }
.t-small { font-family: "Caveat", cursive; font-size: calc(var(--u) * 6); margin-top: calc(var(--u) * 2) !important; color: var(--red-2); }
.t-what { font-family: "Kalam", cursive; font-weight: 700; font-size: calc(var(--u) * 8); line-height: 1.15; }
.t-meta { margin-top: calc(var(--u) * 4.5) !important; font-family: "Kalam", cursive; font-size: calc(var(--u) * 4.4); line-height: 1.35; color: var(--ink); opacity: 0.85; }
.t-note { font-family: "Kalam", cursive; font-size: var(--fs, calc(var(--u) * 6)); line-height: 1.4; color: var(--ink); white-space: pre-line; }
.t-from { align-self: flex-end; margin-top: calc(var(--u) * 3) !important; font-family: "Kalam", cursive; font-weight: 700; font-size: calc(var(--u) * 6); }
.t-events { width: 100%; list-style: none; margin: calc(var(--u) * 3) 0 0; padding: 0; font-family: "Kalam", cursive; font-size: var(--fs, calc(var(--u) * 4.8)); color: var(--ink); }
.t-events li { display: flex; align-items: baseline; gap: calc(var(--u) * 1.5); padding: calc(var(--u) * 1.1) 0; }
.t-events b { color: var(--red); font-weight: 700; white-space: nowrap; }
.t-events i { flex: 1; border-bottom: 1.5px dotted rgba(179, 38, 46, 0.4); transform: translateY(-0.3em); min-width: 1em; }
.t-events span { text-align: right; }
.t-guests { margin-top: calc(var(--u) * 3.5) !important; font-family: "Caveat", cursive; font-size: calc(var(--u) * 5.6); color: var(--red-2); }

.rsvp { display: flex; gap: calc(var(--u) * 2.4); margin-top: calc(var(--u) * 5); }
.rsvp button {
  padding: calc(var(--u) * 2) calc(var(--u) * 4.4); border-radius: 999px; cursor: pointer;
  font-family: "Kalam", cursive; font-weight: 700; font-size: calc(var(--u) * 4.6);
  border: 1.5px solid var(--red); background: transparent; color: var(--red);
  transition: background 0.2s, color 0.2s, transform 0.2s var(--ease);
}
.rsvp button:first-child, .rsvp button:hover { background: var(--red); color: var(--cream); }
.rsvp button:active { transform: scale(0.95); }
.rsvp-done { margin-top: calc(var(--u) * 4) !important; font-family: "Kalam", cursive; font-weight: 700; font-size: calc(var(--u) * 5.4); color: var(--red); }
.rsvp-done button { margin-left: calc(var(--u) * 1.5); border: 0; background: none; color: var(--red-2); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font: inherit; font-size: 0.85em; }

/* ---------------- the strip ---------------- */
.hint {
  position: fixed; left: 0; right: 0; bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 16; margin: 0; text-align: center; pointer-events: none;
  font-size: 12px; letter-spacing: 0.2em; text-transform: uppercase; opacity: 0.6;
}
.bar {
  position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20;
  display: flex; gap: 8px; padding: 7px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.55); border: 1px solid rgba(120, 40, 40, 0.15);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: 0 10px 26px rgba(60, 20, 20, 0.15);
}
body[data-kind="love"] .bar { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.15); }
.bar button {
  white-space: nowrap;
  height: 44px; padding: 0 18px; border-radius: 999px; border: 0; cursor: pointer; font-size: 14px; font-weight: 500;
  background: var(--red); color: #fff4e8;
}
.bar button.ghost { background: transparent; color: inherit; border: 1px solid currentColor; opacity: 0.8; }
.bar button[hidden] { display: none; }

.fab {
  position: fixed; top: max(14px, env(safe-area-inset-top)); right: 14px; z-index: 25;
  padding: 10px 16px; border-radius: 999px; cursor: pointer; font-size: 13px;
  background: rgba(255, 255, 255, 0.6); border: 1px solid rgba(120, 40, 40, 0.2); backdrop-filter: blur(10px);
}
body[data-kind="love"] .fab { background: rgba(0, 0, 0, 0.3); border-color: rgba(255, 255, 255, 0.2); }
.fab[hidden] { display: none; }
.home { position: fixed; top: max(14px, env(safe-area-inset-top)); left: 14px; z-index: 25; font-size: 13px; color: inherit; opacity: 0.7; text-decoration: none; padding: 10px 4px; }

/* ---------------- editor + share ---------------- */
.ed, .share {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  padding: 16px; overflow-y: auto; background: rgba(30, 10, 12, 0.55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.ed[hidden], .share[hidden] { display: none; }
.ed__box {
  position: relative; width: min(500px, 100%); margin: auto; padding: 26px 22px 22px; border-radius: 22px;
  background: #fbf6ee; color: #3b2224; box-shadow: 0 30px 80px rgba(30, 5, 5, 0.4);
}
.ed__x { position: absolute; top: 14px; right: 14px; width: 36px; height: 36px; border-radius: 50%; border: 1px solid rgba(60, 20, 20, 0.15); background: none; cursor: pointer; }
.ed__kicker { margin: 0; font-size: 11px; letter-spacing: 0.26em; text-transform: uppercase; color: var(--red); }
.ed__title { margin: 6px 0 0; font-family: "Kalam", cursive; font-weight: 700; font-size: 30px; line-height: 1.15; color: var(--red); }
.ed__sub { margin: 6px 0 16px; font-size: 14px; line-height: 1.55; color: #7a5a56; }
.ed__field { display: block; margin-bottom: 12px; }
.ed__field > span { display: block; margin-bottom: 6px; font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: #8a6a64; }
.ed__field small { display: block; margin-top: 4px; font-size: 12px; color: #9a7a74; }
.ed__field input, .ed__field textarea {
  width: 100%; padding: 10px 12px; border-radius: 12px; border: 1px solid #e2d2c2; background: #fff;
  font: inherit; font-size: 16px; color: #3b2224; outline: none;
}
.ed__field textarea { resize: vertical; min-height: 84px; line-height: 1.45; }
.ed__field input:focus, .ed__field textarea:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(179, 38, 46, 0.12); }
.ed__note { min-height: 1.3em; margin: 0 0 8px; font-size: 13px; color: var(--red); }
.ed__actions { display: flex; flex-wrap: wrap; gap: 10px; }
.ed__btn {
  flex: 1 1 140px; min-height: 46px; padding: 0 18px; border-radius: 999px; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
  background: var(--red); color: #fff4e8; font-weight: 600; font-size: 15px;
}
.ed__btn.ghost { background: transparent; color: var(--red); border: 1.5px solid var(--red); }
.ed__btn[hidden] { display: none; }
.share__link { width: 100%; margin: 0 0 12px; padding: 10px 12px; border-radius: 12px; border: 1px solid #e2d2c2; background: #fff; font: 13px ui-monospace, Menlo, monospace; color: var(--red-2); }

.broken { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; padding: 28px; text-align: center; background: var(--bg); }
.broken[hidden] { display: none; }
.broken div { max-width: 30em; }
.broken h2 { margin: 0 0 12px; font-family: "Kalam", cursive; font-size: clamp(22px, 5vw, 30px); color: var(--red); }
.broken p { margin: 0; line-height: 1.7; opacity: 0.75; }

@media (prefers-reduced-motion: reduce) {
  .env, .card, .card__in, .env__flap, .garland { transition-duration: 0.01s !important; animation: none !important; }
}
