/* ============================================================
   window.OmniLightbox — full-screen post-image viewer.
   Reuses the app's existing tokens (z-scale, radii, motion, fonts).
   One overlay, layered at --z-modal so it sits above the player bar
   (80) and now-playing sheet (90). Controls are position:absolute
   inside the fixed overlay so the focus trap (offsetParent) sees them.
   ============================================================ */

.om-lb {
  display: none;
  position: fixed; inset: 0;
  z-index: var(--z-modal);
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.om-lb[data-open="1"] { display: flex; align-items: center; justify-content: center; }
.om-lb { overscroll-behavior: contain; }   /* damp scroll-chaining onto the page behind */

/* Dimmed background — purely visual; the stage above it handles taps. */
.om-lb-backdrop {
  position: absolute; inset: 0; z-index: 0;
  background: rgba(0, 0, 0, .92);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}

/* The tap surface. Fills the viewport; a tap on the margin (not the image)
   closes. When zoomed it becomes a scroll container so the enlarged image
   can be panned. */
.om-lb-stage {
  position: relative; z-index: 1;
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  -webkit-overflow-scrolling: touch;
}
.om-lb-stage[data-zoom="1"] { overflow: auto; cursor: zoom-out; }

.om-lb-img {
  display: block;
  max-width: 92vw; max-height: 92vh;
  width: auto; height: auto;
  object-fit: contain;
  border-radius: var(--r-sm);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .6);
  background: #000;
  cursor: zoom-in;
  user-select: none; -webkit-user-select: none; -webkit-user-drag: none;
  animation: om-lb-in var(--dur-2, .2s) var(--ease-out, ease);
}
/* Zoomed: show at natural size and let the stage scroll to pan. */
.om-lb-img[data-zoom="1"] {
  max-width: none; max-height: none;
  cursor: zoom-out;
}
@keyframes om-lb-in { from { opacity: 0; transform: scale(.98); } to { opacity: 1; transform: none; } }

/* Controls — absolute inside the fixed overlay (keeps offsetParent non-null
   so the JS focus trap can find them). */
.om-lb-close, .om-lb-nav {
  position: absolute; z-index: 2;
  -webkit-appearance: none; appearance: none;
  display: grid; place-items: center;
  border: 0; margin: 0; padding: 0;
  color: #fff; background: rgba(0, 0, 0, .5);
  border-radius: 50%; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--dur-2, .2s) var(--ease-out, ease),
              opacity var(--dur-2, .2s) var(--ease-out, ease);
}
.om-lb-close:hover, .om-lb-nav:hover { background: rgba(0, 0, 0, .72); }
.om-lb-close svg, .om-lb-nav svg { width: 24px; height: 24px; }

.om-lb-close {
  top: calc(env(safe-area-inset-top) + 12px);
  right: calc(env(safe-area-inset-right) + 12px);
  width: 44px; height: 44px;
}

/* Arrows are a pointer affordance: touch visitors swipe. Keyboard arrows
   work regardless. */
.om-lb-nav { display: none; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; }
.om-lb-prev { left: calc(env(safe-area-inset-left) + 10px); }
.om-lb-next { right: calc(env(safe-area-inset-right) + 10px); }
.om-lb-nav[hidden] { display: none; }
.om-lb-nav[disabled] { opacity: .32; pointer-events: none; }
@media (hover: hover) and (pointer: fine) {
  .om-lb-nav { display: grid; }
}

/* Slide count, top-centre. */
.om-lb-counter {
  position: absolute; z-index: 2;
  top: calc(env(safe-area-inset-top) + 16px); left: 50%; transform: translateX(-50%);
  padding: 4px 12px; border-radius: var(--r-pill, 999px);
  font: 600 12px/1.5 var(--mono, ui-monospace, monospace);
  color: #fff; background: rgba(0, 0, 0, .55);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  pointer-events: none;
}

/* Caption (image alt text), bottom-centre. Never shown when there is no alt. */
.om-lb-caption {
  position: absolute; z-index: 2;
  left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 16px);
  max-width: min(92vw, 720px);
  padding: 8px 14px; border-radius: var(--r-md, 12px);
  font: 500 13px/1.45 var(--sans, system-ui, sans-serif);
  color: #fff; background: rgba(0, 0, 0, .6);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  text-align: center;
  overflow-wrap: anywhere;
  pointer-events: none;
}

/* Announced to assistive tech, never shown. */
.om-lb-sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Focus ring parity with the rest of the media components. */
.om-lb-close:focus-visible, .om-lb-nav:focus-visible {
  outline: 2px solid var(--violet-2, #7c5cff); outline-offset: 2px;
}

/* Touch: full 44px targets; keep arrows hidden (swipe handles paging). */
@media (max-width: 767px) {
  .om-lb-close { width: 44px; height: 44px; }
}

/* Honour reduced-motion: no entrance animation, no control transitions. */
@media (prefers-reduced-motion: reduce) {
  .om-lb-img { animation: none; }
  .om-lb-close, .om-lb-nav { transition: none; }
}
