html body.collection-page-layout {
  background: var(--theme-bg);
  color: var(--theme-ink);
  font-family: 'Manrope', sans-serif;
  --theme-copy-muted: var(--theme-muted, var(--theme-ink));
  --theme-accent: var(--theme-ink);
}

body.collection-page-layout #navbar.site-header {
  background: var(--theme-bg);
  z-index: var(--z-nav, 50);
}

.collection-layout {
  max-width: 100rem;
  min-width: 0;
  margin-inline: auto;
  padding: 0 var(--page-gutter) 2rem;
}

.collection-layout [hidden] { display: none; }

#viewingRoom {
  position: relative;
  height: calc(100svh - var(--pastelle-nav-height));
}

#viewingRoom:not([hidden]) {
  display: flex;
  flex-direction: column;
}

.room-artist,
.room-medium {
  color: var(--theme-copy-muted);
}

.collection-formats {
  display: flex;
  align-items: center;
  gap: clamp(1rem, 2vw, 1.5rem);
}

.collection-formats button,
.collection-text-link,
.room-navigation button {
  min-height: 44px;
  color: var(--theme-copy-muted);
  font-size: 0.875rem;
}

.collection-formats button {
  border-bottom: 2px solid transparent;
}

.collection-formats button[aria-pressed="true"] {
  border-bottom-color: var(--theme-accent);
  color: var(--theme-ink);
  font-weight: 600;
}

.collection-formats button:hover,
.collection-text-link:hover,
.room-navigation button:not(:disabled):hover {
  color: var(--theme-ink);
}

.collection-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.room-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  align-items: center;
  gap: clamp(2rem, 6vw, 6rem);
  padding-block: clamp(0.75rem, 2.5vh, 2rem) 3.75rem;
}

.room-stage {
  display: grid;
  width: 100%;
  height: clamp(18rem, calc(100svh - var(--pastelle-nav-height) - 8rem), 58rem);
  place-items: center;
  cursor: zoom-in;
}

.room-stage img {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
}

.room-info { min-width: 0; }
.room-artist { font-size: 1.125rem; }

#roomTitle {
  margin: 0.5rem 0 0.75rem;
  font-size: clamp(2.25rem, 4.6vw, 4.25rem);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.05em;
  overflow-wrap: anywhere;
}

.room-medium { margin-bottom: 0.5rem; }
.collection-format-label { color: var(--theme-accent); font-weight: 600; }
.collection-format-label:empty { display: none; }

.room-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.25rem;
  margin-top: 0.625rem;
}

.collection-text-link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  border-bottom: 0;
}

.raster-wordmark {
  display: inline-block;
  width: 3.25rem;
  height: 1rem;
  object-fit: contain;
  vertical-align: middle;
  opacity: 1;
  filter: brightness(0);
}

html.dark .raster-wordmark { filter: brightness(0) invert(1); }

.room-navigation {
  position: absolute;
  inset: auto 0 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  padding-block: 0.5rem;
  border-top: 0;
}

.room-navigation button:first-child { justify-self: start; }
.room-navigation button:last-child { justify-self: end; }
.room-navigation button:disabled { opacity: 0.36; cursor: default; }

.room-nav-center {
  display: inline-flex;
  align-items: center;
  gap: 1.25rem;
  justify-self: center;
}

.room-counter {
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
  color: var(--theme-copy-muted);
}

.room-catalogue-jump {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 44px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--theme-copy-muted);
  text-decoration: none;
  transition: color 150ms ease;
}

.room-catalogue-jump:hover {
  color: var(--theme-ink);
}

#collectionCatalogue {
  margin-top: clamp(3rem, 5vw, 5rem);
  scroll-margin-top: calc(var(--pastelle-nav-height) + 1rem);
}

.catalogue-search {
  display: flex;
  min-height: 5rem;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem 1.25rem;
  padding-block: 1rem 1.25rem;
}

.catalogue-search-field {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: min(100%, 26rem);
  min-width: 0;
  min-height: 3rem;
  padding-inline: 0.875rem;
  border: 1px solid color-mix(in srgb, var(--theme-ink) 32%, transparent);
  background: color-mix(in srgb, var(--theme-ink) 4%, var(--theme-bg));
}

.catalogue-search-field:focus-within {
  outline: 2px solid var(--theme-ink);
  outline-offset: 3px;
}

.catalogue-search-field svg {
  width: 1rem;
  height: 1rem;
  flex: 0 0 auto;
  color: var(--theme-copy-muted);
}

.catalogue-search input {
  flex: 1;
  width: 100%;
  min-width: 0;
  min-height: 2.75rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--theme-ink);
  font: inherit;
}

.collection-layout .catalogue-search-field input:focus-visible { outline: none; }

