/* Photo-viewer controls only. Photograph wrapper geometry remains inline. */
.reader-photo {
  position: absolute;
  display: block;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  appearance: none;
  color: inherit;
  background: transparent;
  font: inherit;
  cursor: zoom-in;
  touch-action: pan-x pan-y;
}

/* turn.js needs the image as the pointer target for allowed page-corner gestures. */
#slider .reader-photo > img {
  position: static !important;
  left: 0 !important;
  top: 0 !important;
  right: auto !important;
  bottom: auto !important;
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: none;
  image-rendering: auto;
  pointer-events: auto;
  user-select: none;
}
.reader-photo:focus-visible {
  outline: 3px solid var(--reader-white, #fff);
  outline-offset: -3px;
  box-shadow: inset 0 0 0 6px var(--reader-blue, #005598);
}

#reader-photo-dialog {
  width: min(96vw, 1400px);
  max-width: none;
  height: min(92vh, 1000px);
  height: min(92dvh, 1000px);
  max-height: none;
  box-sizing: border-box;
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--reader-line-strong, #4f585b);
  border-radius: var(--reader-panel-radius, 18px);
  color: var(--reader-white, #fff);
  background: var(--reader-ink, #231f20);
  box-shadow: 0 16px 52px rgb(35 31 32 / 55%);
  font: 16px/1.4 var(--reader-sans, "Avenir Next", Avenir, system-ui, sans-serif);
}
#reader-photo-dialog::backdrop { background: rgb(35 31 32 / 86%); }
#reader-photo-dialog .reader-photo-dialog__panel {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto auto;
  gap: 10px;
  height: 100%;
  min-height: 0;
  box-sizing: border-box;
  padding: 14px;
  overflow: auto;
  overscroll-behavior: contain;
}
#reader-photo-dialog .reader-photo-dialog__header,
#reader-photo-dialog .reader-photo-dialog__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
#reader-photo-dialog .reader-photo-dialog__header { justify-content: space-between; }
#reader-photo-dialog h2,
#reader-photo-dialog p { margin: 0; }
#reader-photo-dialog h2 {
  min-width: 0;
  color: var(--reader-white, #fff);
  font: 400 clamp(20px, 2.5vw, 29px)/1.15 var(--reader-serif, "Fraunces Reader", Georgia, serif);
  letter-spacing: -.01em;
}
#reader-photo-dialog button {
  min-width: 44px;
  min-height: 44px;
  box-sizing: border-box;
  padding: 8px 13px;
  border: 1px solid var(--reader-white, #ffffff);
  border-radius: var(--reader-control-radius, 999px);
  color: var(--reader-blue, #005598);
  background: var(--reader-white, #fff);
  font: inherit;
  cursor: pointer;
}
#reader-photo-dialog button:hover:enabled { background: var(--reader-paper, #f1f1f1); }
#reader-photo-dialog button:disabled {
  border-color: var(--reader-paper-deep, #c1c4c6);
  color: var(--reader-ink, #231f20);
  background: var(--reader-paper-deep, #c1c4c6);
  cursor: default;
}
#reader-photo-dialog button:focus-visible,
#reader-photo-dialog .reader-photo-dialog__viewport:focus-visible {
  outline: 3px solid var(--reader-white, #ffffff);
  outline-offset: 3px;
}
#reader-photo-dialog .reader-photo-dialog__status,
#reader-photo-dialog .reader-photo-dialog__credit,
#reader-photo-dialog .reader-photo-dialog__description { color: var(--reader-paper, #f1f1f1); }
#reader-photo-dialog .reader-photo-dialog__credit strong { color: var(--reader-white, #fff); }
#reader-photo-dialog .reader-photo-dialog__description {
  max-width: 80ch;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
#reader-photo-dialog .reader-photo-dialog__viewport {
  min-width: 0;
  min-height: 180px;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--reader-line-strong, #4f585b);
  border-radius: 10px;
  background: var(--reader-ink, #231f20);
  scrollbar-gutter: stable;
  touch-action: pan-x pan-y pinch-zoom;
}
#reader-photo-dialog .reader-photo-dialog__stage {
  display: grid;
  place-items: center;
  min-width: 100%;
  min-height: 100%;
}
#reader-photo-dialog .reader-photo-dialog__image {
  display: block;
  max-width: none;
  max-height: none;
  object-fit: contain;
  user-select: none;
}
#reader-photo-dialog [hidden] { display: none !important; }

@media (max-width: 600px), (max-height: 600px) {
  #reader-photo-dialog {
    width: calc(100vw - 12px);
    height: calc(100vh - 12px);
    height: calc(100dvh - 12px);
    border-radius: 12px;
  }
  #reader-photo-dialog .reader-photo-dialog__panel { gap: 6px; padding: 8px; }
  #reader-photo-dialog .reader-photo-dialog__controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  #reader-photo-dialog .reader-photo-dialog__viewport { min-height: 0; }
}

@media (forced-colors: active) {
  .reader-photo:focus-visible { outline-color: Highlight; box-shadow: none; }
  #reader-photo-dialog,
  #reader-photo-dialog .reader-photo-dialog__viewport { border-color: CanvasText; }
  #reader-photo-dialog button { border-color: ButtonText; }
}
