/* Mississippi County: preserve complete photos in the gallery and viewer. */
#mcad-district-photos .gallery-grid {
  align-items: start;
}

#mcad-district-photos .gallery-grid figure {
  min-width: 0;
  height: auto;
}

#mcad-district-photos .gallery-grid img {
  display: block;
  width: 100%;
  height: auto !important;
  aspect-ratio: auto !important;
  object-fit: contain !important;
}

/* Keep the last two gallery previews short; the viewer retains the full photo. */
#mcad-district-photos .gallery-grid figure:nth-child(4) img,
#mcad-district-photos .gallery-grid figure:nth-child(5) img {
  aspect-ratio: 2 / 1 !important;
  object-fit: cover !important;
  object-position: 50% 45%;
}

#rww-lightbox {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 100%;
  max-height: 100%;
  padding: 64px 16px 24px;
  padding-top: max(64px, env(safe-area-inset-top));
  padding-right: max(16px, env(safe-area-inset-right));
  padding-bottom: max(24px, env(safe-area-inset-bottom));
  padding-left: max(16px, env(safe-area-inset-left));
  overflow: hidden;
}

#rww-lightbox:not([hidden]) {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

#rww-lightbox img {
  display: block;
  flex: 0 1 auto;
  min-width: 0;
  min-height: 0;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100vh - 128px);
  max-height: calc(100dvh - 128px);
  object-fit: contain;
}

#rww-lightbox p {
  flex: 0 0 auto;
  min-width: 0;
  max-width: 100%;
  max-height: 18vh;
  margin: 0;
  overflow: auto;
  overflow-wrap: anywhere;
}

#rww-lightbox p:empty {
  display: none;
}

#rww-lightbox .rww-lightbox-close {
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 1;
  width: 44px;
  height: 44px;
}
