/* ==========================================================================
   Modal — Confirmação de presença (RSVP)
   ========================================================================== */
#rsvp-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(7, 22, 13, 0.72);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s var(--ease-soft);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

#rsvp-backdrop.modal-active {
  opacity: 1;
  pointer-events: auto;
}

.rsvp-modal {
  width: 100%;
  max-width: 440px;
  max-height: min(88vh, 720px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: linear-gradient(180deg, #faf7ec, var(--cream));
  border-radius: 24px 24px 0 0;
  padding: 26px 22px calc(28px + var(--sab));
  color: var(--forest-deep);
  transform: translateY(100%);
  opacity: 1;
  transition: transform 0.5s var(--ease-magic), opacity 0.4s ease;
  box-shadow: 0 -10px 40px rgba(0,0,0,0.4);
  border-top: 1px solid rgba(217,184,63,0.5);
}

@media (min-width: 480px) {
  .rsvp-modal {
    border-radius: 24px;
    margin-bottom: 5vh;
  }
}

#rsvp-backdrop.modal-active .rsvp-modal {
  transform: translateY(0);
}

.rsvp-close {
  position: absolute;
  top: 14px;
  right: 18px;
  font-size: 22px;
  color: var(--leaf-green);
  line-height: 1;
  padding: 6px;
}

.rsvp-handle {
  width: 42px;
  height: 4px;
  border-radius: 4px;
  background: rgba(77, 110, 37, 0.3);
  margin: 0 auto 18px;
}

.rsvp-heading {
  font-family: var(--font-display);
  font-size: 23px;
  font-weight: 700;
  text-align: center;
  color: var(--forest);
  margin-bottom: 6px;
}

.rsvp-sub {
  text-align: center;
  font-size: 14px;
  color: var(--leaf-green);
  margin-bottom: 14px;
}

.rsvp-deadline {
  display: block;
  text-align: center;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--forest);
  background: rgba(217, 184, 63, 0.18);
  border: 1px solid rgba(217, 184, 63, 0.5);
  border-radius: 999px;
  padding: 6px 14px;
  width: fit-content;
  margin: 0 auto 20px;
}

.field-group {
  margin-bottom: 18px;
}

.field-group label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--emerald);
  margin-bottom: 8px;
  letter-spacing: 0.01em;
}

.field-group input,
.field-group select {
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1.5px solid rgba(77, 110, 37, 0.25);
  background: var(--white);
  font-size: 16px;
  color: var(--forest-deep);
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
  min-height: 50px;
  appearance: none;
  -webkit-appearance: none;
}

.field-group select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%234D6E25'><path d='M7 10l5 5 5-5z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 20px;
}

.field-group input:focus,
.field-group select:focus {
  outline: none;
  border-color: var(--emerald);
  box-shadow: 0 0 0 3px rgba(37, 144, 97, 0.18);
}

.field-error {
  display: none;
  font-size: 12.5px;
  color: #a4442c;
  margin-top: 6px;
  padding-left: 2px;
}

.field-group.has-error input,
.field-group.has-error select {
  border-color: #c25a3f;
}

.field-group.has-error .field-error {
  display: block;
}

.names-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  animation: fade-in-up 0.4s var(--ease-magic) forwards;
}

.name-row .name-input {
  flex: 1 1 auto;
}

.name-remove {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #a4442c;
  font-size: 16px;
  background: rgba(164, 68, 44, 0.1);
}

.name-remove:active {
  transform: scale(0.92);
}

.add-person-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px;
  margin-top: 14px;
  margin-bottom: 18px;
  border-radius: 12px;
  border: 1.5px dashed rgba(37, 144, 97, 0.45);
  color: var(--emerald);
  font-weight: 700;
  font-size: 14.5px;
  min-height: 48px;
}

.add-person-btn:active {
  transform: scale(0.98);
  background: rgba(37, 144, 97, 0.08);
}

.add-person-icon {
  font-size: 18px;
  line-height: 1;
  font-weight: 700;
}

.rsvp-submit {
  width: 100%;
  margin-top: 6px;
  padding: 16px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--emerald), var(--forest) 75%);
  color: var(--cream);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 8px 20px rgba(37,144,97,0.4);
  position: relative;
}

.rsvp-submit:active {
  transform: scale(0.98);
}

.rsvp-submit[disabled] {
  opacity: 0.85;
  pointer-events: none;
}

.btn-spinner {
  display: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid rgba(245,242,228,0.35);
  border-top-color: var(--cream);
  animation: spinner-rotate 0.7s linear infinite;
}

.rsvp-submit.loading .btn-spinner {
  display: inline-block;
}

.rsvp-submit.loading .btn-label {
  opacity: 0.7;
}

/* --- Estado de sucesso --- */
.rsvp-success {
  text-align: center;
  padding: 18px 6px 6px;
}

/* Envelope de conclusão — reaproveita o visual do envelope de abertura
   (mesmas classes .envelope-wrap/.envelope-body/.envelope-flap/.wax-seal),
   já FECHADO e selado (nunca recebe a classe .opening), para dar a
   sensação de que a carta foi guardada e o convite se encerrou. O texto
   final aparece abaixo dele. */
.rsvp-envelope-wrap.envelope-wrap {
  width: 190px;
  margin: 6px auto 22px;
  opacity: 0;
  transform: scale(0.85);
}

#step-success.step-active .rsvp-envelope-wrap {
  animation: soft-appear 0.6s var(--ease-magic) forwards;
}

#step-success.step-active .rsvp-envelope-wrap .wax-seal {
  animation:
    seal-stamp 0.6s var(--ease-magic) 0.45s both,
    gentle-pulse 2.4s ease-in-out 1.1s infinite;
}

@keyframes seal-stamp {
  0% { transform: translate(-50%, -50%) scale(0) rotate(-20deg); opacity: 0; }
  55% { transform: translate(-50%, -50%) scale(1.25) rotate(4deg); opacity: 1; }
  75% { transform: translate(-50%, -50%) scale(0.92) rotate(-2deg); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1) rotate(0deg); opacity: 1; }
}

.rsvp-success-text {
  opacity: 0;
}

.rsvp-success-text.reveal {
  animation: fade-in-up 0.6s var(--ease-magic) forwards;
}

.rsvp-success h3 {
  font-family: var(--font-display);
  font-size: 24px;
  color: var(--forest);
  margin-bottom: 10px;
}

.rsvp-success p {
  font-size: 15px;
  color: var(--leaf-green);
  line-height: 1.5;
  max-width: 320px;
  margin: 0 auto;
}

.rsvp-success-close {
  margin-top: 24px;
  display: inline-block;
  padding: 12px 26px;
  border-radius: 999px;
  border: 1.5px solid rgba(37,144,97,0.4);
  color: var(--emerald);
  font-weight: 700;
  font-size: 14px;
}

.step {
  display: none;
}

.step.step-active {
  display: block;
  animation: fade-in-up 0.5s var(--ease-magic) forwards;
}
