:root {
  --avorio: #f6f1e7;
  --avorio-2: #efe7d8;
  --carta: #fbf8f2;
  --inchiostro: #2e2b26;
  --tenue: #6f675b;
  --oro: #a98545;
  --oro-chiaro: #cfb27a;
  --bordeaux: #6e2230;
  --serif: "Cormorant Garamond", Garamond, "Times New Roman", serif;
  --script: "Pinyon Script", cursive;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--serif);
  color: var(--inchiostro);
  background: var(--avorio);
  font-size: 19px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
body.chiusa { overflow: hidden; height: 100dvh; }

/* ================= BUSTA ================= */
#intro {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 24px;
  background:
    radial-gradient(ellipse at 50% 30%, #fffdf8 0%, var(--avorio) 55%, #e8dfcd 100%);
  transition: opacity 1s ease, visibility 1s;
}
body:not(.chiusa) #intro { opacity: 0; visibility: hidden; pointer-events: none; }

.intro-sopra {
  letter-spacing: .28em; text-transform: uppercase; font-size: 13px; color: var(--tenue);
  opacity: 0; animation: sali .9s .2s ease forwards;
}
.intro-nome {
  font-family: var(--script); font-size: clamp(40px, 11vw, 64px); line-height: 1.1;
  color: var(--inchiostro); text-align: center; margin-bottom: 18px;
  opacity: 0; animation: sali 1s .45s ease forwards;
}
.intro-hint {
  font-style: italic; color: var(--tenue); margin-top: 26px; font-size: 17px;
  opacity: 0; animation: sali 1s 1.1s ease forwards, pulsa 2.4s 2.2s ease-in-out infinite;
}
#intro.aperta .intro-hint { animation: none; opacity: 0; transition: opacity .3s; }

