article.article {
  --blog-image-max-height: 40rem;
}

article.article > :is(figure, picture, a, p):where(:not([data-blog-image="off"], :has([data-blog-image="off"]))) img,
article.article > img:where(:not([data-blog-image="off"])) {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: var(--blog-image-max-height);
  object-fit: contain;
  margin-inline: auto;
}

article.article > figure:where(:not([data-blog-image="off"], :has([data-blog-image="off"]))):has(img) {
  max-width: 100%;
  margin: var(--space-7) auto;
}

article.article > [data-image-size="readable"] img,
article.article > :is(figure, picture, a, p) img[data-image-size="readable"],
article.article > img[data-image-size="readable"] {
  max-height: none;
}

article.article > figure:where(:not([data-blog-image="off"], :has([data-blog-image="off"]))):has(img) figcaption {
  max-width: 56ch;
  margin: var(--space-4) auto 0;
  text-align: center;
  font-size: var(--text-body-sm);
  line-height: 1.5;
}

article.article .blog-image-link {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin-inline: auto;
  cursor: zoom-in;
}

article.article .blog-image-expand {
  display: block;
  width: fit-content;
  min-height: 44px;
  margin: var(--space-2) auto 0;
  padding: var(--space-2);
  border: 0;
  background: transparent;
  color: var(--iris-600);
  font: inherit;
  font-size: var(--text-body-sm);
  text-decoration: underline;
  text-underline-offset: .2em;
  cursor: zoom-in;
}

.blog-image-viewer {
  box-sizing: border-box;
  width: calc(100% - 2 * var(--space-4));
  max-width: 90rem;
  height: calc(100vh - 2 * var(--space-4));
  height: calc(100dvh - 2 * var(--space-4));
  max-height: none;
  margin: auto;
  padding: var(--space-5);
  border: 1px solid var(--mist);
  border-radius: var(--radius-lg);
  background: var(--paper);
  color: var(--slate-700);
}

.blog-image-viewer::backdrop { background: color-mix(in srgb, var(--ink) 42%, transparent); }
.blog-image-viewer[open] { display: flex; flex-direction: column; }
.blog-image-viewer__tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  font-size: var(--text-body-sm);
}
.blog-image-viewer__tools a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--iris-600);
  text-underline-offset: .2em;
}
.blog-image-viewer__tools button {
  min-height: 44px;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--slate-500);
  border-radius: var(--radius-md);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.blog-image-viewer__tools button:disabled { opacity: .5; cursor: default; }
.blog-image-viewer__body { flex: 1; min-height: 0; overflow: auto; }
.blog-image-viewer__body img { display: block; width: auto; height: auto; max-width: 100%; margin-inline: auto; }
.blog-image-viewer__body img[hidden] { display: none; }
.blog-image-viewer[data-zoom="true"] img { max-width: none; margin: 0; }
.blog-image-viewer__status { margin: 0; }
.blog-image-viewer :is(a, button, [tabindex]):focus-visible,
article.article :is(.blog-image-link, .blog-image-expand):focus-visible {
  outline: 3px solid var(--iris-600);
  outline-offset: 3px;
}
@media (max-width: 40rem) {
  .blog-image-viewer { padding: var(--space-4); }
  .blog-image-viewer__tools { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  .blog-image-viewer__tools a { grid-column: 1 / -1; }
}
