/* ---- Design tokens (from logo palette) ---- */
:root {
  --bg: #f5f0ea;
  --gold: #b8922a;
  --blue: #8fa8bb;
  --text: #3d2b1f;
  /* #9c8b7d was 2.9:1 on --bg — below WCAG AA for body copy */
  --muted: #7a6a5c;
  --field-bg: #fbf8f4;
  --heading: #bd9271;
  --rule: rgba(184, 146, 42, 0.35);
  --serif: "Cormorant";
  --sans: "Cormorant";
}

*,
*::before,
*::after {
  box-sizing: border-box;
}


/* ---- Base (mobile-first, authored for 375px) ---- */
body {
  margin: 0;
  background-color: var(--bg);
  background-image: url("photos/background.png");
  background-repeat: repeat;
  color: var(--text);
  font-family: var(--sans);
  font-size: 20px;

  font-optical-sizing: auto;
  /* Cormorant is a display face: its 400 reads like a 300 elsewhere and goes
     hairline on phone screens. 500 is the legibility floor for body copy. */
  font-weight: 500;
  font-style: normal;

  line-height: 1.6;
  /* page-load fade-in: opacity only, no movement */
  opacity: 0;
  transition: opacity 400ms ease;
}
body.loaded {
  opacity: 1;
}
.grecaptcha-badge { visibility: hidden; }

/* "Conferma ora" jumps to the form without a page navigation. */
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

main {
  width: 100%;
  margin: 0 auto;
  padding: 0 20px;
}

.section {
  max-width: 680px;
  margin: 0 auto;
  padding: 32px 0;
  scroll-margin-top: 24px;
}

h2 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 2rem;
  line-height: 1.35em;
  text-align: center;
  color: var(--heading);
  margin: 0 0 16px;
}

a {
  color: var(--gold);
}

.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;
}

/* ---- Reveal on scroll (IntersectionObserver adds .in) ---- */
[data-reveal] {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 700ms ease, transform 700ms ease;
}
[data-reveal].in {
  opacity: 1;
  transform: none;
}
@media (prefers-reduced-motion: reduce) {
  [data-reveal] {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* ---- Hero ---- */
.hero {
  position: relative;
  overflow: hidden;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  color: #fff;
  /* shows through while the slides decode / if one fails to load */
  background: url("photos/background.png") center / cover no-repeat;
}
.hero__slides {
  position: absolute;
  inset: 0;
}
.hero__slide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 2000ms ease-in-out;
}
.hero__slide.is-active {
  opacity: 1;
}
/* darkening wash, above the photos so the title stays readable */
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(rgba(40, 28, 20, 0.3), rgba(40, 28, 20, 0.45));
}
.hero__inner {
  position: relative;
  z-index: 1;
}
.hero__title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 3.2rem;
  line-height: 1.15;
  letter-spacing: 0.02em;
  margin: 0;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.45);
}
.hero__title .amp {
  font-style: italic;
  font-weight: 400;
}
.hero__sub {
  margin: 14px 0 0;
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.45em;
  /* letter-spacing pads the right side; pull it back to stay optically centred */
  text-indent: 0.45em;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
}

/* ---- Hero scroll cue ---- */
.hero__scroll {
  position: absolute;
  left: 50%;
  bottom: 20px;
  z-index: 1;
  transform: translateX(-50%);
  opacity: 0.7;
  transition: opacity 500ms ease;
}
.hero__scroll.is-hidden {
  opacity: 0;
  pointer-events: none;
}
.hero__scroll-chevron {
  display: block;
  width: 14px;
  height: 14px;
  border-right: 2px solid var(--bg);
  border-bottom: 2px solid var(--bg);
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.45));
  transform: rotate(45deg);
  animation: hero-scroll-bounce 2.2s ease-in-out infinite;
}
@keyframes hero-scroll-bounce {
  0%, 100% { transform: rotate(45deg) translate(0, 0); }
  50% { transform: rotate(45deg) translate(5px, 5px); }
}
@media (prefers-reduced-motion: reduce) {
  .hero__scroll-chevron { animation: none; }
}