.busta {
  position: relative;
  width: min(84vw, 400px); aspect-ratio: 3 / 2;
  cursor: pointer; outline: none;
  opacity: 0; animation: sali 1.1s .7s ease forwards;
  filter: drop-shadow(0 18px 28px rgba(60, 45, 20, .18));
}
.busta-retro {
  position: absolute; inset: 0; border-radius: 4px;
  background: linear-gradient(160deg, #e7dcc6, #ddd0b6);
}
.lettera {
  position: absolute; left: 6%; right: 6%; top: 5%; height: 90%;
  z-index: 2; border-radius: 3px;
  background: var(--carta);
  box-shadow: 0 0 0 1px rgba(169, 133, 69, .25) inset, 0 2px 8px rgba(0,0,0,.06);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  padding-top: 9%;
  transition: transform 1.1s cubic-bezier(.2,.7,.2,1) .75s;
}
.lettera::before {
  content: ""; position: absolute; inset: 7px; border: 1px solid var(--oro-chiaro); border-radius: 2px;
}
.lettera-script { font-family: var(--script); font-size: clamp(26px, 7.5vw, 38px); color: var(--inchiostro); }
.lettera-data { font-size: 12px; letter-spacing: .25em; text-transform: uppercase; color: var(--oro); margin-top: 4px; }

.busta-tasca {
  position: absolute; inset: 0; z-index: 3; border-radius: 4px;
  background: linear-gradient(175deg, #f1e8d7 0%, #e9dec9 100%);
  clip-path: polygon(0 0, 50% 54%, 100% 0, 100% 100%, 0 100%);
}
.busta-tasca::after { /* linee di piega */
  content: ""; position: absolute; inset: 0;
  background:
    linear-gradient(to top right, transparent calc(50% - 1px), rgba(120,95,50,.13) 50%, transparent calc(50% + 1px)) left bottom / 50% 100% no-repeat,
    linear-gradient(to top left, transparent calc(50% - 1px), rgba(120,95,50,.13) 50%, transparent calc(50% + 1px)) right bottom / 50% 100% no-repeat;
}
.busta-aletta {
  position: absolute; left: 0; top: 0; width: 100%; height: 56%; z-index: 4;
  background: linear-gradient(180deg, #e6dbc4, #dccfb4);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top center;
  transition: transform .85s cubic-bezier(.5,0,.3,1), z-index 0s .42s;
}
.sigillo {
  position: absolute; left: 50%; top: 56%; z-index: 5;
  width: 74px; height: 74px; transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #9a3446, var(--bordeaux) 55%, #4d1520 100%);
  box-shadow: 0 3px 8px rgba(70, 15, 25, .35), inset 0 0 0 4px rgba(255,255,255,.06), inset 0 0 0 7px rgba(0,0,0,.12);
  display: grid; place-items: center;
  transition: transform .5s ease, opacity .5s ease;
}
.sigillo span {
  font-family: var(--script); color: #f3dfc0; font-size: 24px; letter-spacing: .02em;
  text-shadow: 0 1px 1px rgba(0,0,0,.35);
}
.busta:hover .sigillo, .busta:focus-visible .sigillo { transform: translate(-50%, -50%) scale(1.07); }

#intro.aperta .busta { animation: none; opacity: 1; cursor: default; }
#intro.aperta .sigillo { transform: translate(-50%, -50%) scale(.6); opacity: 0; }
#intro.aperta .busta-aletta { transform: rotateX(180deg); z-index: 1; }
#intro.aperta .lettera { transform: translateY(-58%); }

/* ================= SITO ================= */
#sito { opacity: 0; transition: opacity 1.2s ease .2s; }
body:not(.chiusa) #sito { opacity: 1; }

.hero {
  min-height: 100dvh; position: relative;
  display: flex; align-items: center; justify-content: center;
  padding: 48px 20px 90px;
  background:
    radial-gradient(ellipse at 50% 0%, #fffdf8 0%, transparent 60%),
    var(--avorio);
}
.cornice {
  position: relative; text-align: center; max-width: 560px; width: 100%;
  padding: 56px 28px;
  border: 1px solid var(--oro-chiaro);
  outline: 1px solid var(--oro-chiaro); outline-offset: 6px;
}
.saluto { font-style: italic; font-size: 24px; margin-bottom: 18px; }
.annuncio { color: var(--tenue); font-size: 18px; letter-spacing: .02em; }
.nomi {
  font-family: var(--script); font-weight: 400;
  font-size: clamp(56px, 16vw, 96px); line-height: 1.05; margin: 14px 0 16px;
  display: flex; flex-direction: column; align-items: center;
}
.nomi .e { font-size: .5em; color: var(--oro); margin: -4px 0; }
.data-grande { font-size: 22px; letter-spacing: .18em; text-transform: uppercase; font-weight: 500; }
.citta { color: var(--tenue); letter-spacing: .3em; text-transform: uppercase; font-size: 13px; margin-top: 6px; }

.ornamento { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 26px auto; color: var(--oro); }
.ornamento span { height: 1px; width: 70px; background: linear-gradient(90deg, transparent, var(--oro-chiaro)); }
.ornamento span:last-child { transform: scaleX(-1); }
.ornamento i { font-style: normal; font-size: 22px; }
.ornamento.piccolo { margin: 10px auto 30px; }

.scorri {
  position: absolute; bottom: 28px; left: 50%; transform: translateX(-50%);
  width: 26px; height: 42px; border: 1px solid var(--oro); border-radius: 14px;
}
.scorri span {
  position: absolute; left: 50%; top: 8px; width: 3px; height: 8px; margin-left: -1.5px;
  background: var(--oro); border-radius: 2px; animation: rotella 1.8s infinite;
}

.countdown { background: var(--inchiostro); color: var(--avorio); text-align: center; padding: 52px 16px; }
.countdown .etichetta { letter-spacing: .35em; text-transform: uppercase; font-size: 13px; color: var(--oro-chiaro); margin-bottom: 16px; }
.conti { display: flex; justify-content: center; gap: clamp(14px, 5vw, 48px); }
.conti div { display: flex; flex-direction: column; min-width: 58px; }
.conti b { font-weight: 300; font-size: clamp(38px, 10vw, 60px); line-height: 1; font-variant-numeric: tabular-nums; }
.conti span { font-size: 13px; letter-spacing: .2em; text-transform: uppercase; color: #c9bfae; margin-top: 8px; }

.sezione { padding: 84px 22px; text-align: center; }
.sezione.chiara { background: var(--carta); }
.titolo { font-family: var(--script); font-weight: 400; font-size: clamp(44px, 11vw, 62px); line-height: 1.1; }
.testo { max-width: 520px; margin: 0 auto; color: var(--tenue); font-size: 20px; }

.eventi { display: grid; gap: 24px; max-width: 760px; margin: 0 auto; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); }
.evento {
  background: var(--carta); padding: 36px 26px 30px; border: 1px solid rgba(169,133,69,.35);
  position: relative;
}
.evento::before { content: ""; position: absolute; inset: 6px; border: 1px solid rgba(169,133,69,.18); pointer-events: none; }
.evento .ora { font-size: 46px; font-weight: 300; line-height: 1; color: var(--oro); }
.evento h3 { font-weight: 500; letter-spacing: .25em; text-transform: uppercase; font-size: 15px; margin: 12px 0 14px; }
.evento .luogo { font-size: 23px; font-style: italic; }
.evento .indirizzo { color: var(--tenue); font-size: 17px; margin: 4px 0 22px; }
.evento .azioni { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; position: relative; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--serif); font-size: 15px; letter-spacing: .18em; text-transform: uppercase; font-weight: 600;
  padding: 13px 26px; border: 1px solid var(--inchiostro); border-radius: 0;
  background: var(--inchiostro); color: var(--avorio); cursor: pointer; text-decoration: none;
  transition: background .25s, color .25s, transform .15s;
}
.btn:hover { background: #45403a; }
.btn:active { transform: scale(.98); }
.btn-linea { background: transparent; color: var(--inchiostro); border-color: var(--oro); }
.btn-linea:hover { background: var(--oro); color: #fff; }
.btn[disabled] { opacity: .55; cursor: wait; }

.alloggi { list-style: none; max-width: 460px; margin: 0 auto; }
.alloggi li { padding: 16px 0; border-bottom: 1px solid rgba(169,133,69,.3); }
.alloggi li:last-child { border-bottom: 0; }
.alloggi b { font-weight: 500; font-size: 22px; }
.alloggi a { color: var(--oro); }
.alloggi small { display: block; color: var(--tenue); font-size: 17px; font-style: italic; }

.iban { margin: 30px auto 0; max-width: 460px; padding: 28px 20px; border: 1px dashed var(--oro-chiaro); }
.iban-int { color: var(--tenue); font-style: italic; }
.iban-num { font-size: 19px; letter-spacing: .08em; margin: 6px 0 18px; font-weight: 500; word-break: break-word; }

/* ================= RSVP ================= */
.rsvp { background: linear-gradient(180deg, var(--avorio), var(--avorio-2)); }
.rsvp-box {
  max-width: 520px; margin: 34px auto 0; text-align: left;
  background: var(--carta); padding: 34px 26px; border: 1px solid rgba(169,133,69,.35);
  box-shadow: 0 20px 40px -24px rgba(60,45,20,.25);
}
.rsvp-per { text-align: center; font-size: 21px; margin-bottom: 22px; font-style: italic; }
.rsvp-per b { font-style: normal; font-weight: 600; }
.scelta { display: grid; gap: 10px; margin-bottom: 22px; }
.opzione { position: relative; display: block; cursor: pointer; }
.opzione input { position: absolute; opacity: 0; }
.opzione span {
  display: block; text-align: center; padding: 15px; font-size: 20px;
  border: 1px solid rgba(169,133,69,.45); transition: all .2s;
}
.opzione input:checked + span { background: var(--inchiostro); color: var(--avorio); border-color: var(--inchiostro); }
.opzione input:focus-visible + span { outline: 2px solid var(--oro); outline-offset: 2px; }

form label { display: block; font-size: 17px; color: var(--tenue); margin-bottom: 18px; }
form small { font-size: 14px; }
form input[type="text"], form textarea, form select {
  display: block; width: 100%; margin-top: 6px;
  font: inherit; font-size: 19px; color: var(--inchiostro);
  background: transparent; border: 0; border-bottom: 1px solid rgba(169,133,69,.6);
  padding: 8px 2px; border-radius: 0; outline: none; resize: vertical;
}
form select { appearance: none; background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23a98545'/%3E%3C/svg%3E") no-repeat right 4px center; }
form input:focus, form textarea:focus, form select:focus { border-bottom-color: var(--inchiostro); }
.riga { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.check { display: flex !important; align-items: center; gap: 10px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--inchiostro); }
.check span { color: var(--inchiostro); }
form .btn { width: 100%; margin-top: 6px; }
.errore { color: var(--bordeaux); margin-bottom: 12px; font-style: italic; }

.grazie { text-align: center; }
.grazie p { margin-bottom: 18px; font-size: 20px; }
.script-grande { font-family: var(--script); font-size: 54px; line-height: 1.1; }

.piede { text-align: center; padding: 70px 20px calc(60px + env(safe-area-inset-bottom)); background: var(--inchiostro); color: var(--avorio); }
.piede .script-grande { color: var(--oro-chiaro); }
.contatti { margin-top: 18px; display: flex; gap: 26px; justify-content: center; flex-wrap: wrap; }
.contatti a { color: var(--avorio); text-decoration: none; font-size: 18px; border-bottom: 1px solid rgba(207,178,122,.5); }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 30px);
  background: var(--inchiostro); color: var(--avorio); padding: 12px 22px; font-size: 17px;
  opacity: 0; pointer-events: none; transition: all .35s; z-index: 60;
}
.toast.vis { opacity: 1; transform: translate(-50%, 0); }

/* animazioni */
.rivela { opacity: 0; transform: translateY(22px); transition: opacity 1s ease, transform 1s ease; }
.rivela.vista { opacity: 1; transform: none; }

@keyframes sali { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes pulsa { 0%,100% { opacity: 1; } 50% { opacity: .45; } }
@keyframes rotella { 0% { opacity: 0; transform: translateY(0); } 30% { opacity: 1; } 100% { opacity: 0; transform: translateY(14px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .2s !important; transition-delay: 0s !important; }
}
