:root {
  --white: #ffffff;
  --cream: #fbf8f4;
  --burgundy: #7a1626;
  --burgundy-dark: #5c0f1c;
  --gold: #a88a5a;          /* oro antico, opaco */
  --gold-soft: #d8c7a6;
  --ink: #3a2a2c;
  --muted: #8a7a76;
  --line: #ece4da;
  --danger: #a3303d;
  --ok: #5f7d5a;
  --dock-h: 68px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--white);
  color: var(--ink);
  font: 15px/1.6 "Montserrat", system-ui, sans-serif;
  padding-bottom: calc(var(--dock-h) + env(safe-area-inset-bottom));
}

button { font: inherit; }

/* ---------- copertina ---------- */

.hero {
  position: relative;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  text-align: center;
  padding: calc(8px + env(safe-area-inset-top)) 18px 8px;
  background: var(--white);
  overflow: hidden;
}
.flowers { width: min(520px, 108%); display: block; pointer-events: none; }
.flowers.top { margin-top: -6px; }
.flowers.bottom { transform: scaleY(-1); width: min(420px, 90%); opacity: .95; }

.hero-text { position: relative; z-index: 1; max-width: 460px; width: 100%; }

.kicker {
  margin: 0;
  font-size: .72rem;
  font-weight: 500;
  letter-spacing: .32em;
  text-transform: uppercase;
  color: var(--muted);
}

h1 {
  margin: 4px 0 6px;
  font: 400 clamp(3rem, 15vw, 4.8rem)/1.05 "Great Vibes", cursive;
  color: var(--gold);
}
.e { font-size: .7em; padding: 0 .08em; }

.date {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font: 500 1.05rem "Cormorant Garamond", serif;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink);
}
.date strong { color: var(--burgundy); font-size: 1.6em; font-weight: 600; vertical-align: -0.12em; padding: 0 .1em; }
.rule { flex: 0 0 34px; height: 1px; background: var(--gold); }

.place {
  margin: 2px 0 0;
  font: italic 500 1.15rem "Cormorant Garamond", serif;
  color: var(--burgundy);
}
.countdown {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 16px auto 0;
}
.countdown[hidden] { display: none; }
.countdown div {
  min-width: 62px;
  padding: 8px 4px 6px;
  border: 1px solid var(--gold-soft);
  border-radius: 4px;
}
.countdown b {
  display: block;
  font: 600 1.7rem/1 "Cormorant Garamond", serif;
  color: var(--burgundy);
  font-variant-numeric: tabular-nums;
}
.countdown span {
  font-size: .6rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}
