/* =========================================================================
   Chiesa di Pandino — Pagina "Album" (album fotografico singolo)
   Stili specifici di questa pagina. I token :root sono definiti in style.css.
   Riproduce il design Album.dc.html: testata album + galleria masonry +
   lightbox a schermo intero.
   ========================================================================= */

/* ---- Testata album ---------------------------------------------------- */
.album-head {
  background: linear-gradient(180deg, #fbeede 0%, var(--bg) 100%);
  border-bottom: 1px solid rgba(38, 48, 58, 0.06);
}
.album-head .container {
  padding-top: 34px;
  padding-bottom: 40px;
}

.album-head__back {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
}
.album-head__back:hover { text-decoration: underline; }

.album-head__row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  margin-top: 22px;
}

.album-head__meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.album-head__badge {
  background: #fbefe2;
  color: var(--accent);
  padding: 5px 13px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.album-head__period {
  font-size: 13.5px;
  color: var(--muted-2);
  font-weight: 600;
}
.album-head__title {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: clamp(34px, 6vw, 46px);
  line-height: 1.04;
  margin: 0;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.album-head__actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.album-pill {
  padding: 11px 18px;
  border-radius: var(--r-pill);
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}
.album-pill--count {
  background: var(--surface);
  border: 1px solid rgba(38, 48, 58, 0.12);
  color: var(--text);
}
.album-pill--locked {
  background: #3e4247;
  color: #fff;
  gap: 8px;
}
.album-pill--locked svg { width: 16px; height: 16px; }

/* Chi è entrato: nome + "esci". Su un dispositivo condiviso serve poterlo fare
   senza chiudere il browser. */
.album-pill--chi {
  background: var(--primary-tint);
  border: 1px solid var(--primary-line);
  color: var(--primary);
  gap: 10px;
}
.album-pill__esci {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  font-weight: 700;
  color: var(--primary);
  text-decoration: underline;
  cursor: pointer;
}

/* ---- Album riservato: stato bloccato ---------------------------------- */
.album-locked {
  max-width: 560px;
  margin: 26px auto 40px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 40px 28px;
}
.album-locked__icona {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary-tint);
  color: var(--primary);
  margin-bottom: 18px;
}
.album-locked__icona svg { width: 26px; height: 26px; }
.album-locked__tit {
  font-family: var(--font-head);
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 10px;
}
.album-locked__testo {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
  margin: 0 0 22px;
}

/* =======================================================================
   MODAL DI ACCESSO (credenziali GIIN)
   Due colonne su schermi larghi, una sola impilata su telefono.
   L'HTML ha il MODULO prima e l'informativa dopo, così da telefono si vede
   subito email e password; qui sotto, da 720px in su, `order` rimette
   l'informativa a sinistra come nel disegno.
   ======================================================================= */
.accesso {
  padding: 0;
  border: 0;
  background: transparent;
  max-width: min(940px, calc(100vw - 32px));
  width: 100%;
  max-height: calc(100vh - 32px);
  overflow: visible;
}
.accesso::backdrop {
  background: rgba(31, 41, 51, 0.62);
}
/* Fallback per i browser senza <dialog>: accesso-album.js aggiunge .is-open. */
.accesso:not([open]).is-open {
  display: block;
  position: fixed;
  inset: 16px;
  margin: auto;
  z-index: 120;
}

.accesso__box {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  background: var(--surface);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(31, 41, 51, 0.28);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  text-align: left;
}

.accesso__x {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.accesso__x:hover { background: #ececec; color: var(--ink); }
.accesso__x svg { width: 16px; height: 16px; }

/* ---- colonna modulo ---- */
.accesso__form {
  padding: 34px 28px 30px;
  background: var(--surface);
}
.accesso__logo {
  display: block;
  max-width: 260px;
  width: 100%;
  height: auto;
  margin: 0 auto 26px;
}
.accesso__logo-txt {
  text-align: center;
  font-family: var(--font-head);
  font-size: 18px;
  color: var(--ink);
  margin: 0 0 26px;
}
/* Riga guida sopra i campi: il modal si apre da solo, quindi questa è la prima
   frase che il genitore legge. Tono informativo, non un avviso d'errore. */
.accesso__hint {
  margin: 0 0 18px;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  background: var(--primary-tint);
  border: 1px solid var(--primary-line);
  color: var(--primary);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
}

.accesso__campo { margin-bottom: 18px; }
.accesso__label {
  display: block;
  font-weight: 700;
  font-size: 14.5px;
  color: var(--ink);
  margin-bottom: 8px;
}
.accesso__input {
  width: 100%;
  box-sizing: border-box;
  /* 16px pieni: sotto i 16px iOS ingrandisce la pagina al focus. */
  font-size: 16px;
  padding: 13px 16px;
  border: 1px solid rgba(38, 48, 58, 0.18);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--ink-2);
}
.accesso__input:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  border-color: var(--primary);
}
.accesso__errore {
  margin: 0 0 14px;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  background: #fdecec;
  border: 1px solid #f3c9c9;
  color: #8c2b2b;
  font-size: 14px;
  line-height: 1.45;
}
.accesso__vai {
  width: 100%;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--primary);
  color: #fff;
  font-family: var(--font-head);
  font-size: 17px;
  font-weight: 700;
  padding: 15px 18px;
  cursor: pointer;
}
.accesso__vai:hover { background: var(--primary-dark); }
.accesso__vai[disabled] { opacity: 0.6; cursor: default; }

