/* Zateemee Bride — "Write to Us": a wedding-invitation card that slips out of its envelope.
 * Ivory card stock, a double gold rule, a script title, and RSVP-style lines to write on. */
.invite {
  --card: #fffaf3;
  --gold: #b88a49;
  --gold-soft: rgba(195, 154, 85, 0.55);
  --ink: #2a2522;
  --muted: #8a7d73;
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: max(14px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom));
  font-family: "DM Sans", Arial, sans-serif;
  color: var(--ink);
}
.invite[hidden] { display: none; }
.invite-veil {
  position: absolute;
  inset: 0;
  background: radial-gradient(90% 90% at 50% 40%, rgba(255, 248, 242, 0.82), rgba(240, 214, 205, 0.9));
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 0.6s ease;
}
.invite.is-open .invite-veil { opacity: 1; }
.invite-stage { position: relative; width: min(580px, 100%); }

/* ---------- the envelope: it opens, then sinks away as the card rises ---------- */
.invite-envelope {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  width: min(520px, 92vw);
  aspect-ratio: 1.5;
  transform: translate(-50%, -40%) scale(0.92);
  background: linear-gradient(160deg, #f6e3da, #efd2c6);
  box-shadow: 0 30px 70px -30px rgba(150, 80, 60, 0.45), inset 0 0 0 1px rgba(195, 154, 85, 0.35);
  opacity: 0;
  pointer-events: none;
  perspective: 900px;
}
.invite-envelope::after {                       /* the front pocket's folds */
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to top right, rgba(255, 255, 255, 0) 49.6%, rgba(195, 154, 85, 0.35) 50%, rgba(255, 255, 255, 0) 50.4%) left bottom / 50% 100% no-repeat,
    linear-gradient(to top left, rgba(255, 255, 255, 0) 49.6%, rgba(195, 154, 85, 0.35) 50%, rgba(255, 255, 255, 0) 50.4%) right bottom / 50% 100% no-repeat;
}
.invite-flap {
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 58%;
  background: linear-gradient(180deg, #f3d8cc, #ecc9bb);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top center;
  z-index: 1;
}
.invite-seal {
  position: absolute;
  left: 50%;
  top: 58%;
  z-index: 2;
  width: 58px; height: 58px;
  margin: -29px 0 0 -29px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 35% 30%, #d9b877, #a87a3c);
  box-shadow: 0 4px 10px rgba(120, 70, 30, 0.35), inset 0 0 0 3px rgba(255, 236, 200, 0.35);
  font: 30px/1 "Pinyon Script", "Snell Roundhand", cursive;
  color: #fff7ea;
}
.invite.is-open .invite-envelope { animation: envIn 1.9s cubic-bezier(0.3, 0.7, 0.3, 1) forwards; }
.invite.is-open .invite-flap { animation: flapOpen 0.7s ease-in-out 0.45s forwards; }
.invite.is-open .invite-seal { animation: sealOff 0.4s ease 0.3s forwards; }
@keyframes envIn {
  0%   { opacity: 0; transform: translate(-50%, -30%) scale(0.86); }
  22%  { opacity: 1; transform: translate(-50%, -40%) scale(0.94); }
  55%  { opacity: 1; transform: translate(-50%, -40%) scale(0.94); }
  100% { opacity: 0; transform: translate(-50%, 30%) scale(0.98); }
}
@keyframes flapOpen { to { transform: rotateX(180deg); filter: brightness(1.06); } }
@keyframes sealOff { to { opacity: 0; transform: scale(0.6); } }

/* ---------- the card ---------- */
.invite-card {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  max-height: calc(100svh - 28px);
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0) 60%),
    radial-gradient(90% 60% at 50% 100%, rgba(246, 228, 214, 0.6), rgba(246, 228, 214, 0) 70%),
    var(--card);
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(195, 154, 85, 0.35), 0 50px 100px -40px rgba(150, 80, 60, 0.5);
  opacity: 0;
  transform: translateY(70px) scale(0.94);
}
.invite-card::before, .invite-card::after {     /* the double gold rule of an invitation */
  content: "";
  position: absolute;
  pointer-events: none;
  border: 1px solid var(--gold-soft);
}
.invite-card::before { inset: 12px; }
.invite-card::after { inset: 17px; border-color: rgba(195, 154, 85, 0.25); }
.invite.is-open .invite-card { animation: cardOut 1.2s cubic-bezier(0.16, 0.84, 0.3, 1) 0.85s forwards; }
@keyframes cardOut { to { opacity: 1; transform: none; } }
.invite.is-closing .invite-card { animation: none; opacity: 0; transform: translateY(24px) scale(0.97); transition: opacity 0.45s ease, transform 0.5s ease; }
.invite.is-closing .invite-veil { opacity: 0; }
.invite.is-closing .invite-envelope { animation: none; opacity: 0; }

.invite-inner {
  position: relative;
  z-index: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: clamp(34px, 6vw, 50px) clamp(30px, 7vw, 58px) clamp(30px, 5vw, 42px);
  text-align: center;
  scrollbar-width: thin;
}
.invite-close {
  position: absolute;
  top: 22px; right: 24px;
  z-index: 2;
  width: 34px; height: 34px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}
