/* ===========================================================================
   Gallery di sezione /weddings/<categoria> — port FEDELE della gallery /food
   di andrea-dilorenzo-website (static/css/gallery.css): TRE colonne masonry come
   vista iniziale, click che passa a UNA colonna (vista singola), warp d'entrata e
   FLIP fra le due viste. Rispetto alla reference sono rimossi i pezzi ADL-specifici
   (monogramma, porte "More pictures", moduli editoriali) — qui la pagina è solo
   griglia. Usata SOLO dalle pagine `type: wedgallery`; le altre gallery del sito
   (layouts/gallery) restano invariate.

   DUE viste, stesso DOM (le celle non si ricostruiscono, cambia la classe sul
   contenitore e il JS anima con una FLIP):
     .is-pair   iniziale: tre colonne desktop, due mobile (masonry)
     .is-zoom   una colonna, immagine quasi a tutto viewport
   =========================================================================== */

@font-face {
  font-family: "Brown Sugar";
  src: url("/fonts/Brown-Sugar-Regular.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
body.is-wedgallery { --rg-persp: 1100; --ff-display: "Brown Sugar", "Times New Roman", serif; background: var(--rg-bg, #fff); overflow: hidden; }

.rg {
  --rg-bg: #ffffff;
  --rg-ink: #111110;
  --rg-pad: 3.2vw;
  --rg-padl: var(--rg-pad);
  --rg-cols: 2;
  --rg-gap-x: 3vw;
  --rg-gap-y: 3vw;
  --rg-top: 12vh;            /* lascia spazio alla top bar condivisa (fixed) */
  --rg-row-max-pair: 84vh;
  --rg-row-max-zoom: 98vh;
  --rg-zoom: 1;
  --rg-warp-z: 620;
  --rg-warp-in: -900;
  --rg-warp-dur: 900;
  --rg-warp-step: 26;
  --rg-morph: 1050;
  --rg-morph-drag: 0.85;
  --rg-morph-lag: 240;
  position: fixed; inset: 0;
  background: var(--rg-bg); color: var(--rg-ink);
}

/* reset link per la top bar condivisa (vedi CLAUDE.md: shared/topbar.css si affida a questo) */
.rg a, body.is-wedgallery a { color: inherit; text-decoration: none; }

/* ---- Contenitore di scroll --------------------------------------------------------- */
.rg-scroll {
  position: absolute; inset: 0;
  overflow-y: auto; overflow-x: hidden;
  padding: var(--rg-top) var(--rg-pad) 12vh var(--rg-padl);
  perspective: calc(var(--rg-persp) * 1px);
  perspective-origin: var(--rg-ox, 50%) var(--rg-oy, 50%);
  scrollbar-width: none; -ms-overflow-style: none;
}
.rg-scroll::-webkit-scrollbar { width: 0; height: 0; display: none; }
.rg.is-warping .rg-scroll { overflow: hidden; }

.rg-status {
  margin: 0; padding: 2vh 0; max-width: 46em;
  font: 500 11px/1.8 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.1em; opacity: 0.55;
}
.rg-status[hidden] { display: none; }

/* ---- Griglia (vista a colonne) ---- */
.rg-grid {
  display: grid;
  grid-template-columns: repeat(var(--rg-cols), 1fr);
  column-gap: var(--rg-gap-x);
  row-gap: var(--rg-gap-y);
  align-items: start;
  transform-style: preserve-3d;
}
.rg-cell {
  margin: 0; padding: 0;
  display: flex; justify-content: center;
  cursor: zoom-in;
}
.rg-cell img {
  display: block;
  width: auto; height: auto;
  max-width: 100%; max-height: var(--rg-row-max-pair);
}
.rg-cell.is-loading img { width: 100%; background: #dcdcdc; }
.rg-cell.is-loading img { opacity: 0; aspect-ratio: var(--ar, 2 / 3); }

/* ---- Vista iniziale (pair) ---- */
.rg.is-pair { --rg-cols: 2; --rg-gap-x: 3vw; --rg-gap-y: 3vw; }
.rg.is-pair .rg-cell img { max-height: var(--rg-row-max-pair); }

/* ---- Vista singola (una colonna, quasi a tutto viewport) ---- */
.rg.is-zoom { --rg-cols: 1; --rg-gap-x: 3vw; --rg-gap-y: 3vw; }
.rg.is-zoom .rg-cell img { max-height: var(--rg-row-max-zoom); }
.rg.is-zoom .rg-cell { cursor: zoom-out; }

/* ---- Titolo della sezione: Brown Sugar GIGANTE, centrato, sopra la griglia (nel flusso) ---- */
.rg-title {
  margin: 0 0 clamp(1.5rem, 4vw, 3.5rem);
  text-align: center;
  font-family: var(--ff-display, "Brown Sugar", serif); font-weight: 400;
  font-size: clamp(3rem, 15vw, 14rem); line-height: 0.82;
  letter-spacing: -0.01em; text-transform: uppercase; color: var(--rg-ink);
}
.rg-title a { color: inherit; }

/* ---- Pulsante di zoom-out ---- */
.rg-out {
  position: fixed; top: 3vh; left: 3vh; z-index: 5;
  width: 48px; height: 48px; padding: 0;
  border-radius: 999px; border: none;
  background: rgba(255,255,255,.72); color: var(--rg-ink);
  box-shadow: 0 8px 20px -6px rgba(0,0,0,.35);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  display: grid; place-items: center; cursor: pointer;
  opacity: 0; transform: scale(0.85); pointer-events: none;
  transition: opacity 300ms ease, transform 300ms cubic-bezier(0.16,1,0.3,1), background 200ms ease;
}
.rg-out[hidden] { display: none; }
.rg.is-zoom .rg-out { opacity: 1; transform: none; pointer-events: auto; }
.rg-out:hover { background: #fff; }
.rg-out svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* ---- Mobile ---- */
@media (max-width: 900px) {
  .rg { --rg-pad: 5vw; --rg-top: 14vh; }
  .rg.is-pair { --rg-cols: 2; }
}

/* ---- Motion ridotto ---- */
@media (prefers-reduced-motion: reduce) {
  .rg-cell, .rg-cell img { transition: none !important; }
  .rg-title { transition: none !important; }
}

/* ---- Desktop ---- */
@media (min-width: 901px) {
  .rg { --rg-col: calc((100vw - 2 * var(--rg-pad) - 2 * var(--rg-gap-x)) / 3); }
  .rg.is-pair { --rg-cols: 3; --rg-gap-x: 1.5vw; --rg-gap-y: 1.5vw; }
  .rg.is-pair .rg-cell img { max-height: none; }
  .rg.is-pair .rg-cell { order: var(--rg-pair-order, 0); }
  .rg.is-pair .rg-cell.is-landscape { grid-column: span 2; }
  .rg.is-pair .rg-cell.is-landscape.is-unpaired-landscape { grid-column: span 3; }
  .rg.is-pair .rg-cell { cursor: zoom-in; }
}

/* ---- Layout masonry (vista iniziale a colonne CSS) ------------------------------------
   Tre pile indipendenti che riempiono ogni vuoto verticale senza crop. Legato a `.is-pair`:
   al click la classe cade e la `.is-zoom` a una colonna torna a essere CSS Grid, quindi il
   warp/FLIP non ha un secondo codice. IDENTICO alla reference /food di ADL. */
body.is-masonry .rg.is-pair .rg-grid {
  display: block;
  column-count: 3;
  column-gap: 1.5vw;
}
body.is-masonry .rg.is-pair .rg-cell {
  display: block;
  width: 100%;
  margin: 0 0 1.5vw;
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
}
body.is-masonry .rg.is-pair .rg-cell img {
  width: 100%;
  max-width: 100%;
  max-height: none;
}
@media (max-width: 900px) {
  body.is-masonry .rg.is-pair .rg-grid { column-count: 2; column-gap: 3vw; }
  body.is-masonry .rg.is-pair .rg-cell { margin-bottom: 3vw; }
}