.accesso__recupero {
  margin-top: 24px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.55;
}
.accesso__recupero p { margin: 0; }
.accesso__recupero-tit {
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 4px !important;
}
.accesso__recupero strong { color: var(--primary); }

/* ---- colonna informativa ---- */
.accesso__info {
  padding: 30px 28px 34px;
  background: var(--primary-tint);
}
.accesso__occhiello {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 16px;
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--primary);
}
.accesso__occhiello svg { width: 16px; height: 16px; flex: none; }
.accesso__tit {
  font-family: var(--font-head);
  font-size: 27px;
  line-height: 1.15;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 22px;
}
.accesso__punti {
  margin: 0;
  padding-left: 22px;
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1.55;
}
.accesso__punti li { margin-bottom: 16px; }
.accesso__punti li:last-child { margin-bottom: 0; }

/* ---- telefono ---------------------------------------------------------
   Con le misure di sopra, in verticale le due colonne impilate arrivano a
   ~870px: su un telefono il modal riempie lo schermo da bordo a bordo e va
   comunque scorso, e il genitore che se lo trova aperto non capisce quanto
   sia lungo. Qui dentro NON cambia niente della struttura: si stringono solo
   le misure, perché stia in una schermata sola con il fondo che si vede
   intorno. Tutto in un blocco max-width, così da 720px in su (il desktop, che
   va bene com'è) non arriva nessuna di queste righe.
   Sostituisce il vecchio blocco max-width:420px, che allargava di nuovo i
   riempimenti proprio sulle larghezze da telefono.
   dvh e non vh: su iOS la barra degli indirizzi si mangia una fetta di 100vh,
   e il riquadro finirebbe più alto della parte di schermo che si vede. */
