.gallery-block {
  width: calc(100% - (var(--pad) * 2));
  min-width: 0;
  margin: clamp(3rem, 7vh, 6rem) var(--pad) 5rem;
  padding-top: 1.4rem;
  border-top: 1px solid rgba(18, 18, 18, .2);
}

.dark .gallery-block {
  border-top-color: rgba(255, 255, 255, .2);
}

.gallery-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 1.2rem;
}

.gallery-heading span {
  display: block;
  margin-bottom: .35rem;
  color: #9a722d;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.dark .gallery-heading span {
  color: #e2bd72;
}

.gallery-heading h3 {
  margin: 0;
  font: 400 clamp(1.6rem, 2.8vw, 2.8rem)/1.05 Georgia, serif;
  letter-spacing: -.035em;
}

.gallery-actions {
  display: flex;
  align-items: center;
  gap: .7rem;
}

.gallery-actions button {
  min-height: 42px;
  padding: .65rem .9rem;
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
  font: 700 .68rem/1 "Avenir Next", Arial, sans-serif;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.gallery-actions button:hover,
.gallery-actions button:focus-visible {
  border-color: #c89a42;
  color: #c89a42;
  outline: none;
}

.gallery-count {
  min-width: 4.5rem;
  margin: 0;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.gallery-track {
  display: flex;
  gap: 18px;
  width: 100%;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
  scrollbar-color: #c89a42 transparent;
  cursor: grab;
  touch-action: pan-y;
}

.gallery-track.dragging {
  cursor: grabbing;
  scroll-snap-type: none;
  user-select: none;
}

.gallery-slide {
  position: relative;
  flex: 0 0 min(72vw, 860px);
  height: clamp(320px, 58vh, 650px);
  margin: 0;
  overflow: hidden;
  scroll-snap-align: start;
  background: #151515;
}

.gallery-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .45s ease, filter .45s ease;
}

.gallery-slide:hover img {
  transform: scale(1.018);
  filter: saturate(1.04) contrast(1.02);
}

.gallery-caption {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  left: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0;
  padding: .45rem .6rem;
  background: rgba(8, 9, 10, .72);
  color: #fff;
  font-size: .7rem;
  letter-spacing: .12em;
}

.gallery-caption b {
  overflow: hidden;
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.gallery-caption span {
  flex: 0 0 auto;
}

@media (max-width: 900px) {
  .gallery-block {
    width: calc(100% - (var(--pad) * 2));
    margin: 3rem var(--pad) 5rem;
  }

  .gallery-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .gallery-slide {
    flex-basis: 86vw;
    height: 52vh;
  }
}

@media print {
  .page.has-gallery .mosaic {
    height: 76mm;
  }

  .page.has-gallery .residence-grid {
    height: 102mm;
  }

  .page.has-gallery .main-photo,
  .page.has-gallery .side-photo {
    height: 102mm;
  }

  .page.has-gallery .duo-grid img,
  .page.has-gallery .triptych img {
    height: 66mm;
  }

  .gallery-block {
    position: absolute;
    right: 20mm;
    bottom: 18mm;
    left: 20mm;
    width: auto;
    height: 38mm;
    margin: 0;
    padding-top: 2.5mm;
    overflow: hidden;
  }

  .gallery-heading {
    margin: 0 0 2mm;
  }

  .gallery-heading h3 {
    font-size: 3mm;
  }

  .gallery-heading span {
    display: none;
  }

  .gallery-actions {
    display: none;
  }

  .gallery-track {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2.5mm;
    overflow: hidden;
  }

  .gallery-slide {
    display: none;
    width: auto;
    height: 27mm;
  }

  .gallery-slide:nth-child(-n + 4) {
    display: block;
  }

  .gallery-caption {
    right: 1.5mm;
    bottom: 1.5mm;
    left: 1.5mm;
    padding: 1mm;
    font-size: 1.7mm;
  }

  .gallery-caption b {
    font-size: 1.55mm;
  }
}
