html:has(.lightbox[open]) { overflow: hidden; }

.lightbox {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgb(8 9 11 / 0.94);
  color: var(--ink);
  touch-action: pinch-zoom;
  opacity: 0;
  transition: opacity 0.2s, overlay 0.2s allow-discrete, display 0.2s allow-discrete;
}
.lightbox[open] { opacity: 1; }
@starting-style {
  .lightbox[open] { opacity: 0; }
}
.lightbox::backdrop { background: transparent; }

.lightbox-stage {
  box-sizing: border-box;
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  place-items: center;
  width: 100%;
  height: 100%;
  padding: clamp(4rem, 8vh, 5.5rem) clamp(1rem, 7vw, 6.5rem);
}

.lightbox-stage:has(.lightbox-caption) {
  grid-template-rows: minmax(0, max-content) auto;
  align-content: center;
}

.lightbox-media {
  display: block;
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  user-select: none;
  -webkit-user-drag: none;
}

.lightbox-caption {
  max-width: 60ch;
  margin: 1rem 0 0;
  color: var(--ink-mid);
  font: 500 0.875rem / 1.55 "Neely Text Sans", sans-serif;
  text-align: center;
  text-wrap: balance;
}
.lightbox-caption strong {
  color: var(--ink);
  font-family: var(--font);
  font-weight: 600;
}

.lightbox-button {
  position: absolute;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.08);
  color: var(--ink);
  cursor: var(--cursor-link, pointer);
  transition: background 0.15s;
}
.lightbox-button:hover { background: rgb(255 255 255 / 0.16); }
.lightbox-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.lightbox-button svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.lightbox-close { top: 1rem; right: 1rem; }
.lightbox-prev,
.lightbox-next { top: 50%; translate: 0 -50%; }
.lightbox-prev { left: clamp(0.5rem, 2vw, 1.5rem); }
.lightbox-next { right: clamp(0.5rem, 2vw, 1.5rem); }
.lightbox.is-single .lightbox-prev,
.lightbox.is-single .lightbox-next { display: none; }

@media (max-width: 560px) {
  .lightbox-prev,
  .lightbox-next { top: auto; bottom: 1rem; translate: none; }
  .lightbox-prev { left: calc(50% - 3.25rem); }
  .lightbox-next { right: calc(50% - 3.25rem); }
}

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