/* ---- Framed card ---- */
.frame {
  position: relative;
  padding: 44px 24px 32px;
  background: rgba(251, 248, 244, 0.72);
  border: 1px solid var(--rule);
  text-align: center;
}
/* gold lozenge ornament straddling the top edge.
   The opaque fill (= --bg) is what hides the border line behind it. */
.frame::before {
  content: "";
  position: absolute;
  top: -14px;
  left: 50%;
  width: 28px;
  height: 28px;
  margin-left: -14px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M16 1 31 16 16 31 1 16Z' fill='%23f5f0ea' stroke='%23b8922a'/%3E%3Cpath d='M16 7 25 16 16 25 7 16Z' fill='none' stroke='%23b8922a' stroke-width='.75' opacity='.5'/%3E%3Ccircle cx='16' cy='16' r='2.2' fill='%23b8922a'/%3E%3C/svg%3E") center / contain no-repeat;
}

.eyebrow {
  margin: 0 0 4px;
  font-style: italic;
  font-weight: 400;
  font-size: 1.5rem;
  color: var(--gold);
}
.lede {
  margin: 0 0 8px;
  font-style: italic;
  color: var(--muted);
}

/* ---- Info blocks (Quando / Dove / RSVP) ---- */
.info {
  padding: 24px 0 0;
}
.info h3 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.4rem;
  margin: 0 0 4px;
  color: var(--text);
}
.info p {
  margin: 0 0 10px;
}
.ornament {
  display: block;
  width: 9px;
  height: 9px;
  margin: 0 auto 14px;
  background: var(--gold);
  transform: rotate(45deg);
}

.link-caps {
  display: inline-block;
  font-size: 1rem;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
  padding-bottom: 2px;
}
.link-caps:hover {
  opacity: 0.75;
}

/* ---- Timeline ---- */
.timeline-section .eyebrow,
.timeline-section h2 {
  text-align: center;
}
.timeline {
  list-style: none;
  margin: 24px 0 0;
  padding: 0 0 0 28px;
  border-left: 1px solid var(--rule);
}
.timeline__item {
  position: relative;
  padding: 0 0 36px;
}
.timeline__item:last-child {
  padding-bottom: 0;
}
.timeline__item::before {
  content: "";
  position: absolute;
  left: -33px;
  top: 10px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--gold);
}
.timeline__time {
  margin: 0;
  font-size: 1.25rem;
  font-style: italic;
  color: var(--gold);
}
.timeline__title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.5rem;
  margin: 0 0 4px;
}
.timeline__text {
  margin: 0;
  font-size: 1.1rem;
  color: var(--muted);
}

/* ---- RSVP form ---- */
/* Form controls don't inherit font from body — they'd fall back to Cormorant 400. */
input,
textarea,
button {
  font-weight: 500;
}
fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}
.locked {
  margin: 8px 0 0;
  font-style: italic;
  color: var(--muted);
}
#rsvp-form {
  margin-top: 24px;
  text-align: left;
}

/* One row per person named in the token — name is text, never an input. */
.guest {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 0;
  border-bottom: 1px solid rgba(184, 146, 42, 0.25);
}
.guest__name {
  font-family: var(--serif);
  font-size: 1.25rem;
  line-height: 1.2;
}
.guest__kind {
  font-size: 0.9rem;
  color: var(--muted);
  letter-spacing: 0.05em;
}

.field {
  margin: 16px 0 0;
}
.field label {
  display: block;
  font-size: 0.85rem;
  letter-spacing: 0.03em;
  margin: 0 0 6px;
}
input[type="email"],
input[type="text"],
input[type="password"],
select,
textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  background: var(--field-bg);
  border: 1px solid rgba(184, 146, 42, 0.45);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 1rem;
}
textarea {
  min-height: 96px;
  resize: vertical;
}
input:focus,
textarea:focus {
  outline: none;
  border-color: var(--gold);
  border-width: 1.5px;
}
.error {
  min-height: 1em;
  margin: 4px 0 0;
  font-size: 0.8rem;
  color: #9a3b2f;
}

