/* Images that open full size say so with the cursor. */
.post-body img.is-zoomable {
  cursor: zoom-in;
}
.post-body img.is-zoomable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 10px;
}

/* The Dialog's overlay, as a near-black lightbox rather than the theme's
   dimmed page: a screenshot reads best over dark. */
.dialog-overlay:has(> .dialog.img-zoom) {
  /* The top strip stays clear so the image never sits under the close
     button. */
  padding: 68px 2vw 3vh;
  background: rgba(10, 16, 24, 0.96);
  backdrop-filter: none;
  cursor: zoom-out;
  /* The browser's pinch would zoom the page, overlay and all; the image's own
     pinch handler zooms just the image instead. */
  touch-action: none;
  overscroll-behavior: contain;
}

/* The panel is the image: no card, no padding, no width cap. The panel's
   enter animation is off so the fixed close button holds still while the
   overlay fades in. */
.dialog.img-zoom {
  width: auto;
  max-width: none;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  animation: none;
}

.img-zoom-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 96vw;
  max-height: calc(100dvh - 68px - 3vh);
}

.img-zoom-img {
  transform-origin: 0 0;
  touch-action: none;
  will-change: transform;
  max-width: 100%;
  max-height: calc(100dvh - 68px - 3vh);
  width: auto;
  height: auto;
  border-radius: 10px;
  /* drop-shadow follows the image's own edges, so a screenshot that
     carries its own transparent margin and shadow (a macOS window) gets
     no second, rectangular layer around it. */
  filter: drop-shadow(0 18px 36px rgba(0, 0, 0, 0.4));
}

/* Solid, ringed and shadowed, so it shows over any part of any screenshot. */
.img-zoom-close,
.img-zoom-close:hover,
.img-zoom-close:focus {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-height: 0;
  padding: 0;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 999px;
  background: #10181f;
  color: #ffffff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}
.img-zoom-close:hover { background: #24303b; }
.img-zoom-close svg { width: 18px; height: 18px; }

/* A drawn element shown full size: the copy keeps its own styles and is
   scaled up with zoom, so text and lines are drawn sharp at the new size
   rather than stretched. */
.img-zoom-el {
  width: min(1100px, 92vw);
  zoom: 1.35;
  cursor: auto;
  pointer-events: auto;
}
.img-zoom-el > [data-zoomable] {
  margin: 0 !important;
  cursor: auto;
}
@media (max-width: 40rem) {
  .img-zoom-el { zoom: 1; width: 96vw; }
}

/* Elements that open in the overlay say so with the cursor. */
[data-zoomable] { cursor: zoom-in; }
