:root {
  --lb-btn-dark-color: #004066;
}

.gallery-block-wrapper {
  width: 100%;
}

.gallery-container {
  position: relative;
  display: flex;
  align-items: flex-start;
  max-width: 85%;
  margin: 0 auto;
  background: transparent;
  padding: 10px 14px;
  border-radius: 6px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  gap: 10px;
  timeline-scope: --gallery-timeline;
  container-type: inline-size;
}

.gallery-track {
  display: flex;
  justify-content: space-evenly;
  align-items: center;
  gap: 12px;
  overflow-x: auto;
  scroll-behavior: smooth;
  scroll-snap-type: x mandatory;
  padding: 6px 0;
  width: 100%;
  scroll-timeline: --gallery-timeline inline;
}

.gallery-item {
  scroll-snap-align: center;
  flex-shrink: 0;
  display: flex;
  text-decoration: none;
}

.gallery-thumb {
  height: var(--thumb-height, 80px);
  width: auto;
  object-fit: cover;
  border-radius: 4px;
  margin: auto;
  display: block;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.gallery-thumb:hover {
  opacity: 0.85;
  transform: scale(1.08);
}

.gallery-track::-webkit-scrollbar { height: 7px; }
.gallery-track::-webkit-scrollbar-track { background: transparent; }
.gallery-track::-webkit-scrollbar-thumb {
  background: var(--wp--preset--color--primary, #006699);
  border-radius: 4px;
}

.nav-btn {
  background: var(--wp--preset--color--primary, #006699);
  color: #ffffff;
  border: none;
  width: 26px;
  height: var(--thumb-height, 80px);
  margin: 6px 0;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  user-select: none;
  transition: opacity 0.2s, transform 0.1s;
}

.nav-btn:hover { opacity: 0.9; }
.nav-btn:active { transform: scale(0.96); }

.gallery-container:not(.has-overflow) .nav-btn { display: none; }

@keyframes disable-left {
  0%, 3% { opacity: 0.25; pointer-events: none; filter: grayscale(1); }
  8%, 100% { opacity: 1; pointer-events: auto; }
}
@keyframes disable-right {
  0%, 92% { opacity: 1; pointer-events: auto; }
  97%, 100% { opacity: 0.25; pointer-events: none; filter: grayscale(1); }
}

.nav-btn.prev { animation: disable-left linear both; animation-timeline: --gallery-timeline; }
.nav-btn.next { animation: disable-right linear both; animation-timeline: --gallery-timeline; }

.lightbox-modal {
  display: flex;
  position: fixed;
  inset: 0;
  z-index: 99999;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.lightbox-modal:has(.lb-slide:target) {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 10, 0.94);
  z-index: 1;
  cursor: default;
}

.lightbox-wrapper {
  position: relative;
  z-index: 2;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 20px 0;
}

.lb-viewport {
  width: 100vw;
  height: fit-content;
  display: flex;
  overflow-x: auto;
  scroll-behavior: smooth;
  scroll-snap-type: x mandatory;
}
.lb-viewport::-webkit-scrollbar { display: none; }

.lb-slide {
  flex: 0 0 100vw;
  width: 100vw;
  height: fit-content;
  margin:auto;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.lb-img-container {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: calc(100vw - 180px);
  max-height: 68vh;
}

.lightbox-img {
  max-width: 100%;
  max-height: 68vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
  display: block;
}

.lb-slide .lb-btn {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.lb-slide:target .lb-btn {
  opacity: 1;
  pointer-events: auto;
}

.lb-btn {
  background: var(--lb-btn-dark-color, #004066);
  color: #ffffff;
  text-decoration: none;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  transition: opacity 0.2s, transform 0.1s;
}

.lb-btn:hover { opacity: 0.88; }

.lb-close {
  position: fixed;
  top: 24px;
  right: 28px;
  width: 36px;
  height: 36px;
  z-index: 4;
  opacity: 1 !important;
  pointer-events: auto !important;
}

.lb-prev, .lb-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 84px;
  z-index: 3;
}

.lb-prev { left: -50px; }
.lb-next { right: -50px; }

.icon-svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.lb-prev .icon-svg, .lb-next .icon-svg {
  width: 24px;
  height: 24px;
}

.lb-thumbs-track {
  display: flex;
  gap: 8px;
  max-width: calc(100vw - 120px);
  overflow-x: auto;
  padding: 6px 4px;
  scroll-behavior: smooth;
}

.lb-thumbs-track::-webkit-scrollbar { height: 4px; }
.lb-thumbs-track::-webkit-scrollbar-track { background: transparent; }
.lb-thumbs-track::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
}

.lb-thumb-item {
  text-decoration: none;
  flex-shrink: 0;
  display: flex;
  scroll-snap-align: center;
}

.lb-thumb-img {
  height: 38px;
  width: auto;
  object-fit: cover;
  border-radius: 3px;
  opacity: 0.45;
  border: 2px solid transparent;
  transition: opacity 0.2s, border-color 0.2s, transform 0.2s;
}

.lb-thumb-img:hover { opacity: 1; }

.lb-thumb-item.is-active .lb-thumb-img {
  opacity: 1;
  border-color: var(--wp--preset--color--primary, #006699);
  transform: scale(1.2);
}

@media (max-width: 768px) {
  .gallery-container { max-width: 95%; padding: 8px; }
  .lb-img-container { max-width: calc(100vw - 80px); max-height: 60vh; }
  .lightbox-img { max-height: 60vh; }
  .lb-thumbs-track { max-width: 90vw; }
  .lb-prev { left: -36px; width: 30px; height: 64px; }
  .lb-next { right: -36px; width: 30px; height: 64px; }
  .lb-close { top: 14px; right: 14px; }
}