/* Scroll lock when lightbox is open */
html.gallery-lightbox-open,
body.gallery-lightbox-open {
  overflow: hidden !important;
}

/* Custom gallery lightbox */
.gallery-lightbox {
  position: fixed;
  inset: 0;
  background: #000000A8;
  z-index: 100000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 73px 40px 40px;
  box-sizing: border-box;
}

.gallery-lightbox.is-hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: visibility 0.2s, opacity 0.2s;
}

.gallery-lightbox:not(.is-hidden) {
  visibility: visible;
  opacity: 1;
  transition: visibility 0.2s, opacity 0.2s;
}

.gallery-lightbox__caption-wrap {
  position: absolute;
  top: 73px;
  left: 40px;
  right: auto;
  max-width: min(300px, calc(100% - 120px));
}

.gallery-lightbox__counter,
.gallery-lightbox__caption,
.gallery-lightbox__title {
  color: #fff;
  font-size: 1rem;
  line-height: 1.4;
  margin: 0 0 0.25em 0;
}

.gallery-lightbox__title:empty,
.gallery-lightbox__caption:empty {
  display: none;
}

.gallery-lightbox__counter:last-child,
.gallery-lightbox__caption:last-child,
.gallery-lightbox__title:last-child {
  margin-bottom: 0;
}

.gallery-lightbox__close {
  position: absolute;
  top: 73px;
  right: 40px;
  left: auto;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* RTL: counter/caption anchored right, close left; thumbs scroll direction RTL */
[dir="rtl"] .gallery-lightbox__caption-wrap {
  left: auto;
  right: 40px;
}

[dir="rtl"] .gallery-lightbox__close {
  right: auto;
  left: 40px;
}

[dir="rtl"] .gallery-lightbox__thumbs {
  direction: rtl;
}

.gallery-lightbox__main-wrap {
  position: relative;
  max-width: 850px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-lightbox__main-img {
  max-width: 850px;
  width: 100%;
  height: 485px;
  object-fit: contain;
  display: block;
  border-radius: 8px;
  transition: opacity 0.2s ease;
}

.gallery-lightbox__arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.gallery-lightbox__arrow.is-prev {
  left: -56px;
}

.gallery-lightbox__arrow.is-next {
  right: -56px;
}

.gallery-lightbox__arrow svg path {
  stroke: #fff;
}

.gallery-lightbox__arrow[disabled] {
  opacity: 0.3;
  cursor: default;
}

.gallery-lightbox__thumbs-wrap {
  margin-top: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 850px;
  width: 100%;
}

.gallery-lightbox__thumbs-arrow {
  display: none;
}

.gallery-lightbox__thumbs-track {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.gallery-lightbox__thumbs {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  overflow-x: auto;
  scroll-behavior: smooth;
  margin-top: 0;
  max-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 24px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.gallery-lightbox__thumbs::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.gallery-lightbox__thumb {
  height: 100px;
  width: 120px;
  min-width: 120px;
  cursor: pointer;
  display: block;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 4px;
  transition: border-color 0.15s, opacity 0.15s;
  overflow: hidden;
  background: transparent;
  flex-shrink: 0;
}

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

.gallery-lightbox__thumb:hover {
  opacity: 0.9;
}

.gallery-lightbox__thumb.is-active {
  border-color: #00B5D3;
}

/* Smaller laptops: fit on screen but keep size and arrow alignment */
@media (max-width: 1400px) {
  .gallery-lightbox__main-wrap {
    max-width: min(850px, calc(100vw - 112px));
  }

  .gallery-lightbox__main-img {
    max-width: 100%;
    height: min(485px, 55vh);
    object-fit: contain;
  }

  .gallery-lightbox__thumbs-wrap {
    max-width: min(850px, calc(100vw - 80px));
    width: 100%;
  }

  .gallery-lightbox__thumb {
    height: 100px;
    width: 120px;
    min-width: 120px;
  }
}

@media (max-width: 767px) {
  .gallery-lightbox {
    padding: 73px 16px 16px;
  }

  .gallery-lightbox__main-wrap {
    max-width: 100%;
    width: 100%;
  }

  .gallery-lightbox__main-img {
    max-width: 100%;
    width: 100%;
    height: 240px;
    object-fit: cover;
    border-radius: 5px;
  }

  .gallery-lightbox__arrow.is-prev {
    left: 0;
    right: auto;
  }

  .gallery-lightbox__arrow.is-next {
    right: 0;
    left: auto;
  }

  .gallery-lightbox__thumbs-wrap {
    margin-top: 12px;
    margin-left: -16px;
    margin-right: -16px;
    width: calc(100% + 32px);
    max-width: none;
  }

  .gallery-lightbox__thumbs-arrow {
    display: none;
  }

  .gallery-lightbox__thumbs {
    margin-top: 0;
    margin-left: 0;
    margin-right: 0;
    padding: 0 15px;
    width: 100%;
    gap: 4px;
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
  }

  .gallery-lightbox__thumb {
    flex: 0 0 calc((100% - 24px) / 3.5);
    min-width: calc((100% - 24px) / 3.5);
    width: auto;
    height: 80px;
    border-radius: 5px;
  }

  /* RTL mobile: same edge-to-edge; strip extends to both sides so no gap on right (start side in RTL) */
  [dir="rtl"] .gallery-lightbox__thumbs-wrap {
    margin-left: -16px;
    margin-right: -16px;
  }

}