/* Supporto alle animazioni GSAP (motion.js): strutture e stati di partenza.
   Le transizioni vere stanno in JS; qui solo cio' che serve a renderle fluide. */

/* ScrollSmoother e ScrollToPlugin gestiscono lo scorrimento: niente smooth nativo. */
html { scroll-behavior: auto; }

/* Elementi che GSAP fa entrare: nascosti finche' motion.js non li anima,
   cosi' non lampeggiano prima dell'animazione. La classe "js" la mette l'head. */
.js .gate-copy,
.js .gate-envelope,
.js .gate-hint,
.js .site-nav,
.js .hero-content > *,
.js .hero-scroll { visibility: hidden; }

/* Barra di avanzamento della lettura. */
.scroll-progress {
  position: fixed; top: 0; left: 0; right: 0; z-index: 60; height: 2px;
  background: linear-gradient(90deg, var(--accent), #dfe9da);
  transform: scaleX(0); transform-origin: 0 50%; pointer-events: none;
}

/* Navigazione fissa: trasparente sull'hero, crema quando si scorre oltre. */
.site-nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50; max-width: none; margin: 0;
  padding-left: max(30px, calc((100% - 1120px) / 2));
  padding-right: max(30px, calc((100% - 1120px) / 2));
  color: #fff;
  transition: background .35s ease, color .35s ease, box-shadow .35s ease, height .35s ease;
}
.site-nav.is-solid {
  height: 64px; color: var(--ink);
  background: #f7f7f2e6; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 1px 0 #d3dccd80, 0 10px 30px #2f3a300f;
}
.site-nav.is-solid .brand span { color: var(--accent); }
.site-nav.is-solid .nav-links { border-color: #4e645026; background: #4e64500d; }
.site-nav.is-solid .nav-links a:hover { background: var(--ink); color: #fff; }
@media (max-width: 650px) {
  .site-nav { padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); }
  .site-nav.is-solid { height: 60px; }
  .site-nav.is-solid .nav-toggle { background: var(--ink); border-color: var(--ink); }
  .site-nav.is-solid .nav-links { top: 54px; background: #4e6450f2; }
  .site-nav.is-solid .nav-links a { color: #fff; }
}

/* Hero: lo sfondo vive in un livello proprio, piu' alto della sezione,
   cosi' puo' scorrere in parallasse senza scoprire i bordi. */
.hero { overflow: hidden; background: var(--ink); padding-top: 80px; }
.hero-bg {
  position: absolute; inset: -10% 0; z-index: 0; will-change: transform;
  background: linear-gradient(180deg, #1c211d88, #1c211d44),
    url('resources/hero.jpg?v=2') center 30% / cover;
}
.hero::before { z-index: 1; }
.hero-content, .hero-scroll { z-index: 2; }
@media (min-width: 768px) { .hero-content { position: relative; } }
@media (max-width: 767px) { .hero-bg { background-position: 56% center; } }
.hero-scroll span { will-change: transform; }
/* Schermi orizzontali: la foto (verticale) e' ingrandita e tagliata a sinistra della coppia,
   cosi' noi due stiamo a destra in primo piano e il titolo a sinistra, sulla casa gialla. */
@media (min-width: 768px) and (min-height: 521px) and (orientation: landscape) {
  .hero-bg {
    background: linear-gradient(90deg, #1c211da6, #1c211d40 55%, #1c211d10),
      linear-gradient(180deg, #1c211d66, transparent 30%),
      url('resources/hero.jpg?v=2') 0% 68% / 133% auto;
  }
  .hero-content { max-width: none; margin-left: 0; margin-right: 46%; }
  .hero h1 { font-size: clamp(54px, 6.4vw, 112px); }
  .hero-scroll { right: 46%; }
}

.hero-sparkle {
  position: absolute; z-index: 1; width: 4px; height: 4px; border-radius: 50%;
  background: #f7f7f2; box-shadow: 0 0 10px #dfe9da; pointer-events: none; opacity: 0;
}
.hero-sparkle.accent { background: #dfe9da; box-shadow: 0 0 12px #6f876b; }

/* Galleria: l'immagine sta in un livello interno per parallasse e zoom. */
.photo .photo-media {
  position: absolute; top: -12%; bottom: -12%; left: 0; right: 0; z-index: 0;
  background-size: cover; background-position: center; will-change: transform;
}
.photo-grid .photo { background-image: none; }
.photo-caption { z-index: 2 !important; }

/* Card sorpresa: profondita' per l'inclinazione 3D al passaggio del mouse. */
.scratch-card { transform-style: preserve-3d; will-change: transform; }
@media (prefers-reduced-motion: reduce) {
  .scratch-card .lock-cover { animation: none; }
}

/* Countdown: le cifre ruotano dentro la propria cella. */
.countdown b { overflow: hidden; }

/* Busta della luna di miele: la lettera si apre in prospettiva. */
.envelope-wrap { perspective: 1200px; }
.letter { transform-origin: 50% 0; }

/* Gate: elementi aggiunti per le animazioni GSAP (motion.js). */
/* Il gate ritaglia bagliore, pulviscolo e volo della lettera: se sporgessero, i browser
   mobile allargherebbero la pagina oltre lo schermo. */
.intro-gate { overflow: hidden; }
.gate-copy, .gate-envelope { position: relative; z-index: 1; }
.gate-dust { position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.gate-dust i {
  position: absolute; width: 5px; height: 5px; border-radius: 50%; opacity: 0;
  background: #b5c6ae; box-shadow: 0 0 8px 1px #cfdcc9cc;
}
.gate-hint {
  position: absolute; left: 0; right: 0; bottom: max(28px, env(safe-area-inset-bottom)); z-index: 1; margin: 0;
  text-align: center; font: 500 11px "DM Sans"; letter-spacing: .28em; text-transform: uppercase; color: var(--ink);
}
.gate-glow {
  position: absolute; left: 50%; top: 50%; z-index: 0; width: min(150vmin, 1100px); aspect-ratio: 1;
  pointer-events: none; opacity: 0; visibility: hidden;
  background: radial-gradient(closest-side, #fbfcf8 0%, #f1f5eed9 30%, #dfe8d966 55%, transparent 100%);
}
.env-seal { overflow: visible; }
.seal-shine {
  position: absolute; inset: 8%; border-radius: 50%; pointer-events: none; mix-blend-mode: overlay;
  background: linear-gradient(105deg, transparent 35%, #fffbe8e6 50%, transparent 65%) 160% 0 / 250% 100% no-repeat;
}
.seal-half { position: absolute; inset: 0; }
.seal-half img { width: 100%; height: 100%; display: block; }
.seal-half.left { clip-path: polygon(0 0, 53% 0, 46% 20%, 56% 38%, 44% 58%, 55% 77%, 47% 100%, 0 100%); }
.seal-half.right { clip-path: polygon(53% 0, 100% 0, 100% 100%, 47% 100%, 55% 77%, 44% 58%, 56% 38%, 46% 20%); }
.seal-ring {
  position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  border: 2px solid #e2c27a; box-shadow: 0 0 18px #cfdcc999;
}
.seal-crumb {
  position: absolute; left: 50%; top: 50%; width: 7px; height: 6px; margin: -3px 0 0 -3px; border-radius: 40% 60% 45% 55%;
  background: radial-gradient(circle at 35% 30%, #f3dc9c, #b8892f 70%); pointer-events: none;
}

/* ---------------------------------------------------------------
   "La nostra storia": di base card in colonna; con GSAP (.is-horizontal)
   la sezione si blocca e le card scorrono in orizzontale.
   --------------------------------------------------------------- */
.story { position: relative; overflow: hidden; }
.story-pin { position: relative; max-width: 1180px; margin: 0 auto; padding: 20px 30px 110px; }
.story-year, .story-line { display: none; }
.story-track { display: grid; gap: 22px; }
.story .story-card {
  position: relative; margin: 0; grid-row: auto; height: clamp(260px, 55vw, 420px); overflow: hidden;
  border-radius: 4px; background: var(--ink); box-shadow: 0 18px 40px #2f3a301f;
}
/* Foto e inquadratura arrivano dalla card stessa (--photo, --photo-pos in index.html). */
.story-card .photo-media {
  position: absolute; inset: -6% -8%; background-size: cover; will-change: transform;
  background-image: var(--photo); background-position: var(--photo-pos, center);
}
.story-card::after {
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(180deg, transparent 45%, #2d3a2fd9);
}
.story-card figcaption {
  position: absolute; left: 24px; right: 24px; bottom: 22px; z-index: 2; display: grid; gap: 4px; color: #fff;
}
.story-when { font: 700 11px "DM Sans"; letter-spacing: .22em; color: #dfe9da; }
.story-what { font: italic 600 clamp(21px, 2.4vw, 30px)/1.15 "Playfair Display"; }

.story.is-horizontal .story-pin {
  max-width: none; height: 100vh; height: 100svh; padding: 0;
  display: flex; flex-direction: column; justify-content: center;
}
.story.is-horizontal .section-heading {
  position: absolute; z-index: 2; margin: 0;
  top: clamp(70px, 12vh, 130px); left: max(30px, calc((100% - 1120px) / 2));
}
.story.is-horizontal .story-year {
  display: block; position: absolute; z-index: 0; right: -1vw; bottom: -3vh; margin: 0; pointer-events: none;
  font: 700 clamp(150px, 30vw, 440px)/.8 "Playfair Display"; letter-spacing: -.04em;
  font-variant-numeric: lining-nums tabular-nums; color: transparent; -webkit-text-stroke: 1.5px #d3dccd;
}
.story.is-horizontal .story-track {
  position: relative; z-index: 1; display: flex; align-items: center; width: max-content;
  gap: clamp(70px, 10vw, 160px); margin-top: 9vh; padding: 0 max(30px, calc((100vw - 1120px) / 2));
  will-change: transform;
}
.story.is-horizontal .story-card { flex: none; width: clamp(260px, 40vw, 560px); height: clamp(240px, 50vh, 470px); }
/* Sfalsamento ripetuto ogni 3 card (in linea, piu' in basso, piu' in alto): vale per qualsiasi numero di foto. */
.story.is-horizontal .story-card:nth-of-type(3n+2) { margin-top: 14vh; }
.story.is-horizontal .story-card:nth-of-type(3n) { margin-top: -8vh; }
.story.is-horizontal .story-line {
  display: block; position: absolute; left: 0; top: 0; z-index: 0; overflow: visible; pointer-events: none;
}
.story-line path { fill: none; stroke-linecap: round; }
.story-line-base { stroke: #bccab5; stroke-width: 1.5; stroke-dasharray: 1 9; }
.story-line-draw { stroke: var(--accent); stroke-width: 2; }
@media (max-width: 650px) {
  .story-pin { padding: 10px 20px 75px; }
  .story.is-horizontal .section-heading { top: 84px; left: 20px; }
  .story.is-horizontal .story-card { width: 74vw; height: 46svh; }
  .story.is-horizontal .story-card:nth-of-type(3n+2) { margin-top: 8svh; }
  .story.is-horizontal .story-card:nth-of-type(3n) { margin-top: -4svh; }
  .story.is-horizontal .story-track { gap: 18vw; margin-top: 12svh; padding: 0 13vw; }
  .story.is-horizontal .story-year { font-size: 42vw; bottom: 2svh; }
}

/* Sul telefono (.is-swipe, motion.js): le card si sfogliano col dito, la pagina non si blocca. */
.story.is-swipe .story-pin { max-width: none; padding: 10px 0 70px; }
.story.is-swipe .section-heading { position: relative; z-index: 2; margin: 0; padding: 0 20px; }
.story.is-swipe .story-year {
  display: block; position: absolute; z-index: 0; right: -2vw; bottom: 40px; margin: 0; pointer-events: none;
  font: 700 42vw/.8 "Playfair Display"; letter-spacing: -.04em;
  font-variant-numeric: lining-nums tabular-nums; color: transparent; -webkit-text-stroke: 1.5px #d3dccd;
}
.story.is-swipe .story-track {
  --card-w: min(76vw, 520px);
  position: relative; z-index: 1; display: flex; align-items: center; gap: 4vw;
  /* Margini laterali: la prima e l'ultima card si fermano al centro; sopra e sotto, spazio per lo sfalsamento. */
  padding: 7svh calc((100vw - var(--card-w)) / 2);
  overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; overscroll-behavior-x: contain;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.story.is-swipe .story-track::-webkit-scrollbar { display: none; }
.story.is-swipe .story-card {
  flex: none; width: var(--card-w); height: min(50svh, 470px);
  scroll-snap-align: center; scroll-snap-stop: always;
}
.story.is-swipe .story-card:nth-of-type(3n+2) { margin-top: 6svh; }
.story.is-swipe .story-card:nth-of-type(3n) { margin-top: -4svh; }
.story.is-swipe .story-line {
  display: block; position: absolute; left: 0; top: 0; z-index: 0; overflow: visible; pointer-events: none;
}
.story-dots { position: relative; z-index: 1; display: flex; justify-content: center; gap: 2px; }
.story-dots button { width: 30px; height: 30px; padding: 0; border: 0; background: none; cursor: pointer; }
.story-dots button::after {
  content: ""; display: block; width: 8px; height: 8px; margin: auto; border-radius: 999px;
  background: #bccab5; transition: width .35s ease, background-color .35s ease;
}
.story-dots button[aria-current="true"]::after { width: 22px; background: var(--accent); }
.hero h1 .hero-name, .hero h1 i { display: inline-block; }

/* Countdown a rulli (motion.js): ogni cifra scorre in verticale. */
.countdown b { display: flex; justify-content: center; line-height: 1.1; font-variant-numeric: lining-nums tabular-nums; }
/* .countdown span (styles.css) e' per le etichette: i rulli ereditano dalla cifra. */
.countdown b span { margin: 0; font-size: inherit; color: inherit; letter-spacing: 0; text-transform: none; }
.reel { display: inline-block; height: 1.1em; overflow: hidden; }
.reel-strip { display: block; will-change: transform; }
.reel-strip span { display: block; height: 1.1em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Percorso cerimonia -> festa (motion.js): linea tratteggiata che, arrivata, diventa due fedi. */
.event-grid.has-route { position: relative; padding-bottom: 120px; }
.route { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; z-index: 2; }
.route-path { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-dasharray: 2 9; }
.route-reveal { fill: none; stroke: #fff; stroke-width: 10; }
.route-dot { fill: var(--cream); stroke: var(--accent); stroke-width: 2; }
.route-ring-line { fill: none; stroke: var(--accent); stroke-width: 1.5; }
/* Fascia piena del colore di fondo (piu' un filo di bordo): nasconde la fede che passa dietro. */
.route-ring-band { fill: var(--cream); fill-rule: evenodd; stroke: var(--cream); stroke-width: 2.5; }
@media (max-width: 650px) {
  .event-grid.has-route { row-gap: 150px; padding-bottom: 0; }
}

/* Aeroplanino della luna di miele (motion.js). */
.honeymoon { position: relative; }
/* Dimensione zero finche' non vola: un svg di default (300x150) sporgerebbe dalla pagina. */
.flight { position: absolute; top: 0; left: 0; width: 0; height: 0; z-index: 5; overflow: hidden; pointer-events: none; }
.flight-path { fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linecap: round; stroke-dasharray: 2 8; }
.flight-reveal { fill: none; stroke: #fff; stroke-width: 8; }
.plane path { fill: #fefefc; stroke: var(--accent); stroke-width: 1.4; stroke-linejoin: round; }
.plane path + path { fill: #eef1e9; }

/* RSVP: stato di invio del bottone e coriandoli (motion.js). */
.rsvp .button { position: relative; justify-self: center; }
.rsvp .button.is-sending { transition: none; cursor: default; }
.btn-label { display: inline-flex; gap: 18px; align-items: center; }
.btn-status {
  position: absolute; left: 50%; top: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px;
  color: var(--page-text); opacity: 0; visibility: hidden; overflow: visible;
}
.btn-ring, .btn-check { fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.btn-ring { stroke: currentColor; }
.btn-check { stroke: currentColor; }
.confetti { position: fixed; inset: 0; z-index: 70; overflow: hidden; pointer-events: none; perspective: 600px; }
.confetti i { position: absolute; left: 0; top: 0; border-radius: 2px; }
.confetti i.petal { border-radius: 60% 0 60% 0; }

/* Info pratiche: icone a linea disegnate da motion.js (DrawSVG). */
.info-icon { display: inline-block; }
.info-icon svg {
  display: block; width: 56px; height: 56px; overflow: visible;
  fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}

/* Sfondo a tinte (motion.js): l'RSVP lascia vedere il colore del body che sfuma. */
.has-tint .rsvp { background: transparent; }

/* RSVP: il "Non ci sara'" che scappa (motion.js) diventa un bottoncino staccato. */
.attendance-toggle button { position: relative; }
.attendance-toggle button.is-fleeing {
  z-index: 3; background: #fff; color: #a3372a; box-shadow: 0 8px 20px #2f3a302e; padding: 0 14px;
}

/* Countdown: sfondo in un livello proprio, piu' alto della sezione, che scorre in parallasse
   con transform (motion.js) senza scoprire i bordi. */
.countdown-wrap.has-bg-layer { background: var(--ink); }
.countdown-bg {
  position: absolute; inset: -25% 0; z-index: 0; pointer-events: none; will-change: transform;
  background: url('resources/countdown-bg.jpg') center / cover;
}
/* Su schermi stretti "cover" ritaglia i bordi dell'immagine e con loro i due archi:
   li ridisegniamo qui, agli angoli della sezione (il livello sborda del 25% sopra e sotto). */
@media (max-width: 650px) {
  .countdown-bg::before, .countdown-bg::after {
    content: ""; position: absolute; width: 300px; aspect-ratio: 1;
    border: 1px solid #ffffff1c; border-radius: 50%; transform: translate(-50%, -50%);
  }
  .countdown-bg::before { left: 0; top: 25%; }
  .countdown-bg::after { left: 100%; top: 75%; }
}