.hero.has-photo .countdown div { border-color: rgba(255,255,255,.5); }
.hero.has-photo .countdown b, .hero.has-photo .countdown span { color: #fff; }

.lead {
  margin: 16px auto 22px;
  font: italic 500 1.15rem/1.4 "Cormorant Garamond", serif;
  color: var(--muted);
}

.cta { display: grid; gap: 10px; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%;
  padding: 15px 18px;
  border-radius: 4px;
  font-weight: 600;
  font-size: .82rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background .2s, color .2s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn.primary { background: var(--burgundy); color: #fff; border: 1px solid var(--burgundy); box-shadow: 0 10px 22px -14px rgba(92, 15, 28, .9); }
.btn.primary:hover { background: var(--burgundy-dark); }
.btn.ghost { background: transparent; color: var(--burgundy); border: 1px solid var(--gold); }
.btn.ghost:hover { background: var(--cream); }

.guest { display: block; margin: 18px auto 0; max-width: 320px; }
.guest span {
  display: block;
  font: italic 500 1rem "Cormorant Garamond", serif;
  color: var(--muted);
  margin-bottom: 2px;
}
.guest input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--gold-soft);
  background: transparent;
  padding: 8px 4px;
  text-align: center;
  font: 16px "Montserrat", sans-serif; /* 16px evita lo zoom su iPhone */
  color: var(--ink);
  border-radius: 0;
}
.guest input:focus { outline: none; border-bottom-color: var(--burgundy); }

/* copertina con foto (se presente static/img/copertina.jpg) */
.hero.has-photo {
  background: #1d1416 var(--cover) center / cover no-repeat;
  justify-content: center;
}
.hero.has-photo::before {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(20, 10, 12, .35), rgba(20, 10, 12, .65));
}
.hero.has-photo .flowers { display: none; }
.hero.has-photo .kicker,
.hero.has-photo .lead,
.hero.has-photo .guest span,
.hero.has-photo .date,
.hero.has-photo .guest input { color: #fff; }
.hero.has-photo h1 { color: var(--gold-soft); }
.hero.has-photo .place { color: #fff; }
.hero.has-photo .date strong { color: #fff; }
.hero.has-photo .rule { background: var(--gold-soft); }
.hero.has-photo .btn.ghost { color: #fff; border-color: rgba(255,255,255,.7); }
.hero.has-photo .btn.ghost:hover { background: rgba(255,255,255,.1); }
.hero.has-photo .guest input::placeholder { color: rgba(255,255,255,.7); }

/* ---------- album ---------- */

main { background: var(--cream); border-top: 1px solid var(--line); }
.album { max-width: 1000px; margin: 0 auto; padding: 44px 6px 32px; text-align: center; }
h2 {
  margin: 4px 0 2px;
  font: 400 2.6rem/1.1 "Great Vibes", cursive;
  color: var(--burgundy);
}
.count { margin: 0 0 20px; color: var(--muted); font-size: .85rem; letter-spacing: .06em; }

.gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
}
@media (min-width: 640px) { .gallery { grid-template-columns: repeat(4, 1fr); gap: 6px; } .album { padding-inline: 16px; } }
@media (min-width: 960px) { .gallery { grid-template-columns: repeat(5, 1fr); } }

.tile {
  position: relative;
  aspect-ratio: 1;
  border: 0; padding: 0;
  background: var(--line);
  overflow: hidden;
  cursor: pointer;
}
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .35s, transform .35s; }
.tile img.ok { opacity: 1; }
.tile:hover img.ok { transform: scale(1.03); }
.tile .badge {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: #fff;
  font-size: 1.8rem;
  text-shadow: 0 1px 8px rgba(0,0,0,.5);
  pointer-events: none;
}
.tile.noprev { background: linear-gradient(135deg, var(--burgundy), var(--gold)); }

.empty { color: var(--muted); font: italic 500 1.2rem/1.4 "Cormorant Garamond", serif; padding: 20px 0; }

footer {
  text-align: center;
  padding: 26px 16px 30px;
  background: var(--cream);
  color: var(--muted);
  font-size: .8rem;
  letter-spacing: .2em;
}
footer .sign { margin: 0; font: 400 2rem "Great Vibes", cursive; letter-spacing: 0; color: var(--gold); }
footer p { margin: 0; }

/* ---------- barra in basso ---------- */

.dock {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 10;
  height: calc(var(--dock-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  align-items: center;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
}
.dock button {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: 0;
  color: var(--ink);
  font-size: .68rem;
  font-weight: 500;
  letter-spacing: .1em;
  text-transform: uppercase;
  cursor: pointer;
}
.dock svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.dock .plus {
  display: grid; place-items: center;
  width: 50px; height: 50px;
  margin-top: -26px;
  border-radius: 50%;
  background: var(--burgundy);
  color: #fff;
  border: 3px solid #fff;
  box-shadow: 0 6px 16px -6px rgba(92, 15, 28, .8);
}
.dock .main { color: var(--burgundy); }
@media (min-width: 900px) {
  .dock { display: none; }
  body { padding-bottom: 0; }
}

/* ---------- pannello caricamenti ---------- */

.tray {
  position: fixed;
  left: 10px; right: 10px;
  bottom: calc(var(--dock-h) + env(safe-area-inset-bottom) + 10px);
  z-index: 11;
  max-width: 460px;
  margin: 0 auto;
  max-height: 45vh;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-top: 3px solid var(--burgundy);
  border-radius: 6px;
  box-shadow: 0 18px 40px -18px rgba(58, 42, 44, .5);
  padding: 10px 14px 4px;
}
@media (min-width: 900px) { .tray { bottom: 20px; } }
.tray-head { display: flex; justify-content: space-between; align-items: center; }
.tray-head strong { font: 600 1.1rem "Cormorant Garamond", serif; color: var(--burgundy); }
.tray-head button { background: none; border: 0; font-size: 1.6rem; line-height: 1; color: var(--muted); cursor: pointer; }

.queue { list-style: none; padding: 0; margin: 6px 0 0; }
.queue li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  font-size: .8rem;
}
.queue .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue .state { color: var(--muted); }
.queue .bar { grid-column: 1 / -1; height: 3px; background: var(--line); overflow: hidden; }
.queue .bar i { display: block; height: 100%; width: 0; background: var(--gold); transition: width .2s; }
.queue li.done .state { color: var(--ok); }
.queue li.done .bar i { background: var(--ok); }
.queue li.error .state { color: var(--danger); }
.queue li.error .bar i { background: var(--danger); }

/* ---------- visualizzatore ---------- */

.viewer {
  width: 100vw; height: 100dvh;
  max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0;
  background: rgba(18, 10, 12, .97);
  color: #fff;
}
.viewer::backdrop { background: rgba(18, 10, 12, .9); }
.viewer .stage { position: absolute; inset: 0; display: grid; place-items: center; }
.viewer .stage img, .viewer .stage video { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer button {
  position: absolute;
  z-index: 2;
  width: 46px; height: 46px;
  border-radius: 50%;
  border: 1px solid rgba(216, 199, 166, .5);
  background: rgba(0, 0, 0, .25);
  color: #fff;
  font-size: 1.8rem; line-height: 1;
  cursor: pointer;
}
.viewer .close { top: calc(12px + env(safe-area-inset-top)); right: 12px; }
.viewer .nav { top: 50%; transform: translateY(-50%); }
.viewer .prev { left: 8px; }
.viewer .next { right: 8px; }

/* ---------- pagina codice d'accesso ---------- */
.code-page { min-height: 100svh; display: grid; place-items: center; padding: 16px; text-align: center; }
.code-page form { display: grid; gap: 12px; max-width: 320px; margin: 0 auto; }
