/* ============================================================
   Wedding Invite — styles
   Palette: warm ivory, blush, sage, antique gold
   ============================================================ */

:root {
  --ivory: #f7f2ea;
  --ivory-deep: #efe6d8;
  --blush: #e7c9c3;
  --blush-deep: #c99b93;
  --sage: #9caa8f;
  --gold: #c08a5a;
  --gold-soft: #d8b48a;
  --ink: #4a3f38;
  --ink-soft: #7a6b60;
  --white: #fffdf9;

  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'Jost', -apple-system, BlinkMacSystemFont, sans-serif;

  --shadow-soft: 0 20px 60px -25px rgba(74, 63, 56, 0.45);
  --radius: 22px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(120% 80% at 50% -10%, #fff9f0 0%, var(--ivory) 45%, var(--ivory-deep) 100%);
  overflow: hidden;
  position: relative;
}

/* Falling petals canvas sits behind everything */
#petals {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

/* ---------- Phone stage ---------- */
#stage {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
  height: 100dvh;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
  display: grid;
  /* "safe" keeps content centered when it fits but falls back to top-aligned
     (never clipped) when it's taller than the screen — e.g. iPhone Safari. */
  place-items: safe center;
  /* Scroll vertically if a scene is taller than the viewport; never sideways. */
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/* On wide screens, frame it like a phone on soft paper */
@media (min-width: 620px) {
  #stage {
    height: 92dvh;
    margin-top: 4dvh;
    border-radius: 34px;
    box-shadow: var(--shadow-soft);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0));
    outline: 1px solid rgba(192, 138, 90, 0.18);
  }
}

/* ---------- Scenes ---------- */
.scene {
  grid-area: 1 / 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(14px);
  transition: opacity 0.7s ease, transform 0.7s ease, visibility 0s linear 0.7s;
}
.scene[data-active='true'] {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
  transition: opacity 0.8s ease 0.15s, transform 0.8s ease 0.15s;
}

.eyebrow {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 0.72rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--ink-soft);
  text-align: center;
}

/* ============================================================
   SCENE 1 — Envelope
   ============================================================ */
.envelope {
  position: relative;
  width: 260px;
  height: 176px;
  cursor: pointer;
  filter: drop-shadow(0 18px 30px rgba(74, 63, 56, 0.25));
  transition: transform 0.5s ease;
}
.envelope:active {
  transform: scale(0.98);
}

.envelope__body {
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, #fffaf2, var(--ivory-deep));
  border-radius: 10px;
  border: 1px solid rgba(192, 138, 90, 0.25);
}
/* the diagonal paper lines of an envelope */
.envelope__body::before,
.envelope__body::after {
  content: '';
  position: absolute;
  bottom: 0;
  width: 55%;
  height: 100%;
  background: linear-gradient(120deg, transparent 49.5%, rgba(192, 138, 90, 0.18) 50%, transparent 50.5%);
}
.envelope__body::before { left: 0; }
.envelope__body::after { right: 0; transform: scaleX(-1); }

.envelope__letter {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 6px;
  height: 76%;
  background: linear-gradient(180deg, var(--white), #fff);
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(74, 63, 56, 0.12);
  transition: transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 1;
}

.envelope__flap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 96px;
  background: linear-gradient(160deg, var(--ivory-deep), #e5d8c5);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top;
  transition: transform 0.7s cubic-bezier(0.6, 0, 0.4, 1);
  z-index: 3;
  border-radius: 10px 10px 0 0;
}

.envelope__seal {
  position: absolute;
  top: 64px;
  left: 50%;
  transform: translate(-50%, 0);
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--blush), var(--blush-deep));
  display: grid;
  place-items: center;
  z-index: 4;
  box-shadow: 0 4px 10px rgba(74, 63, 56, 0.3), inset 0 0 0 2px rgba(255, 255, 255, 0.25);
  transition: transform 0.4s ease, opacity 0.4s ease;
}
.envelope__seal-heart {
  font-size: 1.4rem;
  line-height: 1;
  color: #fff;
  opacity: 0.9;
}

