: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 { animation: card-out 1.5s cubic-bezier(.3, .7, .2, 1) 0.6s forwards; }

/* The card slides out of the pocket, then comes to the front and unfolds to its full height.
   --h0/--h1/--rise/--settle are set in px by openEnvelope() from the image's real size. */
@keyframes card-out {
  0% { transform: translateY(0); height: var(--h0); z-index: 2; }
  45% { transform: translateY(var(--rise)); height: var(--h0); z-index: 2; }
  46% { z-index: 6; }
  100% { transform: translateY(var(--settle)); height: var(--h1); z-index: 6;
         box-shadow: 0 14px 34px -10px rgba(70, 40, 20, 0.45); }
}

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

.envelope.open + .hint { opacity: 0; }
#stage-envelope:has(.envelope.open) .eyebrow { opacity: 0; transition: opacity 0.4s; }

/* ---------- 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 (tear-off pad) ---------- */

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

.tear {
  width: min(240px, 72vw);
  margin-top: 6px;
  filter: drop-shadow(0 18px 28px rgba(70, 40, 20, 0.28));
}

.tear-top {
  position: relative;
  height: 30px;
  background: var(--red-deep);
  border-radius: 10px 10px 0 0;
}

.tear-top i {
  position: absolute;
  top: -9px;
  width: 10px;
  height: 22px;
  border-radius: 6px;
  background: linear-gradient(#e6d3ad, var(--gold));
  left: 30%;
}

.tear-top i + i { left: auto; right: 30%; }

.tear-pad {
  position: relative;
  /* Edges of the pages still underneath */
  box-shadow: 0 3px 0 -1px #efe5d2, 0 6px 0 -2px #e6dac4;
  border-radius: 0 0 8px 8px;
}

.tear-page {
  position: relative;
  background: var(--paper-light);
  border-radius: 0 0 8px 8px;
  padding: 16px 12px 18px;
  text-align: center;
  backface-visibility: hidden;
}

.tear-month {
  font-family: var(--caps);
  font-size: 14px;
  letter-spacing: 0.14em;
  color: var(--red-deep);
}

.tear-day {
  font-family: var(--caps);
  font-size: 92px;
  line-height: 1.05;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.tear-weekday { font-size: 18px; font-style: italic; color: var(--ink-soft); }

.tear-tag {
  min-height: 26px;
  margin-top: 6px;
  font-size: 18px;
  color: var(--gold);
}

html[lang="gu"] .tear-month,
html[lang="gu"] .tear-day { font-family: "Noto Sans Gujarati", var(--caps); letter-spacing: 0.02em; }
html[lang="gu"] .tear-weekday,
html[lang="gu"] .tear-tag { font-family: "Noto Sans Gujarati", var(--serif); font-style: normal; }

.tear-page.is-holiday .tear-day { color: var(--gold); }
.tear-page.is-holiday .tear-tag { animation: rise 0.3s ease both; }

.tear-page.is-event .tear-day { color: var(--red); animation: heartbeat-day 1.1s ease-in-out infinite; }
.tear-page.is-event .tear-tag { color: var(--red-deep); font-size: 21px; font-style: italic; animation: rise 0.35s ease both; }

/* The torn copy sits on top of the real page and flies up and away. */
.tear-page.torn {
  position: absolute;
  inset: 0;
  transform-origin: 50% 0;
  animation: tear-away ease-in forwards;
  pointer-events: none;
}

.tear-page.torn .tear-day { animation: none; }

@keyframes tear-away {
  0% { transform: none; opacity: 1; }
  25% { transform: rotate(calc(var(--spin) * 0.4)) translateY(-4px); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(18px, -90px) rotate(var(--spin)) rotateX(55deg); opacity: 0; }
}

@keyframes heartbeat-day {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.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; }

/* ---------- Event themes ---------- */

.event-art:empty { display: none; }
.event-art { display: flex; justify-content: center; margin: 2px 0 10px; color: var(--red-deep); }
.event-art svg { max-width: 100%; height: auto; }

.event-title {
  margin: -6px 0 8px;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(30px, 8.6vw, 38px);
  line-height: 1.1;
  color: var(--red-deep);
}

.event-tagline {
  margin: 0 auto 18px;
  max-width: 30ch;
  font-style: italic;
  font-size: 18px;
  line-height: 1.4;
  color: var(--ink-soft);
}

.detail-time {
  display: inline-block;
  margin: 10px 0 2px;
  padding: 5px 12px;
  border-radius: 4px;
  font-family: var(--caps);
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

/* Field day: finish-line checker band, scoreboard time chip. */
.event--field-day .panel { padding-top: 34px; overflow: hidden; }
.event--field-day .panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 12px;
  background: repeating-conic-gradient(var(--red-deep) 0 25%, var(--paper-light) 0 50%) 0 0 / 12px 12px;
}
.event--field-day .event-title { font-family: var(--caps); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; font-size: clamp(26px, 7.4vw, 32px); }
.event--field-day .event-title::after {
  content: "";
  display: block;
  width: 120px;
  height: 0;
  margin: 10px auto 0;
  border-top: 2px dashed var(--gold);
}
.event--field-day .detail-time { background: var(--red-deep); color: #f3dcae; }

/* Golden hour: sunset wash behind a setting sun. */
.event--golden-hour .panel {
  background: linear-gradient(180deg, #f9d9a6 0%, #fbe6c4 32%, rgba(251, 246, 236, 0.96) 70%);
  border-color: rgba(214, 150, 80, 0.5);
}
.event--golden-hour .event-title { color: #8a3b14; font-style: italic; }
.event--golden-hour .eyebrow { color: #a0501c; }
.event--golden-hour .detail-time { background: rgba(224, 162, 79, 0.2); color: #8a3b14; }
