/* === GALLERY GRID (PUBLIC VIEW) === */
.gallery {
  padding: 3px 3px 1em 3px;
  display: grid;

  /* Pinch zoom controls this value */
  --cols: 3;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));

  gap: 3px;

  /* allow normal scroll; JS prevents default only during pinch */
  touch-action: pan-x pan-y;
}

@media (max-width: 520px) {
  .gallery { --cols: 3; }
}
@media (min-width: 900px) {
  .gallery { --cols: 5; }
}

/* ✅ Public tiles can be image OR video */
.gallery .media-tile {
  position: relative;
}

/* ✅ Make thumbnails square */
.gallery .media-tile img,
.gallery .media-tile video {
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.15s ease;
  display: block;
  background: #000;
}

.gallery .media-tile:hover img,
.gallery .media-tile:hover video {
  transform: scale(1.01);
}

.gallery .gallery-sentinel {
  grid-column: 1 / -1;
  height: 1px;
}

/* ✅ Optional overlay for videos */
.gallery .play-badge {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 34px;
  color: #fff;
  text-shadow: 0 2px 12px rgba(0,0,0,0.65);
  pointer-events: none;
}

/* ✅ Optional corner star for starred items */
.gallery .star-corner {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(255,215,120,0.35);
  border: 1px solid rgba(255,215,120,0.55);
  border-radius: 999px;
  padding: 3px 6px;
  font-size: 12px;
  line-height: 1;
  pointer-events: none;
}

/* ✅ Lightbox (fixed so hidden doesn't block clicks) */
#lightbox[hidden] { display: none !important; }

#lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: grid;
  place-items: center;
  z-index: 2000;
}

/* ✅ Close button (top-right, circle cutout) */
.lightbox-close {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  right: calc(10px + env(safe-area-inset-right));
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,0.85);
  background: rgba(0,0,0,0.35);
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 2100;
  -webkit-tap-highlight-color: transparent;
}

.lightbox-close:hover { background: rgba(0,0,0,0.5); }
.lightbox-close svg { width: 22px; height: 22px; color: #fff; }

#lightbox-video { display: none; }

.lightbox-inner img,
.lightbox-inner video {
  max-width: min(94vw, 980px);
  max-height: 90vh;
  border-radius: 12px;
  background: #000;
}

/* ✅ Download button (bottom-right, same look as close button) */
.lightbox-download{
  position: fixed;
  right: calc(10px + env(safe-area-inset-right));
  bottom: calc(10px + env(safe-area-inset-bottom));
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,0.85);
  background: rgba(0,0,0,0.35);
  display: none;              /* shown only for images via JS */
  place-items: center;
  cursor: pointer;
  z-index: 2100;
  -webkit-tap-highlight-color: transparent;
}

.lightbox-download:hover { background: rgba(0,0,0,0.5); }
.lightbox-download svg { width: 22px; height: 22px; color: #fff; }