/* ==========================================================
   Page gallery [bm_gallery] + lightbox
   Bohemian Marine – Overnight Charter page

   Layouts:
     [bm_gallery]                          1–4 tiles
     [bm_gallery layout="grid" show="all"] photo grid,
                                           5 per row on desktop
   ========================================================== */

/* ---------- Gallery grid ---------- */

.bm-gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

/* Fewer than 4 images */
.bm-gallery--1 {
  grid-template-columns: minmax(0, 1fr);
}

.bm-gallery--3 .bm-gallery__item:first-child {
  grid-column: 1 / -1;
  aspect-ratio: 2 / 1;
}

/* ---------- Tiles ---------- */

.bm-gallery__item {
  position: relative;
  display: block;
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  overflow: hidden;
  background: #d3e2f2;
}

.bm-gallery__item[hidden] {
  display: none;
}

.bm-gallery__img {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.bm-gallery__item:hover .bm-gallery__img,
.bm-gallery__item:focus-visible .bm-gallery__img {
  transform: scale(1.04);
}

.bm-gallery__item:focus-visible {
  outline: 3px solid var(--color-secondary);
  outline-offset: 3px;
}

/* ---------- Grid layout (layout="grid") ----------
   Phones (600px and less) : 2 per row
   Tablets                 : 3 per row
   Desktop (1025px and up) : 5 per row
   Tiles, corners and hover come from the rules above. */

.bm-gallery.bm-gallery--grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

@media (min-width: 601px) {
  .bm-gallery.bm-gallery--grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
  }
}

@media (min-width: 1025px) {
  .bm-gallery.bm-gallery--grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 16px;
  }
}

/* ---------- "+N photos" overlay on the last tile ---------- */

.bm-gallery__more {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(27, 79, 155, 0.6); /* --color-primary */
  color: #ffffff;
  font-weight: 700;
  transition: background-color 0.3s ease;
}

.bm-gallery__item--more:hover .bm-gallery__more,
.bm-gallery__item--more:focus-visible .bm-gallery__more {
  background: rgba(27, 79, 155, 0.75);
}

/* ==========================================================
   Lightbox
   ========================================================== */

body.bm-lightbox-open {
  overflow: hidden;
}

.bm-lightbox {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 64px 80px;
  background: rgba(10, 20, 35, 0.94);
  color: #ffffff;
}

.bm-lightbox[hidden] {
  display: none;
}

.bm-lightbox__figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  max-height: 100%;
  margin: 0;
}

.bm-lightbox__img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100vh - 160px);
  margin: 0;
  border-radius: 8px;
  object-fit: contain;
}

.bm-lightbox__caption {
  text-align: center;
  color: rgba(255, 255, 255, 0.85);
}

.bm-lightbox__caption:empty {
  display: none;
}

.bm-lightbox__count {
  position: absolute;
  top: 24px;
  left: 24px;
  color: rgba(255, 255, 255, 0.85);
}

/* Buttons – reset theme button styles first */
.bm-lightbox .bm-lightbox__btn {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  box-shadow: none;
  color: #ffffff;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.bm-lightbox .bm-lightbox__btn:hover {
  background: var(--color-secondary);
}

.bm-lightbox .bm-lightbox__btn:focus-visible {
  outline: 2px solid var(--color-secondary);
  outline-offset: 2px;
}

.bm-lightbox .bm-lightbox__btn svg {
  display: block;
  width: 24px;
  height: 24px;
}

.bm-lightbox .bm-lightbox__close {
  top: 16px;
  right: 16px;
}

.bm-lightbox .bm-lightbox__prev {
  top: 50%;
  left: 16px;
  transform: translateY(-50%);
}

.bm-lightbox .bm-lightbox__next {
  top: 50%;
  right: 16px;
  transform: translateY(-50%);
}

/* Mobile: arrows move below the photo */
@media (max-width: 767px) {
  .bm-lightbox {
    padding: 64px 16px 88px;
  }

  .bm-lightbox__img {
    max-height: calc(100vh - 176px);
  }

  .bm-lightbox .bm-lightbox__prev,
  .bm-lightbox .bm-lightbox__next {
    top: auto;
    bottom: 16px;
    transform: none;
  }

  .bm-lightbox .bm-lightbox__prev {
    left: calc(50% - 56px);
  }

  .bm-lightbox .bm-lightbox__next {
    right: calc(50% - 56px);
  }
}