.sab-photo-gallery {
  width: 100%;
  box-sizing: border-box;
}

.sab-photo-gallery * {
  box-sizing: border-box;
}

.sab-photo-gallery-item {
  position: relative;
  overflow: hidden;
  margin: 0;
}

.sab-photo-gallery-item-img {
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
}

.sab-photo-gallery-item-img.sab-photo-gallery-crop {
  object-fit: cover;
}

.sab-photo-gallery-item-img.sab-photo-gallery-contain {
  object-fit: contain;
}

/* Higher specificity (two classes) than .sab-photo-gallery-item-img above, so this still wins even though
   both are !important — masonry relies on each image's natural aspect ratio for its row flow,
   the opposite of every other type's fill-the-cell behavior. */
.sab-photo-gallery-type-masonry .sab-photo-gallery-item-img {
  height: auto !important;
}

.sab-photo-gallery-item-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 13px;
  margin: 0;
}

.sab-photo-gallery-hidden {
  display: none !important;
}

.sab-photo-gallery-pagination-controls {
  display: block;
}

/* Loading skeleton — placeholder tiles shown the instant a fetch starts (Load More click or
   an infinite-scroll sentinel), so there's always a visible "it's working" state instead of
   a pause that looks unresponsive. Numbered pages don't use this at all — dimming the
   existing batch (see .sab-photo-gallery-grid-transitioning below) is the loading state there.
   A faint grid-line texture plus a hairline border keep adjacent tiles reading as separate
   cells even when a gallery's gutter is 0 — without it, several same-color tiles packed
   edge-to-edge just look like one oversized gray slab instead of a grid of incoming photos. */
.sab-photo-gallery-skeleton {
  background-color: #ececed;
  background-image:
    linear-gradient(to right, rgba(0, 0, 0, 0.05) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0, 0, 0, 0.05) 1px, transparent 1px);
  background-size: 16px 16px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  animation: sab-photo-gallery-skeleton-pulse 1.4s ease-in-out infinite;
}

@keyframes sab-photo-gallery-skeleton-pulse {
  0%,
  100% {
    opacity: 0.4;
  }
  50% {
    opacity: 0.65;
  }
}

/* Masonry has no img to derive a height from (that's what real items rely on) — give
   skeleton tiles a fixed height so they actually show up as boxes. Custom Grid doesn't need
   this: as a grid item it stretches to fill the row span set inline by buildSkeletonItem(). */
.sab-photo-gallery-type-masonry .sab-photo-gallery-skeleton {
  height: 160px;
}

/* Numbered pages: the outgoing batch stays in the DOM (never wiped up front) and is just
   dimmed in place while the next page loads, so a slow/failed request always has real
   content to fall back to instead of an empty grid — no skeleton tiles involved here. */
.sab-photo-gallery-grid-transitioning .sab-photo-gallery-item {
  opacity: 0.35;
  pointer-events: none;
}

.sab-photo-gallery-load-more {
  display: block;
  margin: 16px auto 0;
  padding: 10px 24px;
  background: #1d2327;
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 14px;
}

.sab-photo-gallery-load-more:hover {
  background: #2c3338;
}

.sab-photo-gallery-load-more.is-loading {
  opacity: 0.7;
  cursor: default;
}

.sab-photo-gallery-infinite-loading {
  text-align: center;
  padding: 12px 0;
  font-size: 13px;
  color: #646970;
  visibility: hidden;
}

.sab-photo-gallery-infinite-loading.is-visible {
  visibility: visible;
}

/* Invisible trigger element for infinite-scroll style — IntersectionObserver watches this,
   nothing to actually show. A little height keeps it reliably observable even in an empty grid. */
.sab-photo-gallery-scroll-sentinel {
  height: 1px;
}

.sab-photo-gallery-pagination-nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 16px;
}

.sab-photo-gallery-page-btn {
  min-width: 36px;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid #dcdcde;
  color: #1d2327;
  cursor: pointer;
  font-size: 14px;
}

.sab-photo-gallery-page-btn:hover {
  background: #f0f0f1;
}

.sab-photo-gallery-page-btn.is-active {
  background: #1d2327;
  border-color: #1d2327;
  color: #fff;
}

.sab-photo-gallery-powered-by {
  text-align: center;
  margin-top: 10px;
  font-size: 12px;
}

.sab-photo-gallery-powered-by a {
  color: inherit;
  opacity: 0.6;
  text-decoration: none;
}

.sab-photo-gallery-message {
  padding: 16px;
  background: #f0f0f1;
  border: 1px dashed #c3c4c7;
  text-align: center;
}

/* Lightbox — triggers get a pointer cursor and a focus ring for keyboard users (they
   render with tabindex="0" + role="button", see Sab_Photo_Gallery_Renderer::render_item()). */
.sab-photo-gallery-lightbox-trigger {
  cursor: zoom-in;
}

.sab-photo-gallery-lightbox-trigger:focus-visible {
  outline: 2px solid #2271b1;
  outline-offset: 2px;
}

/* Single shared overlay for every gallery on the page — built once by public.js on
   first open, toggled via .is-open rather than added/removed from the DOM each time. */
.sab-photo-gallery-lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000; /* above any theme header/sticky nav */
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease;
}

.sab-photo-gallery-lightbox-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

/* Sizing is entirely vw/vh, driven by the per-gallery Lightbox Width/Height settings
   (Sab_Photo_Gallery_Renderer::render(), data-sab-photo-gallery-lightbox-w/-h) — viewport units already scale
   correctly at any screen size on their own, mobile included, with no separate
   mobile-only override needed. object-fit keeps the image itself from distorting
   inside whatever box that vw/vh pair produces. */
.sab-photo-gallery-lightbox-image {
  max-width: 90vw;
  max-height: 90vh;
  width: auto;
  height: auto;
  object-fit: contain;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

.sab-photo-gallery-lightbox-close {
  position: absolute;
  top: 16px;
  right: 24px;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 36px;
  line-height: 1;
  cursor: pointer;
  padding: 8px;
}

.sab-photo-gallery-lightbox-close:hover,
.sab-photo-gallery-lightbox-close:focus-visible {
  color: #ccc;
}

/* Prevents background scroll behind the overlay while it's open. */
body.sab-photo-gallery-lightbox-locked {
  overflow: hidden;
}
