#gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
#gallery::after {
  content: '';
  flex-grow: 999;
}
.gallery-item {
  position: relative;
  overflow: hidden;
  max-width: 48%;
  cursor: zoom-in;
  background-color: #e6ebf2;
  background-image: linear-gradient(
    100deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.55) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  background-size: 220% 100%;
  background-repeat: no-repeat;
  animation: gallery-shimmer 1.6s ease-in-out infinite;
}
.gallery-item-loaded {
  animation: none;
  background-image: none;
}
.gallery-item a {
  display: block;
  border-bottom: none;
}
.gallery-item a:hover {
  border-bottom: none;
}
.gallery-item img {
  width: 100%;
  height: auto;
  display: block;
  opacity: 0;
  transition: transform 0.35s ease, opacity 0.4s ease;
}
.gallery-item-loaded img {
  opacity: 1;
}
@keyframes gallery-shimmer {
  0%   { background-position: -120% 0; }
  100% { background-position:  220% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .gallery-item { animation: none; }
}
.gallery-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.5em 0.7em;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 0.8rem;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.gallery-item:hover .gallery-caption {
  opacity: 1;
}
@media (max-width: 1200px) {
  #gallery {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
  }
  #gallery::after {
    display: none;
  }
  .gallery-item {
    max-width: 100%;
    flex-grow: unset !important;
    flex-basis: unset !important;
  }
  .gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    aspect-ratio: 1.5;
  }
}
@media (hover: hover) {
  .gallery-item:hover img {
    transform: scale(1.04);
  }
  .gallery-item a::before {
    content: '';
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.55);
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='15 3 21 3 21 9'/><polyline points='9 21 3 21 3 15'/><line x1='21' y1='3' x2='14' y2='10'/><line x1='3' y1='21' x2='10' y2='14'/></svg>");
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0;
    transform: scale(0.85);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
    z-index: 2;
  }
  .gallery-item:hover a::before {
    opacity: 1;
    transform: scale(1);
  }
}
.gallery-item a:focus-visible {
  outline: 3px solid #4a7bd6;
  outline-offset: 2px;
}

.pswp__button--zoom {
  display: none !important;
}

.pswp__img,
.pswp__zoom-wrap,
.pswp__container,
.pswp--zoomed-in .pswp__img,
.pswp--click-to-zoom.pswp--zoom-allowed .pswp__img {
  cursor: default !important;
}

.pswp__caption {
  position: absolute;
  left: 50%;
  bottom: 110px;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 8px 18px;
  text-align: center;
  color: #fff;
  font-size: 1.15rem;
  line-height: 1.35;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 4px;
  pointer-events: none;
  z-index: 1050;
}
.pswp__caption:empty {
  display: none;
}

.pswp__filmstrip {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  padding: 6px;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 6px;
  z-index: 1050;
  max-width: calc(100% - 24px);
}
.pswp__filmstrip-thumb {
  width: 96px;
  height: 72px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 3px;
  background: transparent;
  cursor: pointer;
  overflow: hidden;
  opacity: 0.6;
  transition: opacity 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
  flex: 0 0 auto;
}
.pswp__filmstrip-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.pswp__filmstrip-thumb:hover {
  opacity: 1;
}
.pswp__filmstrip-thumb--current {
  opacity: 1;
  border-color: #fff;
  transform: scale(1.05);
  cursor: default;
}
@media (max-width: 600px) {
  .pswp__filmstrip-thumb { width: 60px; height: 48px; }
  .pswp__caption { bottom: 88px; font-size: 0.95rem; padding: 6px 12px; }
}
