/* 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-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)); }
}

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

/* ---------- mosaic: a portfolio — four columns of rows of one height, every fifth photo two rows tall ---------- */
.gallery--mosaic .gallery-grid { grid-auto-rows: clamp(9rem, 15vw, 13.75rem); grid-auto-flow: dense; gap: .75rem; }
.gallery--mosaic .gallery-item:nth-child(5n + 1) { grid-row: span 2; }
.gallery--mosaic .gallery-link { height: 100%; aspect-ratio: auto; }
.gallery--mosaic .gallery-link img { width: 100%; height: 100%; object-fit: cover; }
@media (max-width: 899px) { .gallery--mosaic .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
