/* =========================================================
   CRIS Gallery – Premium Lightbox
   ========================================================= */

.cris-gallery-lightbox,
.cris-gallery-lightbox * {
  box-sizing: border-box;
}

.cris-gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 72px 92px 40px;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.22s ease,
    visibility 0.22s ease;
}

.cris-gallery-lightbox.is-open {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.cris-gallery-lightbox__backdrop {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: rgba(3, 16, 25, 0.97);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* =========================================================
   Topbar
   ========================================================= */

.cris-gallery-lightbox__topbar {
  position: absolute;
  top: 18px;
  left: 22px;
  right: 22px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  pointer-events: none;
}

.cris-gallery-lightbox__counter {
  min-width: 74px;
  padding: 9px 13px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(21, 38, 50, 0.92);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* =========================================================
   X + strelice – zajednički dizajn
   ========================================================= */

.cris-gallery-lightbox button.cris-gallery-lightbox__close,
.cris-gallery-lightbox button.cris-gallery-lightbox__nav {
  width: 58px !important;
  min-width: 58px !important;
  max-width: 58px !important;
  height: 58px !important;
  min-height: 58px !important;
  max-height: 58px !important;

  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;

  margin: 0 !important;
  padding: 0 !important;

  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  border-radius: 13px !important;

  background: rgba(21, 38, 50, 0.94) !important;
  background-color: rgba(21, 38, 50, 0.94) !important;
  color: #fff !important;

  outline: none !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.32) !important;

  cursor: pointer !important;
  appearance: none !important;
  -webkit-appearance: none !important;

  line-height: 1 !important;
  font-size: 0 !important;

  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);

  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    transform 0.2s ease !important;
}

.cris-gallery-lightbox button.cris-gallery-lightbox__close:hover,
.cris-gallery-lightbox button.cris-gallery-lightbox__close:focus,
.cris-gallery-lightbox button.cris-gallery-lightbox__close:focus-visible,
.cris-gallery-lightbox button.cris-gallery-lightbox__close:active,
.cris-gallery-lightbox button.cris-gallery-lightbox__nav:hover,
.cris-gallery-lightbox button.cris-gallery-lightbox__nav:focus,
.cris-gallery-lightbox button.cris-gallery-lightbox__nav:focus-visible,
.cris-gallery-lightbox button.cris-gallery-lightbox__nav:active {
  background: #0c6196 !important;
  background-color: #0c6196 !important;
  color: #fff !important;
  border-color: #268dc7 !important;
  outline: none !important;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.38) !important;
}

/* X */
.cris-gallery-lightbox button.cris-gallery-lightbox__close {
  position: relative !important;
  z-index: 21;
  pointer-events: auto !important;
}

.cris-gallery-lightbox button.cris-gallery-lightbox__close:hover,
.cris-gallery-lightbox button.cris-gallery-lightbox__close:focus {
  transform: scale(1.05);
}

/* SVG */
.cris-gallery-lightbox button.cris-gallery-lightbox__close svg,
.cris-gallery-lightbox button.cris-gallery-lightbox__nav svg {
  width: 29px !important;
  height: 29px !important;
  display: block !important;
  flex: 0 0 auto;
  color: #fff !important;
  fill: none !important;
  pointer-events: none !important;
}

/* =========================================================
   Figure / Stage / Image
   ========================================================= */

.cris-gallery-lightbox__figure {
  position: relative;
  z-index: 5;
  width: min(1320px, 100%);
  max-height: calc(100vh - 112px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0;
  text-align: center;
}

.cris-gallery-lightbox__stage {
  position: relative;
  width: 100%;
  min-height: min(64vh, 680px);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
}

.cris-gallery-lightbox__image {
  max-width: 100%;
  max-height: 72vh;
  width: auto;
  height: auto;
  display: block;
  object-fit: contain;
  border-radius: 14px;
  background: transparent;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.4);

  transform-origin: center center;
  will-change: transform;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  cursor: zoom-in;

  transition: transform 0.2s ease;
}

.cris-gallery-lightbox__image.is-zoomed {
  cursor: grab;
}

.cris-gallery-lightbox__image.is-dragging {
  cursor: grabbing;
  transition: none !important;
}

/* =========================================================
   Loader
   ========================================================= */

.cris-gallery-lightbox__loader {
  position: absolute;
  width: 46px;
  height: 46px;
  display: none;
  border: 4px solid rgba(255, 255, 255, 0.18);
  border-top-color: #fff;
  border-radius: 50%;
  animation: cris-gallery-lightbox-spin 0.8s linear infinite;
}

.cris-gallery-lightbox__loader.is-visible {
  display: block;
}

@keyframes cris-gallery-lightbox-spin {
  to {
    transform: rotate(360deg);
  }
}

