/* ---------- Theme ---------- */
:root {
  --bg: #0b0a0a;
  --bg-2: #141212;
  --card: #151313;
  --line: rgba(212, 175, 55, 0.28);
  --line-strong: rgba(212, 175, 55, 0.6);
  --gold: #d4af37;
  --gold-light: #f3dc8a;
  --gold-deep: #a8842a;
  --ink: #f4efe4;
  --ink-muted: #b9b1a1;
  --danger: #ff8a8a;
  --display: "Playfair Display", "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 14px;
  --gold-gradient: linear-gradient(135deg, #b8902c 0%, #f3dc8a 45%, #d4af37 70%, #a8842a 100%);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 40% at 50% -10%, rgba(212, 175, 55, 0.18), transparent 60%),
    radial-gradient(ellipse 60% 30% at 50% 110%, rgba(212, 175, 55, 0.08), transparent 60%);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
  min-height: 100dvh;
}
::selection { background: rgba(212, 175, 55, 0.35); }

.sparkles {
  position: fixed; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 0;
}

.page {
  position: relative; z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  padding: calc(32px + env(safe-area-inset-top)) 16px calc(40px + env(safe-area-inset-bottom));
}

/* ---------- Typography ---------- */
.display {
  font-family: var(--display);
  font-weight: 500;
  letter-spacing: 0.01em;
  line-height: 1.12;
  margin: 0;
  /* background-clip: text clips to the box, so give descenders (y, g, j) room and pull the margin back */
  padding: 0.06em 0 0.16em;
  margin-bottom: -0.16em;
  background: var(--gold-gradient);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
h1.display { font-size: clamp(2.6rem, 11vw, 4.2rem); text-wrap: balance; }
h2.display { font-size: 1.9rem; margin-bottom: calc(4px - 0.16em); }
.eyebrow {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.25rem;
  color: var(--gold-light);
  letter-spacing: 0.04em;
  margin: 0 0 10px;
}
.muted { color: var(--ink-muted); margin: 0 0 18px; }
.small { font-size: 0.85rem; }
.hint { color: var(--ink-muted); font-weight: 400; font-size: 0.9em; }
.link { color: var(--gold-light); text-decoration: none; border-bottom: 1px solid var(--line-strong); }
.link:hover { color: var(--gold); }

/* ---------- Hero ---------- */
.hero { text-align: center; padding: 8px 0 26px; }
.ornament {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  margin: 18px auto 14px; color: var(--gold);
}
.ornament span { display: block; width: 70px; height: 1px; background: linear-gradient(90deg, transparent, var(--gold), transparent); }
.ornament i { font-style: normal; font-size: 0.9rem; }
.hero-when {
  font-family: var(--serif);
  font-size: 1.35rem;
  line-height: 1.4;
  margin: 0;
  color: var(--ink);
}
.hero-when span:last-child { color: var(--gold-light); }

/* ---------- Countdown ---------- */
.countdown { text-align: center; margin: 6px 0 24px; }
.countdown-label { color: var(--ink-muted); font-size: 0.9rem; letter-spacing: 0.12em; text-transform: uppercase; margin: 0 0 12px; }
.countdown-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.tile {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 4px 10px;
}
.tile b {
  display: block;
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(1.6rem, 7vw, 2.2rem);
  line-height: 1;
  color: var(--gold-light);
  font-variant-numeric: tabular-nums;
}
.tile small { display: block; margin-top: 6px; font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-muted); }
.countdown.done .countdown-grid { display: none; }
.countdown.done .countdown-label { font-family: var(--serif); font-size: 1.3rem; text-transform: none; letter-spacing: 0; color: var(--gold-light); }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 20px;
  margin-bottom: 18px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  position: relative;
}
.card::before {
  content: ""; position: absolute; inset: 6px; border-radius: 10px;
  border: 1px solid rgba(212, 175, 55, 0.12); pointer-events: none;
}

.details dl { margin: 0; display: grid; gap: 16px; }
.details dt {
  font-size: 0.75rem; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--gold); margin-bottom: 4px;
}
.details dd { margin: 0; }
.details address { font-style: normal; white-space: pre-line; margin-bottom: 6px; }
.signoff { font-family: var(--serif); font-style: italic; font-size: 1.2rem; color: var(--gold-light); margin: 18px 0 0; }

