/* ============================================================
   Foglio di stile principale — mobile-first, accessibile (WCAG AA)
   Pubblico tipico: pellegrini 50+, spesso poco tecnologici.
   Quindi: testi grandi, contrasti alti, bersagli touch generosi.
   ============================================================ */

/* --- Variabili: tutta la palette in un posto solo --- */
:root {
  --sfondo: #faf7f2;        /* crema caldo */
  --carta: #ffffff;         /* sfondo delle card */
  --testo: #2b2118;         /* marrone quasi nero: contrasto ~13:1 */
  --testo-soft: #5c4f43;    /* per testi secondari: contrasto ~6:1 */
  --primario: #7b4a2d;      /* marrone francescano */
  --primario-scuro: #5e3820;
  --bordo: #e6ddd1;
  --focus: #1a56c4;         /* anello di focus ben visibile */
  --raggio: 14px;
}

/* --- Reset essenziale --- */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
img, svg { display: block; max-width: 100%; }

/* --- Base tipografica ---
   112.5% di 16px = 18px: testo base grande, e chi ha ingrandito i
   caratteri nel telefono li vede ancora più grandi (unità relative). */
html { font-size: 112.5%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--sfondo);
  color: var(--testo);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main {
  flex: 1;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 1rem;
}
h1 { font-size: 1.55rem; line-height: 1.25; margin: 0.5rem 0; }
h2 { font-size: 1.25rem; }
a { color: var(--primario); }

/* Focus visibile per chi naviga da tastiera o con lettori di schermo */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

/* --- Link "salta al contenuto" (visibile solo quando riceve focus) --- */
.skip {
  position: absolute;
  left: -9999px;
  background: var(--primario);
  color: #fff;
  padding: 0.75rem 1rem;
  border-radius: var(--raggio);
}
.skip:focus { left: 0.5rem; top: 0.5rem; z-index: 100; }

/* --- Testata --- */
.testata {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  background: var(--primario);
}
.brand {
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.05rem;
  padding: 0.5rem 0;            /* allarga il bersaglio touch */
}

/* --- Selettore lingua nella testata (<details>: funziona senza JS) --- */
.cambia-lingua { position: relative; }
.cambia-lingua summary {
  list-style: none;
  cursor: pointer;
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  padding: 0.5rem 1rem;
  min-height: 48px;             /* bersaglio touch minimo */
  display: flex;
  align-items: center;
}
.cambia-lingua summary::-webkit-details-marker { display: none; }
.cambia-lingua ul {
  position: absolute;
  right: 0;
  margin: 0.4rem 0 0;
  padding: 0.3rem;
  list-style: none;
  background: var(--carta);
  border: 1px solid var(--bordo);
  border-radius: var(--raggio);
  box-shadow: 0 6px 24px rgba(43, 33, 24, 0.18);
  min-width: 11rem;
  z-index: 50;
}
.cambia-lingua a {
  display: block;
  padding: 0.75rem 1rem;        /* ~48px di altezza */
  text-decoration: none;
  color: var(--testo);
  border-radius: 8px;
}
.cambia-lingua a:hover { background: var(--sfondo); }
.cambia-lingua a[aria-current="true"] { font-weight: 700; color: var(--primario); }

/* --- Sezione di benvenuto --- */
.benvenuto { text-align: center; padding: 0.5rem 0 1rem; }
.benvenuto p { color: var(--testo-soft); margin: 0.25rem 0 0; }

