/* =========================================================
   Pagina invito — busta animata + foglio invito
   ========================================================= */

.page-invito {
  background: #E5DBC8;
  min-height: 100vh;
  margin: 0;
}

.page-invito.is-closed,
.page-invito.is-opening {
  overflow: hidden;
}

/* ---------- Scena busta ---------- */
.envelope-scene {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2.5rem;
  background: #E5DBC8;
  perspective: 1400px;
  transition: opacity 0.5s ease 0.9s, visibility 0s linear 1.4s;
}
.page-invito.is-open .envelope-scene {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* ---------- Busta ---------- */
.envelope {
  position: relative;
  width: min(360px, 85vw);
  aspect-ratio: 3 / 2;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  transform-style: preserve-3d;
  animation: envelopeIntro 1s ease 0.1s both;
}
@keyframes envelopeIntro {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

.envelope:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 12px;
  border-radius: 4px;
}

/* Corpo busta (dietro al lembo) */
.envelope-back,
.envelope-front {
  position: absolute;
  inset: 0;
  background: #F5EFE3;
  border: 1px solid var(--c-border);
  border-radius: 3px;
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.6),
    0 12px 30px -10px rgba(42,37,34,0.25);
}

/* Triangoli laterali della busta (visibili sotto il lembo aperto) */
.envelope-back::before,
.envelope-back::after {
  content: '';
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  background: linear-gradient(135deg, transparent 49.5%, rgba(42,37,34,0.08) 50%, transparent 50.5%);
}
.envelope-back::before { left: 0; }
.envelope-back::after  { right: 0; transform: scaleX(-1); }

/* Fronte: tasca che nasconde il foglio in basso. Sopra il back, sotto il flap */
.envelope-front {
  z-index: 3;
  background: #EFE7D6;
  clip-path: polygon(0 50%, 100% 50%, 100% 100%, 0 100%);
  box-shadow: inset 0 6px 12px -6px rgba(42,37,34,0.15);
}

/* ---------- Lembo (si ribalta) ---------- */
.envelope-flap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 50%;
  background: #F5EFE3;
  border: 1px solid var(--c-border);
  border-bottom: none;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top center;
  transform: rotateX(0deg);
  transition: transform 0.7s cubic-bezier(.6,.05,.4,1) 0.15s;
  z-index: 4;
  backface-visibility: hidden;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}
.page-invito.is-opening .envelope-flap,
.page-invito.is-open    .envelope-flap {
  transform: rotateX(-180deg);
}

/* ---------- Sigillo ---------- */
.envelope-seal {
  position: absolute;
  top: 65%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 28%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #D8B973 0%, var(--c-accent) 55%, var(--c-accent-dk) 100%);
  box-shadow:
    inset 0 2px 4px rgba(255,255,255,0.35),
    inset 0 -2px 4px rgba(0,0,0,0.2),
    0 2px 5px rgba(42,37,34,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.envelope-seal::before {
  content: '';
  position: absolute;
  inset: 8%;
  border: 1px dashed rgba(255,255,255,0.5);
  border-radius: 50%;
}
.seal-text {
  font-family: var(--f-display);
  font-style: italic;
  font-size: clamp(0.7rem, 2vw, 0.95rem);
  font-weight: 500;
  line-height: 1;
  color: #FFF8E7;
  text-align: center;
  text-shadow: 0 1px 1px rgba(0,0,0,0.3);
  letter-spacing: 0.02em;
}
.page-invito.is-opening .envelope-seal,
.page-invito.is-open    .envelope-seal {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.6);
}

/* ---------- Hint sotto la busta ---------- */
.envelope-hint {
  margin: 0;
  font-size: 0.8rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--c-text-soft);
  animation: hintPulse 2.4s ease-in-out infinite;
}
@keyframes hintPulse {
  0%, 100% { opacity: 0.5; }
  50%      { opacity: 1;   }
}
.page-invito.is-opening .envelope-hint,
.page-invito.is-open    .envelope-hint {
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* =========================================================
   Foglio invito (sotto la busta, esce verso l'alto)
   ========================================================= */

.invito-main {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}
/* Foglio inizia a salire mentre la busta si sta ancora aprendo */
.page-invito.is-opening .invito-main {
  opacity: 0.35;
  transform: translateY(20px);
  transition: opacity 0.8s ease 0.6s, transform 0.8s ease 0.6s;
}
.page-invito.is-open .invito-main {
  opacity: 1;
  transform: translateY(0);
}

.invito-topbar {
  padding: 1.5rem 0;
}
.back-link {
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--c-text-soft);
}
.back-link:hover { color: var(--c-accent-dk); }

/* ---------- Card invito ---------- */
.invito-card {
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: clamp(2rem, 5vw, 4rem) clamp(1.5rem, 4vw, 3rem);
  text-align: center;
  box-shadow: var(--shadow);
  position: relative;
}
.invito-card::before,
.invito-card::after {
  content: '';
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 1px;
  background: var(--c-accent);
}
.invito-card::before { top: 1.25rem; }
.invito-card::after  { bottom: 1.25rem; }

.invito-for-label {
  font-family: var(--f-body);
  font-size: 0.85rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--c-text-soft);
  margin: 1rem 0 0.5rem;
}

.invito-for-name {
  font-family: var(--f-display);
  font-style: italic;
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  font-weight: 500;
  color: var(--c-accent-dk);
  margin: 0 0 1rem;
  line-height: 1.2;
  outline: none;
}

.invito-lead {
  font-family: var(--f-body);
  font-size: 0.85rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--c-text-soft);
  margin: 0 0 1rem;
}

.invito-names {
  font-family: var(--f-display);
  font-size: clamp(3rem, 9vw, 5rem);
  font-weight: 400;
  line-height: 1;
  margin: 0 0 1rem;
}
.invito-names em {
  font-style: italic;
  font-weight: 300;
  color: var(--c-accent);
  margin: 0 0.2rem;
}

.invito-date {
  font-size: 0.95rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--c-text-soft);
  margin: 0;
}

.invito-divider {
  border: none;
  height: 1px;
  background: var(--c-border);
  margin: 2.5rem 0;
}

.invito-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 2rem;
  text-align: center;
}
.invito-detail h3,
.invito-rsvp h3 {
  font-family: var(--f-body);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  color: var(--c-accent-dk);
  margin: 0 0 0.75rem;
}
.invito-detail p {
  font-family: var(--f-display);
  font-size: 1.15rem;
  line-height: 1.5;
  margin: 0;
}

.invito-rsvp p {
  color: var(--c-text-soft);
  margin: 0 0 1rem;
}
.invito-contacts {
  font-family: var(--f-display);
  font-size: 1.15rem;
  color: var(--c-text) !important;
  margin-top: 1rem !important;
}
.invito-contacts a {
  color: var(--c-text);
  border-bottom: 1px solid var(--c-accent);
}

.invito-footer-note {
  margin-top: 2.5rem;
  font-size: 0.9rem;
  color: var(--c-text-soft);
}

/* =========================================================
   Reduced motion: niente animazioni 3D, apertura istantanea
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
  .envelope,
  .envelope-flap,
  .envelope-seal,
  .envelope-hint,
  .envelope-scene,
  .invito-main {
    animation: none !important;
    transition: opacity 0.2s linear !important;
    transform: none !important;
  }
  .page-invito.is-open .envelope-scene {
    transition: opacity 0.2s linear, visibility 0s linear 0.2s !important;
  }
}
