/* Override the theme's image spacing without changing the theme itself. */
article section img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 320px;
  object-fit: contain;
  margin: 1.5rem auto !important;
}

.image-preview {
  display: block;
  max-width: min(100%, 520px);
  margin: 1.5rem auto !important;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.image-preview img {
  margin: 0 !important;
}

.image-preview:focus-visible {
  outline: 3px solid #4b9fff;
  outline-offset: 4px;
}

.carousel-slide .image-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  margin: 0 !important;
}

article section .carousel-slide img {
  max-height: 100%;
}

html:has(.image-viewer[open]) {
  overflow: hidden;
}

.image-viewer {
  position: fixed;
  inset: 0;
  box-sizing: border-box;
  width: 100%;
  max-width: none;
  height: 100%;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 4rem 1rem 1rem !important;
  border: 0;
  background: rgb(0 0 0 / 94%);
  color: white;
}

.image-viewer[open] {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.image-viewer img {
  flex: 1;
  min-height: 0;
  width: 100%;
  object-fit: contain;
}

.image-viewer-caption {
  margin: 0;
  max-width: 65ch;
  text-align: center;
}

.image-viewer-close,
.image-viewer-nav {
  position: absolute;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid rgb(255 255 255 / 25%) !important;
  border-radius: 50% !important;
  background: rgb(24 24 24 / 85%) !important;
  color: white !important;
  box-shadow: 0 2px 12px rgb(0 0 0 / 25%);
  cursor: pointer;
}

.image-viewer button svg {
  width: 22px;
  height: 22px;
  pointer-events: none;
}

.image-viewer button:hover {
  background: #383838 !important;
  border-color: rgb(255 255 255 / 55%) !important;
}

.image-viewer button:focus-visible {
  outline: 2px solid #4b9fff;
  outline-offset: 3px;
}

.image-viewer-close {
  top: 0.5rem;
  right: 0.5rem;
}

.image-viewer-nav {
  top: 50%;
  transform: translateY(-50%);
}

.image-viewer-prev { left: 0.5rem; }
.image-viewer-next { right: 0.5rem; }
.image-viewer-nav[hidden] { display: none !important; }

.image-viewer::backdrop { background: transparent; }