@media (max-width: 767px) {
  .catalogue-search-field { width: 100%; }
}

.catalogue-search input::placeholder { color: var(--theme-copy-muted); }

.catalogue-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.catalogue-table :is(th, td) {
  padding: 0.5rem clamp(0.375rem, 1vw, 1rem) 0.5rem 0;
}

.catalogue-table th {
  height: 3.5rem;
  border-bottom: 1px solid var(--theme-hairline);
  color: var(--theme-copy-muted);
  font-size: 0.8125rem;
  font-weight: 500;
}

.catalogue-table td {
  padding-block: 0.875rem;
  font-size: 0.875rem;
}
.catalogue-table th:first-child { width: 41%; }
.catalogue-table th:nth-child(2) { width: 25%; }
.catalogue-table td:nth-child(3) { font-variant-numeric: tabular-nums; }

.catalogue-artwork {
  display: flex;
  align-items: center;
  gap: clamp(0.625rem, 2vw, 1.75rem);
  width: 100%;
  min-height: 4.375rem;
  text-align: left;
  font-weight: 600;
}

.catalogue-artwork:hover span {
  text-decoration: underline;
  text-underline-offset: 0.25em;
}

.catalogue-thumbnail {
  width: 3.875rem;
  height: 3.875rem;
  flex: 0 0 auto;
  object-fit: contain;
}

.collection-empty { padding-block: 2rem; color: var(--theme-copy-muted); }

@media (max-width: 767px) {
  #viewingRoom { height: auto; min-height: calc(100svh - var(--pastelle-nav-height)); }
  .room-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: clamp(0.5rem, 1.5vh, 1rem);
    padding-block: 0.5rem 3.75rem;
  }
  .room-stage {
    height: clamp(12rem, min(56svh, calc(100svh - var(--pastelle-nav-height) - 19rem)), 30rem);
  }
  .room-nav-suffix { display: none; }
  .room-nav-center { gap: 0.75rem; }
  .room-catalogue-jump { font-size: 0.75rem; }

  .catalogue-table th:first-child { width: 54%; }
  .catalogue-table th:nth-child(2) { width: auto; }
  .catalogue-table :is(th, td):nth-child(3) { display: none; }
  .catalogue-thumbnail { width: 2rem; height: 2.75rem; }
  .catalogue-artwork { overflow-wrap: anywhere; }
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal, 100);
  color: var(--theme-ink);
  background: var(--theme-bg);
  opacity: 0;
  visibility: hidden;
  transition: opacity 180ms ease, visibility 180ms ease;
}

.lightbox .modal-content {
  translate: 0 0.2rem;
  transition: translate 180ms var(--ease-out-expo);
}

.lightbox.active .modal-content {
  translate: none;
}

.lightbox.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  --modal-rail: 4rem;
  display: grid;
  grid-template-columns: var(--modal-rail) minmax(0, 1fr) var(--modal-rail);
  grid-template-rows: minmax(0, 1fr) auto;
  width: 100%;
  height: 100%;
  padding: env(safe-area-inset-top, 0px) clamp(1rem, 2vw, 2rem) env(safe-area-inset-bottom, 0px);
}

.modal-caption { grid-column: 1 / -1; grid-row: 2; }
.modal-stage { grid-column: 2; grid-row: 1; }

.modal-navigation,
.modal-footer-actions {
  display: flex;
  align-items: center;
}

#modalArtist {
  margin: 0;
  color: var(--theme-copy-muted);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.015em;
}

#modalCounter {
  min-width: 3.5rem;
  color: var(--theme-copy-muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.lightbox.is-single .modal-navigation { display: none; }
.lightbox.is-single .modal-stage { grid-column: 1 / -1; }

.modal-nav-btn,
.lightbox-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  color: var(--theme-ink);
  font-size: 1.125rem;
  border-radius: 0.375rem;
  transition: color 180ms ease, background-color 180ms ease;
}

.modal-nav-btn:not(:disabled) { color: var(--theme-copy-muted); }
.modal-nav-btn:not(:disabled):hover,
.lightbox-close-btn:hover { color: var(--theme-ink); }

.modal-nav-btn:disabled { opacity: 0.25; cursor: default; }
.modal-nav-btn:not(:disabled):hover,
.lightbox-close-btn:hover { background: var(--theme-hover-soft); }
.lightbox.is-single .modal-thumbnails { display: none; }

.lightbox-close-btn {
  position: absolute;
  top: max(0.5rem, env(safe-area-inset-top, 0px));
  right: clamp(1rem, 2vw, 2rem);
  z-index: 3;
  gap: 0.75rem;
  padding-inline: 0.5rem;
  font-size: 0.75rem;
  background: transparent;
  color: var(--theme-copy-muted);
}

