/* Shared image viewers only. Load after existing page/viewer styles.
 * These classes are assigned only through explicit image-lightbox.js mappings;
 * form dialogs, interactive maps, demos and arbitrary dialog headings are excluded. */
dialog.image-lightbox,
#integration-controls-viewer.integration-controls-viewer.image-lightbox {
  box-sizing: border-box;
  width: min(1200px, calc(100vw - 36px));
  max-width: calc(100vw - 36px);
  height: auto;
  max-height: calc(100vh - 36px);
  max-height: calc(100dvh - 36px);
  margin: auto;
  padding: 24px;
  border: 1px solid #d8c9e6;
  border-radius: 20px;
  background: #f7f3fb;
  color: #33283f;
  box-shadow: 0 30px 90px #09051066;
  overflow: auto;
  overscroll-behavior: contain;
}

dialog.image-lightbox[open],
#integration-controls-viewer.integration-controls-viewer.image-lightbox[open] {
  display: block;
  grid-template-rows: none;
}

dialog.image-lightbox::backdrop,
#integration-controls-viewer.integration-controls-viewer.image-lightbox::backdrop {
  background: #171322d9;
}

dialog.image-lightbox .image-lightbox__surface {
  box-sizing: border-box;
  width: auto;
  min-width: 0;
  max-width: 100%;
  height: auto;
  min-height: 0;
  padding: 0;
  border: 0;
  background: #f7f3fb;
  color: #33283f;
}

dialog.image-lightbox .image-lightbox__heading {
  display: flex;
  flex-wrap: nowrap;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  min-height: 0;
  margin: 0 0 20px;
  padding: 0;
  border: 0;
  background: transparent;
}

dialog.image-lightbox .image-lightbox__title {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding: 0;
  color: #33283f;
  font-family: inherit;
  font-size: 19px;
  font-weight: 600;
  font-style: normal;
  line-height: 1.3;
  letter-spacing: normal;
  text-transform: none;
  overflow-wrap: anywhere;
}

dialog.image-lightbox .image-lightbox__image {
  display: block;
  position: static;
  inset: auto;
  max-width: 100%;
  width: auto;
  height: auto;
  max-height: max(80px, calc(100vh - 220px));
  max-height: max(80px, calc(100dvh - 220px));
  aspect-ratio: auto;
  object-fit: contain;
  margin: 0 auto;
  padding: 0;
  border: 0;
}

dialog.image-lightbox.image-lightbox--caption .image-lightbox__image {
  max-height: max(80px, calc(100vh - 300px));
  max-height: max(80px, calc(100dvh - 300px));
}

/* Preserve the integrations image-stage DIV, without its old dark frame. */
dialog.image-lightbox .image-lightbox__frame {
  display: block;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

dialog.image-lightbox .image-lightbox__caption {
  max-width: 72ch;
  margin: 16px 0 0;
  color: #655b6d;
  font-size: 13px;
  line-height: 1.85;
}

dialog.image-lightbox .image-lightbox__nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 0;
  margin: 20px 0 0;
  padding: 0;
  border: 0;
  background: transparent;
}

dialog.image-lightbox .image-lightbox__control {
  display: inline-flex;
  flex: 0 0 auto;
  justify-content: center;
  align-items: center;
  min-height: 0;
  margin: 0;
  padding: 10px 13px;
  border: 1px solid #d8c8e5;
  border-radius: 8px;
  background: #fff;
  color: #5b4270;
  font: inherit;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.3;
  letter-spacing: normal;
  text-transform: none;
  cursor: pointer;
}

dialog.image-lightbox .image-lightbox__control:hover {
  border-color: #d8c8e5;
  background: #ede4f5;
  color: #5b4270;
}

dialog.image-lightbox .image-lightbox__control[hidden] {
  display: none !important;
}

dialog.image-lightbox .image-lightbox__control:focus-visible,
dialog.image-lightbox .image-lightbox__original:focus-visible {
  outline: 3px solid #7861ad;
  outline-offset: 4px;
}

dialog.image-lightbox .image-lightbox__status {
  flex: 1 1 80px;
  min-width: 0;
  margin: auto;
  color: #766783;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.3;
  letter-spacing: normal;
  text-transform: none;
  text-align: center;
  overflow-wrap: anywhere;
}

dialog.image-lightbox .image-lightbox__footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 18px;
  margin: 18px 0 0;
  padding: 0;
  border: 0;
  background: transparent;
}

dialog.image-lightbox .image-lightbox__original {
  display: inline-block;
  flex: 0 1 auto;
  order: 0;
  width: auto;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  color: #5b4270;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.6;
  letter-spacing: normal;
  text-transform: none;
  white-space: normal;
}

dialog.image-lightbox .image-lightbox__original:hover {
  color: #5b4270;
}

/* DIALOG is ineligible for requestFullscreen: the complete inner DIV is used. */
dialog.image-lightbox .image-lightbox__surface:fullscreen {
  width: 100vw;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 24px;
  border: 0;
  border-radius: 0;
  background: #f7f3fb;
  color: #33283f;
  overflow: auto;
  overscroll-behavior: contain;
}

dialog.image-lightbox .image-lightbox__surface::backdrop {
  background: #171322d9;
}

@media (max-width: 560px) {
  dialog.image-lightbox,
  #integration-controls-viewer.integration-controls-viewer.image-lightbox {
    padding: 16px;
    border-radius: 14px;
  }

  dialog.image-lightbox .image-lightbox__heading {
    gap: 12px;
  }

  dialog.image-lightbox .image-lightbox__title {
    font-size: 16px;
  }

  dialog.image-lightbox .image-lightbox__control {
    padding: 10px;
    font-size: 10px;
  }

  dialog.image-lightbox .image-lightbox__surface:fullscreen {
    padding: 16px;
  }
}
