/* expanded image viewer built by js/components/lightbox.js (see overlay.css for the shell) */

.lightbox {
  overflow: hidden;
  font-family: system-ui, -apple-system, "Helvetica Neue", sans-serif;
}

.lightbox[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 1rem;
  padding: clamp(1rem, 3vw, 2rem) clamp(1rem, 6vw, 5rem);
}

.lightbox .overlay-close {
  justify-self: end;
}

.lightbox-figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  min-height: 0;
  margin: 0;
  transform: scale(0.96);
  transition: transform 0.3s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.lightbox[open] .lightbox-figure {
  transform: none;
}

@starting-style {
  .lightbox[open] .lightbox-figure {
    transform: scale(0.96);
  }
}

/* the image and the video player take turns; their display rules would otherwise beat [hidden] */
.lightbox-figure [hidden] {
  display: none;
}

/* 16:9, as large as fits: the row's height caps the width through the aspect ratio */
.lightbox-video {
  width: min(100%, calc((100vh - 10rem) * 16 / 9));
  aspect-ratio: 16 / 9;
  background: #111;
}

.lightbox-video iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.lightbox-img {
  display: block;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.lightbox-caption {
  font-size: 0.95rem;
  color: var(--dim, rgba(255, 255, 255, 0.55));
  text-align: center;
}

.lightbox-caption:empty {
  display: none;
}

.lightbox-count {
  margin: 0;
  font-size: 0.85rem;
  color: var(--dim, rgba(255, 255, 255, 0.55));
  text-align: center;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  padding: 1rem;
  font: inherit;
  font-size: 1.5rem;
  background: none;
  border: 0;
  cursor: inherit;
  color: var(--dim, rgba(255, 255, 255, 0.55));
  transition: color 0.2s ease;
}

.lightbox-nav:hover {
  color: #fff;
}

.lightbox-nav:focus-visible {
  outline: 1px solid #fff;
  outline-offset: -4px;
}

.lightbox-prev {
  left: clamp(0rem, 1vw, 1rem);
}

.lightbox-next {
  right: clamp(0rem, 1vw, 1rem);
}

/* narrow screens: arrows move down beside the counter instead of over the image */
@media (max-width: 36rem) {
  .lightbox-nav {
    top: auto;
    bottom: 0;
    transform: none;
  }
}

/* only one image: nothing to step through */
.lightbox.is-single :is(.lightbox-nav, .lightbox-count) {
  display: none;
}

/* thumbnails that open it */
img[data-expandable]:focus-visible {
  outline: 1px solid #fff;
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .lightbox-figure,
  .lightbox-nav {
    transition: none;
  }
}