.invite-close:hover, .invite-close:focus-visible { color: var(--ink); background: rgba(195, 154, 85, 0.12); outline: none; }

.invite-mono {
  width: 58px; height: 58px;
  margin: 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px var(--gold), 0 0 0 4px var(--card), 0 0 0 5px rgba(195, 154, 85, 0.35);
  font: 32px/1 "Pinyon Script", "Snell Roundhand", cursive;
  color: var(--gold);
}
.invite-kicker {
  margin: 18px 0 0;
  font-family: "Italiana", "Didot", Georgia, serif;
  font-size: 12px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--muted);
}
.invite-title {
  margin: 6px 0 0;
  font: 400 clamp(46px, 9vw, 64px)/1.05 "Pinyon Script", "Snell Roundhand", cursive;
  color: var(--gold);
}
.invite-lede {
  margin: 4px 0 0;
  font-family: "Italiana", "Didot", Georgia, serif;
  font-size: 16px;
  letter-spacing: 0.06em;
  color: #5d544d;
}
.invite-flourish { display: block; width: 160px; height: 14px; margin: 16px auto 8px; fill: none; stroke: var(--gold); stroke-width: 1; }
.invite-flourish circle { fill: var(--gold); stroke: none; }

/* RSVP lines to write on */
.invite-form { display: grid; gap: 16px; margin-top: 10px; text-align: center; }
.invite-form[hidden] { display: none; }
.invite-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 22px; }
.invite-field { display: grid; gap: 4px; }
.invite-field > span {
  font-size: 10px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--muted);
}
.invite-field input, .invite-field select, .invite-field textarea {
  width: 100%;
  min-width: 0;
  border: 0;
  border-bottom: 1px solid var(--gold-soft);
  border-radius: 0;
  background: transparent;
  padding: 7px 4px 8px;
  font: 16px/1.4 "DM Sans", Arial, sans-serif;     /* 16px: phones do not zoom in */
  color: var(--ink);
  text-align: center;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
  -webkit-appearance: none;
  appearance: none;
}
.invite-field select {
  text-align-last: center;
  cursor: pointer;
  background: linear-gradient(45deg, transparent 50%, var(--gold) 50%) calc(100% - 12px) 55% / 5px 5px no-repeat,
              linear-gradient(-45deg, transparent 50%, var(--gold) 50%) calc(100% - 7px) 55% / 5px 5px no-repeat;
  padding-right: 22px;
}
.invite-field input[type="date"] { min-height: 40px; }
.invite-field textarea { resize: vertical; min-height: 92px; text-align: left; border: 1px solid rgba(195, 154, 85, 0.35); padding: 10px 12px; }
.invite-field input:focus, .invite-field select:focus, .invite-field textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 1px 0 0 var(--gold); }
.invite-field [aria-invalid="true"] { border-color: #c0566a; }
.invite-error { margin: -4px 0 0; font-size: 12px; letter-spacing: 0.06em; color: #b04a5e; }
.invite-error[hidden] { display: none; }
.invite-send {
  justify-self: center;
  margin-top: 6px;
  padding: 15px 38px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #d6b273, #b88a49);
  box-shadow: 0 10px 24px -10px rgba(150, 100, 40, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  font: 500 11px/1 "DM Sans", Arial, sans-serif;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: #fff;
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease, filter 0.3s ease;
}
.invite-send:hover, .invite-send:focus-visible { transform: translateY(-1px); filter: brightness(1.05); box-shadow: 0 14px 28px -10px rgba(150, 100, 40, 0.7); outline: none; }
.invite-small { margin: 0; font-size: 11px; line-height: 1.6; color: var(--muted); }

.invite-thanks { margin-top: 18px; }
.invite-thanks[hidden] { display: none; }
.invite-thanks-title { margin: 0; font: 400 40px/1.1 "Pinyon Script", "Snell Roundhand", cursive; color: var(--gold); }
.invite-thanks p:not(.invite-thanks-title) { margin: 12px auto 22px; max-width: 34ch; font-size: 15px; line-height: 1.7; color: #4c443e; }

@media (max-width: 560px) {
  .invite-row { grid-template-columns: 1fr; }
  .invite-card::before { inset: 8px; }
  .invite-card::after { inset: 12px; }
}
@media (max-height: 520px) {                    /* a phone held sideways: a compact card, two fields to a line */
  .invite-inner { padding: 24px 34px 22px; }
  .invite-mono { display: none; }
  .invite-kicker { margin-top: 0; font-size: 10px; }
  .invite-title { font-size: 38px; }
  .invite-lede { font-size: 14px; }
  .invite-flourish { margin: 8px auto 2px; }
  .invite-form { grid-template-columns: 1fr 1fr; gap: 10px 22px; }
  .invite-row, .invite-field--topic, .invite-field--note, .invite-error, .invite-send, .invite-small { grid-column: 1 / -1; }
  .invite-field textarea { min-height: 60px; }
}
@media (prefers-reduced-motion: reduce) {
  .invite.is-open .invite-envelope { animation: none; opacity: 0; }
  .invite.is-open .invite-card { animation: none; opacity: 1; transform: none; }
}
