/* ═══════════ Gallery lightbox ═══════════
   Clicking a thumbnail opens a full-screen viewer rather than a new tab.
   The markup stays a plain <a href="full.jpg"> so it still works with JS off —
   gallery.js intercepts the click and takes over. */

.glb {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 18, 18, 0.96);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s ease, visibility 0.22s;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.glb.open { opacity: 1; visibility: visible; }

/* Stage holds the image; it is also the click target for closing when the
   user clicks the empty space around the photo. */
.glb-stage {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Bottom padding clears the filmstrip. */
  padding: 4.5rem 4.5rem 7.5rem;
  overflow: hidden;
}
.glb-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 0.4rem;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
  transform: scale(0.97);
  opacity: 0;
  transition: transform 0.28s cubic-bezier(.19,1,.22,1), opacity 0.2s ease;
  cursor: zoom-in;
  user-select: none;
  -webkit-user-drag: none;
}
.glb.open .glb-img { transform: scale(1); opacity: 1; }
.glb.loading .glb-img { opacity: 0.35; }

/* Click-to-zoom: the image grows past the viewport and can be dragged. */
.glb.zoomed .glb-stage { padding: 0; overflow: auto; -webkit-overflow-scrolling: touch; }
.glb.zoomed .glb-img {
  max-width: none;
  max-height: none;
  width: auto;
  height: 175%;
  border-radius: 0;
  cursor: zoom-out;
}
@media (max-width: 700px) { .glb.zoomed .glb-img { height: 140%; } }

/* Controls */
.glb-btn {
  position: absolute;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.glb-btn:hover { background: rgba(255, 255, 255, 0.18); border-color: rgba(255, 255, 255, 0.3); }
.glb-btn:active { transform: scale(0.94); }
.glb-btn:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.glb-btn svg { width: 20px; height: 20px; display: block; pointer-events: none; }

.glb-close { top: 1.1rem; right: 1.1rem; }
.glb-prev  { left: 1.1rem;  top: 50%; margin-top: -23px; }
.glb-next  { right: 1.1rem; top: 50%; margin-top: -23px; }
.glb.zoomed .glb-prev, .glb.zoomed .glb-next { display: none; }

.glb-count {
  position: absolute;
  top: 1.55rem;
  left: 1.5rem;
  z-index: 2;
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.72);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

/* ── Filmstrip: the whole gallery sits along the bottom, so you can see
      what's coming and browse straight to it. Drag to scrub when there are
      more images than fit. ── */
.glb-strip {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  padding: 0.9rem 1rem 1.1rem;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0));
}
.glb-strip::-webkit-scrollbar { display: none; }
/* Only offer the drag affordance when there is actually somewhere to drag to. */
.glb-strip.scrollable { cursor: grab; }
.glb-strip.scrollable.dragging { cursor: grabbing; scroll-behavior: auto; }
.glb-strip.dragging .glb-thumb { pointer-events: none; }

/* Inner row: auto margins centre the strip when every thumbnail fits, and
   collapse to zero when it overflows — so nothing gets clipped either way. */
.glb-strip-inner {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  margin: 0 auto;
  width: max-content;
}

.glb-thumb {
  flex: 0 0 auto;
  width: 62px;
  height: 46px;
  padding: 0;
  border: 0;
  border-radius: 0.28rem;
  overflow: hidden;
  cursor: pointer;
  background: none;
  opacity: 0.5;
  outline: 2px solid transparent;
  outline-offset: 2px;
  transition: opacity 0.18s ease, outline-color 0.18s ease, transform 0.18s ease;
}
.glb-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.glb-thumb:hover { opacity: 0.85; transform: translateY(-2px); }
.glb-thumb.active { opacity: 1; outline-color: #fff; }
.glb-thumb:focus-visible { outline-color: #fff; opacity: 1; }

/* Zoomed in, the chrome gets out of the way. */
.glb.zoomed .glb-strip { display: none; }

@media (max-width: 700px) {
  .glb-stage { padding: 4rem 0.75rem 6rem; }
  .glb-prev { left: 0.6rem; }
  .glb-next { right: 0.6rem; }
  .glb-btn { width: 42px; height: 42px; }
  .glb-strip { padding: 0.6rem 0.75rem 0.85rem; }
  .glb-strip-inner { gap: 0.3rem; }
  .glb-thumb { width: 50px; height: 38px; }
}

/* Grid thumbnails are ordinary clickable links — plain pointer, not zoom. */
.gallery-grid a { cursor: pointer; }

@media (prefers-reduced-motion: reduce) {
  .glb, .glb-img, .glb-btn { transition: none; }
}
