.gallery-section { overflow: visible; content-visibility: visible; }
.gallery-section .gallery-card-stage {
  --gallery-card-width: min(70vw,380px);
  width: 100vw; max-width: none; height: auto; min-height: 0; aspect-ratio: auto;
  margin-inline: calc((100% - 100vw) / 2); padding: 0 0 8px;
  overflow-x: auto; overflow-y: hidden; border: 0; border-radius: 0;
  background: transparent; box-shadow: none; scrollbar-width: none;
  scroll-snap-type: x mandatory; overscroll-behavior-x: contain;
  touch-action: pan-x pan-y pinch-zoom;
}
.gallery-card-stage::-webkit-scrollbar { display: none; }
.gallery-section .gallery-card-stage::before,
.gallery-section .gallery-card-stage::after,
.gallery-section .gallery-dots { display: none; }
.gallery-section .gallery-grid {
  display: grid; grid-template-columns: none; grid-auto-flow: column;
  grid-auto-columns: var(--gallery-card-width); gap: 16px; height: auto; min-height: 0;
  width: max-content; padding-inline: calc((100vw - var(--gallery-card-width)) / 2);
}
.gallery-section :is(.gallery-item,.gallery-card-clone) {
  position: relative; inset: auto; width: 100%; height: auto; aspect-ratio: 3 / 4; margin: 0;
  padding: 0; border: 0; overflow: hidden;
  border-radius: 24px; opacity: 1; pointer-events: auto; transform: none;
  scroll-snap-align: center; background: #101521; cursor: zoom-in;
}
.gallery-section :is(.gallery-item,.gallery-card-clone) img {
  display: block; width: 100%; height: 100%; object-fit: cover; object-position: center;
  animation: none !important; transform: none; filter: none;
}
.gallery-card-footer { display: flex; justify-content: flex-end; margin-top: 18px; }
.gallery-card-footer > div { display: flex; gap: 10px; }
.gallery-card-footer button {
  position: static; inset: auto; transform: none; width: 44px; height: 44px;
  display: grid; place-items: center; border-radius: 50%; border: 1px solid #ffffff24;
  background: #101521; color: #fff; box-shadow: none; cursor: pointer;
  transition: background 180ms ease, color 180ms ease, border-color 180ms ease;
}
.gallery-card-footer button svg { width: 22px; height: 22px; }
.gallery-card-footer .gallery-nav,
.gallery-card-footer .gallery-nav:is(:hover,:focus-visible,:active) {
  position: relative; inset: auto; transform: none; translate: none;
}
.gallery-card-footer .gallery-nav::before { display: none; }
.gallery-card-footer button:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.gallery-card-footer button:active { background: #c1ff5c; color: #080510; }
@media (hover: hover) {
  .gallery-section .gallery-item:hover img { transform: scale(1.035); }
  .gallery-card-footer button:hover { background: #c1ff5c; color: #080510; border-color: #c1ff5c; }
}
@media (max-width: 860px) {
  .gallery-section .gallery-card-stage { --gallery-card-width: min(74vw,340px); }
}
@media (min-width: 861px) {
  .gallery-section .gallery-card-stage { --gallery-card-width: min(calc(100vw - 64px),calc(380px * 4 / 3 * 16 / 9)); }
  .gallery-section :is(.gallery-item,.gallery-card-clone) { aspect-ratio: 16 / 9; }
}
@media (prefers-reduced-motion: reduce) {
  .gallery-section .gallery-item img { transition: none; }
  .gallery-section .gallery-item:hover img { transform: none; }
}

/* Size the viewer to the available viewport, including scrollbar and safe areas. */
html:has(body.lightbox-open) { overflow: hidden; }
.lightbox {
  inset: 0; width: auto; max-width: 100%; height: 100dvh; max-height: 100dvh;
  box-sizing: border-box;
}
.lightbox-header {
  left: max(20px,env(safe-area-inset-left));
  right: max(20px,env(safe-area-inset-right));
}
.lightbox-viewport { width: min(1440px,calc(100% - 120px)); max-width: 100%; }
.lightbox-nav.prev { left: max(20px,env(safe-area-inset-left)); }
.lightbox-nav.next { right: max(20px,env(safe-area-inset-right)); }
.lightbox-footer { width: calc(100% - 40px); }
@media (max-width: 700px) {
  .lightbox-viewport { width: calc(100% - 24px); }
  .lightbox-header { top: max(16px,env(safe-area-inset-top)); }
  .lightbox-footer { bottom: max(16px,env(safe-area-inset-bottom)); }
}
