/* Keep large originals and long titles inside the available viewport. */
.image-viewer-backdrop {
  box-sizing: border-box;
  grid-template-columns: minmax(0, 1fr);
  padding: 24px;
  overflow: hidden;
}
.image-viewer-backdrop > .image-viewer {
  box-sizing: border-box;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(980px, 100%);
  height: min(900px, calc(100vh - 48px));
  height: min(900px, calc(100dvh - 48px));
  max-width: 100%;
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  min-width: 0;
  min-height: 0;
}
.image-viewer > * { min-width: 0; }
.image-viewer .image-viewer-copy {
  box-sizing: border-box;
  max-height: min(180px, 28vh);
  max-height: min(180px, 28dvh);
  overflow: auto;
}
.image-viewer .image-viewer-copy h2 {
  white-space: normal;
  overflow-wrap: anywhere;
  text-overflow: clip;
  line-height: 1.4;
}
.image-viewer .image-stage {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  padding: clamp(8px, 2vw, 24px);
  overflow: hidden;
}
.image-viewer .image-stage img {
  box-sizing: border-box;
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
  margin: 0;
}
.image-viewer footer { box-sizing: border-box; flex-wrap: wrap; }
.image-viewer footer span, .image-viewer footer a { overflow-wrap: anywhere; }
.client-photo-modal section, .mobile-photo-modal section {
  box-sizing: border-box;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: calc(100dvh - 40px);
  display: flex;
  flex-direction: column;
  overflow: auto;
}
.client-photo-modal h3, .mobile-photo-modal h3 { white-space: normal; overflow-wrap: anywhere; flex-shrink: 0; }
.client-photo-modal img, .mobile-photo-modal img { min-width: 0; min-height: 0; object-position: center; object-fit: contain; flex-shrink: 1; }
@media (max-width: 760px) {
  .image-viewer-backdrop { padding: 10px; }
  .image-viewer-backdrop > .image-viewer {
    height: calc(100vh - 20px);
    height: calc(100dvh - 20px);
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - 20px);
  }
  .image-viewer .image-viewer-copy { padding: 14px 58px 12px 15px; }
  .image-viewer .image-stage { min-height: 0; padding: 10px; }
  .image-viewer footer { gap: 8px; }
}