/* Presente / assente toggle */
.pill-toggle {
  display: inline-flex;
  border: 1px solid rgba(184, 146, 42, 0.45);
  border-radius: 999px;
  overflow: hidden;
  align-self: flex-start;
}
.pill {
  min-height: 48px;
  padding: 0 22px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.95rem;
  cursor: pointer;
}
.pill.active {
  background: var(--gold);
  color: var(--bg);
}

.submit {
  width: 100%;
  min-height: 52px;
  margin-top: 24px;
  background: var(--gold);
  border: 0;
  border-radius: 4px;
  color: var(--bg);
  font-family: var(--sans);
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  cursor: pointer;
}
.submit:disabled {
  opacity: 0.6;
  cursor: default;
}

.status {
  margin: 16px 0 0;
  text-align: center;
  font-size: 0.95rem;
}
.status.ok {
  color: var(--gold);
}
.status.ko {
  color: #9a3b2f;
}

/* ---- Viaggio di nozze ---- */
.iban {
  margin: 24px 0 16px;
  padding: 18px 12px;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.iban dt {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}
.iban dd {
  margin: 2px 0 12px;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
}
.iban dd:last-child {
  margin-bottom: 0;
}
/* one tap selects the whole IBAN on a phone */
.selectable {
  user-select: all;
}
.thanks {
  margin: 0;
  font-style: italic;
  color: var(--muted);
}

/* ---- Divider ---- */
.divider { text-align: center; padding: 0; }
.divider__img { width: 100%; max-width: 600px; opacity: 0.65; }

/* ---- Floating RSVP CTA ---- */
/* Visible only between "scrolled past hero" and "has seen #rsvp" — see
   initRsvpCta() in main.js. visibility (delayed) keeps it out of the tab
   order and off screen readers while hidden; opacity alone wouldn't. */
#rsvp-cta {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  z-index: 500; /* above content, below #spinner's 9999 */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 26px;
  max-width: calc(100vw - 40px);
  background: var(--gold);
  color: var(--bg);
  font-family: var(--sans);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
  text-decoration: none;
  white-space: normal;
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(61, 43, 31, 0.3);
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 10px);
  transition: opacity 500ms ease, transform 500ms ease, visibility 0s linear 500ms;
}
#rsvp-cta.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
  transition: opacity 500ms ease, transform 500ms ease, visibility 0s linear 0s;
}
#rsvp-cta:hover {
  opacity: 0.75;
}
@media (prefers-reduced-motion: reduce) {
  #rsvp-cta {
    transform: translate(-50%, 0);
    transition: opacity 300ms ease, visibility 0s linear 300ms;
  }
  #rsvp-cta.is-visible {
    transition: opacity 300ms ease, visibility 0s linear 0s;
  }
}

/* ---- Desktop (progressive enhancement) ---- */
@media (min-width: 768px) {
  .section { padding: 56px 0; }
  .frame { padding: 56px 48px 44px; }
  .hero__title { font-size: 4.6rem; }
  .hero__sub { font-size: 0.95rem; }
  .hero__scroll { bottom: 32px; }
  .hero__scroll-chevron { width: 18px; height: 18px; border-width: 3px; }

  /* timeline alternates around a centre rail */
  .timeline {
    position: relative;
    max-width: 720px;
    margin: 32px auto 0;
    padding: 0;
    border-left: 0;
  }
  .timeline::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 6px;
    bottom: 6px;
    width: 1px;
    background: var(--rule);
  }
  .timeline__item {
    width: 50%;
    padding: 0 40px 48px 0;
    text-align: right;
  }
  .timeline__item:nth-child(even) {
    margin-left: 50%;
    padding: 0 0 48px 40px;
    text-align: left;
  }
  .timeline__item::before {
    left: auto;
    right: -5px;
  }
  .timeline__item:nth-child(even)::before {
    right: auto;
    left: -5px;
  }

  .guest {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
  }

  #rsvp-cta { bottom: 32px; }
}

/* ---- Fullscreen spinner overlay ---- */
#spinner {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 9999;
  align-items: center;
  justify-content: center;
}
#spinner.active { display: flex; }
#spinner::after {
  content: "";
  width: 56px;
  height: 56px;
  border: 5px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