/* --- Griglia delle scorciatoie in home --- */
.griglia {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}
.scheda {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 7rem;             /* bersaglio enorme: impossibile sbagliare */
  padding: 1rem 0.5rem;
  background: var(--carta);
  border: 1px solid var(--bordo);
  border-radius: var(--raggio);
  text-decoration: none;
  color: var(--testo);
  font-weight: 600;
  text-align: center;
  box-shadow: 0 1px 4px rgba(43, 33, 24, 0.06);
}
.scheda:active { transform: scale(0.985); }
.scheda svg {
  width: 34px;
  height: 34px;
  fill: none;
  stroke: var(--primario);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --- Cartello "in costruzione" e bottoni --- */
.cartello {
  background: var(--carta);
  border: 1px solid var(--bordo);
  border-radius: var(--raggio);
  padding: 1.25rem;
}
.bottone {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.6rem 1.4rem;
  background: var(--primario);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  border-radius: 999px;
}
.bottone:hover { background: var(--primario-scuro); }

/* --- Piè di pagina --- */
.pie {
  text-align: center;
  color: var(--testo-soft);
  font-size: 0.85rem;
  padding: 1rem;
  border-top: 1px solid var(--bordo);
  margin-top: 1.5rem;
}
.pie-promo { margin: 0.2rem 0 0.6rem; font-size: 0.95rem; }
.pie-mail {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 48px;             /* bersaglio touch pieno anche nel footer */
  padding: 0.4rem 1.2rem;
  margin-bottom: 0.8rem;
  border: 2px solid var(--primario);
  border-radius: 999px;
  color: var(--primario);
  font-weight: 700;
  text-decoration: none;
  background: var(--carta);
}
.pie-mail svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.pie-mail:hover, .pie-mail:focus-visible { background: var(--primario); color: #fff; }

/* --- Selettore lingua a tutto schermo (primo accesso) --- */
.velo {
  position: fixed;
  inset: 0;
  background: rgba(43, 33, 24, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 200;
}
.velo[hidden] { display: none; }
.dialogo {
  background: var(--carta);
  border-radius: var(--raggio);
  padding: 1.5rem;
  width: 100%;
  max-width: 24rem;
  text-align: center;
}
.dialogo h2 { margin-top: 0; }
.bottone-lingua {
  display: block;
  margin: 0.6rem 0;
  padding: 0.8rem;              /* ben oltre i 48px */
  border: 2px solid var(--bordo);
  border-radius: var(--raggio);
  text-decoration: none;
  color: var(--testo);
  font-size: 1.1rem;
  font-weight: 600;
}
.bottone-lingua:hover, .bottone-lingua:focus-visible {
  border-color: var(--primario);
  background: var(--sfondo);
}

/* --- Pagina orari --- */
.sezione-orari { margin: 1.4rem 0; }
.lista-orari {
  list-style: none;
  margin: 0.5rem 0;
  padding: 0;
  background: var(--carta);
  border: 1px solid var(--bordo);
  border-radius: var(--raggio);
  overflow: hidden;
}
.lista-orari li {
  display: flex;
  gap: 0.9rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--bordo);
  align-items: baseline;
}
.lista-orari li:last-child { border-bottom: 0; }
.lista-orari .ora {
  font-weight: 700;
  font-variant-numeric: tabular-nums; /* le cifre si allineano in colonna */
  min-width: 5.2rem;
}
.lista-orari .dettaglio { flex: 1; }
.lista-orari .nota { display: block; color: var(--testo-soft); }
.verifica-globale { color: #2e7d32; font-weight: 600; }
.disclaimer { color: var(--testo-soft); font-size: 0.9rem; margin-top: 1.5rem; }

/* --- Chip / etichette --- */
.chip {
  display: inline-block;
  background: var(--sfondo);
  border: 1px solid var(--bordo);
  border-radius: 999px;
  padding: 1px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  vertical-align: middle;
}
.chip-attenzione { background: #fff0d6; border-color: #e0b96a; color: #7a5410; }
.chip-ok { background: #e6f3e6; border-color: #9cc89c; color: #205c23; }

/* --- Pagine luoghi --- */
.gruppo-luoghi { margin: 1.4rem 0; }
.lista-luoghi { display: grid; gap: 0.7rem; }
.scheda-luogo {
  display: block;
  background: var(--carta);
  border: 1px solid var(--bordo);
  border-radius: var(--raggio);
  padding: 0.9rem 1rem;
  text-decoration: none;
  color: var(--testo);
}
.scheda-luogo .breve { display: block; color: var(--testo-soft); margin-top: 0.2rem; }
.briciole { margin: 0.4rem 0 0.8rem; }
.sottotitolo { margin: 0.2rem 0 0.8rem; }
.foto-segnaposto {
  background: var(--bordo);
  color: var(--testo-soft);
  border-radius: var(--raggio);
  display: flex;
  align-items: center;
  justify-content: center;
  height: 10rem;
  margin: 0.8rem 0;
}
.foto-segnaposto svg { width: 48px; height: 48px; }
.azioni { display: flex; gap: 0.7rem; flex-wrap: wrap; margin: 1.2rem 0; }
.bottone-secondario { background: var(--carta); color: var(--primario); border: 2px solid var(--primario); }
.bottone-secondario:hover { background: var(--sfondo); }
.cartello h2 { margin-top: 0; }

/* --- Sezione "oggi" in home e meteo --- */
.oggi { margin: 0 0 1.4rem; }
.oggi .bottone-secondario { width: 100%; }
.lista-orari.compatta li { padding: 0.55rem 1rem; }
.meteo {
  background: var(--carta);
  border: 1px solid var(--bordo);
  border-radius: var(--raggio);
  padding: 0.8rem 1rem;
  margin-bottom: 1.2rem;
}
.meteo h2 { margin: 0 0 0.3rem; font-size: 1rem; color: var(--testo-soft); }
.meteo p { margin: 0; font-size: 1.15rem; }
.meteo-icona { font-size: 1.5rem; vertical-align: middle; }
.blocco-info { margin: 1.4rem 0; }
.numeri-utili { list-style: none; margin: 0.5rem 0; padding: 0; }
.numeri-utili li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  background: var(--carta);
  border: 1px solid var(--bordo);
  border-radius: var(--raggio);
  padding: 0.6rem 1rem;
  margin-bottom: 0.5rem;
}

/* --- Directory attività --- */
.chip-partner {
  background: #fdf3d7;
  border-color: #d4a514;
  color: #6b5208;
}
.scheda-partner { border: 2px solid #d4a514; }
.avviso-demo {
  background: #eef3fb;
  border: 1px dashed #9db8dd;
  border-radius: var(--raggio);
  padding: 0.6rem 1rem;
  color: #2c4a76;
  font-size: 0.9rem;
}

/* --- Coupon: il box nella scheda attività --- */
.coupon-box {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: #fdf3d7;
  border: 2px dashed #d4a514;
  border-radius: var(--raggio);
  padding: 0.9rem 1.1rem;
  text-decoration: none;
  color: var(--testo);
  margin: 1rem 0;
}
.coupon-box-sconto { font-size: 1.8rem; font-weight: 800; color: #6b5208; }
.coupon-box-testo strong { display: block; }

/* --- Coupon: la pagina a schermo intero --- */
.coupon { text-align: center; }
.coupon-testa { margin-bottom: 1rem; }
.coupon-attivita { color: var(--testo-soft); margin: 0; }
.coupon-sconto {
  font-size: 4rem;
  font-weight: 800;
  color: var(--primario);
  margin: 0.1rem 0;
  line-height: 1.1;
}
.coupon-titolo { margin: 0.2rem 0; font-size: 1.3rem; }
.coupon-condizioni, .coupon-scadenza { color: var(--testo-soft); margin: 0.2rem 0; }
.bottone-grande { font-size: 1.2rem; padding: 0.9rem 2rem; width: 100%; }
.coupon-countdown { font-size: 1.3rem; }
.coupon-countdown strong { font-variant-numeric: tabular-nums; font-size: 1.7rem; }
.coupon-istruzione { color: var(--testo-soft); }
.coupon-esercente { text-align: center; margin-top: 1.2rem; }
.coupon-pin {
  display: block;
  margin: 0.6rem auto;
  font-size: 2rem;
  letter-spacing: 0.6rem;
  text-align: center;
  width: 11rem;
  padding: 0.4rem;
  border: 2px solid var(--bordo);
  border-radius: var(--raggio);
}
.coupon-errore { color: #b03030; font-weight: 600; }
.coupon-validato {
  background: #1d7a2c;
  color: #fff;
  border-radius: var(--raggio);
  padding: 2.5rem 1rem;
}
.coupon-spunta { font-size: 4rem; margin: 0; }
.coupon-validato-testo { font-size: 1.5rem; font-weight: 700; margin: 0.4rem 0; }
.coupon-validato-attivita { opacity: 0.9; margin: 0; }

/* --- Mappa --- */
.mappa-grande { height: 65vh; min-height: 320px; border-radius: var(--raggio); border: 1px solid var(--bordo); }
.mappa-media { height: 320px; border-radius: var(--raggio); border: 1px solid var(--bordo); margin: 0.8rem 0 0.2rem; }
.filtri-mappa { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0.6rem 0 0.8rem; }
.chip-filtro { cursor: pointer; padding: 0.45rem 0.9rem; font-size: 0.9rem; }
.chip-filtro input { accent-color: var(--primario); margin-right: 0.3rem; }
#mappa-offline img { width: 100%; border-radius: var(--raggio); border: 1px solid var(--bordo); background: #fff; }

/* Marcatore numerato delle tappe (usato da mappa.js nei percorsi) */
.marcatore-tappa {
  background: var(--primario);
  color: #fff;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(43, 33, 24, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
}

/* --- Percorsi --- */
.sottotitolo-pagina { color: var(--testo-soft); margin-top: -0.3rem; }
.dati-percorso { display: block; margin-top: 0.4rem; font-size: 0.9rem; color: var(--testo-soft); }
.tappe { padding-left: 0; counter-reset: tappa; list-style: none; }
.tappe li {
  counter-increment: tappa;
  background: var(--carta);
  border: 1px solid var(--bordo);
  border-radius: var(--raggio);
  padding: 0.8rem 1rem 0.8rem 3.2rem;
  margin-bottom: 0.5rem;
  position: relative;
}
.tappe li::before {
  content: counter(tappa);
  position: absolute;
  left: 0.8rem;
  top: 0.8rem;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  background: var(--primario);
  color: #fff;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
}
.tappe a { font-weight: 600; }
.tappe .nota { display: block; color: var(--testo-soft); margin-top: 0.15rem; }

/* --- Immagini: hero, galleria, foto dei luoghi --- */
.hero {
  position: relative;
  border-radius: var(--raggio);
  overflow: hidden;
  margin: 0.2rem 0 1.2rem;
  box-shadow: 0 2px 12px rgba(43, 33, 24, 0.14);
}
.hero-img {
  width: 100%;
  height: clamp(180px, 42vw, 300px);
  object-fit: cover;
}
.hero-testo {
  position: absolute;
  inset: auto 0 0 0;
  padding: 1.6rem 1.1rem 1rem;
  /* Gradiente scuro in basso: il titolo resta leggibile su qualunque foto */
  background: linear-gradient(to top, rgba(43, 33, 24, 0.82), rgba(43, 33, 24, 0.32) 55%, transparent);
}
.hero-testo h1 { margin: 0; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45); }
.hero-testo p { margin: 0.25rem 0 0; color: #fff; opacity: 0.95; }

/* Foto a tutta larghezza nella scheda del luogo */
.foto-luogo {
  width: 100%;
  height: clamp(200px, 50vw, 320px);
  object-fit: cover;
  border-radius: var(--raggio);
  margin: 0.8rem 0;
  border: 1px solid var(--bordo);
}

/* Galleria "Scopri il santuario" sulla home */
.galleria { margin: 1.8rem 0 0.5rem; }
.galleria h2 { margin-bottom: 0.7rem; }
.galleria-griglia { display: grid; grid-template-columns: 1fr; gap: 0.7rem; }
.tassello {
  position: relative;
  display: block;
  border-radius: var(--raggio);
  overflow: hidden;
  text-decoration: none;
  box-shadow: 0 1px 4px rgba(43, 33, 24, 0.1);
}
.tassello img { width: 100%; height: 160px; object-fit: cover; }
.tassello span {
  position: absolute;
  inset: auto 0 0 0;
  padding: 1.6rem 0.8rem 0.6rem;
  color: #fff;
  font-weight: 700;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  background: linear-gradient(to top, rgba(43, 33, 24, 0.82), transparent);
}
.tassello:active { transform: scale(0.99); }

/* Card del luogo con miniatura (lista luoghi) */
.scheda-luogo.con-foto { display: flex; align-items: stretch; gap: 0; padding: 0; overflow: hidden; }
.scheda-luogo-foto { width: 40%; max-width: 170px; object-fit: cover; }
.scheda-luogo.con-foto .scheda-luogo-testo { padding: 0.85rem 1rem; align-self: center; }

/* --- Schermi più larghi (tablet/desktop): 4 colonne --- */
@media (min-width: 600px) {
  .griglia { grid-template-columns: repeat(4, 1fr); }
  .lista-luoghi { grid-template-columns: 1fr 1fr; }
  .galleria-griglia { grid-template-columns: repeat(3, 1fr); }
}

/* ============================================================
   Animazioni — sobrie, brevi, mai indispensabili.
   Tutte dentro prefers-reduced-motion: chi ha chiesto al telefono
   meno movimento riceve l'app perfettamente statica di prima.
   ============================================================ */

/* Dissolvenza tra le pagine (View Transitions: attiva solo dove supportata,
   gli altri browser ignorano la regola senza alcun danno) */
@view-transition { navigation: auto; }

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }

  /* Il vocabolario: due movimenti soli, riusati ovunque (coerenza) */
  @keyframes salita {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: none; }
  }
  @keyframes comparsa { from { opacity: 0; } }

  /* Hero: la foto "respira" con uno zoom lentissimo, il titolo sale */
  .hero-img { animation: respiro 22s ease-out both; }
  @keyframes respiro { from { transform: scale(1.07); } to { transform: scale(1); } }
  .hero-testo h1 { animation: salita 0.7s ease-out both; }
  .hero-testo p  { animation: salita 0.7s ease-out 0.15s both; }

  /* Le scorciatoie della home entrano una dopo l'altra (scalino di 50 ms) */
  .griglia .scheda { animation: salita 0.45s ease-out backwards; }
  .griglia .scheda:nth-child(2) { animation-delay: 0.05s; }
  .griglia .scheda:nth-child(3) { animation-delay: 0.10s; }
  .griglia .scheda:nth-child(4) { animation-delay: 0.15s; }
  .griglia .scheda:nth-child(5) { animation-delay: 0.20s; }
  .griglia .scheda:nth-child(6) { animation-delay: 0.25s; }
  .griglia .scheda:nth-child(7) { animation-delay: 0.30s; }
  .griglia .scheda:nth-child(8) { animation-delay: 0.35s; }

  /* Vita sotto il dito e il mouse: card che si sollevano, icone vive */
  .scheda, .scheda-luogo, .tassello, .bottone, .coupon-box, .pie-mail {
    transition: transform 0.18s ease, box-shadow 0.18s ease,
                background-color 0.18s ease, color 0.18s ease;
  }
  .scheda:hover, .scheda:focus-visible {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(43, 33, 24, 0.13);
  }
  .scheda svg { transition: transform 0.18s ease; }
  .scheda:hover svg, .scheda:focus-visible svg { transform: scale(1.15) rotate(-4deg); }
  .scheda-luogo:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(43, 33, 24, 0.1); }
  .bottone:hover { transform: translateY(-1px); }
  .coupon-box:hover { transform: scale(1.015); }

  /* Le foto della galleria si avvicinano dolcemente */
  .tassello img { transition: transform 0.4s ease; }
  .tassello:hover img, .tassello:focus-visible img { transform: scale(1.06); }
  .tassello:hover, .tassello:focus-visible { box-shadow: 0 6px 18px rgba(43, 33, 24, 0.18); }

  /* Comparsa dolce durante lo scorrimento (le classi le mette app.js:
     senza JavaScript nessun elemento resta mai nascosto) */
  .rivela { opacity: 0; transform: translateY(16px); transition: opacity 0.55s ease, transform 0.55s ease; }
  .rivela.visibile { opacity: 1; transform: none; }

  /* Il selettore lingua del primo accesso appare con dolcezza */
  .velo { animation: comparsa 0.25s ease-out; }
  .dialogo { animation: salita 0.3s ease-out; }

  /* Spunta verde del coupon validato: un piccolo applauso */
  .coupon-spunta { animation: applauso 0.5s cubic-bezier(0.3, 1.6, 0.5, 1) both; }
  @keyframes applauso { from { transform: scale(0); } }
}
