/* ============================================================
   gallery.css - only needed on pages with the image gallery
   (masonry grid + lightbox). Uses the shared variables from
   theme.css, plus a few of its own below.
   ============================================================ */

:root {
  --gallery-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
  --gallery-hover-shadow: 0 10px 25px rgba(255, 196, 255, 0.7);
  --lightbox-bg: rgba(255, 255, 255, 0.95);
  --lightbox-img-shadow: 0 0 40px rgba(255, 196, 255, 0.8);
}

html.dark {
  --gallery-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  --gallery-hover-shadow: 0 10px 25px rgba(200, 100, 255, 0.5);
  --lightbox-bg: rgba(10, 12, 30, 0.97);
  --lightbox-img-shadow: 0 0 40px rgba(200, 100, 255, 0.6);
}

/* ============================================================
   Masonry gallery
   ============================================================ */
.gallery {
  column-count: 4;
  column-gap: 20px;
  padding: 40px;
  max-width: 1200px;
  margin: auto;
}

/* Images start invisible and fade in once loaded */
.gallery img {
  width: 100%;
  height: auto;
  margin-bottom: 20px;
  border-radius: 18px;
  cursor: pointer;
  box-shadow: var(--gallery-shadow);
  display: block;
  opacity: 0;
  transition: opacity 0.5s ease, transform 0.3s ease, box-shadow 0.3s ease;
}

.gallery img.loaded {
  opacity: 1;
}

.gallery img:hover {
  transform: scale(1.05);
  box-shadow: var(--gallery-hover-shadow);
}

@media (max-width: 900px) { .gallery { column-count: 2; } }
@media (max-width: 600px) { .gallery { column-count: 1; } }

/* ============================================================
   Lightbox
   ============================================================ */
#lightbox {
  position: fixed;
  inset: 0;
  background: var(--lightbox-bg);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: var(--z-lightbox);
  touch-action: pan-y;
}

#lightbox-img {
  max-width: 90%;
  max-height: 90%;
  border-radius: 20px;
  box-shadow: var(--lightbox-img-shadow);
  opacity: 0;                      /* hidden until the new image has loaded */
  transition: opacity 0.2s ease;
  user-select: none;
  -webkit-user-drag: none;
}

.lb-btn {
  position: absolute;
  background: rgba(var(--btn-rgb), 0.85);
  color: white;
  border: none;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  font-size: 1.8em;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s, transform 0.2s;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  z-index: 2;
}

.lb-btn:hover { background: var(--btn-hover); transform: scale(1.1); }
.lb-prev  { left: 20px;  top: 50%; margin-top: -24px; padding-bottom: 4px; }
.lb-next  { right: 20px; top: 50%; margin-top: -24px; padding-bottom: 4px; }
.lb-close { right: 20px; top: 20px; font-size: 1.3em; }

/* Arrows are redundant on phones (swipe works), so tuck them away */
@media (max-width: 600px) {
  .lb-prev, .lb-next { display: none; }
}

#lightbox-counter {
  position: absolute;
  top: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(var(--btn-rgb), 0.88);
  color: white;
  font-size: 0.85em;
  padding: 4px 14px;
  border-radius: 20px;
  pointer-events: none;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

#lightbox-credit {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 196, 255, 0.88);
  color: white;
  font-size: 0.9em;
  font-family: var(--font);
  padding: 6px 16px;
  border-radius: 20px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  white-space: nowrap;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

#lightbox-credit.visible { opacity: 1; }