/* =========================================================
   Caption
   ========================================================= */

.cris-gallery-lightbox__caption {
  width: 100%;
  max-width: 840px;
  min-height: 54px;
  padding-top: 14px;
  color: #fff;
}

.cris-gallery-lightbox__caption strong {
  display: block;
  color: #fff;
  font-size: 18px;
  line-height: 1.35;
}

.cris-gallery-lightbox__caption p {
  margin: 6px 0 0;
  color: rgba(255, 255, 255, 0.72);
  line-height: 1.55;
}

/* =========================================================
   Actions
   ========================================================= */

.cris-gallery-lightbox__actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 18px;
}

.cris-gallery-lightbox
  .cris-gallery-lightbox__actions
  .cris-gallery-share-button,
.cris-gallery-lightbox
  .cris-gallery-lightbox__actions
  .cris-gallery-download-button {
  min-height: 44px !important;
  padding: 11px 18px !important;
  border: 1px solid #0c6196 !important;
  border-radius: 12px !important;
  background: #0c6196 !important;
  background-color: #0c6196 !important;
  color: #fff !important;
  outline: none !important;
  box-shadow: none !important;
  text-decoration: none !important;
  cursor: pointer !important;
  font-weight: 700 !important;
  appearance: none !important;
  -webkit-appearance: none !important;
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    transform 0.2s ease !important;
}

.cris-gallery-lightbox
  .cris-gallery-lightbox__actions
  .cris-gallery-share-button:hover,
.cris-gallery-lightbox
  .cris-gallery-lightbox__actions
  .cris-gallery-share-button:focus,
.cris-gallery-lightbox
  .cris-gallery-lightbox__actions
  .cris-gallery-share-button:focus-visible,
.cris-gallery-lightbox
  .cris-gallery-lightbox__actions
  .cris-gallery-share-button:active,
.cris-gallery-lightbox
  .cris-gallery-lightbox__actions
  .cris-gallery-download-button:hover,
.cris-gallery-lightbox
  .cris-gallery-lightbox__actions
  .cris-gallery-download-button:focus,
.cris-gallery-lightbox
  .cris-gallery-lightbox__actions
  .cris-gallery-download-button:focus-visible,
.cris-gallery-lightbox
  .cris-gallery-lightbox__actions
  .cris-gallery-download-button:active {
  background: #268dc7 !important;
  background-color: #268dc7 !important;
  color: #fff !important;
  border-color: #268dc7 !important;
  outline: none !important;
  box-shadow: none !important;
  transform: translateY(-2px);
}

/* =========================================================
   Share menu
   ========================================================= */

