/* Gallery: restrained framing, preserving photo order and carousel layouts. */
.gallery-section { --link: #0076b3; }
body.theme-dark .gallery-section { --link: #81d2fa; }
.gallery-section .publications-heading { padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.gallery-section .publications-heading h1 { letter-spacing: -.025em; }
.gallery-section .gallery-year-group { border-top: 0; padding-top: 0; gap: 16px; }
.gallery-section .gallery-year-group + .gallery-year-group { margin-top: 30px; }
.gallery-section .gallery-year-heading { color: var(--text); font-size: 1.35rem; font-weight: 650; letter-spacing: -.025em; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
body .gallery-section .gallery-grid figure { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; box-shadow: none; }
.gallery-section .gallery-grid figure[id] { scroll-margin-top: calc(var(--sticky-utility-height, 38px) + var(--sticky-nav-height, 44px) + 24px); }
body .gallery-section .gallery-grid figure:target {
  border-color: #e4b323;
  box-shadow: 0 0 0 3px #f5cc47, 0 0 0 7px #f5cc4726;
}
.gallery-section .gallery-grid figure:target figcaption { background: #fff8db; }
body.theme-dark .gallery-section .gallery-grid figure:target figcaption { background: #3b3219; }
.gallery-section .gallery-grid figcaption { gap: 6px; padding: 12px 14px 14px; border-top: 1px solid var(--light-line); font-weight: 600; }
body .gallery-section .gallery-caption-head { color: var(--link); font-size: .8rem; font-weight: 600; font-variant-numeric: tabular-nums; }
body .gallery-section .gallery-caption-text { color: var(--text); font-size: .88rem; font-weight: 400; line-height: 1.5; }
.gallery-section .gallery-carousel-count { color: var(--muted); font-size: .72rem; font-weight: 500; }
.gallery-section .gallery-carousel-button { background: var(--paper); color: var(--link); border: 1px solid var(--line); border-radius: 7px; box-shadow: 0 1px 4px #00000014; font-weight: 500; }
.gallery-section .gallery-carousel-button:hover,
.gallery-section .gallery-carousel-button:focus-visible { background: var(--link); color: var(--paper); border-color: var(--link); }
.gallery-section .gallery-carousel-button:focus-visible { outline: 2px solid var(--link); outline-offset: 3px; }

.gallery-section .gallery-caption-text strong { font-weight: 650; }

/* Let gallery photos use the viewport instead of the publication carousel width. */
.gallery-image-lightbox { padding: 16px; }
.gallery-image-lightbox .image-carousel-panel {
  width: 100%;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
}
.gallery-image-lightbox .image-carousel-stage { order: 0; min-width: 0; }
.gallery-image-lightbox .image-carousel-stage img {
  max-width: min(1800px, calc(100vw - 32px));
  max-height: min(1200px, calc(100vh - 96px));
  max-height: min(1200px, calc(100dvh - 96px));
}
.gallery-image-lightbox .image-carousel-button {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: auto;
  z-index: 1;
}
.gallery-image-lightbox .image-carousel-button:first-child { left: 16px; }
.gallery-image-lightbox .image-carousel-button:nth-child(3) { right: 16px; }
.gallery-image-lightbox .image-carousel-close {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2;
}
@media (max-width: 600px) {
  .gallery-image-lightbox .image-carousel-stage img {
    max-height: calc(100vh - 160px);
    max-height: calc(100dvh - 160px);
  }
  .gallery-image-lightbox .image-carousel-button {
    top: auto;
    bottom: 16px;
    transform: none;
  }
}
