/* A separate collection, sharing Blue Note's editorial surface. */
.gallery-page .page-content {
  padding: 0;
}

.gallery-page .content-column,
.gallery-page .masthead__inner {
  width: min(calc(100% - 4rem), 1160px);
  max-width: 1160px;
}

.gallery-collection {
  min-height: 16rem;
  color: var(--text);
  font-family: Charter, Georgia, "Times New Roman", "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", STSong, serif;
}

.gallery-empty {
  margin: 1.5rem 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.78;
}

.gallery-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.gallery-bay {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 100vh;
  min-height: 100svh;
}

.gallery-bay + .gallery-bay {
  margin-top: clamp(4rem, 8vh, 7rem);
  margin-top: clamp(4rem, 8svh, 7rem);
}

.gallery-bay + .gallery-bay--continuation {
  margin-top: clamp(2rem, 4vh, 3.5rem);
  margin-top: clamp(2rem, 4svh, 3.5rem);
}

.gallery-row {
  display: flex;
  align-items: flex-start;
  gap: 2rem;
  width: 100%;
  max-width: calc(var(--gallery-row-ratio) * min(78vh, 840px) + var(--gallery-row-gutter));
  max-width: calc(var(--gallery-row-ratio) * min(78svh, 840px) + var(--gallery-row-gutter));
  margin: 0 auto;
}

.gallery-item {
  flex: var(--gallery-ratio) 1 0%;
  min-width: 0;
  margin: 0;
}

/* A lone portrait has a grow factor below 1; it must still fill its centered row. */
.gallery-row > .gallery-item:only-child {
  flex: 1 1 0%;
}

.gallery-collection [hidden] { display: none !important; }

.gallery-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  margin: -0.75rem 0 2.5rem;
  font-size: 0.9375rem;
  line-height: 1.6;
}

.gallery-modes { display: flex; gap: 1.5rem; }

.gallery-mode,
.gallery-reshuffle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.5rem 0;
  color: var(--text);
  background: none;
  border: 0;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

.gallery-mode[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--link);
}

.gallery-mode:hover,
.gallery-reshuffle:hover {
  color: var(--text);
  text-decoration: none;
  border-bottom-color: var(--link);
}

.gallery-reshuffle { color: var(--text); }
.gallery-reshuffle--bottom {
  display: flex;
  justify-content: center;
  width: max-content;
  margin: clamp(5rem, 10vh, 8rem) auto 1rem;
  margin: clamp(5rem, 10svh, 8rem) auto 1rem;
}
.gallery-reshuffle-symbol { font-size: 1.35rem; line-height: 1; }
.gallery-mode:focus-visible,
.gallery-reshuffle:focus-visible { outline: 2px solid var(--link); outline-offset: 5px; }

.gallery-grid--few .gallery-bay + .gallery-bay {
  margin-top: clamp(4rem, 7vh, 5rem);
  margin-top: clamp(4rem, 7svh, 5rem);
}
.gallery-grid--few .gallery-row--lead {
  max-width: min(1040px, calc(var(--gallery-row-ratio) * min(82vh, 900px) + var(--gallery-row-gutter)));
  max-width: min(1040px, calc(var(--gallery-row-ratio) * min(82svh, 900px) + var(--gallery-row-gutter)));
}
.gallery-grid--few .gallery-row--counterpoint > .gallery-item:last-child { margin-top: 3.5rem; }
.gallery-grid--few .gallery-bay:nth-child(odd) .gallery-row--counterpoint > .gallery-item:last-child { margin-top: 2.5rem; }
.gallery-grid--few .gallery-row--coda {
  width: 86%;
}

.gallery-photo {
  display: block;
  color: inherit;
  cursor: zoom-in;
}

.gallery-page .gallery-photo img {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  margin: 0;
  object-fit: contain;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.gallery-photo:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 6px;
}

