:root {
  color-scheme: light;
  --paper: #f4ebdc;
  --paper-light: #fbf6ec;
  --env-back: #e3d3b6;
  --env-front: #efe3cc;
  --env-flap: #e8d8bb;
  --ink: #3a2a22;
  --ink-soft: #6e5a4c;
  --red: #9e1b22;
  --red-deep: #7a1018;
  --gold: #b8955a;
  --line: rgba(184, 149, 90, 0.45);
  --serif: "Cormorant Garamond", Georgia, serif;
  --caps: "Cinzel", "Trajan Pro", Georgia, serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(1200px 600px at 50% -10%, #fffaf0 0%, transparent 60%),
    radial-gradient(900px 500px at 50% 110%, #ead9bd 0%, transparent 60%),
    var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.5;
}

.page {
  max-width: 460px;
  margin: 0 auto;
  padding: max(28px, env(safe-area-inset-top)) 16px max(40px, env(safe-area-inset-bottom));
}

[hidden] { display: none !important; }

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: rise 0.8s cubic-bezier(.2, .7, .2, 1) both;
}

.stage--msg {
  min-height: 70vh;
  justify-content: center;
  text-align: center;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

.eyebrow {
  font-family: var(--caps);
  font-size: 13px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--red);
  margin: 0 0 18px;
  text-align: center;
}

/* ---------- Envelope ---------- */

#stage-envelope { min-height: 80vh; justify-content: center; }

.envelope {
  position: relative;
  width: min(360px, 100%);
  aspect-ratio: 10 / 7;
  margin-top: 90px; /* room for the card to rise */
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  perspective: 1400px;
  -webkit-tap-highlight-color: transparent;
}

.envelope > span { position: absolute; display: block; }

.env-back {
  inset: 0;
  z-index: 1;
  border-radius: 6px;
  background: var(--env-back);
  box-shadow: 0 18px 40px -18px rgba(70, 40, 20, 0.45), 0 2px 6px rgba(70, 40, 20, 0.12);
}

.env-card {
  z-index: 2;
  left: 7%;
  right: 7%;
  top: 5%;
  height: 92%;
  overflow: hidden;
  border-radius: 3px;
  background: var(--paper-light);
  box-shadow: 0 2px 8px rgba(70, 40, 20, 0.15);
  transition: transform 1s cubic-bezier(.3, .7, .2, 1) 0.7s;
}

.env-card img { width: 100%; display: block; }

.env-front {
  inset: 0;
  z-index: 3;
  border-radius: 6px;
  background: linear-gradient(180deg, var(--env-front), #ead9bd);
  clip-path: polygon(0 0, 50% 54%, 100% 0, 100% 100%, 0 100%);
  display: flex !important;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding-bottom: 5%;
}

.env-to {
  font-family: var(--caps);
  font-size: 11px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.env-name {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(22px, 6.4vw, 28px);
  color: var(--red-deep);
  line-height: 1.2;
  padding: 0 12px;
  text-align: center;
}

.env-flap {
  z-index: 4;
  left: 0;
  right: 0;
  top: 0;
  height: 58%;
  background: linear-gradient(180deg, #efe2c9, var(--env-flap));
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top center;
  transition: transform 0.7s ease-in-out, z-index 0s linear 0.35s;
  filter: drop-shadow(0 3px 3px rgba(70, 40, 20, 0.12));
}

.seal {
  z-index: 5;
  left: 50%;
  top: 58%;
  width: 68px;
  height: 68px;
  margin: -34px 0 0 -34px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #c2333a, var(--red) 55%, var(--red-deep));
  box-shadow: 0 4px 10px rgba(90, 10, 15, 0.4), inset 0 0 0 4px rgba(0, 0, 0, 0.08), inset 0 0 0 7px rgba(255, 255, 255, 0.06);
  display: grid !important;
  place-items: center;
  color: #f3dcae;
  font-family: var(--caps);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 0.04em;
  transition: transform 0.4s ease, opacity 0.4s ease;
  animation: pulse 2.4s ease-in-out infinite;
}

.seal i { font-family: var(--serif); font-style: italic; font-weight: 500; margin: 0 1px; color: #e7c27e; }

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

.envelope.open { cursor: default; }
.envelope.open .seal { opacity: 0; transform: scale(0.6); animation: none; }
.envelope.open .env-flap { transform: rotateX(180deg); z-index: 1; }
.envelope.open .env-card { transform: translateY(-62%); }

.hint {
  margin: 26px 0 0;
  font-style: italic;
  color: var(--ink-soft);
  transition: opacity 0.3s;
}

.envelope.open + .hint { opacity: 0; }

/* ---------- Card ---------- */

.card {
  margin: 0;
  width: 100%;
}

.card img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 20px 40px -20px rgba(70, 40, 20, 0.5);
}

.card--teaser img {
  -webkit-mask-image: linear-gradient(180deg, #000 88%, transparent 100%);
  mask-image: linear-gradient(180deg, #000 88%, transparent 100%);
  box-shadow: none;
}

/* ---------- Panel / form ---------- */

.panel {
  width: 100%;
  margin-top: -8px;
  position: relative;
  padding: 26px 20px 24px;
  background: rgba(251, 246, 236, 0.92);
  border: 1px solid var(--line);
  border-radius: 6px;
  text-align: center;
  box-shadow: 0 10px 30px -18px rgba(70, 40, 20, 0.35);
}

.panel--details { margin-top: 20px; }

.invite-line {
  margin: 0 0 8px;
  font-style: italic;
  color: var(--ink-soft);
}

.panel-title {
  margin: 0 0 6px;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 26px;
  line-height: 1.2;
  color: var(--red-deep);
}

.panel-sub {
  margin: 0 0 18px;
  color: var(--ink-soft);
}

form { text-align: left; }

.field {
  display: block;
  margin-bottom: 14px;
  min-width: 0;
}

.field > span {
  display: block;
  font-family: var(--caps);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 4px;
}

.field em { font-family: var(--serif); text-transform: none; letter-spacing: 0; font-size: 13px; }

.field input {
  width: 100%;
  font: inherit;
  font-size: 18px; /* stops iOS zooming on focus */
  color: var(--ink);
  background: #fffdf8;
  border: 1px solid #dccaa8;
  border-radius: 4px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(184, 149, 90, 0.22);
}

.field input[aria-invalid="true"] { border-color: var(--red); }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-error {
  margin: 0 0 12px;
  color: var(--red);
  font-style: italic;
  text-align: center;
}

.btn {
  display: inline-block;
  width: 100%;
  margin-top: 6px;
  padding: 14px 18px;
  border: 0;
  border-radius: 4px;
  background: var(--red);
  color: #fbefd8;
  font-family: var(--caps);
  font-size: 14px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn:hover { background: var(--red-deep); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.6; cursor: progress; }

.btn--ghost {
  background: transparent;
  color: var(--red-deep);
  border: 1px solid var(--line);
  font-size: 12px;
  letter-spacing: 0.14em;
  padding: 12px 10px;
}

.btn--ghost:hover { background: rgba(184, 149, 90, 0.12); }

/* ---------- Reveal ---------- */

.detail-date {
  margin: 0;
  font-family: var(--caps);
  font-size: clamp(20px, 5.6vw, 24px);
  letter-spacing: 0.08em;
  color: var(--red-deep);
}

.detail-location {
  margin: 8px 0 4px;
  font-size: 21px;
  font-style: italic;
}

.link {
  color: var(--red);
  font-size: 16px;
  text-underline-offset: 3px;
}

.cal {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 20px 0 16px;
}

#thanks-line { margin: 0; font-style: italic; }

.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--red);
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 0.01s !important; transition-delay: 0s !important; }
}

/* ---------- Multiple events ---------- */

.teasers { width: 100%; display: grid; gap: 10px; }
.teasers--2 { grid-template-columns: 1fr 1fr; align-items: start; }
.teasers--2 .card--teaser img { -webkit-mask-image: none; mask-image: none; box-shadow: 0 10px 24px -14px rgba(70, 40, 20, 0.5); }
.teasers:empty + .panel { margin-top: 0; }
.teasers--2 + .panel { margin-top: 18px; }

.reveal-list { width: 100%; display: grid; gap: 36px; }
.event .panel--details { margin-top: 16px; }
.event .card[hidden] + .panel--details { margin-top: 0; }

.thanks {
  margin: 28px 0 0;
  text-align: center;
  font-style: italic;
  color: var(--ink-soft);
}

/* ---------- Language switch ---------- */

.lang-switch {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  right: 12px;
  z-index: 10;
  display: flex;
  background: rgba(251, 246, 236, 0.9);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px;
}

.lang-switch button {
  font: inherit;
  font-size: 14px;
  padding: 3px 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
}

.lang-switch button[aria-pressed="true"] { background: var(--red); color: #fbefd8; }

html[lang="gu"] body { font-family: "Noto Sans Gujarati", var(--serif); }
html[lang="gu"] .eyebrow,
html[lang="gu"] .field > span,
html[lang="gu"] .btn { font-family: "Noto Sans Gujarati", var(--caps); letter-spacing: 0.04em; text-transform: none; }

/* ---------- Calendar countdown ---------- */

#stage-calendar { min-height: 80vh; justify-content: center; }

.cal-card {
  width: min(340px, 100%);
  background: var(--paper-light);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 18px 40px -22px rgba(70, 40, 20, 0.5);
  padding: 14px 14px 16px;
  transform-origin: top center;
  perspective: 800px;
}

.cal-card.flip-out { animation: flip-out 0.2s ease-in forwards; }
.cal-card.flip-in { animation: flip-in 0.26s ease-out; }

@keyframes flip-out { to { transform: rotateX(-80deg); opacity: 0.2; } }
@keyframes flip-in { from { transform: rotateX(80deg); opacity: 0.2; } to { transform: none; opacity: 1; } }

.cal-month {
  text-align: center;
  font-family: var(--caps);
  font-size: 18px;
  letter-spacing: 0.12em;
  color: var(--red-deep);
  margin-bottom: 10px;
}

html[lang="gu"] .cal-month { font-family: "Noto Sans Gujarati", var(--caps); letter-spacing: 0.02em; }

.cal-week,
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  text-align: center;
}

.cal-week span { font-size: 12px; color: var(--ink-soft); padding-bottom: 4px; }

.cal-grid span {
  position: relative;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  font-size: 15px;
  border-radius: 50%;
  color: var(--ink);
  transition: background 0.25s, color 0.25s, transform 0.25s;
}

.cal-grid .past { color: #c9b9a0; }
.cal-grid .today { box-shadow: inset 0 0 0 1.5px var(--gold); }

.cal-grid .holiday::after {
  content: "";
  position: absolute;
  bottom: 3px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--gold);
}

.cal-grid .holiday.lit { background: rgba(184, 149, 90, 0.22); transform: scale(1.08); }

.cal-grid .event { color: var(--red-deep); font-weight: 600; }
.cal-grid .event.lit {
  background: var(--red);
  color: #fbefd8;
  transform: scale(1.12);
  animation: heartbeat 1.1s ease-in-out infinite;
}

@keyframes heartbeat {
  0%, 100% { transform: scale(1.12); }
  50% { transform: scale(1.22); }
}

.cal-notes {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  min-height: 84px;
  text-align: center;
}

.cal-notes li {
  font-size: 17px;
  color: var(--ink-soft);
  animation: rise 0.35s ease both;
}

.cal-notes li.big { font-size: 21px; color: var(--red-deep); font-style: italic; }

.link-btn {
  margin-top: 10px;
  border: 0;
  background: none;
  font: inherit;
  font-size: 15px;
  color: var(--ink-soft);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* ---------- Music toggle ---------- */

.music-btn {
  position: fixed;
  right: 14px;
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 10;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(251, 246, 236, 0.92);
  color: var(--red-deep);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 16px -10px rgba(70, 40, 20, 0.5);
}

.music-btn[aria-pressed="false"] { color: var(--ink-soft); opacity: 0.75; }