.lightbox-close-btn span { font-size: 1.25rem; }

.modal-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  margin-block: 0.5rem;
  overflow: hidden;
  container-type: size;
}

#modalImage {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

#modalIframe,
#modalVideo {
  width: min(100%, calc(65svh * var(--artwork-ratio, 1)));
  height: auto;
  max-height: 100%;
  border: 0;
}

@supports (width: 1cqw) {
  #modalIframe,
  #modalVideo {
    width: min(100cqw, calc(100cqh * var(--artwork-ratio, 1)));
  }
}

.modal-caption {
  display: grid;
  position: relative;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 0.75rem 1.5rem;
  padding-block: 0.75rem;
}

.modal-work-info { min-width: 0; }

.modal-artist-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.35rem;
}

#modalTitle {
  font-size: clamp(1rem, 1.5vw, 1.25rem);
  line-height: 1.3;
  letter-spacing: -0.025em;
  font-weight: 500;
  text-wrap: pretty;
}

#modalYear,
.modal-meta-separator {
  color: var(--theme-copy-muted);
  font-size: 0.75rem;
}

.modal-navigation {
  justify-self: center;
  padding: 2px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--theme-ink) 4%, transparent);
}

.modal-navigation .modal-nav-btn {
  min-width: 40px;
  min-height: 40px;
  border-radius: 50%;
}

.modal-navigation #modalCounter {
  min-width: 3rem;
  font-size: 0.6875rem;
  letter-spacing: 0.025em;
}

.modal-footer-actions {
  grid-column: 3;
  justify-self: end;
  gap: 0.125rem;
}

.modal-footer-actions :is(button, a) {
  min-height: 40px;
  padding-inline: 0.625rem;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  font-weight: 500;
  transition: color 180ms ease, background-color 180ms ease;
}

.modal-footer-actions :is(button, a):hover {
  background: var(--theme-hover-soft);
  text-decoration: none;
}

.modal-footer-actions .coll-action-btn { gap: 0.5rem; }
.lightbox.is-single .modal-work-info { grid-column: 1 / 3; }

.modal-bio {
  min-width: 0;
  max-width: 55ch;
  color: var(--theme-copy-muted);
  font-size: 0.875rem;
  line-height: 1.55;
  text-wrap: pretty;
}

.modal-bio[hidden] { display: none; }

.modal-meta-grid {
  display: flex;
  gap: 2rem;
  font-size: 0.6875rem;
  line-height: 1.7;
}

.modal-meta-grid dt { color: var(--theme-copy-muted); }

.coll-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 1.25rem;
  min-height: 44px;
  font-size: 0.75rem;
  white-space: nowrap;
}

.coll-action-btn:hover {
  text-decoration: underline;
  text-underline-offset: 0.3em;
}

.modal-zoom-btn {
  min-width: 52px;
  min-height: 44px;
  margin-right: 0;
  color: var(--theme-ink);
  font-size: 0.75rem;
}

#modalZoom[hidden],
#modalDetails[hidden],
#modalLoading[hidden] { display: none; }

.modal-zoom-btn:disabled { opacity: 0.3; }

.modal-zoom-btn,
#modalDetailsToggle,
.coll-action-btn {
  color: var(--theme-copy-muted);
  transition: color 180ms ease;
}

.modal-zoom-btn:hover,
#modalDetailsToggle:hover,
.coll-action-btn:hover { color: var(--theme-ink); }

.modal-stage.is-zoomed {
  display: block;
  overflow: auto;
  overscroll-behavior: contain;
}

#modalImage { cursor: zoom-in; }
.modal-stage.is-zoomed #modalImage { cursor: zoom-out; margin-inline: auto; }

.modal-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 1;
  max-width: 18rem;
  transform: translate(-50%, -50%);
  color: var(--theme-copy-muted);
  font-size: 0.75rem;
  text-align: center;
  pointer-events: none;
}

.modal-footer-actions {
  display: flex;
  align-items: center;
}

#modalDetailsToggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  font-size: 0.75rem;
}

#modalDetailsToggle[aria-expanded="true"] span { transform: rotate(45deg); }

.modal-details {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.75rem);
  z-index: 2;
  width: min(30rem, calc(100vw - 2rem));
  max-height: min(28rem, 65svh);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1.5rem;
  border: 1px solid color-mix(in srgb, var(--theme-hairline) 50%, transparent);
  border-radius: 0.5rem;
  background: var(--theme-bg);
  box-shadow: 0 8px 30px color-mix(in srgb, var(--theme-ink) 8%, transparent);
}

