:root {
  --ivory: #F7F1E3;
  --paper: #FDFAF3;
  --wine: #4B1023;
  --wine-deep: #35081A;
  --gold: #B8863B;
  --gold-soft: #E4C98A;
  --ink: #2A1420;
  --ink-quiet: #6B5A63;
  --line: rgba(75, 16, 35, 0.14);
  --radius: 18px;
  --shadow: 0 18px 40px -22px rgba(53, 8, 26, 0.45);
}

* { box-sizing: border-box; }

/* Hides the gallery file input visually while keeping it clickable via JS.
   iOS WebKit (Safari, and every other browser on iOS, since Apple requires
   them all to use WebKit) unreliably opens the file picker when .click() is
   called on an input that's display:none (which the "hidden" attribute
   sets) — so this hides it off-screen instead, which WebKit handles fine. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html {
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  background: var(--ivory);
  background-image:
    radial-gradient(circle at 15% 8%, rgba(184, 134, 59, 0.10), transparent 42%),
    radial-gradient(circle at 88% 20%, rgba(75, 16, 35, 0.07), transparent 40%);
  color: var(--ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

/* ---------- Landing ---------- */

.landing-body {
  min-height: 100vh;
  display: flex;
}

.landing {
  margin: auto;
  width: 100%;
  max-width: 380px;
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.landing__card {
  width: 100%;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 44px 32px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.landing__logo {
  width: 200px;
  height: 200px;
  margin-bottom: 6px;
}

.landing__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  margin-top: 8px;
  padding: 12px 20px;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 600;
  text-decoration: none;
  color: var(--paper);
  background: rgba(75, 16, 35, 0.45);
  border-radius: 999px;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.landing__cta:active {
  transform: scale(0.97);
}

/* ---------- Hero ---------- */

.hero {
  padding: 56px 24px 28px;
  text-align: center;
  max-width: 560px;
  margin: 0 auto;
}

.hero__thread {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: 0.16em;
  color: var(--gold);
  font-weight: 600;
}

.hero__names {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-optical-sizing: auto;
  font-weight: 500;
  font-size: clamp(40px, 11vw, 64px);
  line-height: 1.05;
  color: var(--wine-deep);
}

.hero__amp {
  font-style: italic;
  color: var(--gold);
  padding: 0 6px;
}

.hero__line {
  margin: 16px auto 0;
  max-width: 42ch;
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink-quiet);
}

/* ---------- Booth ---------- */

.booth {
  max-width: 420px;
  margin: 0 auto;
  padding: 8px 20px 12px;
}

.booth__panel { display: none; }
.booth__panel:not([hidden]) {
  display: flex;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 24px;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.booth__ring {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 1.5px solid var(--gold-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--wine);
  margin-bottom: 20px;
}

.booth__camicon { width: 32px; height: 32px; }

.booth__hint {
  margin: 14px 0 0;
  font-size: 12.5px;
  color: var(--ink-quiet);
  max-width: 30ch;
}

.booth__start-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  align-items: center;
}

.booth__frame {
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: 12px;
  overflow: hidden;
  background: var(--ink);
  margin-bottom: 18px;
}

.booth__frame video,
.booth__frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.booth__controls {
  display: flex;
  align-items: center;
  gap: 22px;
}

.booth__controls--row {
  width: 100%;
  gap: 12px;
}

.booth__controls--row .btn { flex: 1; }

.booth__status {
  min-height: 18px;
  font-size: 13px;
  color: var(--wine);
  margin: 12px 0 0;
}

.booth__error {
  color: var(--wine-deep);
  font-size: 14px;
  line-height: 1.6;
  margin: 0 0 18px;
}

/* ---------- Buttons ---------- */

.btn {
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 600;
  border: none;
  border-radius: 999px;
  padding: 13px 24px;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; }

.btn--primary {
  background: var(--wine);
  color: var(--paper);
}

.btn--ghost {
  background: transparent;
  color: var(--ink-quiet);
  border: 1px solid var(--line);
}

.btn--shutter {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: var(--paper);
  border: 3px solid var(--wine);
  padding: 0;
}

/* ---------- Fields ---------- */

.field {
  display: block;
  width: 100%;
  text-align: left;
  margin-bottom: 14px;
}

.field__label {
  display: block;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--ink-quiet);
  margin-bottom: 6px;
}

.field__label em { color: var(--gold); font-style: normal; }

.field textarea,
.field input {
  width: 100%;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--ivory);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 13px;
  resize: none;
}

.field textarea:focus,
.field input:focus {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

/* ---------- Divider ---------- */

.divider {
  max-width: 420px;
  margin: 32px auto 8px;
  padding: 0 20px;
  display: flex;
  align-items: center;
}

.divider span {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-soft), transparent);
}

/* ---------- Wall ---------- */

.wall {
  max-width: 560px;
  margin: 0 auto;
  padding: 8px 20px 80px;
}

.wall__title {
  text-align: center;
  font-family: "Fraunces", Georgia, serif;
  font-weight: 500;
  font-size: 22px;
  color: var(--wine-deep);
  margin: 0 0 24px;
}

.wall__feed {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 30px;
}

.wall__empty {
  text-align: center;
  color: var(--ink-quiet);
  font-size: 14px;
  margin-top: 8px;
}

.wall__feed:not(:empty) + .wall__empty { display: none; }

