/* gallery.css — Stili specifici per gallery.html */

@view-transition { navigation: auto; }
::view-transition-old(root) { animation: fade-out-vt 0.2s cubic-bezier(0.4,0,1,1) both; }
::view-transition-new(root) { animation: fade-in-vt  0.3s cubic-bezier(0.16,1,0.3,1) both; }
@keyframes fade-out-vt { to { opacity: 0; } }
@keyframes fade-in-vt  { from { opacity: 0; } }

.gallery-grid {
  columns: 3 300px;
  column-gap: 1rem;
  max-width: 1200px;
  margin: 0 auto;
}
.gallery-item {
  break-inside: avoid;
  margin-bottom: 1rem;
  border-radius: 1rem;
  overflow: hidden;
  cursor: zoom-in;
  transition: transform 180ms cubic-bezier(0.16,1,0.3,1), box-shadow 180ms cubic-bezier(0.16,1,0.3,1);
}
.gallery-item:hover { transform: scale(1.015); box-shadow: 0 12px 40px rgba(0,0,0,0.2); }
.gallery-item img,
.gallery-item video { width: 100%; height: auto; display: block; }
@media (max-width: 768px) { .gallery-grid { columns: 2 200px; } }
@media (max-width: 480px) { .gallery-grid { columns: 1; } }

/* ── Video in griglia: autoplay/loop muti, senza controlli ── */
.gallery-item--video { position: relative; }
.gallery-item--video video { background: #000; object-fit: cover; }
/* badge "ingrandisci" per segnalare che il video è cliccabile */
.gallery-zoom {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: #fff;
  background: rgba(20, 16, 10, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  transition: transform 200ms cubic-bezier(0.16,1,0.3,1), background 200ms ease;
}
.gallery-item--video:hover .gallery-zoom {
  transform: scale(1.12);
  background: rgba(88, 144, 27, 0.85);
}

/* ── Lightbox: video con controlli (play/pausa, avanti/indietro) ── */
.lightbox video {
  max-width: 90vw;
  max-height: 88vh;
  border-radius: 0.5rem;
  background: #000;
  object-fit: contain;
}

/* Lightbox */
.lightbox { position:fixed;inset:0;z-index:1000;background:rgba(0,0,0,0.92);display:flex;align-items:center;justify-content:center;opacity:0;pointer-events:none;transition:opacity 0.3s; }
.lightbox.open { opacity:1;pointer-events:all; }
.lightbox img { max-width:90vw;max-height:88vh;object-fit:contain;border-radius:0.5rem; }
.lightbox-close { position:absolute;top:1.5rem;right:1.5rem;color:white;font-size:2rem;cursor:pointer;background:rgba(255,255,255,0.1);border:none;width:44px;height:44px;border-radius:50%;display:flex;align-items:center;justify-content:center; }

/* ════════════════════════════════════════════════════════════════
   ESPANSIONE VERTICALE FLUIDA + NODO "SCOPRI DI PIÙ / NASCONDI"
   ════════════════════════════════════════════════════════════════ */

.gallery-shell { position: relative; }

/* ── Contenitore delle 15 foto extra: si apre/chiude in altezza ──
   Il trucco grid-template-rows 0fr → 1fr permette di animare in modo
   fluido da altezza 0 ad altezza automatica (senza max-height "a occhio"). */
.gallery-extra {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.7s cubic-bezier(0.22,1,0.36,1);
}
.gallery-shell.is-open .gallery-extra {
  grid-template-rows: 1fr;
}
.gallery-extra-inner {
  overflow: hidden;
  min-height: 0;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.45s ease, transform 0.45s ease;
}
.gallery-shell.is-open .gallery-extra-inner {
  opacity: 1;
  transform: none;
  transition: opacity 0.6s ease 0.15s, transform 0.6s ease 0.15s;
}
.gallery-grid--extra { padding-top: 1rem; }

/* Comparsa "a cascata" delle foto extra quando si apre */
.gallery-shell.is-open .gallery-item--more {
  animation: galleryReveal 0.6s cubic-bezier(0.16,1,0.3,1) both;
}
@keyframes galleryReveal {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}

/* Riquadro "Foto in arrivo": fallback se un'immagine non è ancora caricata */
.gallery-item.is-empty {
  aspect-ratio: 4 / 3;
  cursor: default;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--color-primary) 16%, var(--color-surface)),
    var(--color-surface));
  border: 1px dashed color-mix(in srgb, var(--color-primary) 35%, transparent);
}
.gallery-item.is-empty:hover { transform: none; box-shadow: none; }
.gallery-item.is-empty::after {
  content: 'Foto in arrivo';
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

/* ── Il "nodo" interattivo: niente bottone classico ── */
.gallery-reveal {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  margin-top: -180px;          /* tirato su per sovrapporsi alle foto */
  padding-top: 170px;          /* tiene il nodo sotto la sfumatura */
  z-index: 5;
  transition: margin-top 0.6s cubic-bezier(0.22,1,0.36,1),
              padding-top 0.6s cubic-bezier(0.22,1,0.36,1);
}
.gallery-shell.is-open .gallery-reveal {
  margin-top: 2.5rem;          /* da aperto, si appoggia sotto le foto */
  padding-top: 0;
}

/* La sfumatura che sfuma le ultime foto verso lo sfondo (sparisce da aperto) */
.gallery-fade {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 210px;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.5s ease;
  background: linear-gradient(to bottom,
    transparent 0%,
    color-mix(in srgb, var(--color-bg) 70%, transparent) 55%,
    var(--color-bg) 92%);
}
.gallery-shell.is-open .gallery-fade { opacity: 0; }

/* La linea verticale (curva di strada / tralcio) che "appende" il nodo */
.gallery-reveal-line {
  width: 2px;
  height: 46px;
  border-radius: 2px;
  background: linear-gradient(to bottom,
    transparent,
    color-mix(in srgb, var(--color-primary) 80%, transparent));
}

/* Il nodo circolare */
.reveal-node {
  position: relative;
  width: 66px;
  height: 66px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  color: #fff;
  background: radial-gradient(circle at 32% 28%, #6ba81f 0%, #58901b 45%, #4a5b46 100%);
  box-shadow: 0 12px 30px rgba(88,144,27,0.40), inset 0 1px 0 rgba(255,255,255,0.30);
  transition: transform 0.35s cubic-bezier(0.22,1,0.36,1), box-shadow 0.35s ease;
}
.reveal-node:hover { transform: scale(1.09); box-shadow: 0 18px 42px rgba(88,144,27,0.52), inset 0 1px 0 rgba(255,255,255,0.35); }
.reveal-node:active { transform: scale(1.02); }
.reveal-node:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--color-primary) 55%, transparent);
  outline-offset: 4px;
}

