work-gallery {
  display: block;
  width: 100%;
  margin-top: clamp(20px, 2.5cqw, 36px);
}
.gallery-viewport {
  position: relative;
  overflow: hidden;
  aspect-ratio: var(--gallery-ratio, 16 / 9);
  border-radius: 12px;
  touch-action: manipulation;
}
.gallery-next {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.gallery-next:focus-visible { outline: 2px solid #aa9dff; outline-offset: -4px; }
.gallery-track { display: flex; height: 100%; will-change: transform; }
.gallery-slide { display: grid; place-items: center; flex: 0 0 100%; height: 100%; min-width: 0; }
.gallery-slide img { display: block; width: 100%; height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; }
@media (min-width: 801px) {
  work-gallery[wide-pair] .gallery-slide { flex-basis: 50%; width: 50%; }
}
work-gallery:focus-visible { outline: 2px solid #aa9dff; outline-offset: 4px; }
@media (prefers-reduced-motion: reduce) { .gallery-track { transition: none !important; } }

.gallery-track { min-height: 0; }
.gallery-slide { overflow: hidden; min-height: 0; width: 100%; box-sizing: border-box; padding: 20px; }
.gallery-slide img { max-width: 100%; max-height: 100%; min-width: 0; min-height: 0; width: 100%; height: 100%; }
@media (max-width: 600px) { .gallery-slide { padding: 14px; } }

work-gallery { position: relative; }
.gallery-zoom {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: white;
  font: 400 24px/44px Arial, sans-serif;
  cursor: zoom-in;
  isolation: isolate;
}
.gallery-zoom::before {
  content: "";
  position: absolute;
  inset: 7px;
  z-index: -1;
  border: 1px solid #ffffff88;
  border-radius: 50%;
  background: #1b1b1bd9;
}
.gallery-zoom:hover::before { background: #7e6afa; }
.gallery-zoom:focus-visible, .gallery-detail button:focus-visible { outline: 2px solid #aa9dff; outline-offset: 2px; }
.gallery-detail {
  width: min(96vw, 1640px);
  max-width: 96vw;
  max-height: 94dvh;
  padding: 12px;
  border: 1px solid #ffffff55;
  border-radius: 14px;
  background: #1b1b1b;
  color: white;
  overflow: hidden;
}
.gallery-detail::backdrop { background: #000d; }
.gallery-detail-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; font: 400 14px/1.3 "Portfolio Jost", sans-serif; }
.gallery-detail-header button { flex: 0 0 44px; height: 44px; border: 1px solid #fff8; border-radius: 50%; color: white; background: #262626; font-size: 26px; cursor: pointer; }
.gallery-detail-viewport { max-height: calc(94dvh - 100px); overflow: auto; overscroll-behavior: contain; touch-action: pan-x pan-y pinch-zoom; }
.gallery-detail-viewport img { display: block; min-width: 100%; max-width: none; height: auto; margin-inline: auto; }

.gallery-progress {
  display: flex;
  justify-content: center;
  max-width: 100%;
  margin: 3px auto 0;
}
.gallery-progress button {
  position: relative;
  flex: 0 1 24px;
  min-width: 0;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
}
.gallery-progress button::before {
  content: "";
  position: absolute;
  inset: 50% 2px auto;
  height: 2px;
  border-radius: 999px;
  background: #ffffff3d;
  transform: translateY(-50%);
}
.gallery-progress button:hover::before { background: #ffffff8c; }
.gallery-progress button[aria-current="true"]::before { height: 3px; background: #aa9dff; }
.gallery-progress button:focus-visible { outline: 2px solid #aa9dff; outline-offset: -2px; }
@media (pointer: coarse) {
  .gallery-progress button { height: 40px; }
}


/* Scale scene artwork from its visible bounds within the 4:3 slide. */
.gallery-slide:has(.gallery-scene) { position: relative; padding: 0; }
.gallery-slide img.gallery-scene {
  position: absolute;
  left: var(--scene-left);
  top: var(--scene-top);
  width: var(--scene-width);
  height: auto;
  max-width: none;
  max-height: none;
}
