a[data-image-viewer] { cursor: zoom-in; }
.photo-link { display: block; }

.image-expand-mark {
  width: .83em;
  aspect-ratio: 1;
  background: currentColor;
  clip-path: polygon(0 0, 37% 0, 37% 12%, 12% 12%, 12% 37%, 0 37%, 0 0,
    100% 0, 100% 37%, 88% 37%, 88% 12%, 63% 12%, 63% 0, 100% 0,
    100% 100%, 63% 100%, 63% 88%, 88% 88%, 88% 63%, 100% 63%, 100% 100%,
    0 100%, 0 63%, 12% 63%, 12% 88%, 37% 88%, 37% 100%, 0 100%);
}

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

.image-viewer {
  --viewer-accent: var(--album-accent, var(--lime));
  --viewer-matte: var(--album-stage, #22221f);
  width: min(calc(100vw - 2rem), 71rem);
  height: min(calc(100dvh - 2rem), 54rem);
  max-width: none;
  max-height: none;
  margin: auto;
  padding: 4px;
  border: 2px solid #22231e;
  background: var(--album-surface, var(--paper));
  color: var(--ink);
  box-shadow: .35rem .35rem 0 #11120e;
}
.image-viewer[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.image-viewer::backdrop { background: #121310ce; }
.image-viewer-bar,
.image-viewer-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .65rem;
}
.image-viewer-bar {
  border: 1px solid #22231e;
  padding-inline-start: .8rem;
  background: var(--viewer-accent);
  color: #22231e;
}
.image-viewer-bar h2 {
  font: 700 .78rem/1.25 var(--mono);
  letter-spacing: .09em;
  text-transform: uppercase;
}
.image-viewer button {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid currentColor;
  background: none;
  font: 700 .81rem/1 var(--mono);
  cursor: pointer;
}
.image-viewer-bar button { border-width: 0 0 0 1px; padding-inline: .8rem; }
.image-viewer-bar button:hover { background: #22231e; color: var(--viewer-accent); }
.image-viewer button:focus-visible,
.image-viewer-stage:focus-visible { outline-offset: -4px; }
.image-viewer-stage {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable both-edges;
  touch-action: pan-x pan-y;
  border-inline: 1px solid #22231e;
  background: var(--viewer-matte);
  color: #fff3e6;
}
.image-viewer-stage[data-zoomed] { cursor: grab; }
.image-viewer-stage.is-dragging { cursor: grabbing; }
.image-viewer-canvas {
  display: grid;
  place-items: center;
  width: max-content;
  height: max-content;
  min-width: 100%;
  min-height: 100%;
}
.image-viewer-canvas img { max-width: none; user-select: none; }
.image-viewer-status { margin: 1rem; font: 700 .83rem/1.4 var(--mono); }
.image-viewer-footer {
  border: 1px solid #22231e;
  min-width: 0;
  padding: .35rem .55rem;
}
.image-viewer-caption {
  margin: 0;
  min-width: 0;
  max-height: 4.35em;
  overflow: auto;
  font-size: .83rem;
  line-height: 1.4;
}
.image-viewer-controls { display: flex; align-items: center; gap: .35rem; margin-inline-start: auto; }
.image-viewer-controls output { min-width: 4ch; text-align: center; font: 700 .78rem/1 var(--mono); }
.image-viewer-controls button[aria-disabled="true"] { opacity: .49; cursor: default; }
.image-viewer-controls button:not([aria-disabled="true"]):hover { background: var(--viewer-accent); color: #22231e; }
@media (max-width: 560px) {
  .image-viewer { width: calc(100vw - 1rem); height: calc(100dvh - 1rem); }
  .image-viewer-footer { flex-wrap: wrap; }
  .image-viewer-caption { width: 100%; }
}