.gallery-item figcaption {
  margin-top: 0.75rem;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.6;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.gallery-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Native modal: neutral surround, complete frame, no slideshow or thumbnails. */
.gallery-viewer {
  --viewer-background: #242424;
  --viewer-foreground: #eeeae3;
  --viewer-secondary: #bdbab4;
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  color: var(--viewer-foreground);
  background: var(--viewer-background);
  border: 0;
  font-family: Charter, Georgia, "Times New Roman", "Songti SC", serif;
}

.gallery-viewer[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.gallery-viewer::backdrop {
  background: #242424;
}

.gallery-viewer [hidden] {
  display: none !important;
}

.gallery-viewer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: max(0.5rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) 0.5rem max(1.5rem, env(safe-area-inset-left));
}

.gallery-viewer-count {
  margin: 0;
  color: var(--viewer-secondary);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.gallery-viewer-controls {
  display: flex;
  gap: 0.5rem;
}

.gallery-viewer-controls button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
  border-radius: 0;
  font: 1.5rem / 1 Georgia, serif;
  cursor: pointer;
}

.gallery-viewer-controls button:disabled {
  opacity: 0.3;
  cursor: default;
}

.gallery-viewer-controls button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
}

.gallery-viewer button:focus-visible,
.gallery-viewer a:focus-visible {
  outline: 1px solid var(--viewer-foreground);
  outline-offset: -3px;
}

.gallery-viewer-stage {
  position: relative;
  min-height: 0;
  margin: 0 1.5rem max(1.5rem, env(safe-area-inset-bottom));
  overflow: hidden;
  touch-action: pan-y pinch-zoom;
}

.gallery-image-toggle {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  cursor: zoom-in;
}

.gallery-viewer .gallery-image-toggle img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  object-fit: contain;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.gallery-viewer-stage.is-zoomed {
  overflow: auto;
  touch-action: pan-x pan-y pinch-zoom;
}

.is-zoomed .gallery-image-toggle {
  width: var(--original-width);
  height: var(--original-height);
  cursor: zoom-out;
}

.gallery-viewer-status {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  color: var(--viewer-secondary);
  font-size: 1rem;
}

.gallery-viewer-status p {
  margin: 0;
}

.has-preview .gallery-viewer-status {
  inset: auto auto max(0.75rem, env(safe-area-inset-bottom)) 50%;
  width: max-content;
  max-width: calc(100% - 2rem);
  padding: 0;
  background: transparent;
  font-size: 0.875rem;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  transform: translateX(-50%);
}

.has-preview.has-error .gallery-viewer-status {
  padding: 0.45rem 0.65rem;
  background: rgba(36, 36, 36, 0.88);
  text-shadow: none;
}

.gallery-viewer-status a {
  color: var(--viewer-foreground);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.gallery-viewer-caption {
  max-height: 20vh;
  margin: -0.5rem auto 0;
  padding: 0 1.5rem max(1rem, env(safe-area-inset-bottom));
  overflow: auto;
  color: var(--viewer-secondary);
  font-size: 0.875rem;
  line-height: 1.6;
  text-align: center;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

@media (max-width: 900px) {
  .gallery-page .content-column,
  .gallery-page .masthead__inner {
    width: calc(100% - 3rem);
  }
  .gallery-row { flex-direction: column; gap: 1.5rem; max-width: none; }
  .gallery-bay + .gallery-bay { margin-top: 4rem; }
  .gallery-bay + .gallery-bay--continuation { margin-top: 2.5rem; }
  .gallery-item,
  .gallery-row > .gallery-item:only-child { flex: none; width: 100%; }
  .gallery-grid--few .gallery-row--lead { max-width: none; }
  .gallery-grid--few .gallery-row--coda { width: 100%; }
  .gallery-grid--few .gallery-bay + .gallery-bay { margin-top: 3.5rem; }
  .gallery-grid--few .gallery-row--counterpoint > .gallery-item:last-child { margin-top: 0; }
  .gallery-grid--few .gallery-bay:nth-child(odd) .gallery-row--counterpoint > .gallery-item:last-child { margin-top: 0; }
  .gallery-toolbar { margin-bottom: 2rem; }
  .gallery-modes { gap: 1rem; }
  .gallery-viewer-stage { margin-right: 0.75rem; margin-left: 0.75rem; }
}
