/* The photo gallery (components/photo-gallery.js): a grid of 4:3 thumbnails,
   three across (two on phones), each a .zoom link; and its lightbox, a native
   <dialog> the script opens: the page darkened, the photograph as large as the
   viewport allows, a bar under it with previous / next and the caption, the X
   top right. The lightbox is dark in both themes: it is a photo viewer. */

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.gallery-grid img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }

@media (max-width: 700px) {
  .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; }
}

/* The lightbox */
.lightbox {
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  border: 0;
  padding: var(--page-inset);
  background: transparent;
  color: var(--bone);
  display: none;
  flex-direction: column;
  gap: var(--sm);
}
.lightbox[open] { display: flex; }
.lightbox::backdrop { background: rgba(13, 23, 32, 0.94); }

.lightbox-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.lightbox-stage img, .lightbox-stage picture { display: block; max-width: 100%; max-height: 100%; }
.lightbox-stage picture { height: 100%; }
.lightbox-stage img { width: auto; height: 100%; object-fit: contain; }

.lightbox-bar { display: flex; align-items: center; justify-content: center; gap: var(--md); }
.lightbox-caption {
  font-family: var(--mono);
  font-size: var(--kicker);
  letter-spacing: var(--track);
  text-transform: uppercase;
  color: var(--mist);
  text-align: center;
  margin: 0;
}
.lightbox-count { color: var(--bone); margin-right: var(--md); }

/* The controls: the header's bare circle of an icon (header.css .theme-toggle) */
.lightbox button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 2.6rem;
  height: 2.6rem;
  border: 1px solid var(--hairline-dark);
  border-radius: var(--pill);
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.lightbox button:hover { border-color: currentColor; color: var(--sea-light); }
.lightbox button:focus-visible { outline: 2px solid var(--sea-light); outline-offset: 2px; }
.lightbox-close { position: absolute; top: var(--page-inset); right: var(--page-inset); }

@media (max-width: 700px) {
  .lightbox-caption { font-size: 0.6rem; }
  .lightbox-alt { display: block; margin-top: 0.3rem; }
  .lightbox-count { margin-right: 0; }
}
