/* Photo viewer — rid-energy.uz
 *
 * The stage is near-black rather than a translucent white scrim: these are
 * site photographs of substations and construction work, and a dark ground
 * is what lets them carry their own contrast instead of competing with the
 * page behind them.
 */

.lbx-target { cursor: zoom-in; }
.lbx-target:focus-visible { outline: 2px solid #0066ff; outline-offset: 3px; }

html.lbx-locked { overflow: hidden; }

/* The overlay used to toggle display:none <-> grid. `display` does not
   animate, so the dark ground snapped in and out while only the photo inside
   faded — which read as the viewer appearing before it opened. Visibility is
   transitionable in steps, so it can be delayed until the fade has finished,
   and the element is fixed-position so leaving it in the layout costs nothing.
   Keep the 280ms in step with FADE in lightbox.js. */
.lbx {
  position: fixed;
  inset: 0;
  /* Measured on the live page: header.fixedHeader is z-index 99999 and
     .language-dropdown is 100001, so at 2000 the sticky header painted over
     the top of the viewer — including its close button. A modal overlay has to
     outrank the chrome it covers, and on this site the chrome is numbered
     absurdly high, so this is the number that clears it. */
  z-index: 100010;
  display: grid;
  grid-template-rows: 1fr auto;
  background: rgba(9, 13, 17, .94);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .28s ease, visibility 0s linear .28s;
}
.lbx.is-open {
  opacity: 1;
  visibility: visible;
  transition: opacity .28s ease, visibility 0s linear 0s;
}

/* The controls are declared BEFORE the stage in the DOM, and both are
   positioned with z-index:auto — so painting order put the later one, the
   stage, on top of them. Clicking the next arrow hit .lbx__stage instead of
   the button, which is exactly the backdrop the click-to-close handler looks
   for, so the viewer closed rather than advancing. Verified by hit-testing the
   arrow's own centre: document.elementFromPoint returned DIV.lbx__stage.
   Numbering both ends of the pair keeps the fix from depending on DOM order. */
.lbx__stage {
  z-index: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 56px 72px 12px;
}

.lbx__img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 2px;
  opacity: 0;
  transform: scale(.985);
  transition: opacity .22s ease, transform .22s ease;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .55);
}
.lbx__img.is-ready { opacity: 1; transform: none; }

.lbx__close,
.lbx__nav { z-index: 2; }

.lbx__spin {
  position: absolute;
  width: 30px; height: 30px;
  border: 2px solid rgba(255, 255, 255, .22);
  border-top-color: #fff;
  border-radius: 50%;
  animation: lbx-spin .7s linear infinite;
}
@keyframes lbx-spin { to { transform: rotate(360deg); } }

.lbx__close,
.lbx__nav {
  position: absolute;
  display: grid;
  place-items: center;
  width: 46px; height: 46px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .09);
  color: #fff;
  cursor: pointer;
  transition: background-color .16s ease;
}
.lbx__close:hover, .lbx__nav:hover { background: rgba(255, 255, 255, .2); }
.lbx__close:focus-visible, .lbx__nav:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.lbx__close svg, .lbx__nav svg { width: 21px; height: 21px; }

.lbx__close { top: 16px; right: 18px; }
.lbx__nav--prev { left: 14px; top: 50%; transform: translateY(-50%); }
.lbx__nav--next { right: 14px; top: 50%; transform: translateY(-50%); }

.lbx__bar {
  display: flex;
  align-items: baseline;
  gap: 18px;
  padding: 14px 24px 22px;
  color: rgba(255, 255, 255, .78);
  font-size: .9375rem;
}
.lbx__cap { flex: 1; min-width: 0; line-height: 1.45; }
.lbx__count { flex: 0 0 auto; font-variant-numeric: tabular-nums; color: rgba(255, 255, 255, .5); }

@media (max-width: 767px) {
  .lbx__stage { padding: 52px 12px 8px; }
  .lbx__nav { width: 40px; height: 40px; }
  .lbx__nav--prev { left: 6px; }
  .lbx__nav--next { right: 6px; }
  .lbx__bar { padding: 10px 16px 18px; font-size: .875rem; }
}

@media (prefers-reduced-motion: reduce) {
  .lbx__img { transition: none; transform: none; }
  .lbx__spin { animation-duration: 2s; }
  /* No fade, but visibility must still flip or the overlay stays clickable. */
  .lbx { transition: visibility 0s linear .01s; }
  .lbx.is-open { transition: visibility 0s linear 0s; }
}
