/* A single scrolling row, with three visible photos on desktop. */
.gallery-tools { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.gallery-tools .gallery-filters { margin-bottom: 0; }
.gallery-scroll-controls { display: flex; gap: 10px; flex-shrink: 0; }
.gallery-scroll-arrow { display: grid; place-items: center; width: 44px; height: 44px; padding: 0 0 4px; border: 1px solid #cdbfa5; border-radius: 50%; background: var(--paper); color: var(--saffron); font-size: 30px; line-height: 1; }
.gallery-scroll-arrow:hover:not(:disabled) { background: var(--saffron); border-color: var(--saffron); color: white; }
.gallery-scroll-arrow:disabled { opacity: .3; cursor: default; }
#gallery-grid { --gallery-gap: 20px; display: flex; flex-wrap: nowrap; gap: var(--gallery-gap); overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x mandatory; scrollbar-width: none; padding-block: 5px; }
#gallery-grid::-webkit-scrollbar { display: none; }
#gallery-grid > .gallery-card { flex: 0 0 calc((100% - 2 * var(--gallery-gap)) / 3); min-width: 0; display: flex; flex-direction: column; scroll-snap-align: start; }
#gallery-grid > .gallery-card > img { flex-shrink: 0; }
#gallery-grid .gallery-caption { width: 100%; flex: 1; overflow-wrap: anywhere; }
#gallery-grid > .gallery-card:focus-visible { outline-offset: -3px; }
#gallery-grid > .empty-state { flex: 0 0 100%; }
@media (max-width: 800px) {
  #gallery-grid > .gallery-card { flex-basis: calc((100% - var(--gallery-gap)) / 2); }
  .gallery-tools { align-items: flex-end; gap: 12px; }
}
@media (max-width: 600px) {
  .gallery-tools { flex-wrap: wrap; margin-bottom: 20px; }
  .gallery-tools .gallery-filters { width: 100%; }
  .gallery-scroll-controls { margin-left: auto; }
  #gallery-grid { --gallery-gap: 12px; }
  #gallery-grid > .gallery-card { flex-basis: 86%; }
}

/* The toolbar stays outside the scrolling content so Close is always reachable. */
html.dialog-open { overflow: hidden; scrollbar-gutter: stable; }
#detail-dialog {
  width: min(720px, calc(100% - 32px));
  max-width: none;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  padding: 0;
  overflow: hidden;
  box-shadow: 0 24px 100px #17150e55;
}
#detail-dialog[open] { display: grid; grid-template-rows: auto minmax(0, 1fr); }
.dialog-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 68px;
  padding: 10px 20px 10px 26px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
#dialog-label { font-size: 10px; letter-spacing: 1.8px; text-transform: uppercase; color: var(--saffron); }
#detail-dialog .dialog-close {
  position: static;
  float: none;
  margin: 0;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
}
#detail-dialog .dialog-close:hover { background: var(--cream); border-color: var(--saffron); color: var(--saffron); }
#dialog-content { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 26px; }
#dialog-content h2 { overflow-wrap: anywhere; }
#detail-dialog.gallery-viewer {
  width: min(1040px, calc(100% - 40px));
  height: min(900px, calc(100vh - 32px));
  height: min(900px, calc(100dvh - 32px));
}
.gallery-viewer #dialog-content {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  overflow: hidden;
  padding: 0;
}
.gallery-stage {
  min-height: 0;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 48px;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: #ede9df;
}
.gallery-image-wrap { min-width: 0; min-height: 0; height: 100%; touch-action: pan-y pinch-zoom; }
.gallery-image-wrap img { width: 100%; height: 100%; object-fit: contain; user-select: none; }
.viewer-arrow {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0 0 4px;
  border: 1px solid #d2c7b4;
  border-radius: 50%;
  background: var(--paper);
  color: var(--saffron);
  font-family: var(--sans);
  font-size: 34px;
  line-height: 1;
}
.viewer-arrow:hover:not(:disabled) { background: var(--saffron); color: white; border-color: var(--saffron); }
.viewer-arrow:disabled { opacity: .3; cursor: default; }
.viewer-meta { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 26px; border-top: 1px solid var(--line); }
.viewer-caption { min-width: 0; max-height: 100px; overflow-y: auto; }
.viewer-meta .eyebrow { margin-bottom: 5px; font-size: 9px; }
.gallery-viewer #dialog-title { font-size: 28px; line-height: 1.2; letter-spacing: -.6px; }
.viewer-counter { color: var(--muted); font-size: 12px; letter-spacing: 1px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.viewer-thumbnails { position: relative; display: flex; gap: 10px; padding: 4px 26px 18px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; }
.viewer-thumbnail { width: 60px; height: 60px; flex: 0 0 60px; padding: 3px; background: transparent; border: 2px solid transparent; opacity: .65; }
.viewer-thumbnail img { width: 100%; height: 100%; object-fit: cover; }
.viewer-thumbnail:hover { opacity: 1; }
.viewer-thumbnail[aria-current] { border-color: var(--saffron); opacity: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
@media (max-width: 600px) {
  #detail-dialog, #detail-dialog.gallery-viewer { width: calc(100% - 16px); max-height: calc(100dvh - 16px); }
  #detail-dialog.gallery-viewer { height: calc(100dvh - 16px); }
  .dialog-toolbar { min-height: 62px; padding: 8px 12px 8px 18px; }
  #dialog-label { font-size: 9px; letter-spacing: 1.3px; }
  #dialog-content { padding: 20px; }
  .gallery-stage { grid-template-columns: 1fr 1fr; grid-template-rows: minmax(0, 1fr) 44px; padding: 12px; gap: 12px; }
  .gallery-image-wrap { grid-column: 1 / -1; grid-row: 1; }
  .viewer-previous { grid-column: 1; grid-row: 2; justify-self: end; }
  .viewer-next { grid-column: 2; grid-row: 2; justify-self: start; }
  .viewer-arrow { width: 44px; height: 44px; font-size: 30px; }
  .viewer-meta { padding: 16px 18px; gap: 14px; }
  .gallery-viewer #dialog-title { font-size: 23px; }
  .viewer-counter { font-size: 11px; }
  .viewer-thumbnails { padding: 4px 18px 14px; gap: 7px; }
  .viewer-thumbnail { width: 52px; height: 52px; flex-basis: 52px; }
}
@media (max-height: 500px) {
  .dialog-toolbar { min-height: 54px; padding-block: 4px; }
  .gallery-stage { padding-block: 8px; }
  .viewer-meta { padding-block: 8px; }
  .viewer-caption { max-height: 60px; }
  .gallery-viewer #dialog-title { font-size: 21px; }
  .viewer-thumbnails { display: none; }
}