/* opened state */
.envelope.is-open .envelope__flap {
  transform: rotateX(180deg);
  z-index: 1;
}
.envelope.is-open .envelope__seal {
  transform: translate(-50%, -14px) scale(0.6);
  opacity: 0;
}
.envelope.is-open .envelope__letter {
  transform: translateY(-150%) scale(1.04);
}

.tap-hint {
  animation: breathe 2.4s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { opacity: 0.5; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-3px); }
}

/* ============================================================
   SCENE 2 — Invitation card
   ============================================================ */
.card {
  width: 100%;
  background: linear-gradient(180deg, var(--white), #fffdfa);
  border: 1px solid rgba(192, 138, 90, 0.2);
  border-radius: var(--radius);
  padding: 30px 26px 32px;
  text-align: center;
  box-shadow: var(--shadow-soft);
  position: relative;
}
.card::before {
  content: '';
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(192, 138, 90, 0.22);
  border-radius: calc(var(--radius) - 8px);
  pointer-events: none;
}

.names {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.02;
  margin: 6px 0 4px;
  color: var(--ink);
}
.names span { display: block; font-size: 2.9rem; }
.names .amp {
  font-style: italic;
  font-size: 1.5rem;
  color: var(--gold);
  margin: 2px 0;
}

/* couple illustration */
.couple {
  position: relative;
  width: 190px;
  height: 190px;
  margin: 16px auto 8px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--white);
  box-shadow: 0 12px 30px -10px rgba(74, 63, 56, 0.4), 0 0 0 1px rgba(192, 138, 90, 0.3);
}
.couple img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top; /* keep faces in frame */
  display: block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.details {
  margin: 20px 0 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.detail { display: flex; flex-direction: column; gap: 3px; }
.detail__label {
  font-size: 0.66rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--gold);
}
.detail__value {
  font-family: var(--font-display);
  font-size: 1.35rem;
  color: var(--ink);
}
.detail__sub { font-size: 0.85rem; color: var(--ink-soft); }
.divider {
  height: 1px;
  width: 60%;
  margin: 0 auto;
  background: linear-gradient(90deg, transparent, rgba(192, 138, 90, 0.4), transparent);
}

.countdown {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 22px 0 24px;
}
.count {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 54px;
  padding: 10px 4px;
  border-radius: 14px;
  background: var(--ivory);
  border: 1px solid rgba(192, 138, 90, 0.18);
}
.count b {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--ink);
}
.count small {
  font-size: 0.58rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: none;
  border-radius: 999px;
  padding: 14px 30px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.btn--primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-soft));
  color: #fff;
  box-shadow: 0 12px 24px -10px rgba(192, 138, 90, 0.8);
}
.btn--primary:active { transform: translateY(1px) scale(0.99); }
.btn--ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid rgba(192, 138, 90, 0.35);
}

/* ============================================================
   SCENE 3 — RSVP steps
   ============================================================ */
.card--form { min-height: 60dvh; display: flex; align-items: stretch; }
.steps { position: relative; width: 100%; display: grid; }
.step {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transform: translateX(20px);
  transition: opacity 0.45s ease, transform 0.45s ease, visibility 0s linear 0.45s;
}
.step[data-active='true'] {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity 0.5s ease 0.05s, transform 0.5s ease 0.05s;
}
.step__q {
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 500;
  color: var(--ink);
  text-align: center;
}
.step__hint { text-align: center; color: var(--ink-soft); font-size: 0.9rem; }

.choice { display: flex; flex-direction: column; gap: 12px; margin-top: 6px; }
.choice__btn {
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 18px;
  border-radius: 16px;
  border: 1px solid rgba(192, 138, 90, 0.3);
  background: var(--ivory);
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s;
}
.choice__btn:active { transform: scale(0.98); }
.choice__btn:not(.choice__btn--soft) {
  background: linear-gradient(135deg, rgba(231, 201, 195, 0.4), rgba(216, 180, 138, 0.3));
  border-color: rgba(192, 138, 90, 0.5);
}
.choice__emoji { font-size: 1.3rem; }

