body.is-lightbox-open {
  overflow: hidden;
}

[data-lightbox] { cursor: zoom-in; }

.lightbox[hidden],
.lightbox [hidden] {
  display: none !important;
}

.lightbox {
  position: fixed;
  z-index: 1200;
  inset: 0;
  display: grid;
  place-items: center;
  padding: clamp(0.5rem, 2vw, 1.5rem);
  background: rgb(10 35 41 / 92%);
  overscroll-behavior: contain;
}

.lightbox.is-open {
  animation: lightbox-fade-in 180ms ease both;
}

.lightbox__dialog {
  position: relative;
  display: grid;
  width: min(100%, 100rem);
  height: 100%;
  min-height: 0;
  grid-template-rows: minmax(0, 1fr) auto;
}

.lightbox__stage {
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: center;
  padding: 3.25rem clamp(2.75rem, 6vw, 5rem) 0.75rem;
  touch-action: pan-y;
}

.lightbox__image {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100vh - 7rem);
  max-height: calc(100dvh - 7rem);
  border-radius: var(--radius-sm, 0.75rem);
  object-fit: contain;
  box-shadow: 0 1rem 3rem rgb(0 0 0 / 35%);
  user-select: none;
  -webkit-user-drag: none;
}

.lightbox__caption {
  justify-self: center;
  max-width: min(100%, 64rem);
  padding: 0.5rem 0.875rem;
  border-radius: var(--radius-sm, 0.75rem);
  background: rgb(10 35 41 / 72%);
  color: #ffffff;
  font-size: 0.9375rem;
  line-height: 1.4;
  text-align: center;
}

.lightbox__button {
  position: absolute;
  z-index: 1;
  display: grid;
  width: 3rem;
  height: 3rem;
  place-items: center;
  padding: 0;
  border: 1px solid rgb(255 255 255 / 35%);
  border-radius: 50%;
  background: rgb(255 255 255 / 92%);
  color: var(--color-primary-dark, #247a8a);
  font: inherit;
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
  transition:
    background-color var(--transition, 180ms ease),
    color var(--transition, 180ms ease),
    transform var(--transition, 180ms ease);
}

.lightbox__button:hover {
  background: var(--color-primary, #3aafc1);
  color: #ffffff;
}

.lightbox__button:active {
  transform: scale(0.94);
}

.lightbox__close {
  top: 0;
  right: 0;
}

.lightbox__previous,
.lightbox__next {
  top: 50%;
  transform: translateY(-50%);
}

.lightbox__previous:active,
.lightbox__next:active {
  transform: translateY(-50%) scale(0.94);
}

.lightbox__previous {
  left: 0;
}

.lightbox__next {
  right: 0;
}

.lightbox__sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

@keyframes lightbox-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (max-width: 40rem) {
  .lightbox {
    padding: 0.5rem;
  }

  .lightbox__stage {
    padding: 3.25rem 0.25rem 0.5rem;
  }

  .lightbox__image {
    max-height: calc(100vh - 7.5rem);
    max-height: calc(100dvh - 7.5rem);
    border-radius: 0.5rem;
  }

  .lightbox__button {
    width: 2.75rem;
    height: 2.75rem;
    background: rgb(255 255 255 / 88%);
  }

  .lightbox__previous {
    left: 0.25rem;
  }

  .lightbox__next {
    right: 0.25rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lightbox.is-open {
    animation: none;
  }

  .lightbox__button {
    transition: none;
  }
}