.modal-details .modal-bio { margin-bottom: 1.5rem; }
.modal-details .modal-bio[hidden] { margin-bottom: 0; }

/* Thumbnails sit in a column to the right of the stage, centered, scrolling when an artist has many works. */
.modal-thumbnails {
  position: relative;
  display: flex;
  flex-direction: column;
  grid-column: 3;
  grid-row: 1;
  gap: 0.5rem;
  min-height: 0;
  margin: 3.5rem 0 0.5rem 0.25rem;
  padding: 3px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.modal-thumbnails > :first-child { margin-top: auto; }
.modal-thumbnails > :last-child { margin-bottom: auto; }

.modal-thumbnail {
  position: relative;
  flex: 0 0 52px;
  width: 52px;
  height: 52px;
  padding: 3px;
  border: 0;
  border-radius: 0.25rem;
  opacity: 0.45;
  transition: opacity 200ms ease, background-color 200ms ease;
}

.modal-thumbnail img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.modal-thumbnail[aria-pressed="true"],
.modal-thumbnail:hover {
  opacity: 1;
}

.modal-thumbnail[aria-pressed="true"] {
  background: var(--theme-hover-soft);
}

.modal-thumbnail[aria-pressed="true"]::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 35%;
  right: 35%;
  height: 1px;
  background: var(--theme-copy-muted);
}

.collection-layout :is(button, input, select, a):focus-visible,
.lightbox :is(button, a):focus-visible {
  outline: 2px solid var(--theme-ink);
  outline-offset: 3px;
}

@media (max-width: 767px) {
  .modal-content {
    padding-inline: 1rem;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto auto;
  }
  .modal-stage { grid-column: 1; margin-block: 3rem 0.5rem; }
  #modalImage { cursor: default; }
  .modal-caption { grid-template-columns: auto minmax(0, 1fr); gap: 0.5rem; padding-block: 0.75rem; }
  .modal-work-info,
  .lightbox.is-single .modal-work-info { grid-column: 1 / -1; }
  #modalArtist { font-size: 0.75rem; }
  .modal-artist-row { gap: 0.4rem; }
  .modal-navigation { grid-column: 1; justify-self: start; }
  .modal-navigation .modal-nav-btn { min-width: 44px; min-height: 44px; }
  .modal-nav-btn { min-width: 36px; }
  #modalCounter { min-width: 2.75rem; font-size: 0.6875rem; }
  .modal-footer-actions { grid-column: 2; justify-content: flex-end; flex-wrap: wrap; gap: 0; }
  .modal-footer-actions :is(button, a) { min-height: 44px; padding-inline: 0.5rem; font-size: 0.75rem; }
  .modal-zoom-btn { min-width: 44px; font-size: 0.75rem; }
  .lightbox-close-btn { right: 1rem; gap: 0.5rem; }
  .modal-bio { font-size: 0.8125rem; }
  .modal-thumbnails {
    flex-direction: row;
    grid-column: 1;
    grid-row: 3;
    justify-self: start;
    max-width: 100%;
    margin: 0 0 0.5rem;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .modal-thumbnails > :first-child,
  .modal-thumbnails > :last-child { margin-block: 0; }
  .modal-thumbnail { flex-basis: 44px; width: 44px; height: 44px; }
  .modal-details { right: 0; padding: 1rem; }
  #modalDetailsToggle { font-size: 0.6875rem; }
  .modal-meta-grid { gap: 1.5rem; font-size: 0.625rem; }
  .coll-action-btn { font-size: 0.6875rem; gap: 0.5rem; }
}

@media (max-width: 359px) {
  .modal-caption { grid-template-columns: minmax(0, 1fr); }
  .modal-navigation { grid-column: 1; justify-self: center; }
  .modal-footer-actions { grid-column: 1; justify-self: stretch; justify-content: space-between; flex-wrap: nowrap; }
}

@media (min-width: 600px) and (max-width: 767px) and (max-height: 500px) {
  .modal-content { grid-template-rows: minmax(0, 1fr) auto; }
  .modal-stage { margin: 0.5rem 3.5rem; }
  .modal-thumbnails { display: none; }
  .modal-caption { grid-template-columns: minmax(0, 1fr) auto auto; }
  .modal-work-info, .lightbox.is-single .modal-work-info { grid-column: 1; }
  .modal-navigation { grid-column: 2; }
  .modal-footer-actions { grid-column: 3; }
}

@media (prefers-reduced-motion: reduce) {
  .modal-thumbnail,
  .modal-nav-btn,
  .lightbox-close-btn,
  .modal-zoom-btn,
  #modalDetailsToggle,
  .coll-action-btn,
  .lightbox,
  .lightbox .modal-content,
  #modalImage {
    transition: none;
  }

}
