/**
 * BecA Image Gallery block.
 * Extracted from the BecA Stories "Image Gallery" section.
 */

.beca-image-gallery {
  width: 100%;
  margin-top: var(--beca-image-gallery-margin-top, 0px);
  margin-bottom: var(--beca-image-gallery-margin-bottom, 0px);
  padding-top: var(--beca-image-gallery-padding-top, 0px);
  padding-bottom: var(--beca-image-gallery-padding-bottom, 0px);
}

.beca-image-gallery__container {
  width: 100%;
  max-width: 1240px;
  margin-left: auto;
  margin-right: auto;
}

.beca-image-gallery__heading {
  margin: 0 0 3rem;
  font-family: "Open Sans", sans-serif;
  font-size: calc(clamp(1rem, 1.3vw, 1.25rem) + 0.5rem);
  font-weight: 500;
  line-height: 1.3;
}

.beca-image-gallery__grid {
  display: grid;
  gap: 3rem;
}

.beca-image-gallery__grid--two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.beca-image-gallery__grid--three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.beca-image-gallery__grid--featured { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.beca-image-gallery__grid--featured .beca-image-gallery__item:first-child {
  grid-column: 1 / -1;
}

.beca-image-gallery__item { margin: 0; }
.beca-image-gallery__item img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 6px;
}
.beca-image-gallery__grid--featured .beca-image-gallery__item:first-child img { aspect-ratio: 16 / 9; }

.beca-image-gallery__item figcaption {
  text-align: left;
}
.beca-image-gallery__item-title {
  display: block;
  text-align: left;
  font-weight: 700;
}
.beca-image-gallery__item-caption {
  display: block;
  text-align: left;
  color: #475569;
}
.beca-image-gallery__item-credit {
  display: block;
  text-align: left;
  color: #94a3b8;
  font-size: .85em;
  font-style: normal;
  font-weight: 400;
  opacity: .85;
}

@media (max-width: 700px) {
  .beca-image-gallery__grid--two,
  .beca-image-gallery__grid--three,
  .beca-image-gallery__grid--featured { grid-template-columns: 1fr; }
  .beca-image-gallery__grid--featured .beca-image-gallery__item:first-child { grid-column: auto; }
}

/* Gallery image enlargement / lightbox. */
.beca-image-gallery__image-button {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: zoom-in;
  text-align: inherit;
}

.beca-image-gallery__image-button:focus-visible {
  outline: 3px solid #07a5f6;
  outline-offset: 4px;
}

.beca-image-gallery__image-button img {
  pointer-events: none;
}

.beca-image-gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: rgba(5, 10, 18, .94);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .2s ease, visibility .2s ease;
}

.beca-image-gallery-lightbox.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.beca-image-gallery-lightbox__backdrop {
  position: absolute;
  inset: 0;
  cursor: zoom-out;
}

.beca-image-gallery-lightbox__dialog {
  position: relative;
  z-index: 1;
  width: 100vw;
  height: 100vh;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  outline: none;
  cursor: move;
}

.beca-image-gallery-lightbox__image {
  display: block;
  position: absolute;
  top: 50%;
  left: 50%;
  /* Rendered larger than the viewport so there's room to pan; JS shifts
     this transform on mousemove to reveal the area under the cursor. */
  width: 140%;
  height: 140%;
  max-width: none;
  max-height: none;
  object-fit: cover;
  transform: translate(-50%, -50%);
  border-radius: 0;
  box-shadow: none;
  user-select: none;
  will-change: transform;
}

.beca-image-gallery-lightbox__close {
  position: absolute;
  top: clamp(.25rem, 1vw, 1rem);
  right: clamp(.25rem, 1vw, 1rem);
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .35);
  border-radius: 50%;
  background: rgba(0, 0, 0, .45);
  color: #fff;
  font-family: Arial, sans-serif;
  font-size: 2rem;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
  transition: background-color .2s ease, border-color .2s ease, transform .2s ease;
}

.beca-image-gallery-lightbox__close:hover {
  background: rgba(255, 255, 255, .16);
  border-color: rgba(255, 255, 255, .7);
  transform: scale(1.04);
}

.beca-image-gallery-lightbox__close:focus-visible {
  outline: 3px solid #07a5f6;
  outline-offset: 3px;
}

html.beca-image-gallery-lightbox-open,
body.beca-image-gallery-lightbox-open {
  overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .beca-image-gallery-lightbox {
    transition: none;
  }
  .beca-image-gallery-lightbox__close {
    transition: none;
  }
}

@media (max-width: 700px) {
  .beca-image-gallery-lightbox__close {
    top: .5rem;
    right: .5rem;
    width: 2.75rem;
    height: 2.75rem;
  }
}

/* Admin form: media autocomplete preview thumbnail. */
.beca-image-gallery-admin-preview {
  margin-top: .5rem;
}
.beca-image-gallery-admin-preview__empty {
  color: #64748b;
  font-size: .85rem;
  font-style: italic;
}
.beca-image-gallery-admin-preview img {
  max-width: 160px;
  height: auto;
  border-radius: 4px;
  border: 1px solid #cbd5e1;
}

/* Match BecA Header Mega's mobile visible content edges.
   Only the gallery inner container is inset; the lightbox remains fullscreen. */
@media (max-width: 768px) {
  .beca-image-gallery .beca-image-gallery__container {
    width: 100%;
    max-width: 1240px;
    margin-inline: auto;
    padding-inline: 2rem;
    box-sizing: border-box;
    min-width: 0;
  }
  .beca-image-gallery .beca-image-gallery__grid,
  .beca-image-gallery .beca-image-gallery__item {
    min-width: 0;
    max-width: 100%;
  }
}
