/* gallery.css
   Rebuilt CSS grid/masonry layer for overview, multiexpo, waterbus
*/

.gallery,
.gallery-section-wrapper,
.gallery-masonry{
  width: 100%;
}

.gallery{
  padding: 8px 0 36px;
}

.gallery-masonry{
  max-width: min(var(--jcb-max), calc(100vw - (2 * var(--jcb-space-x))));
  margin: 0 auto;
}

.gallery-masonry-wrapper{
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 22px;
  align-items: start;
}

.gallery-masonry-item{
  margin: 0 !important;
  break-inside: avoid;
}

.gallery-masonry-item-wrapper{
  overflow: hidden;
  background: #e9e9e9;
}

.gallery-masonry-item a{
  display: block;
}

.gallery-masonry-item img{
  width: 100% !important;
  height: auto !important;
  aspect-ratio: auto;
  transition: transform .28s ease, opacity .28s ease;
}

.gallery-masonry-item a:hover img{
  transform: scale(1.012);
  opacity: .96;
}

.gallery-caption{
  padding-top: 10px;
}

.gallery-caption-wrapper{
  padding: 0;
}

.gallery-caption-content{
  margin: 0;
  color: var(--jcb-text);
  font-size: 13px;
  line-height: 1.45;
}

.gallery-masonry-item.has-clickthrough .gallery-caption-content{
  font-size: 15px;
}

.gallery-masonry-item.has-clickthrough .gallery-caption{
  text-align: center;
}

.gallery-masonry-item.has-clickthrough .gallery-caption-content{
  display: inline-block;
  padding-top: 2px;
}

.gallery-lightbox-outer-wrapper,
.gallery-lightbox{
  display: none !important;
}

.page-section[data-sqsp-section="gallery"],
section[data-sqsp-section="gallery"]{
  padding-top: 16px;
  padding-bottom: 40px;
}

@media (max-width: 980px){
  .gallery-masonry-wrapper{
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
  }
}

@media (max-width: 640px){
  .gallery{
    padding-bottom: 24px;
  }

  .gallery-masonry-wrapper{
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .gallery-caption-content{
    font-size: 12.5px;
  }
}
/* --- JCB local lightbox + loupe overlay --- */

.gallery-masonry-item-wrapper{
  position: relative;
}

.gallery-masonry-lightbox-link{
  position: relative;
  cursor: zoom-in;
}

.gallery-masonry-lightbox-link::before{
  content: "+";
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 3;
  width: 42px;
  height: 42px;
  border: 2px solid rgba(255,255,255,.95);
  border-radius: 999px;
  background: rgba(17,17,17,.42);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 700 28px/1 Arial, Helvetica, sans-serif;
  opacity: 0;
  transform: scale(.9);
  transition: opacity .22s ease, transform .22s ease, background .22s ease;
  pointer-events: none;
}

.gallery-masonry-lightbox-link::after{
  content: "";
  position: absolute;
  right: 8px;
  bottom: 9px;
  z-index: 3;
  width: 12px;
  height: 3px;
  border-radius: 2px;
  background: rgba(255,255,255,.95);
  transform: rotate(45deg);
  opacity: 0;
  transition: opacity .22s ease;
  pointer-events: none;
}

.gallery-masonry-item:hover .gallery-masonry-lightbox-link::before,
.gallery-masonry-item:hover .gallery-masonry-lightbox-link::after,
.gallery-masonry-lightbox-link:focus-visible::before,
.gallery-masonry-lightbox-link:focus-visible::after{
  opacity: 1;
  transform: scale(1);
}

.gallery-masonry-item:hover .gallery-masonry-lightbox-link::before,
.gallery-masonry-lightbox-link:focus-visible::before{
  background: rgba(17,17,17,.58);
}

@media (hover: none){
  .gallery-masonry-lightbox-link::before,
  .gallery-masonry-lightbox-link::after{
    opacity: 1;
    transform: scale(1);
  }
}

/* Lightbox local */

html.jcb-lightbox-open,
body.jcb-lightbox-open{
  overflow: hidden;
}

.jcb-lightbox[hidden]{
  display: none !important;
}

.jcb-lightbox{
  position: fixed;
  inset: 0;
  z-index: 9999;
}

.jcb-lightbox__backdrop{
  position: absolute;
  inset: 0;
  background: rgba(245,245,245,.94);
  backdrop-filter: blur(2px);
}

.jcb-lightbox__dialog{
  position: relative;
  z-index: 2;
  width: min(92vw, 1600px);
  height: min(90vh, 980px);
  margin: 5vh auto;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 72px;
  align-items: center;
}

.jcb-lightbox__figure{
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
}

.jcb-lightbox__image{
  max-width: 100%;
  max-height: calc(90vh - 110px);
  width: auto;
  height: auto;
  object-fit: contain;
  box-shadow: 0 0 0 1px rgba(0,0,0,.06);
  background: #fff;
}

.jcb-lightbox__caption{
  margin-top: 18px;
  text-align: center;
  color: #5e5e5e;
  font-size: 15px;
  line-height: 1.45;
  max-width: min(100%, 1100px);
}

.jcb-lightbox__close,
.jcb-lightbox__nav{
  appearance: none;
  border: 0;
  background: transparent;
  color: #202020;
  cursor: pointer;
}

.jcb-lightbox__close{
  position: absolute;
  top: 10px;
  right: 8px;
  z-index: 3;
  width: 54px;
  height: 54px;
  font-size: 52px;
  line-height: 1;
}

.jcb-lightbox__nav{
  width: 72px;
  height: 72px;
  font-size: 64px;
  line-height: 1;
  opacity: .82;
}

.jcb-lightbox__nav:hover,
.jcb-lightbox__close:hover{
  opacity: 1;
}

.jcb-lightbox__nav[hidden]{
  visibility: hidden;
}

@media (max-width: 820px){
  .jcb-lightbox__dialog{
    width: 96vw;
    height: 92vh;
    margin: 4vh auto;
    grid-template-columns: 56px minmax(0, 1fr) 56px;
  }

  .jcb-lightbox__image{
    max-height: calc(92vh - 120px);
  }

  .jcb-lightbox__close{
    top: 2px;
    right: 2px;
    width: 46px;
    height: 46px;
    font-size: 42px;
  }

  .jcb-lightbox__nav{
    width: 56px;
    height: 56px;
    font-size: 46px;
  }

  .jcb-lightbox__caption{
    font-size: 14px;
    margin-top: 14px;
  }
}

