/* Article images stay whole in their reading column; detail belongs in the viewer. */
.detail-layout > *, .gh-content, .article-feature { min-width: 0; }
.gh-content figure, .gh-content figure > a, .gh-content figure [role="region"], .article-feature {
  min-width: 0 !important;
  max-width: 100% !important;
}
.gh-content figure [role="region"] { width: 100% !important; overflow: visible !important; }
.gh-content img, .article-feature img {
  display: block;
  width: auto !important;
  min-width: 0 !important;
  max-width: 100% !important;
  height: auto !important;
  margin-inline: auto;
  object-fit: contain;
}
.gh-content figcaption { overflow-wrap: anywhere; }
/* Reserve the feature's declared ratio before its image arrives. */
.article-feature img, .gh-content figure img { width: 100% !important; }
/* Enhancement wraps only the image, without adding space to the reading flow. */
.image-viewer-trigger {
  display: block;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: inherit;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: 0;
  text-align: inherit;
  cursor: zoom-in;
  -webkit-tap-highlight-color: transparent;
}
.image-viewer-trigger > picture { display: block; }
.image-viewer-trigger:focus-visible { outline: 3px solid var(--blue, #175cd3); outline-offset: 4px; }
/* The portrait keeps its original fixed-size place in the author profile. */
.author-profile > .image-viewer-trigger--portrait {
  flex: 0 0 200px;
  width: 200px;
  height: 200px;
  align-self: center;
  border-radius: 18px;
}
.author-profile > .image-viewer-trigger--portrait .author-profile-image {
  display: block;
  width: 200px;
  height: 200px;
  margin: 0;
  object-fit: cover;
  border-radius: inherit;
}
@media (max-width: 640px) {
  .author-profile > .image-viewer-trigger--portrait {
    flex-basis: 152px;
    width: 152px;
    height: 152px;
    margin-bottom: 24px;
    border-radius: 14px;
  }
  .author-profile > .image-viewer-trigger--portrait .author-profile-image { width: 152px; height: 152px; margin-bottom: 0; }
}
html.image-viewer-open { overflow: hidden; }
dialog.image-viewer {
  box-sizing: border-box;
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: max(80px, calc(env(safe-area-inset-top, 0px) + 72px)) max(20px, env(safe-area-inset-right, 0px), 4vw) max(20px, env(safe-area-inset-bottom, 0px)) max(20px, env(safe-area-inset-left, 0px), 4vw);
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #fff;
  overflow: hidden;
}
dialog.image-viewer::backdrop {
  background: rgba(9, 13, 22, .87);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
dialog.image-viewer[open] { display: flex; flex-direction: column; gap: 12px; }
.image-viewer-header { flex: 0 0 0; min-height: 0; }
.image-viewer-header h2 {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.image-viewer-controls {
  position: fixed;
  z-index: 2;
  top: max(16px, calc(env(safe-area-inset-top, 0px) + 12px));
  right: max(16px, calc(env(safe-area-inset-right, 0px) + 12px));
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100% - 32px);
}
.image-viewer-controls button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-width: 48px;
  min-height: 48px;
  margin: 0;
  padding: 10px 16px;
  border: 1px solid rgba(255, 255, 255, .3);
  border-radius: 24px;
  background: rgba(20, 28, 42, .82);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), 0 4px 18px rgba(0, 0, 0, .2);
  -webkit-backdrop-filter: blur(16px) saturate(120%);
  backdrop-filter: blur(16px) saturate(120%);
  font: inherit;
  font-size: 14px;
  line-height: 1.4;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
}
.image-viewer-controls button:hover { background: rgba(43, 54, 73, .94); border-color: rgba(255, 255, 255, .55); }
.image-viewer-controls button:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.image-viewer-controls .image-viewer-close {
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  padding: 12px;
}
.image-viewer-close svg { display: block; width: 24px; height: 24px; flex-shrink: 0; pointer-events: none; }
.image-viewer-viewport {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  background: transparent;
  border-radius: 0;
}
.image-viewer-viewport:focus-visible { outline: 2px solid rgba(255, 255, 255, .9); outline-offset: 4px; }
.image-viewer-viewport > img { display: block; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; object-fit: contain; }
.image-viewer-viewport[data-zoom="true"] > img { width: var(--image-detail-width); height: auto; object-fit: initial; }
.image-viewer-description {
  flex-shrink: 0;
  max-height: min(6em, 24dvh);
  overflow: auto;
  overscroll-behavior: contain;
  margin: 0;
  color: rgba(255, 255, 255, .92);
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
  overflow-wrap: anywhere;
}
.image-viewer-description:empty { display: none; }
@media (forced-colors: active) {
  .image-viewer-controls button { border: 2px solid ButtonText; background: ButtonFace; color: ButtonText; box-shadow: none; }
  .image-viewer-controls button:focus-visible, .image-viewer-trigger:focus-visible, .image-viewer-viewport:focus-visible { outline-color: Highlight; }
  .image-viewer-description { color: CanvasText; background: Canvas; }
}
@media print { dialog.image-viewer { display: none !important; } }