@media (max-width: 719px) {
  .accesso {
    /* 20px di fondo per lato: si vede che è un riquadro sopra la pagina.
       Il tetto di 420px serve al tablet in verticale, che è ancora a colonna
       sola: senza, il riquadro si stira a tutta larghezza e i campi diventano
       righe lunghissime. Sul telefono non cambia nulla (335px a 375 di
       schermo, già sotto il tetto). */
    max-width: min(420px, calc(100vw - 40px));
    max-height: calc(100dvh - 24px);
  }
  .accesso__box {
    border-radius: 14px;
    max-height: calc(100dvh - 24px);
  }
  .accesso__x { top: 8px; right: 8px; width: 30px; height: 30px; }
  .accesso__x svg { width: 14px; height: 14px; }

  /* modulo */
  .accesso__form { padding: 20px 16px 18px; }
  .accesso__logo { max-width: 150px; margin-bottom: 14px; }
  .accesso__logo-txt { font-size: 16px; margin-bottom: 14px; }
  .accesso__hint { margin-bottom: 12px; padding: 7px 11px; font-size: 13px; }
  .accesso__campo { margin-bottom: 11px; }
  .accesso__label { font-size: 13.5px; margin-bottom: 5px; }
  /* I 16px del campo NON si toccano: sotto quella misura iOS zooma al focus. */
  .accesso__input { padding: 11px 15px; }
  .accesso__errore { margin-bottom: 12px; padding: 9px 12px; font-size: 13.5px; }
  .accesso__vai { font-size: 15.5px; padding: 12px 16px; }
  .accesso__recupero { margin-top: 14px; font-size: 12.75px; line-height: 1.5; }

  /* informativa: resta leggibile ma passa in secondo piano rispetto ai campi. */
  .accesso__info { padding: 16px 16px 18px; }
  .accesso__occhiello { margin-bottom: 10px; font-size: 11.5px; }
  .accesso__occhiello svg { width: 14px; height: 14px; }
  .accesso__tit { font-size: 17px; margin-bottom: 10px; }
  .accesso__punti { padding-left: 18px; font-size: 13px; line-height: 1.45; }
  .accesso__punti li { margin-bottom: 7px; }
}

@media (min-width: 720px) {
  .accesso__box {
    grid-template-columns: 1fr 1fr;
  }
  /* Il disegno vuole l'informativa a sinistra: l'ordine del DOM resta
     modulo-prima (per il telefono), qui si scambiano le colonne. */
  .accesso__info { order: 1; padding: 44px 40px; }
  .accesso__form { order: 2; padding: 44px 40px; }
  .accesso__logo { margin-bottom: 34px; }
}
/* ---- Galleria masonry ------------------------------------------------- */
.album-gallery .container {
  padding-top: 40px;
  padding-bottom: 8px;
}

.masonry {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 200px;
  grid-auto-flow: dense;
  gap: 14px;
}
.masonry__item { grid-column: span 1; grid-row: span 1; }
/* Tasselli di dimensioni diverse (mosaico), ripetuti ogni 6 elementi */
.masonry__item:nth-child(6n+1) { grid-column: span 2; grid-row: span 2; } /* grande */
.masonry__item:nth-child(6n+3) { grid-row: span 2; }                      /* alto */
.masonry__item:nth-child(6n+5) { grid-column: span 2; }                   /* largo */

/* Placeholder a righe nello stile del design ([ foto ]) */
.thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  color: var(--muted);
  padding: 0;
  transition: transform 0.35s ease, box-shadow 0.35s ease;
}
.thumb:hover,
.thumb:focus-visible {
  transform: scale(1.03);
  box-shadow: 0 16px 36px rgba(31, 41, 51, 0.18);
}
/* Quando si inserisce una foto reale: <img> dentro .thumb riempie il tassello */
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Deterrenti sulle foto della galleria (vedi js/main.js). Solo qui, non su tutte le
   immagini del sito: il logo e le foto degli articoli devono restare trascinabili e
   avere il loro menu contestuale. Il tocco prolungato su iOS aprirebbe "Salva
   immagine": disattivato, il tocco resta quello che apre la foto a schermo intero. */
.thumb img {
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  user-select: none;
  -webkit-user-select: none;
}

/* Velo trasparente sopra la miniatura: intercetta il tasto destro e il
   trascinamento senza aggiungere un elemento al DOM (un <div> dentro la lightbox
   ne romperebbe la chiusura cliccando lo sfondo). */
.thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Varianti colore delle copertine (dal design) */
.thumb--blue {
  background:
    repeating-linear-gradient(45deg, rgba(31,41,51,.05) 0 12px, rgba(31,41,51,.08) 12px 24px),
    #cdd8e2;
}
.thumb--accent {
  background:
    repeating-linear-gradient(45deg, rgba(181,100,31,.07) 0 12px, rgba(181,100,31,.12) 12px 24px),
    #ecd9c4;
}
.thumb--teal {
  background:
    repeating-linear-gradient(45deg, rgba(43,163,154,.07) 0 12px, rgba(43,163,154,.12) 12px 24px),
    #d6ece9;
}
.thumb--sand {
  background:
    repeating-linear-gradient(45deg, rgba(31,41,51,.05) 0 12px, rgba(31,41,51,.08) 12px 24px),
    #d8cdbb;
}
.thumb--gold {
  background:
    repeating-linear-gradient(45deg, rgba(242,169,59,.1) 0 12px, rgba(242,169,59,.16) 12px 24px),
    #f5e6c8;
}