.card {
  --tilt: 0deg;
  background: #fff;
  padding: 12px 12px 10px;
  border-radius: 3px;
  box-shadow: 0 14px 26px -12px rgba(53, 8, 26, 0.4), 0 3px 8px rgba(42, 20, 32, 0.12);
  overflow: visible;
  animation: rise 0.5s ease both;
  max-width: 240px;
  width: 100%;
  transition: transform 0.2s ease;
}

.card:nth-child(10n+1) { --tilt: -1.8deg; }
.card:nth-child(10n+2) { --tilt: 1.1deg; }
.card:nth-child(10n+3) { --tilt: 0.2deg; }
.card:nth-child(10n+4) { --tilt: -2.4deg; }
.card:nth-child(10n+5) { --tilt: 0.8deg; }
.card:nth-child(10n+6) { --tilt: -0.5deg; }
.card:nth-child(10n+7) { --tilt: 2deg; }
.card:nth-child(10n+8) { --tilt: -1.2deg; }
.card:nth-child(10n+9) { --tilt: 0deg; }
.card:nth-child(10n+10) { --tilt: 1.6deg; }

.card:hover { transform: rotate(0deg) scale(1.03); }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px) rotate(0deg); }
  to { opacity: 1; transform: translateY(0) rotate(var(--tilt)); }
}

.card__photo {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  background: var(--ink);
  border-radius: 1px;
}

.card__body {
  padding: 12px 4px 8px;
  text-align: center;
}

.card__wish {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-style: italic;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--ink);
}

.card__meta {
  margin: 6px 0 0;
  font-size: 10.5px;
  letter-spacing: 0.03em;
  color: var(--gold);
  font-weight: 600;
  text-transform: uppercase;
}

.card__date {
  margin: 3px 0 0;
  font-size: 9.5px;
  letter-spacing: 0.02em;
  color: var(--ink-quiet);
  font-weight: 500;
}

.site-footer {
  text-align: center;
  padding: 36px 20px 44px;
}

.site-footer__logo {
  width: 300px;
  height: 300px;
  display: block;
  margin: 0 auto 6px;
}

.site-footer__thanks {
  font-family: "Fira Sans", sans-serif;
  font-size: 10px;
  color: var(--ink-quiet);
  margin: 0;
}

@media (min-width: 640px) {
  .hero { padding-top: 72px; }
  .wall__feed { gap: 34px; }
}

/* ---------- Collage toggle button ---------- */

.collage-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 60;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  color: var(--wine);
  border: 1px solid var(--line);
  border-radius: 50%;
  box-shadow: var(--shadow);
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s ease;
}

.collage-toggle:active { transform: scale(0.93); }

.collage-toggle__icon {
  width: 20px;
  height: 20px;
}

/* ---------- Collage modal ---------- */

.collage-modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: var(--ivory);
  overflow-y: auto;
  padding: 68px 16px 60px;
}

.collage-modal[hidden] { display: none; }

.collage-modal__close {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 72;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  color: var(--wine);
  border: 1px solid var(--line);
  border-radius: 50%;
  box-shadow: var(--shadow);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.collage-grid {
  max-width: 720px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

@media (min-width: 640px) {
  .collage-grid { grid-template-columns: repeat(4, 1fr); gap: 6px; }
}

.collage-grid__item {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 3px;
  background: var(--ink);
  padding: 0;
  border: none;
  cursor: pointer;
}

.collage-grid__item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.15s ease;
}

.collage-grid__item:active img { transform: scale(0.95); }

.collage-empty {
  text-align: center;
  color: var(--ink-quiet);
  font-size: 14px;
  margin-top: 40px;
}

/* ---------- Lightbox ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(42, 20, 32, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.lightbox[hidden] { display: none; }

.lightbox__close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(253, 250, 243, 0.92);
  color: var(--wine);
  border: none;
  border-radius: 50%;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.lightbox__card {
  max-width: 260px;
  width: 100%;
  max-height: 100%;
  overflow-y: auto;
}

.lightbox__card .card {
  --tilt: 0deg;
  width: 100%;
  max-width: none;
}

.lightbox__card .card:hover {
  transform: none;
}

/* ---------- Download page ---------- */

.dl-hero {
  padding: 56px 24px 24px;
  text-align: center;
  max-width: 640px;
  margin: 0 auto;
}

.dl-back {
  display: inline-block;
  margin-bottom: 18px;
  font-size: 13px;
  color: var(--ink-quiet);
  text-decoration: none;
}

.dl-back:active { opacity: 0.6; }

.dl-hero h1 {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 500;
  font-size: clamp(28px, 7vw, 40px);
  color: var(--wine-deep);
  margin: 0 0 8px;
}

.dl-hero__line {
  margin: 0 0 20px;
  font-size: 14px;
  color: var(--ink-quiet);
}

.dl-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.dl-progress {
  font-size: 12.5px;
  color: var(--ink-quiet);
  min-height: 16px;
  margin: 0;
}

.dl-grid {
  max-width: 900px;
  margin: 0 auto;
  padding: 8px 20px 90px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
}

.dl-card {
  background: #fff;
  border-radius: 3px;
  overflow: hidden;
  box-shadow: 0 14px 26px -12px rgba(53, 8, 26, 0.4), 0 3px 8px rgba(42, 20, 32, 0.12);
  display: flex;
  flex-direction: column;
}

.dl-card__img {
  width: 100%;
  height: auto;
  display: block;
  background: var(--ink);
}

.dl-card__actions {
  padding: 10px;
  display: flex;
  justify-content: center;
}

.dl-card__download {
  width: 100%;
}

.dl-empty {
  text-align: center;
  color: var(--ink-quiet);
  font-size: 14px;
  margin-top: 60px;
}