.field { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.field > span {
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}
.field input,
.field textarea {
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--ink);
  background: var(--ivory);
  border: 1px solid rgba(192, 138, 90, 0.28);
  border-radius: 12px;
  padding: 13px 14px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  resize: none;
  width: 100%;
}
.field input:focus,
.field textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(192, 138, 90, 0.12);
}

.stepper {
  display: flex;
  align-items: center;
  gap: 18px;
  align-self: flex-start;
  background: var(--ivory);
  border: 1px solid rgba(192, 138, 90, 0.28);
  border-radius: 12px;
  padding: 6px 10px;
}
.stepper button {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--white);
  color: var(--gold);
  font-size: 1.3rem;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(74, 63, 56, 0.12);
}
.stepper b {
  font-family: var(--font-display);
  font-size: 1.4rem;
  min-width: 22px;
  text-align: center;
}

.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  font-family: var(--font-body);
  font-size: 0.85rem;
  padding: 9px 15px;
  border-radius: 999px;
  border: 1px solid rgba(192, 138, 90, 0.3);
  background: var(--ivory);
  color: var(--ink);
  cursor: pointer;
  transition: all 0.2s ease;
}
.pill.is-selected {
  background: linear-gradient(135deg, var(--gold), var(--gold-soft));
  color: #fff;
  border-color: transparent;
}

/* Event selector (multi-select) */
.events { display: flex; flex-direction: column; gap: 10px; }
.event {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  text-align: left;
  font-family: var(--font-body);
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(192, 138, 90, 0.3);
  background: var(--ivory);
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.15s ease;
}
.event:active { transform: scale(0.99); }
.event__emoji { font-size: 1.35rem; }
.event__name { font-size: 1rem; font-weight: 500; }
.event__date {
  grid-column: 2;
  grid-row: 2;
  font-size: 0.78rem;
  color: var(--ink-soft);
}
.event__check {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1.5px solid rgba(192, 138, 90, 0.4);
  display: grid;
  place-items: center;
  color: transparent;
  font-size: 0.8rem;
  transition: all 0.2s ease;
}
.event.is-selected {
  border-color: var(--gold);
  background: linear-gradient(135deg, rgba(216, 180, 138, 0.28), rgba(231, 201, 195, 0.28));
}
.event.is-selected .event__check {
  background: linear-gradient(135deg, var(--gold), var(--gold-soft));
  border-color: transparent;
  color: #fff;
}

.step__nav { display: flex; gap: 10px; margin-top: 8px; }
.step__nav .btn { flex: 1; padding: 14px; }

.step--done { text-align: center; align-items: center; }
.done__mark {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--sage), #b6c3a8);
  color: #fff;
  font-size: 2rem;
  display: grid;
  place-items: center;
  box-shadow: 0 12px 24px -10px rgba(156, 170, 143, 0.9);
  animation: pop 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes pop {
  0% { transform: scale(0); }
  70% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* ---------- misc ---------- */
.reveal { animation: fadeUp 1s ease both; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.rotate-note {
  position: fixed;
  bottom: 10px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.72rem;
  color: var(--ink-soft);
  letter-spacing: 0.08em;
  z-index: 2;
  opacity: 0.6;
  display: none;
}
@media (min-width: 620px) { .rotate-note { display: block; } }

.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: var(--white);
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 0.85rem;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 10;
}
.toast.is-show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.2s !important; }
}

/* Compact layout for shorter screens so the whole invite (incl. the RSVP
   button) fits without scrolling on most phones. */
@media (max-height: 780px) {
  .scene { gap: 14px; }
  .card { padding: 22px 24px 24px; }
  .names span { font-size: 2.3rem; }
  .couple { width: 132px; height: 132px; margin: 10px auto 4px; }
  .details { margin: 12px 0 4px; gap: 10px; }
  .detail__value { font-size: 1.2rem; }
  .countdown { margin: 14px 0 16px; gap: 8px; }
  .count { min-width: 48px; padding: 8px 4px; }
  .count b { font-size: 1.3rem; }
  .btn { padding: 12px 28px; }
}
