/* Load after site.css. No inline style or runtime stylesheet injection required. */
#lightbox[data-gallery-ready] {
  width: min(1080px, 94vw);
  max-width: 94vw;
  max-height: 94dvh;
  box-sizing: border-box;
  overflow: auto;
  overscroll-behavior: contain;
}
#lightbox [hidden] { display: none !important; }
/* Stay reachable above photo/controls while the dialog itself scrolls. */
#lightbox .lightbox-close {
  position: sticky;
  top: 0;
  z-index: 2;
  margin-bottom: 10px;
  color: #fff;
  background: #29221d;
}
#lightbox .gallery-viewport {
  --gallery-size: min(80vw, 52dvh);
  --gallery-scale: 1;
  width: 100%;
  height: var(--gallery-size);
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-y pinch-zoom;
  background: #141211;
}
#lightbox .gallery-viewport[data-zoom="1"] { --gallery-scale: 1.5; }
#lightbox .gallery-viewport[data-zoom="2"] { --gallery-scale: 2; }
#lightbox .gallery-viewport[data-zoom="3"] { --gallery-scale: 3; }
#lightbox .gallery-viewport:not([data-zoom="0"]) { touch-action: auto; cursor: grab; }
#lightbox .gallery-viewport[data-dragging="true"] { cursor: grabbing; }
/* A square containing box means every rotated image stays within scrollable bounds.
   Increasing its real layout size (not just transform scale) exposes all zoomed pixels. */
#lightbox .gallery-stage {
  width: calc(var(--gallery-size) * var(--gallery-scale));
  height: calc(var(--gallery-size) * var(--gallery-scale));
  margin-inline: auto;
  position: relative;
}
#lightbox .gallery-stage > img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: contain;
  user-select: none;
  transform-origin: center;
}
#lightbox .gallery-stage[data-rotation="1"] > img { transform: rotate(90deg); }
#lightbox .gallery-stage[data-rotation="2"] > img { transform: rotate(180deg); }
#lightbox .gallery-stage[data-rotation="3"] > img { transform: rotate(270deg); }
#lightbox .gallery-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
#lightbox .gallery-toolbar button,
#lightbox .gallery-thumbnail,
#lightbox .gallery-original {
  min-height: 44px;
  min-width: 44px;
  border: 1px solid #95877d;
  color: #fff;
  background: #29221d;
  font: inherit;
  font-size: .8rem;
  padding: 8px 12px;
}
#lightbox button:not(:disabled):hover,
#lightbox .gallery-original:hover { background: #5c4631; }
#lightbox button:disabled { opacity: .45; cursor: not-allowed; }
#lightbox :focus-visible { outline: 3px solid #e3c9ff; outline-offset: 3px; }
#lightbox .gallery-view-status { flex-basis: 100%; font-size: .8rem; }
#lightbox .gallery-status { font-size: .85rem; text-align: left; margin: 8px 0; }
#lightbox .gallery-status:empty { display: none; }
#lightbox .gallery-original { display: inline-flex; align-items: center; margin: 8px 0; text-decoration: underline; }
#lightbox .gallery-thumbs { display: flex; gap: 8px; overflow-x: auto; padding: 5px; overscroll-behavior-x: contain; }
#lightbox .gallery-thumbnail { flex: 0 0 68px; height: 68px; padding: 3px; }
#lightbox .gallery-thumbnail[aria-current="true"] { border: 3px solid #e3c9ff; }
#lightbox .gallery-thumbnail img { display: block; width: 100%; height: 100%; object-fit: cover; }
@media (max-width: 480px) {
  #lightbox .gallery-toolbar button { flex: 1 1 42%; }
  #lightbox .lightbox-controls { gap: 10px; }
  #lightbox .gallery-thumbnail { flex-basis: 56px; height: 56px; }
}
@media (prefers-reduced-motion: reduce) {
  #lightbox *, #lightbox { scroll-behavior: auto; animation: none; transition: none; }
}
