/* Gallery-only mobile compatibility. The unique filename bypasses host and
   browser caches that remove WordPress asset-version query strings. */
.stbv-page-gallery .gallery-page {
  opacity: 1 !important;
  transform: none !important;
}

.stbv-page-gallery .gallery-button {
  -webkit-column-break-inside: avoid;
  break-inside: avoid;
  page-break-inside: avoid;
}

.stbv-page-gallery .gallery-button img {
  opacity: 1 !important;
  visibility: visible !important;
}

@media (max-width: 780px) {
  .stbv-page-gallery .gallery-filters {
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    margin-inline: -16px;
    overflow-x: auto;
    padding: 0 16px 12px;
  }

  .stbv-page-gallery .gallery-filters button {
    flex: 0 0 auto;
    touch-action: manipulation;
  }

  .stbv-page-gallery .masonry-gallery {
    columns: auto;
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .stbv-page-gallery .gallery-button {
    display: block;
    margin: 0;
    min-height: 1px;
    min-width: 0;
    touch-action: manipulation;
    width: 100%;
  }

  .stbv-page-gallery .gallery-button[hidden] {
    display: none;
  }

  .stbv-page-gallery .gallery-button img {
    display: block !important;
    height: auto !important;
    max-height: none;
    pointer-events: none;
    width: 100% !important;
  }

  .stbv-page-gallery .gallery-button span {
    max-width: 100%;
    opacity: 1;
    pointer-events: none;
    text-align: left;
    white-space: normal;
  }

  .stbv-page-gallery .lightbox {
    height: 100vh;
    height: 100dvh;
    max-height: none;
    overflow: hidden;
    padding: max(64px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
  }

  .stbv-page-gallery .lightbox img {
    display: block !important;
    height: auto !important;
    max-height: calc(100vh - 150px);
    max-height: calc(100dvh - 150px);
    max-width: 100%;
    opacity: 1 !important;
    visibility: visible !important;
    width: auto !important;
  }

  .stbv-page-gallery .lightbox-close {
    height: 48px;
    right: max(12px, env(safe-area-inset-right));
    top: max(12px, env(safe-area-inset-top));
    touch-action: manipulation;
    width: 48px;
    z-index: 2;
  }
}

@media (max-width: 620px) {
  .stbv-page-gallery .masonry-gallery {
    grid-template-columns: minmax(0, 1fr);
  }
}