/* ---------- Form ---------- */
.field { margin-bottom: 18px; border: 0; padding: 0; min-width: 0; }
fieldset.field legend, .field > label { display: block; font-weight: 600; margin-bottom: 8px; }
input[type="text"], input[type="search"], input[type="password"], select, textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none; appearance: none;
}
textarea { resize: vertical; min-height: 96px; }
select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'><path d='M1 1l6 6 6-6' fill='none' stroke='%23d4af37' stroke-width='1.6'/></svg>");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 40px;
}
input::placeholder, textarea::placeholder { color: #6f6757; }
input:focus, select:focus, textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.2);
}
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: 0.85rem; margin: 6px 0 0; min-height: 0; }
.field-error:empty { display: none; }
.field-counter { text-align: right; font-size: 0.75rem; color: var(--ink-muted); margin: 4px 0 0; }

.choices { display: grid; gap: 8px; }
.choice { position: relative; display: block; cursor: pointer; }
.choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.choice span {
  display: block; padding: 12px 14px 12px 44px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px;
  transition: border-color 0.15s, background 0.15s;
}
.choice span::before {
  content: ""; position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--gold-deep);
}
.choice input:checked + span { border-color: var(--gold); background: rgba(212, 175, 55, 0.1); }
.choice input:checked + span::before { background: var(--gold); box-shadow: inset 0 0 0 4px var(--bg-2); border-color: var(--gold); }
.choice input:focus-visible + span { box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.3); }

