/*
 * VJFNL Native Masonry Gallery
 *
 * Gallery items are positioned by JavaScript. The gallery remains a normal
 * block-level element so it can reserve its calculated height in the page.
 */

/* Native masonry gallery container */
.vjfnl-nmg-gallery {
  box-sizing: border-box;
  display: block;
  position: relative;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin: 1.5em 0;
  padding: 0;
  list-style: none;
}

/* Keep sizing predictable inside themes and page builders. */
.vjfnl-nmg-gallery,
.vjfnl-nmg-gallery *,
.vjfnl-nmg-gallery *::before,
.vjfnl-nmg-gallery *::after {
  box-sizing: border-box;
}

/*
 * These elements become absolutely positioned by JavaScript. Their width,
 * left position and top position are set by the masonry script.
 */
.vjfnl-nmg-gallery .vjfnl-nmg-item,
.vjfnl-nmg-gallery .blocks-gallery-item,
.vjfnl-nmg-gallery .wp-block-image {
  min-width: 0;
}

/* Make every gallery image fill its masonry item. */
.vjfnl-nmg-gallery .vjfnl-nmg-item img,
.vjfnl-nmg-gallery .blocks-gallery-item img,
.vjfnl-nmg-gallery .wp-block-image img {
  display: block;
  width: 100%;
  height: auto;
}

/* Gallery captions remain available when supplied by WordPress. */
.vjfnl-nmg-gallery figcaption {
  margin-top: 0.45em;
  font-size: 0.9em;
}

/* Full-screen lightbox overlay. */
.vjfnl-nmg-lightbox {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: grid;
  place-items: center;
  padding: 2rem 5rem;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.92);
}

/*
 * The slider is the visible viewport for the previous, current and next
 * image panels. Pointer Events provide touch and mouse dragging support.
 */
.vjfnl-nmg-slider {
  width: 100%;
  max-width: 1200px;
  overflow: hidden;
  touch-action: pan-y;
  cursor: grab;
}

.vjfnl-nmg-slider:active {
  cursor: grabbing;
}

/* Horizontal three-panel slider track. */
.vjfnl-nmg-slider-track {
  display: flex;
  width: 100%;
  transform: translateX(-100%);
  will-change: transform;
}

/* One lightbox image panel. */
.vjfnl-nmg-slide {
  display: grid;
  flex: 0 0 100%;
  place-items: center;
  min-width: 0;
  height: 90vh;
}

/* Keep enlarged images fully visible inside the lightbox. */
.vjfnl-nmg-slide img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 90vh;
  object-fit: contain;
  user-select: none;
  pointer-events: none;
}

/* Shared close and navigation button styling. */
.vjfnl-nmg-lightbox button {
  position: fixed !important;
  z-index: 1000000 !important;
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  margin: 0 !important;
  padding: 0 !important;
  color: #fff;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 50%;
  box-shadow: none;
  cursor: pointer;
  font-size: 2rem;
  line-height: 1;
}

.vjfnl-nmg-lightbox button:hover,
.vjfnl-nmg-lightbox button:focus {
  color: #fff;
  background: rgba(255, 255, 255, 0.22);
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* Close button in the upper-right corner. */
.vjfnl-nmg-lightbox .vjfnl-nmg-close {
  top: 1rem !important;
  right: 1rem !important;
  bottom: auto !important;
  left: auto !important;
}

/* Previous image button. */
.vjfnl-nmg-lightbox .vjfnl-nmg-prev {
  top: 50% !important;
  right: auto !important;
  bottom: auto !important;
  left: 1rem !important;
  transform: translateY(-50%) !important;
}

/* Next image button. */
.vjfnl-nmg-lightbox .vjfnl-nmg-next {
  top: 50% !important;
  right: 1rem !important;
  bottom: auto !important;
  left: auto !important;
  transform: translateY(-50%) !important;
}

/* Smaller lightbox controls on phones. */
@media (max-width: 600px) {
  .vjfnl-nmg-lightbox {
    padding: 1rem 3.75rem;
  }

  .vjfnl-nmg-slide {
    height: 85vh;
  }

  .vjfnl-nmg-slide img {
    max-height: 85vh;
  }

  .vjfnl-nmg-lightbox button {
    width: 2.5rem;
    height: 2.5rem;
    font-size: 1.6rem;
  }

  .vjfnl-nmg-lightbox .vjfnl-nmg-prev {
    left: 0.5rem !important;
  }

  .vjfnl-nmg-lightbox .vjfnl-nmg-next {
    right: 0.5rem !important;
  }

  .vjfnl-nmg-lightbox .vjfnl-nmg-close {
    top: 0.5rem !important;
    right: 0.5rem !important;
  }
}