/* Animazione di comparsa (rispettata da prefers-reduced-motion in style.css) */
@keyframes albumFadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
.masonry__item:not([hidden]) {
  animation: albumFadeUp 0.55s ease both;
}

/* ---- "Carica altre foto" --------------------------------------------- */
.album-more {
  display: flex;
  justify-content: center;
  padding: 30px 0 64px;
}
.album-more__btn {
  background: var(--surface);
  color: var(--primary);
  border: 1px solid rgba(47, 93, 134, 0.3);
  font-weight: 700;
  font-size: 15px;
  padding: 14px 30px;
}
.album-more__btn:hover { background: var(--primary-tint); }
.album-more[hidden] { display: none; }

/* ---- Lightbox a schermo intero --------------------------------------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(15, 22, 30, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  /* Tap ravvicinati su ‹ › non devono zoomare la pagina (double-tap zoom
     mobile) né selezionare contenuti coi doppi click da desktop. */
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.lightbox button { touch-action: manipulation; }
.lightbox[hidden] { display: none; }

.lightbox__counter {
  position: absolute;
  top: 24px;
  left: 32px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.lightbox__close {
  position: absolute;
  top: 18px;
  right: 28px;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
}
.lightbox__close:hover { background: rgba(255, 255, 255, 0.22); }

.lightbox__stage {
  display: flex;
  align-items: center;
  gap: 22px;
  max-width: 1100px;
  width: 100%;
}
.lightbox__nav {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
}
.lightbox__nav:hover { background: rgba(255, 255, 255, 0.22); }

.lightbox__photo {
  flex: 1;
  height: 74vh;
  border-radius: 16px;
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,.04) 0 12px, rgba(255,255,255,.07) 12px 24px),
    #2a3742;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.65);
  animation: albumLbIn 0.3s ease;
}
@keyframes albumLbIn {
  from { opacity: 0; transform: scale(.97); }
  to   { opacity: 1; transform: scale(1); }
}

/* Varianti di copertina riflesse nel lightbox (impostate via JS) */
.lb-cover--blue {
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,.04) 0 12px, rgba(255,255,255,.07) 12px 24px),
    #3a4a59;
}
.lb-cover--accent {
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,.05) 0 12px, rgba(255,255,255,.09) 12px 24px),
    #5c3a16;
}
.lb-cover--teal {
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,.05) 0 12px, rgba(255,255,255,.09) 12px 24px),
    #1f4a47;
}
.lb-cover--sand {
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,.04) 0 12px, rgba(255,255,255,.07) 12px 24px),
    #4a4234;
}
.lb-cover--gold {
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,.05) 0 12px, rgba(255,255,255,.09) 12px 24px),
    #5c4a1e;
}

.lightbox__caption {
  margin-top: 20px;
  color: rgba(255, 255, 255, 0.55);
  font-size: 13px;
}

/* =========================================================================
   Responsive
   ========================================================================= */
@media (max-width: 1023px) {
  .masonry { grid-template-columns: repeat(3, 1fr); grid-auto-rows: 180px; }
}

@media (max-width: 620px) {
  .album-head .container { padding-top: 28px; padding-bottom: 32px; }
  .album-head__row { align-items: flex-start; }
  .album-head__actions { width: 100%; }
  .masonry { grid-template-columns: repeat(2, 1fr); grid-auto-rows: 150px; gap: 10px; }
  .lightbox { padding: 16px; }
  .lightbox__counter { left: 18px; top: 16px; }
  .lightbox__close { top: 12px; right: 16px; }
  .lightbox__stage { gap: 10px; }
  .lightbox__nav { width: 44px; height: 44px; font-size: 20px; }
  .lightbox__photo { height: 64vh; }
}
