/* Photo viewer is above the pinned site header, at every page scroll position. */
#lightbox {
  position:fixed!important;
  inset:0!important;
  z-index:10020!important;
  margin:0!important;
  border:0;
  box-sizing:border-box;
  width:100%;
  max-width:none;
  overflow:hidden;
  height:100vh;
  height:100dvh;
  max-height:100dvh;
  padding:max(10px,env(safe-area-inset-top)) max(10px,env(safe-area-inset-right)) max(10px,env(safe-area-inset-bottom)) max(10px,env(safe-area-inset-left));
  isolation:isolate;
  overscroll-behavior:contain;
}

#lightbox::backdrop { background:#050c14; }
html { scrollbar-gutter:stable; }

/* Short gallery gestures keep vertical page scrolling and pinch zoom native. */
#donorPhotoBox, #partPhotoBox { touch-action:pan-y pinch-zoom; }
:is(#donorMainImg,#partMainImg,#lbImg) { user-select:none; -webkit-user-drag:none; }

/* Main gallery cues mirror one another without covering the photograph. */
#donorPhotoStage :is(#donorSwipeHint,#donorPhotoCount) {
  bottom:6px;
  padding:4px 5px;
  font-size:clamp(9px,1.73vw,13px);
  line-height:1.2;
}
#donorPhotoStage #donorSwipeHint {
  left:6px;
  z-index:4;
  max-width:calc(50% - 50px);
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  pointer-events:none;
}
#donorPhotoStage #donorSwipeHint[hidden] { display:none; }
#donorPhotoStage #donorPhotoCount { right:6px; }
/* A connected mouse gets explicit previous/next controls as well as dragging. */
@media (any-hover:hover) and (any-pointer:fine) {
  #donorPhotoStage #donorPhotoBox .photo-nav {
    display:grid;
    width:44px;
    height:44px;
    padding:0;
    border:1px solid #c7f4ffb3;
    border-radius:8px;
    background:#04284f80;
    color:#fff;
    font-size:30px;
    cursor:pointer;
  }
  #donorPhotoStage #donorPhotoBox .photo-nav[hidden] { display:none; }
  #donorPhotoStage #donorPhotoBox .photo-nav:focus-visible { outline:3px solid #7ce6ff;outline-offset:2px; }
}

/* Every media popup blocks the background. Only its own card may scroll. */
html:has(#partModal.show,#truckSectionViewer[open],#lightbox[open]),
body:has(#partModal.show,#truckSectionViewer[open],#lightbox[open]) {
  overflow:hidden!important; overscroll-behavior:none!important;
}
#partModal {
  max-width:none;max-height:none;width:100%;height:100dvh;margin:0;border:0;
  box-sizing:border-box;overflow:hidden;overscroll-behavior:contain;
}
#partModal::backdrop {background:transparent;}
#partModal .part-card {
  max-height:calc(100dvh - 24px - var(--manco-photo-clearance,0px));
  overflow:auto;overscroll-behavior:contain;touch-action:pan-y pinch-zoom;
}

/* The image decodes inside the existing fixed photo window. */
#partPhotoBox > #partMainImg { position:absolute;inset:0;width:100%;height:100%;object-fit:cover; }

.gallery-video-button { position:absolute;left:50%;transform:translateX(-50%);bottom:6px;z-index:4;min-height:30px;padding:4px 7px;border:1px solid #b8ebff;border-radius:6px;background:#073468e8;color:#fff;font:700 12px/1.2 system-ui;cursor:pointer; }
