/* =========================================================
   Photo gallery. Loaded only by other.html, on top of style.css.
   ========================================================= */

:root {
  --photo-ratio: 4 / 3;    /* every photo is cropped to this shape; try 3 / 2, 1 / 1 or 4 / 5 */
  --photo-radius: 14px;    /* roundness of the corners */
}

.gallery {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3rem 2rem;
  list-style: none;
  margin: clamp(2rem, 5vw, 3.5rem) 0 0;
  padding: 0;
}
@media (max-width: 60rem) { .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 38rem) { .gallery { grid-template-columns: minmax(0, 1fr); gap: 2.5rem; } }

.photo { margin: 0; }
.photo__link {
  display: block;
  overflow: hidden;
  border-radius: var(--photo-radius);
  background: var(--paper-alt);
}
.photo img {
  width: 100%;
  aspect-ratio: var(--photo-ratio);
  object-fit: cover;               /* fills the shape; the edges get cropped */
  object-position: 50% 50%;        /* per photo, e.g. style="object-position: 50% 25%" keeps the upper part */
  transition: transform 0.4s ease;
}
.photo__link:hover img { transform: scale(1.03); }
.photo__link:focus-visible { outline-offset: 4px; border-radius: var(--photo-radius); }

.photo figcaption { margin-top: 1rem; }
.photo__title { font-size: 1.3rem; line-height: 1.3; margin: 0 0 0.3rem; }
.photo__text { color: var(--muted); font-size: 1.0625rem; line-height: 1.55; margin: 0; }

/* ---------- Enlarged view (opens when a photo is clicked) ---------- */
/* Sits on a dark backdrop in both light and dark mode, like a photo viewer. */
.lightbox {
  width: min(94vw, 75rem);
  max-width: none;
  max-height: 96vh;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--on-night);
  overflow: visible;
}
.lightbox::backdrop { background: rgba(4, 7, 18, 0.96); backdrop-filter: blur(6px); }
.lightbox img {
  display: block;
  width: auto; height: auto;
  max-width: 100%;
  max-height: 80vh;
  margin: 0 auto;
  border-radius: var(--photo-radius);   /* now hugs the photo itself */
}
.lightbox__bar {
  display: flex; align-items: flex-start; gap: 1.25rem;
  max-width: 60rem; margin: 1rem auto 0;
}
.lightbox__caption { flex: 1; min-width: 0; }
.lightbox__caption .photo__title { color: var(--on-night); margin-bottom: 0.2rem; }
.lightbox__caption .photo__text { color: var(--on-night-muted); }
.lightbox__controls { display: flex; gap: 0.5rem; flex: none; }
.lightbox__btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.5rem; height: 2.5rem;
  color: var(--on-night);
  background: rgba(238, 241, 247, 0.06);
  border: 1px solid rgba(238, 241, 247, 0.4);
  border-radius: 999px;
  cursor: pointer;
}
.lightbox__btn:hover { background: rgba(238, 241, 247, 0.16); border-color: var(--on-night); }
.lightbox__btn svg { width: 1.1rem; height: 1.1rem; }
.lightbox :focus-visible { outline-color: var(--on-night); }

@media (prefers-reduced-motion: reduce) {
  .photo img { transition: none; }
  .photo__link:hover img { transform: none; }
}
