/* Keep the enlarged gallery within the visible screen, including mobile chrome. */
.property-lightbox[role="dialog"] {
  box-sizing: border-box;
  display: block;
  width: min(1100px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  height: min(800px, calc(100vh - 32px));
  height: min(800px, calc(100dvh - 32px));
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  padding: 0;
  gap: 0;
  overflow: hidden;
}

.property-lightbox-stage {
  box-sizing: border-box;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  padding: 56px 56px 112px;
}

.property-lightbox [data-testid="img-lightbox-main"] {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  min-width: 0;
  min-height: 0;
  object-fit: contain;
}

/* Use the existing, labelled custom close control rather than a second X. */
.property-lightbox > button { display: none; }
.property-lightbox [data-testid="button-close-lightbox"] {
  top: 10px;
  right: 10px;
  width: 40px;
  height: 40px;
  padding: 0;
}
.property-lightbox [data-testid="button-lightbox-prev"] { left: 8px; }
.property-lightbox [data-testid="button-lightbox-next"] { right: 8px; }
.property-lightbox [data-testid="button-lightbox-prev"],
.property-lightbox [data-testid="button-lightbox-next"] {
  width: 40px;
  height: 44px;
  padding: 0;
}

.property-lightbox-thumbnails {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  width: max-content;
  max-width: calc(100% - 24px);
  padding: 8px;
  overflow-x: auto;
  border-radius: 8px;
  background: rgb(0 0 0 / 50%);
}
.property-lightbox-thumbnails > button {
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
}

@media (max-width: 640px) {
  .property-lightbox[role="dialog"] {
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    height: calc(100vh - 16px);
    height: calc(100dvh - 16px);
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
  }
  .property-lightbox-stage { padding: 56px 40px 104px; }
  .property-lightbox-thumbnails { gap: 6px; padding: 6px; }
  .property-lightbox-thumbnails > button {
    flex-basis: 40px;
    width: 40px;
    height: 40px;
  }
}

@media (max-height: 480px) {
  .property-lightbox-stage { padding: 48px 48px 84px; }
  .property-lightbox-thumbnails { bottom: 36px; padding: 4px; }
  .property-lightbox-thumbnails > button {
    flex-basis: 32px;
    width: 32px;
    height: 32px;
  }
}
