/*
 * Spolek Za rozvoj Konské — galerie immersive fix 0.9.130
 * Hard fix po 0.9.129:
 * - spodní PWA navigace je při otevřeném lightboxu opravdu mimo layout
 * - lightbox využije celý viditelný viewport
 * - obrázek se vždy vejde celý bez ořezu
 */

html.sp-gallery-lightbox-open,
html.sp-gallery-lightbox-open body {
  overflow: hidden !important;
  overscroll-behavior: none !important;
}

/* 0.9.118 drží navigaci přes display/fixed + maximální z-index.
   Proto ji nestačí jen zprůhlednit — při lightboxu ji z layoutu odstraníme. */
html.sp-gallery-lightbox-open #mobile-bottom-nav-v09115,
html.sp-gallery-lightbox-open .mobile-bottom-nav-v09115 {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

html.sp-gallery-lightbox-open body {
  padding-bottom: 0 !important;
}

.sp-gallery-lightbox {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  width: 100dvw !important;
  height: 100vh !important;
  height: 100dvh !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  padding: 0 !important;
  background: #050b08 !important;
  z-index: 2147483647 !important;
  overflow: hidden !important;
  overscroll-behavior: none !important;
  touch-action: none !important;
}

/* Android Chrome s dynamickou adresní lištou: použijeme rozměry visualViewport. */
@supports (height: 100dvh) {
  .sp-gallery-lightbox {
    left: var(--sp-gallery130-left, 0px) !important;
    top: var(--sp-gallery130-top, 0px) !important;
    width: var(--sp-gallery130-width, 100dvw) !important;
    height: var(--sp-gallery130-height, 100dvh) !important;
    right: auto !important;
    bottom: auto !important;
  }
}

.sp-gallery-lightbox.is-open {
  display: block !important;
}

.sp-gallery-lightbox__stage {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  box-sizing: border-box !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  overflow: hidden !important;
  padding: 4px max(44px, env(safe-area-inset-left)) 4px max(44px, env(safe-area-inset-right)) !important;
  touch-action: none !important;
  user-select: none !important;
  -webkit-user-select: none !important;
}

.sp-gallery-lightbox__image {
  display: block !important;
  width: auto !important;
  height: auto !important;
  max-width: 100% !important;
  max-height: 100% !important;
  object-fit: contain !important;
  object-position: center center !important;
  margin: auto !important;
  border-radius: 0 !important;
  touch-action: none !important;
  -webkit-user-drag: none !important;
  user-select: none !important;
  transform: translate3d(0, 0, 0) scale(1);
  transform-origin: center center !important;
  will-change: transform, opacity;
}

.sp-gallery-lightbox__top {
  position: absolute !important;
  z-index: 20 !important;
  inset: 0 0 auto 0 !important;
  min-height: 54px !important;
  padding: max(7px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 14px max(8px, env(safe-area-inset-left)) !important;
  background: linear-gradient(to bottom, rgba(0,0,0,.58), rgba(0,0,0,0)) !important;
  pointer-events: none !important;
}

.sp-gallery-lightbox__top > * { pointer-events: auto !important; }

.sp-gallery-lightbox__bottom { display: none !important; }

.sp-gallery-lightbox__prev,
.sp-gallery-lightbox__next {
  position: absolute !important;
  z-index: 21 !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
}

.sp-gallery-lightbox__prev { left: max(4px, env(safe-area-inset-left)) !important; }
.sp-gallery-lightbox__next { right: max(4px, env(safe-area-inset-right)) !important; }

@media (orientation: landscape) and (max-height: 600px) {
  .sp-gallery-lightbox__stage {
    padding-top: 2px !important;
    padding-bottom: 2px !important;
  }

  .sp-gallery-lightbox__button {
    width: 42px !important;
    height: 42px !important;
  }

  .sp-gallery-lightbox__prev,
  .sp-gallery-lightbox__next {
    width: 38px !important;
    height: 50px !important;
  }
}
