/* =========================================================
   Public gallery — CSS-column masonry (no forced crop/aspect
   ratio) + infinite scroll + scroll-to-top button.
   ========================================================= */

.gallery-masonry {
  column-count: 4;
  column-gap: 16px;
}
@media (max-width: 1100px) { .gallery-masonry { column-count: 3; } }
@media (max-width: 760px)  { .gallery-masonry { column-count: 2; } }
@media (max-width: 480px)  { .gallery-masonry { column-count: 1; } }

.gallery-tile {
  break-inside: avoid;
  margin: 0 0 16px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card);
  box-shadow: var(--shadow-card);
  cursor: pointer;
  position: relative;
}
.gallery-tile:focus-visible { outline: 2.5px solid var(--blue); outline-offset: 2px; }
.gallery-tile img {
  display: block;
  width: 100%;
  height: auto;
  transition: transform .3s ease;
}
.gallery-tile:hover img { transform: scale(1.03); }
.gallery-tile figcaption {
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text-2);
}

.gallery-empty, .gallery-loading {
  text-align: center;
  color: var(--text-2);
  padding: 40px 0;
}

.scroll-top-btn {
  position: fixed; left: 20px; bottom: 20px; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--blue); color: #fff; border: none; cursor: pointer;
  box-shadow: var(--shadow-lift);
  opacity: 0; transform: translateY(8px);
  transition: opacity .2s ease, transform .2s ease, background .15s ease;
  pointer-events: none;
}
.scroll-top-btn.is-visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
.scroll-top-btn:hover { background: var(--blue-dark); }

@media (max-width: 599px) {
  .scroll-top-btn { left: 14px; bottom: 14px; width: 44px; height: 44px; }
}

/* ---------- Lightbox ---------- */
body.lightbox-open { overflow: hidden; }

.lightbox {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(9, 20, 28, .92);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: lightbox-fade-in .18s ease;
}
@keyframes lightbox-fade-in { from { opacity: 0; } to { opacity: 1; } }

.lightbox-stage {
  max-width: min(1100px, 90vw);
  max-height: 90vh;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.lightbox-stage img {
  max-width: 100%; max-height: 78vh; width: auto; height: auto;
  border-radius: 8px; box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
  display: block;
}
.lightbox-caption { color: rgba(255, 255, 255, .85); font-size: 15px; text-align: center; margin: 0; max-width: 70ch; }
.lightbox-caption:empty { display: none; }

.lightbox-close, .lightbox-nav {
  position: absolute; background: rgba(255, 255, 255, .1); color: #fff; border: none;
  border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s ease;
}
.lightbox-close:hover, .lightbox-nav:hover { background: rgba(255, 255, 255, .22); }
.lightbox-close { top: 20px; right: 20px; width: 42px; height: 42px; }
.lightbox-nav { top: 50%; transform: translateY(-50%); width: 52px; height: 52px; }
.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }

@media (max-width: 599px) {
  .lightbox { padding: 12px; }
  .lightbox-close { top: 10px; right: 10px; width: 38px; height: 38px; }
  .lightbox-nav { width: 42px; height: 42px; }
  .lightbox-prev { left: 6px; }
  .lightbox-next { right: 6px; }
}
