/* gallery — this component's own styles, put in the head by the renderer where it is drawn.
   Colours and sizes only through var(--*), so the design drives these too.

   The root says the look: gallery--grid | --masonry | --strip, and a grid's frames gallery--square | --landscape. */

/* ---------- grid: four columns, three, two ---------- */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .9rem;
}

.gallery-item {
  margin: 0;
  scroll-margin-top: calc(var(--header-sticky-h, 0px) + 1.5rem);
}

/* The frame: the photo cut to it, «+3» in its corner. */
.gallery-link {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: var(--radius-small);
  background: var(--hover-wash);
  cursor: zoom-in;
}

.gallery--square .gallery-link { aspect-ratio: 1; }

.gallery--landscape .gallery-link { aspect-ratio: 4 / 3; }

.gallery-link img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .3s ease;
}

.gallery-link:hover img { transform: scale(1.04); }

.gallery-link:focus-visible { outline: 2px solid var(--mark, var(--primary)); outline-offset: 2px; }

.gallery-more {
  position: absolute;
  right: .5rem;
  bottom: .5rem;
  padding: .15rem .55rem;
  border-radius: var(--pill);
  background: color-mix(in srgb, var(--shade) 70%, transparent);
  color: #fff;
  font-size: .8rem;
  font-weight: 600;
}

/* The record's name under its photo — two lines at most. */
.gallery-caption {
  margin-top: .45rem;
  font-size: .85rem;
  line-height: 1.4;
  color: var(--body-text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (max-width: 899px) {
  .gallery-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

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

/* ---------- masonry: natural heights instead of a uniform crop; portrait shots keep their tops and bottoms ---------- */
.gallery--masonry .gallery-grid {
  display: block;
  columns: 4;
  column-gap: 1rem;
}

.gallery--masonry .gallery-item {
  break-inside: avoid;
  margin: 0 0 1rem;
}

.gallery--masonry .gallery-link { aspect-ratio: auto; }

.gallery--masonry .gallery-link img { height: auto; }

@media (max-width: 899px) {
  .gallery--masonry .gallery-grid { columns: 3; }
}

@media (max-width: 559px) {
  .gallery--masonry .gallery-grid { columns: 2; }
}

/* ---------- strip: one scrolling row ---------- */
.gallery--strip .gallery-grid {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: .6rem;
  scrollbar-width: thin;
}

.gallery--strip .gallery-item { flex: 0 0 min(20rem, 70vw); scroll-snap-align: start; }

@media (prefers-reduced-motion: reduce) {
  .gallery-link img { transition: none; }
}
