/* ══════════════════════════════════════════
   gallery.css — Stili galleria foto (pubblico + admin)
   Compatibile con il sistema di variabili CSS di style.css (var(--accent), var(--bg2)…)
══════════════════════════════════════════ */

/* ─── Sezione pubblica ─────────────────── */
#gallery { padding: 80px 0; }

.gallery-count {
  color: var(--text-muted, #999);
  font-size: 0.9rem;
  margin-bottom: 28px;
  font-family: var(--font-mono, monospace);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.gallery-item {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border: 0;
  padding: 0;
  margin: 0;
  background: var(--surface, #1a1a1a);
  border-radius: 10px;
  cursor: zoom-in;
  transition: transform .3s ease, box-shadow .3s ease;
}
.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .4s ease;
}
.gallery-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(0,0,0,.5), 0 0 0 2px var(--accent, #e3000f);
}
.gallery-item:hover img { transform: scale(1.08); }
.gallery-item:focus-visible {
  outline: 2px solid var(--accent, #e3000f);
  outline-offset: 3px;
}

/* ─── Lightbox fullscreen ──────────────── */
.gallery-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.95);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: galFadeIn .2s ease;
}
.gallery-lightbox.hidden { display: none; }
@keyframes galFadeIn { from { opacity: 0 } to { opacity: 1 } }

.gallery-lb-figure {
  margin: 0;
  max-width: 92vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.gallery-lb-img {
  max-width: 92vw;
  max-height: 85vh;
  display: block;
  border-radius: 6px;
  box-shadow: 0 20px 60px rgba(0,0,0,.8);
}
.gallery-lb-caption {
  color: #fff;
  margin-top: 14px;
  font-size: 0.9rem;
  text-align: center;
  max-width: 80vw;
  opacity: .85;
  font-family: var(--font-mono, monospace);
}

.gallery-lb-close,
.gallery-lb-prev,
.gallery-lb-next {
  position: absolute;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.15);
  color: #fff;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
  transition: background .2s, transform .2s;
  font-family: sans-serif;
}
.gallery-lb-close { top: 20px; right: 20px; width: 44px; height: 44px; font-size: 1.7rem; line-height: 1; }
.gallery-lb-prev  { left: 20px;  top: 50%; transform: translateY(-50%); width: 50px; height: 50px; font-size: 1.3rem; }
.gallery-lb-next  { right: 20px; top: 50%; transform: translateY(-50%); width: 50px; height: 50px; font-size: 1.3rem; }
.gallery-lb-close:hover { background: rgba(255,255,255,.2); }
.gallery-lb-prev:hover  { background: rgba(255,255,255,.2); transform: translateY(-50%) scale(1.05); }
.gallery-lb-next:hover  { background: rgba(255,255,255,.2); transform: translateY(-50%) scale(1.05); }

@media (max-width: 600px) {
  .gallery-grid     { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; }
  .gallery-lb-prev,
  .gallery-lb-next  { width: 40px; height: 40px; }
  .gallery-lb-close { top: 10px; right: 10px; }
}

/* ─── Admin: grid upload + tiles ───────── */
.gallery-admin-upload {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.gallery-upload-progress {
  font-size: 0.85rem;
  color: var(--text-muted, #999);
  font-family: var(--font-mono, monospace);
}

.gallery-admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.gallery-admin-tile {
  position: relative;
  background: var(--surface2, #222);
  border-radius: 8px;
  overflow: hidden;
  cursor: grab;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: opacity .2s, transform .2s;
}
.gallery-admin-tile.dragging { opacity: .4; cursor: grabbing; }
.gallery-admin-tile img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 4px;
  display: block;
  pointer-events: none;
}

.gallery-alt-input {
  width: 100%;
  padding: 4px 6px;
  background: var(--bg2, #111);
  border: 1px solid rgba(255,255,255,.1);
  color: var(--text, #eee);
  border-radius: 4px;
  font-size: 0.75rem;
  font-family: inherit;
  box-sizing: border-box;
}
.gallery-alt-input:focus {
  outline: none;
  border-color: var(--accent, #e3000f);
}

.gallery-del-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 50%;
  background: rgba(227,0,15,.85);
  color: #fff;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s, transform .2s;
}
.gallery-del-btn:hover { background: #e3000f; transform: scale(1.1); }