/* Song search (Apple Music typeahead) */
.song-search { position: relative; }
.song-results {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 20;
  margin: 0; padding: 6px; list-style: none;
  background: #1b1817; border: 1px solid var(--line-strong); border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55); max-height: 320px; overflow-y: auto;
}
.song-results li {
  display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; cursor: pointer;
}
.song-results li:hover, .song-results li[aria-selected="true"] { background: rgba(212, 175, 55, 0.14); }
.song-results img { width: 40px; height: 40px; border-radius: 6px; background: var(--bg-2); flex: none; }
.song-results b { display: block; font-weight: 600; font-size: 0.95rem; line-height: 1.25; }
.song-results span { display: block; color: var(--ink-muted); font-size: 0.82rem; }
.song-results .song-note { color: var(--ink-muted); font-size: 0.85rem; padding: 10px; cursor: default; }
.song-results .song-note:hover { background: none; }
.song-pick {
  display: flex; align-items: center; gap: 10px; margin-top: 8px; padding: 8px 10px;
  border: 1px solid var(--line-strong); border-radius: 10px; background: rgba(212, 175, 55, 0.08);
}
.song-pick img { width: 44px; height: 44px; border-radius: 6px; background: var(--bg-2); flex: none; }
.song-pick-text { min-width: 0; flex: 1; }
.song-pick-text b { display: block; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song-pick-text span { display: block; color: var(--ink-muted); font-size: 0.82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song-clear { background: none; border: 0; color: var(--ink-muted); font-size: 1rem; cursor: pointer; padding: 6px; }
.song-clear:hover { color: var(--ink); }
.song-hint { margin: 8px 0 0; font-size: 0.85rem; color: var(--ink-muted); }
.music-badge { display: inline-block; color: var(--gold); margin-right: 2px; }
.song-searching { display: flex; align-items: center; gap: 10px; color: var(--gold-light) !important; }
.song-searching::before {
  content: ""; width: 14px; height: 14px; border-radius: 50%; flex: none;
  border: 2px solid rgba(212, 175, 55, 0.3); border-top-color: var(--gold);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.song-slot { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.song-slot .song-search { flex: 1; min-width: 0; }
.song-slot .song-pick { margin-top: 0; flex: 1; min-width: 0; }
.song-remove { background: none; border: 1px solid var(--line); border-radius: 10px; color: var(--ink-muted); font-size: 1rem; cursor: pointer; padding: 0 12px; height: 49px; flex: none; }
.song-remove:hover { color: var(--ink); border-color: var(--line-strong); }
.add-song { margin: 0; padding: 6px 0; color: var(--gold-light); text-decoration: none; font-weight: 600; }
.add-song:hover { text-decoration: underline; }

.nudge {
  display: flex; gap: 10px; align-items: flex-start;
  margin: 0 0 18px; padding: 12px 14px;
  border: 1px solid var(--line-strong); border-radius: 10px;
  background: rgba(212, 175, 55, 0.08);
  font-family: var(--serif); font-size: 1.1rem; line-height: 1.4; color: var(--gold-light);
}
.nudge > span:first-child { color: var(--gold); flex: none; margin-top: 2px; font-size: 0.8rem; }

/* Photo uploads */
.photo-hint { margin: -4px 0 10px; font-size: 0.85rem; }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.photo-grid:empty { display: none; }
.photo-thumb { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--bg-2); border: 1px solid var(--line); }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-thumb .photo-x {
  position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 50%;
  background: rgba(0, 0, 0, 0.65); color: #fff; border: 1px solid rgba(255, 255, 255, 0.3);
  font-size: 0.9rem; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.photo-thumb .photo-state {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 3px 6px; font-size: 0.7rem; text-align: center;
  background: rgba(0, 0, 0, 0.6); color: var(--gold-light);
}
.photo-thumb.done .photo-state { color: #9be39b; }
.photo-thumb.failed .photo-state { color: var(--danger); }
.photo-add {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px; border: 1px dashed var(--line-strong); border-radius: 10px; cursor: pointer;
  color: var(--gold-light); font-weight: 600; background: var(--bg-2);
}
.photo-add:hover { background: rgba(212, 175, 55, 0.08); }
.photo-add input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.photo-add-icon { font-size: 1.3rem; line-height: 1; }
.photo-add.disabled { opacity: 0.5; pointer-events: none; }

.hp { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 100%; padding: 14px 20px;
  font: inherit; font-weight: 600; font-size: 1.05rem;
  border-radius: 999px; cursor: pointer; text-decoration: none;
  transition: transform 0.1s, filter 0.15s, opacity 0.15s;
}
.btn:active { transform: translateY(1px); }
.btn-gold { background: var(--gold-gradient); color: #1a1400; border: 0; box-shadow: 0 8px 24px rgba(212, 175, 55, 0.25); }
.btn-gold:hover { filter: brightness(1.05); }
.btn-gold[disabled] { opacity: 0.6; cursor: wait; }
.btn-outline { background: transparent; color: var(--gold-light); border: 1px solid var(--line-strong); }
.btn-outline:hover { background: rgba(212, 175, 55, 0.08); }
.link-btn { background: none; border: 0; color: var(--ink-muted); font: inherit; text-decoration: underline; cursor: pointer; padding: 8px; margin-top: 10px; }
.form-error { color: var(--danger); margin: 12px 0 0; text-align: center; }
.form-error:empty { display: none; }

/* ---------- Confirmation ---------- */
.confirmation { text-align: center; }
.confirm-icon { color: var(--gold); font-size: 1.6rem; margin-bottom: 6px; }
.confirmation p { margin: 8px 0 0; }
.pill {
  display: inline-block; margin-top: 12px !important; padding: 4px 12px;
  border: 1px solid var(--line-strong); border-radius: 999px; font-size: 0.8rem; color: var(--gold-light);
}
.actions { display: grid; gap: 10px; margin-top: 22px; }

.foot { text-align: center; color: var(--ink-muted); font-family: var(--serif); font-style: italic; font-size: 1.1rem; margin-top: 10px; }

/* ---------- Motion ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.hero, .countdown, .card, .foot { animation: rise 0.7s ease both; }
.countdown { animation-delay: 0.15s; }
.card:nth-of-type(1) { animation-delay: 0.25s; }
.card:nth-of-type(2) { animation-delay: 0.35s; }
.foot { animation-delay: 0.45s; }

@media (prefers-reduced-motion: reduce) {
  .hero, .countdown, .card, .foot { animation: none; }
  .song-searching::before { animation: none; border-top-color: var(--gold); }
  .sparkles { display: none; }
  * { transition: none !important; }
}

@media (min-width: 600px) {
  .page { padding-top: 56px; }
  .card { padding: 30px 32px; }
  .actions { grid-template-columns: 1fr 1fr; }
}
