.work-gallery:not(:has(.work-gallery__grid a)),
.work-gallery__controls[hidden] {
  display: none;
}

.work-gallery__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(8px, 2vw, 20px);
}

.work-gallery__grid a {
  display: block;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
  background: var(--tint);
  box-shadow: var(--shadow);
  cursor: zoom-in;
}

.work-gallery__grid img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.work-gallery__grid a:focus-visible {
  outline: 3px solid var(--p);
  outline-offset: 3px;
}

@media (max-width: 680px) {
  .work-gallery__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .work-gallery__grid img {
    transition: transform 180ms ease;
  }
  .work-gallery__grid a:hover img {
    transform: scale(1.045);
  }
}

html:has(.work-gallery__viewer[open]) {
  overflow: hidden;
}

.work-gallery__viewer {
  width: max-content;
  max-width: calc(100% - 24px);
  max-height: calc(100% - 24px);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: #1d1a26;
  color: #fff;
}

.work-gallery__viewer::backdrop {
  background: rgba(19, 14, 29, .88);
}

.work-gallery__stage {
  position: relative;
  min-width: min(200px, 80vw);
}

.work-gallery__stage img {
  display: block;
  width: auto;
  height: auto;
  max-width: min(1100px, calc(100vw - 24px));
  max-height: min(78vh, calc(100dvh - 88px));
  margin: 0 auto;
  object-fit: contain;
}

.work-gallery__viewer button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .45);
  border-radius: 50%;
  background: #242030;
  color: #fff;
  font: 1.65rem / 1 system-ui, sans-serif;
  cursor: pointer;
}

.work-gallery__viewer button:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.work-gallery__close {
  position: absolute;
  top: 8px;
  right: 8px;
}

.work-gallery__controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  padding: 8px;
  font-variant-numeric: tabular-nums;
}
