:root {
  --linen: #e7e2d8;
  --paper: #ffffff;
  --ink: #3a3532;
  --muted: #6f6862;
  --blush: #e8b4b8;
  --peach: #efd0b0;
  --sage: #8a9a7b;
  --navy: #2c3a4a;
  --line: #d8d2c8;
  --env-paper: #f4efe6;
  --env-flap: #ebe4d6;
  --shadow: 0 12px 36px rgba(44, 40, 36, 0.1);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body.page {
  font-family: "Vazirmatn", sans-serif;
  color: var(--ink);
  background-color: var(--linen);
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 3px, rgba(60, 50, 40, 0.02) 4px),
    repeating-linear-gradient(90deg, transparent, transparent 3px, rgba(60, 50, 40, 0.018) 4px);
  overflow-x: hidden;
}

.page--simple {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.simple-card {
  width: min(420px, 100%);
  background: var(--paper);
  border-radius: 14px;
  padding: 40px 28px;
  text-align: center;
  box-shadow: var(--shadow);
}

.simple-card h1 {
  margin: 0 0 12px;
  font-size: 1.35rem;
  font-weight: 500;
}

.simple-card p {
  margin: 0;
  color: var(--muted);
  line-height: 2;
}

.ornament {
  color: var(--sage);
  margin: 0 0 8px;
}

.gate {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.gate.is-gone {
  position: absolute;
  inset: auto;
  height: 0;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
}

.envelope {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  width: min(360px, 90vw);
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.envelope__stack {
  position: relative;
  display: block;
  width: 100%;
  height: 230px;
  filter: drop-shadow(0 14px 24px rgba(44, 40, 36, 0.16));
}

.envelope__letter {
  position: absolute;
  left: 10%;
  right: 10%;
  top: -14px;
  height: 72px;
  border-radius: 4px 4px 0 0;
  background: #fff;
  z-index: 1;
}

.envelope__body {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 3px 3px 8px 8px;
  background-color: var(--env-paper);
  background-image:
    linear-gradient(180deg, rgba(255, 255, 255, 0.35), transparent 40%),
    repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(80, 70, 50, 0.03) 3px);
  z-index: 2;
}

.envelope__liner {
  position: absolute;
  inset: 0 0 auto;
  height: 46%;
  background: linear-gradient(180deg, #f3d6d0, #c9b8a4);
  opacity: 0.35;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}

.envelope__names {
  justify-content: center;
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 22px;
  z-index: 3;
  display: flex;
  /* flex-direction: column; */
  align-items: center;
  gap: 2px;
}

.envelope__pair {
  font-weight: 500;
  font-size: clamp(1.2rem, 5vw, 1.45rem);
  color: var(--ink);
  line-height: 1.35;
  margin-right: 6px;
  margin-left: 6px;
}

.envelope__and {
  color: var(--muted);
  font-size: 1rem;
}

.envelope__flap {
  position: absolute;
  inset: 0 0 auto;
  height: 48%;
  background: linear-gradient(180deg, #f7f3ea, var(--env-flap) 60%, #ddd4c4);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  z-index: 4;
  transform-origin: top center;
  transition: transform 600ms ease, opacity 600ms ease;
}

.envelope__flap::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 46%;
  background: linear-gradient(180deg, transparent, rgba(70, 60, 50, 0.1));
}

.envelope__seal {
  position: absolute;
  top: 38%;
  left: 50%;
  width: 46px;
  height: 46px;
  margin-left: -23px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 32% 28%, #c9a3a6, #7a4a52 70%, #4a3034);
  color: #f7f1ea;
  font-size: 1.1rem;
  z-index: 5;
  box-shadow: 0 3px 0 #4a3034, 0 6px 10px rgba(74, 48, 52, 0.22);
}

.envelope__cta {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  padding: 0 20px;
  border-radius: 10px;
  background: var(--navy);
  color: #f7f3ee;
  font-weight: 500;
  font-size: 0.95rem;
}

body.is-opening .envelope__flap {
  transform: translateY(-22%) scaleY(0.12);
  opacity: 0;
}

body.is-opening .envelope__seal {
  transform: translateY(-10px) scale(0.7);
  opacity: 0;
  transition: transform 500ms ease, opacity 500ms ease;
}

body.is-opening .envelope__letter {
  transform: translateY(-10px);
  transition: transform 500ms ease;
}

body.is-opening .envelope {
  transform: scale(0.94);
  opacity: 0;
  transition: transform 700ms 700ms ease, opacity 700ms 700ms ease;
}

.burst {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.petal {
  position: absolute;
  top: 48%;
  right: 50%;
  width: 12px;
  height: 16px;
  border-radius: 70% 12% 70% 12%;
  background: var(--blush);
  opacity: 0;
  animation: petal-burst 1000ms ease forwards;
  animation-delay: var(--delay, 0ms);
}

.petal:nth-child(3n) { background: var(--sage); }
.petal:nth-child(3n + 1) { background: var(--peach); }
.petal:nth-child(3n + 2) { background: var(--navy); }

@keyframes petal-burst {
  0% {
    opacity: 1;
    transform: translate3d(0, 0, 0) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--x, 0), -42vh, 0) rotate(var(--rot, 20deg));
  }
}

.stage {
  position: relative;
  width: min(560px, 100%);
  margin: 0 auto;
  padding: 56px 12px 64px;
}

.flora {
  position: absolute;
  width: 168px;
  height: 168px;
  pointer-events: none;
  z-index: 0;
  opacity: 0;
}

body.is-open .flora {
  opacity: 0.95;
  transition: opacity 700ms ease;
}

.flora__svg {
  width: 100%;
  height: 100%;
  display: block;
}

.flora--tl { top: 8px; right: 4px; }
.flora--tr { top: 18px; left: 0; transform: scaleX(-1) rotate(8deg); }
.flora--bl { bottom: 24px; right: 0; transform: rotate(198deg); }
.flora--br { bottom: 10px; left: 6px; transform: scaleX(-1) rotate(-200deg); }
.flora--l { top: 42%; right: -18px; transform: rotate(-18deg) scale(0.86); }
.flora--r { top: 40%; left: -16px; transform: scaleX(-1) rotate(16deg) scale(0.86); }

.card {
  position: relative;
  z-index: 1;
  width: min(400px, calc(100% - 36px));
  margin: 36px auto;
  padding: 48px 28px 40px;
  background: var(--paper);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.card section {
  text-align: center;
}

.card h1,
.card p {
  margin: 0;
}

.card__names {
  margin-bottom: 18px;
}

.card__name {
  display: block;
  font-size: clamp(2.1rem, 8vw, 2.7rem);
  font-weight: 400;
  line-height: 1.35;
  color: var(--ink);
}

.card__amp {
  display: inline-block;
  margin: 2px 0 6px;
  color: var(--muted);
  font-size: 1.35rem;
  font-weight: 400;
}

.card__invite {
  padding: 0 8px 22px;
  border-bottom: 1px solid var(--line);
}

.card__kicker {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  line-height: 2.1;
}

.card__label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  margin-bottom: 8px;
}

.card__guest,
.card__when,
.card__where,
.card__rsvp {
  margin-top: 26px;
}

.card__guest-name,
.card__date {
  font-size: 1rem;
  font-weight: 500;
  line-height: 2;
}

.card__venue {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.9;
}

.card__address {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 2;
  margin-top: 4px;
}

.maps {
  margin-top: 20px;
}

.maps__row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

.map-btn {
  width: 52px;
  height: 52px;
  min-width: 52px;
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 0;
  text-decoration: none;
  border: 0;
}

.map-btn__logo {
  width: 30px;
  height: 30px;
  display: block;
}

.map-btn--google {
  background: #fff;
  box-shadow: inset 0 0 0 1px #e4dfd6;
}

.map-btn--balad { background: #0f8a7a; }
.map-btn--neshan { background: #e31c23; }

.countdown {
  margin-top: 22px;
}

.countdown__row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.countdown__cell {
  padding: 10px 4px 8px;
  border: 1px solid var(--line);
  background: #faf8f4;
  border-radius: 10px;
}

.countdown__cell strong {
  display: block;
  font-size: 1.25rem;
  font-weight: 500;
  line-height: 1.4;
}

.countdown__cell span {
  display: block;
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
}

.countdown__ended {
  color: var(--muted);
  margin-top: 8px;
}

.is-hidden {
  display: none;
}

.card__hint {
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 14px;
}

.form-error {
  color: #8a3038;
  margin-bottom: 10px;
}

.count-picks {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.choice {
  cursor: pointer;
  display: block;
}

.choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  border-radius: 10px;
  background: #fff;
  padding: 0 12px;
  text-align: center;
  border: 1px solid var(--line);
  font-weight: 500;
}

.choice input:checked + span {
  border-color: var(--navy);
  background: #f4f1ec;
  color: var(--navy);
}

.count-field {
  display: grid;
  gap: 8px;
  text-align: right;
  margin-bottom: 14px;
  font-size: 0.9rem;
}

.count-field.is-hidden {
  display: none;
}

.count-field select {
  font: inherit;
  min-height: 46px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 0 12px;
}

.submit-btn {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 10px;
  background: var(--navy);
  color: #f7f3ee;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}

.rsvp-done {
  padding: 8px 0 0;
  color: var(--ink);
  line-height: 2;
}

.rsvp-done__thanks {
  font-weight: 500;
}

.rsvp-done__answer {
  margin-top: 6px;
  color: var(--muted);
}

.card .reveal {
  opacity: 0;
  transform: translateY(16px);
}

body.is-open .card .reveal {
  animation: rise 700ms ease forwards;
}

body.is-open .card .reveal:nth-child(1) { animation-delay: 0ms; }
body.is-open .card .reveal:nth-child(2) { animation-delay: 140ms; }
body.is-open .card .reveal:nth-child(3) { animation-delay: 280ms; }
body.is-open .card .reveal:nth-child(4) { animation-delay: 420ms; }
body.is-open .card .reveal:nth-child(5) { animation-delay: 560ms; }
body.is-open .card .reveal:nth-child(6) { animation-delay: 700ms; }

@keyframes rise {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 640px) {
  .flora--l,
  .flora--r {
    display: none;
  }

  .flora {
    width: 120px;
    height: 120px;
  }

  body.is-open .flora {
    opacity: 0.85;
  }

  .stage {
    padding: 36px 8px 48px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .envelope__flap,
  .envelope,
  .envelope__seal,
  .envelope__letter,
  .card .reveal,
  .flora {
    transition: none !important;
    animation: none !important;
  }

  body.is-open .card .reveal {
    opacity: 1;
    transform: none;
  }
}
