/* Only gallery pages load these rules. The photograph retains its full aspect ratio. */
.static-gallery { display: flow-root; clear: both; text-align: center; }
.static-gallery__figure {
  display: inline-block;
  vertical-align: top;
  width: fit-content;
  max-width: calc(100% - 2 * var(--gallery-margin));
  margin: var(--gallery-margin);
  padding: var(--gallery-padding);
  border: var(--gallery-border) solid var(--gallery-border-color);
}
/* Bound captions to each preview frame; approved singleton geometry stays unchanged. */
.static-gallery--multiple .static-gallery__figure {
  box-sizing: border-box;
  width: calc(var(--gallery-width) + 2 * var(--gallery-padding) + 2 * var(--gallery-border));
  overflow-wrap: anywhere;
}
.static-gallery__link { display: block; max-width: 100%; }
.static-gallery__link img {
  display: block;
  width: auto;
  height: auto;
  max-width: min(100%, var(--gallery-width));
  max-height: var(--gallery-height);
  margin: 0 auto;
}
.static-gallery figcaption { margin-top: 6px; }
.static-gallery__link:focus-visible, .gallery-viewer button:focus-visible {
  outline: 3px solid var(--accent, #26739b);
  outline-offset: 4px;
}
html.gallery-viewer-open { overflow: hidden; }
dialog.gallery-viewer {
  width: fit-content;
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 24px);
  padding: 12px;
  border: 2px solid #808080;
  background: white;
  color: #383838;
  overflow: auto;
}
dialog.gallery-viewer:not([open]) { display: none; }
.gallery-viewer::backdrop { background: rgb(0 0 0 / 80%); }
.gallery-viewer__toolbar { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.gallery-viewer button { font: inherit; min-width: 44px; min-height: 44px; cursor: pointer; }
.gallery-viewer figure { margin: 8px 0 0; text-align: center; }
.gallery-viewer__image {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100dvh - 200px);
  margin: auto;
}
.gallery-viewer figcaption p { margin: 4px 0 0; }
.gallery-viewer__thumbnails { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }
.gallery-viewer__thumbnails img { display: block; width: 60px; height: 60px; object-fit: contain; }
.gallery-viewer [hidden] { display: none; }
/* No transitions or autoplay, including under prefers-reduced-motion. */
@media (prefers-reduced-motion: reduce) {
  .static-gallery *, .gallery-viewer * { scroll-behavior: auto; }
}
/* Visual review: uniform multi-image previews and viewport-bounded thumbnail viewer. */
.static-gallery--multiple .static-gallery__link {
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--gallery-height);
}
.static-gallery--multiple figcaption {
  margin-top: 4px;
  font-size: 11px;
  line-height: 1.4;
}
/* Keep singleton dialogs untouched. Grid reserves actual chrome/caption/thumbnail
   heights before assigning the remaining space to the uncropped photograph. */
dialog.gallery-viewer[open]:has(.gallery-viewer__thumbnails button) {
  display: grid;
  grid-template-rows: auto minmax(min-content, 1fr) auto;
  width: min(1228px, calc(100vw - 24px));
  height: calc(100dvh - 24px);
  box-sizing: border-box;
  overscroll-behavior: contain;
}
.gallery-viewer:has(.gallery-viewer__thumbnails button) figure {
  display: grid;
  grid-template-rows: minmax(80px, 1fr) auto;
  min-height: 0;
}
.gallery-viewer:has(.gallery-viewer__thumbnails button) .gallery-viewer__image {
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: 100%;
  object-fit: contain;
  contain: size;
}
/* End visual review correction. */
/* Final preview alignment: measured bilingual captions need at most 30.8px. */
.static-gallery--multiple .static-gallery__figure {
  display: inline-grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 165px 32px;
  row-gap: 4px;
  height: calc(201px + 2 * var(--gallery-padding) + 2 * var(--gallery-border));
}
.static-gallery--multiple .static-gallery__link {
  height: auto;
  min-height: 0;
}
.static-gallery--multiple .static-gallery__link img {
  /* A common photographic height keeps the visible caption gap consistent
     across the approved 3:2 and 4:3 images, without cropping either ratio. */
  height: 146px;
  max-height: 100%;
}
.static-gallery--multiple figcaption {
  margin-top: 0;
  min-width: 0;
}
/* End final preview alignment. */
/* Bulk containment: auto sizes preserve proportions when width constrains a
   panorama. Approved Sevrier 3:2/4:3 images still render at 146px high. */
.static-gallery--multiple .static-gallery__link img {
  height: auto;
  max-height: 146px;
}
/* End bulk containment. */
/* Bulk-only large strips retain all controls in a bounded scroll region. */
.gallery-viewer__thumbnails--large {
  height: clamp(72px, 25dvh, 160px);
  min-height: 72px;
  max-height: 160px;
  overflow-y: auto;
  align-content: start;
}
/* End bulk large strip. */
/* E2 exact wide perspectives: natural uncropped image and caption heights. */
.static-gallery--wide .static-gallery__figure {
  display: inline-block;
  box-sizing: border-box;
  width: calc(var(--gallery-width) + 2 * var(--gallery-padding) + 2 * var(--gallery-border));
  height: auto;
  max-width: calc(100% - 2 * var(--gallery-margin));
}
.static-gallery--wide .static-gallery__link { display: block; height: auto; }
.static-gallery--wide .static-gallery__link img {
  width: auto; height: auto; max-width: 100%; max-height: var(--gallery-height);
}
.static-gallery--wide figcaption { margin-top: 6px; font-size: inherit; line-height: inherit; }
/* End E2 exact wide perspectives. */
/* E2 skiing singleton: include padding and border in the responsive cap. */
.static-gallery--ski .static-gallery__figure { box-sizing: border-box; }
