.gallery {
  --gallery-ratio: 3 / 2;
  --gallery-bg: #111;
  max-width: 60rem;
  margin-block: 0.5rem;
}

.gallery__stage { position: relative; }

.gallery__figure {
  position: relative;
  margin: 0;
  aspect-ratio: var(--gallery-ratio);
  background: var(--gallery-bg);
  border-radius: 6px;
  overflow: hidden;
}

.gallery__image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.gallery__caption {
  position: absolute;
  inset: auto 0 0 0;
  padding: .5rem .75rem;
  background: rgba(0, 0, 0, .6);
  color: #fff;
  font-size: .875rem;
}

.gallery__caption[hidden] { display: none; }

.gallery__nav {
  position: absolute;
  top: 50%;
  z-index: 2;
  translate: 0 -50%;
  width: 2.75rem;
  height: 2.75rem;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font-size: 1.25rem;
  cursor: pointer;
}

.gallery__nav:hover { background: rgba(0, 0, 0, .8); }
.gallery__nav--prev { left: .75rem; }
.gallery__nav--next { right: .75rem; }

.gallery__counter {
  margin: .5rem 0 0;
  font-size: .8rem;
  text-align: center;
  opacity: .7;
}

.gallery__thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin: .5rem 0 0;
  padding: 0;
  list-style: none;
}

.gallery__thumb {
  display: block;
  padding: 0;
  width: 4.5rem;
  height: 4.5rem;
  border: 2px solid transparent;
  border-radius: 4px;
  overflow: hidden;
  background: none;
  cursor: pointer;
  opacity: .6;
}

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

.gallery__thumb:hover,
.gallery__thumb.is-active {
  opacity: 1;
  border-color: currentColor;
}

.gallery :focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}