.cris-gallery-share-menu {
  display: none;
  width: min(320px, 100%);
  margin: 14px auto 0;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.cris-gallery-share-menu.is-open {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.cris-gallery-lightbox .cris-gallery-share-menu .cris-gallery-share-option {
  min-height: 40px;
  padding: 8px 12px !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  border-radius: 10px !important;
  background: rgba(255, 255, 255, 0.12) !important;
  color: #fff !important;
  font-weight: 700 !important;
  cursor: pointer !important;
  outline: none !important;
  box-shadow: none !important;
  appearance: none !important;
  -webkit-appearance: none !important;
}

.cris-gallery-lightbox
  .cris-gallery-share-menu
  .cris-gallery-share-option:hover,
.cris-gallery-lightbox
  .cris-gallery-share-menu
  .cris-gallery-share-option:focus,
.cris-gallery-lightbox
  .cris-gallery-share-menu
  .cris-gallery-share-option:active {
  background: #fff !important;
  color: #0c6196 !important;
  border-color: #fff !important;
  outline: none !important;
  box-shadow: none !important;
}

/* =========================================================
   DESKTOP nav: sa strane slike
   ========================================================= */

.cris-gallery-lightbox__nav-row {
  display: contents;
}

.cris-gallery-lightbox button.cris-gallery-lightbox__nav {
  position: absolute !important;
  top: 50%;
  z-index: 12;
  transform: translateY(-50%);
}

.cris-gallery-lightbox button.cris-gallery-lightbox__nav.is-prev {
  left: 20px;
}

.cris-gallery-lightbox button.cris-gallery-lightbox__nav.is-next {
  right: 20px;
}

.cris-gallery-lightbox button.cris-gallery-lightbox__nav:hover,
.cris-gallery-lightbox button.cris-gallery-lightbox__nav:focus {
  transform: translateY(-50%) scale(1.05);
}

/* =========================================================
   Scroll lock
   ========================================================= */

body.cris-gallery-lightbox-open {
  overflow: hidden !important;
}

/* =========================================================
   Tablet
   ========================================================= */

@media (max-width: 950px) {
  .cris-gallery-lightbox {
    padding-right: 74px;
    padding-left: 74px;
  }
}

/* =========================================================
   MOBILE
   Slika -> naslov -> actions -> nav
   ========================================================= */

@media (max-width: 650px) {
  .cris-gallery-lightbox {
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;

    padding: calc(76px + env(safe-area-inset-top)) 12px
      calc(26px + env(safe-area-inset-bottom));

    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .cris-gallery-lightbox__topbar {
    position: fixed;
    top: calc(10px + env(safe-area-inset-top));
    left: 12px;
    right: 12px;
  }

  .cris-gallery-lightbox__counter {
    min-width: 72px;
    padding: 10px 14px;
    font-size: 14px;
  }

  /* pravi kvadratni X */
  .cris-gallery-lightbox button.cris-gallery-lightbox__close {
    width: 54px !important;
    min-width: 54px !important;
    max-width: 54px !important;
    height: 54px !important;
    min-height: 54px !important;
    max-height: 54px !important;
    border-radius: 12px !important;
  }

  .cris-gallery-lightbox button.cris-gallery-lightbox__close svg {
    width: 27px !important;
    height: 27px !important;
  }

  .cris-gallery-lightbox__figure {
    width: 100%;
    max-height: none;
    justify-content: flex-start;
  }

  /*
   * VAŽNO:
   * slika nikada ne smije progutati cijeli ekran.
   * Portretne slike staju u 58vh, landscape se širi po širini.
   */
  .cris-gallery-lightbox__stage {
    width: 100%;
    min-height: 0;
    max-height: 58vh;
    overflow: hidden;
  }

  .cris-gallery-lightbox__image {
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 58vh;
    object-fit: contain;
    border-radius: 12px;
  }

  .cris-gallery-lightbox__caption {
    width: 100%;
    max-width: 100%;
    min-height: 0;
    padding: 14px 8px 0;
  }

  .cris-gallery-lightbox__caption strong {
    font-size: 17px;
  }

  .cris-gallery-lightbox__caption p {
    font-size: 13px;
  }

  .cris-gallery-lightbox__actions {
    width: 100%;
    margin-top: 16px;
    gap: 10px;
  }

  .cris-gallery-lightbox
    .cris-gallery-lightbox__actions
    .cris-gallery-share-button,
  .cris-gallery-lightbox
    .cris-gallery-lightbox__actions
    .cris-gallery-download-button {
    flex: 1 1 0;
    min-width: 0;
    min-height: 52px !important;
    padding: 10px 12px !important;
    font-size: 16px !important;
    border-radius: 12px !important;
  }

  /*
   * Strelice više NISU fixed / absolute.
   * Sada su normalno odmah ispod Podijeli / Preuzmi.
   */
  .cris-gallery-lightbox__nav-row {
    position: relative;
    z-index: 10;

    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;

    margin: 18px 0 0;
    padding: 0 0 4px;
  }

  .cris-gallery-lightbox button.cris-gallery-lightbox__nav {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;

    width: 58px !important;
    min-width: 58px !important;
    max-width: 58px !important;

    height: 58px !important;
    min-height: 58px !important;
    max-height: 58px !important;

    border-radius: 12px !important;

    transform: none !important;
  }

  .cris-gallery-lightbox button.cris-gallery-lightbox__nav:hover,
  .cris-gallery-lightbox button.cris-gallery-lightbox__nav:focus,
  .cris-gallery-lightbox button.cris-gallery-lightbox__nav:active {
    transform: scale(1.04) !important;
  }

  .cris-gallery-lightbox button.cris-gallery-lightbox__nav svg {
    width: 30px !important;
    height: 30px !important;
  }

  .cris-gallery-share-menu {
    width: 100%;
  }

  .cris-gallery-share-menu.is-open {
    grid-template-columns: 1fr 1fr;
  }
}

/* Vrlo uski telefoni */
@media (max-width: 390px) {
  .cris-gallery-lightbox
    .cris-gallery-lightbox__actions
    .cris-gallery-share-button,
  .cris-gallery-lightbox
    .cris-gallery-lightbox__actions
    .cris-gallery-download-button {
    font-size: 14px !important;
  }

  .cris-gallery-lightbox button.cris-gallery-lightbox__nav {
    width: 54px !important;
    min-width: 54px !important;
    max-width: 54px !important;
    height: 54px !important;
    min-height: 54px !important;
    max-height: 54px !important;
  }
}

/* =========================================================
   Reduced motion
   ========================================================= */

@media (prefers-reduced-motion: reduce) {
  .cris-gallery-lightbox,
  .cris-gallery-lightbox__close,
  .cris-gallery-lightbox__nav,
  .cris-gallery-lightbox__image {
    transition: none !important;
  }

  .cris-gallery-lightbox__loader {
    animation-duration: 1.5s;
  }
}