/* La freccia che ruota: giù = "apri", su = "chiudi" */
.reveal-chevron {
  position: relative;
  z-index: 2;
  transition: transform 0.5s cubic-bezier(0.22,1,0.36,1);
}
.reveal-node[aria-expanded="true"] .reveal-chevron { transform: rotate(180deg); }

/* Anelli che pulsano dal nodo (solo quando è chiuso, per invitare al click) */
.reveal-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--color-primary) 70%, transparent);
  opacity: 0;
  pointer-events: none;
  animation: revealPulse 2.6s ease-out infinite;
}
.reveal-ring--2 { animation-delay: 1.3s; }
@keyframes revealPulse {
  0%   { transform: scale(1);   opacity: 0.55; }
  100% { transform: scale(1.9); opacity: 0; }
}
.reveal-node[aria-expanded="true"] .reveal-ring { animation: none; opacity: 0; }

/* Etichetta che cambia testo (Scopri di più ⇄ Nascondi) */
.reveal-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  transition: color 0.3s ease;
}
.reveal-node:hover ~ .reveal-label,
.reveal-node:focus-visible ~ .reveal-label { color: var(--color-primary); }

@media (max-width: 480px) {
  .gallery-reveal { margin-top: -140px; padding-top: 135px; }
  .gallery-fade { height: 160px; }
}

/* Rispetto delle preferenze di movimento ridotto */
@media (prefers-reduced-motion: reduce) {
  .gallery-extra,
  .gallery-extra-inner,
  .gallery-reveal,
  .reveal-chevron,
  .reveal-node { transition: none; }
  .reveal-ring { animation: none; }
  .gallery-shell.is-open .gallery-item--more { animation: none; }
}