/*!
 * Bronicable Gallery styles.
 * Colours come from custom properties so the theme can override them in one place.
 */

.bcg {
  --bcg-gap: 6px;
  --bcg-radius: 3px;
  --bcg-ink: #1c1c1c;
  --bcg-muted: #6b6b6b;
  --bcg-line: #dcdcdc;
  --bcg-hover: #0f5c4e;
  --bcg-columns: 3;

  margin: 1.8rem 0;
}

/* Neutralise the core gallery flex rules on the container we take over. */
.wp-block-gallery.bcg-host {
  display: block;
  gap: 0;
}

/* ------------------------------------------------------------------- grid */

.bcg-grid {
  display: grid;
  grid-template-columns: repeat(var(--bcg-columns), 1fr);
  gap: var(--bcg-gap);
}

.bcg-cell {
  position: relative;
  display: block;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: var(--bcg-radius);
  overflow: hidden;
  background: #f0f0f0;
  aspect-ratio: 1 / 1;
  cursor: zoom-in;
  -webkit-appearance: none;
  appearance: none;
}

.bcg-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease, opacity 0.2s ease;
}

.bcg-cell:hover img,
.bcg-cell:focus-visible img {
  transform: scale(1.04);
}

.bcg-cell:focus-visible {
  outline: 2px solid var(--bcg-hover);
  outline-offset: 2px;
}

/* ------------------------------------------------------------- pagination */

.bcg-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem 1rem;
  margin-top: 0.9rem;
}

.bcg-nav:empty {
  display: none;
}

.bcg-range {
  margin: 0;
  font-size: 0.82rem;
  color: var(--bcg-muted);
}

.bcg-pages {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.bcg-page {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--bcg-line);
  border-radius: var(--bcg-radius);
  background: #fff;
  color: var(--bcg-ink);
  font: inherit;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.bcg-page:hover:not(:disabled) {
  border-color: var(--bcg-hover);
  color: var(--bcg-hover);
}

.bcg-page.is-current {
  border-color: var(--bcg-ink);
  background: var(--bcg-ink);
  color: #fff;
  cursor: default;
}

.bcg-page:disabled {
  opacity: 0.35;
  cursor: default;
}

.bcg-step {
  font-size: 1.1rem;
}

.bcg-gap {
  padding: 0 2px;
  color: var(--bcg-muted);
  font-size: 0.85rem;
}

/* Standalone images outside galleries, made openable in the viewer. */
.wp-block-image.bcg-zoomable {
  cursor: zoom-in;
}

.wp-block-image.bcg-zoomable img {
  transition: opacity 0.2s ease;
}

.wp-block-image.bcg-zoomable:hover img {
  opacity: 0.92;
}

/* --------------------------------------------------------------- lightbox */

body.bcg-locked {
  overflow: hidden;
}

.bcg-lightbox {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: none;
  flex-direction: column;
  background: rgba(12, 12, 14, 0.97);
}

.bcg-lightbox.is-open {
  display: flex;
}

.bcg-track {
  flex: 1;
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}

.bcg-track::-webkit-scrollbar {
  display: none;
}

.bcg-slide {
  flex: 0 0 100%;
  scroll-snap-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  margin: 0;
  padding: 3.2rem 1rem 0.6rem;
  box-sizing: border-box;
}

.bcg-slide img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 2px;
}

.bcg-slide figcaption {
  max-width: 62ch;
  color: #cfcfcf;
  font-size: 0.85rem;
  line-height: 1.5;
  text-align: center;
}

.bcg-counter {
  margin: 0;
  padding: 0.4rem 1rem 0;
  color: #9a9a9a;
  font-size: 0.8rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* A single image has nothing to navigate between. */
.bcg-lightbox.is-single .bcg-bar,
.bcg-lightbox.is-single .bcg-counter {
  display: none;
}

.bcg-lightbox.is-single .bcg-slide {
  padding-bottom: calc(1.2rem + env(safe-area-inset-bottom, 0px));
}

.bcg-close {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
}

.bcg-close:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* Bottom strip: arrows plus scrollable thumbnails. */

.bcg-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0.6rem 0.75rem calc(0.6rem + env(safe-area-inset-bottom, 0px));
}

.bcg-arrow {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 56px;
  padding: 0;
  border: 0;
  border-radius: var(--bcg-radius, 3px);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
}

.bcg-arrow:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.18);
}

.bcg-arrow:disabled {
  opacity: 0.25;
  cursor: default;
}

.bcg-strip {
  flex: 1;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: thin;
  scroll-behavior: smooth;
  padding: 2px;
}

.bcg-strip::-webkit-scrollbar {
  height: 4px;
}

.bcg-strip::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.25);
  border-radius: 2px;
}

.bcg-thumb {
  flex: 0 0 auto;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 0;
  border-radius: 2px;
  overflow: hidden;
  background: #222;
  opacity: 0.45;
  cursor: pointer;
  transition: opacity 0.15s ease, box-shadow 0.15s ease;
}

.bcg-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.bcg-thumb:hover {
  opacity: 0.8;
}

.bcg-thumb.is-current {
  opacity: 1;
  box-shadow: 0 0 0 2px #fff;
}

.bcg-lightbox :focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

@media (max-width: 600px) {
  .bcg-thumb {
    width: 46px;
    height: 46px;
  }

  .bcg-arrow {
    width: 34px;
    height: 46px;
  }

  .bcg-slide {
    padding-top: 2.6rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bcg-cell img,
  .bcg-track,
  .bcg-strip {
    transition: none;
    scroll-behavior: auto;
  }
}
