/* NORDIAL GALLERY GLOBAL v3
   Top preview:
   - current main image + next 4 images
   Fullscreen:
   - ALL product images for this product, no grouping by variant
*/

.nd-global-source-hidden {
  position: absolute !important;
  left: -99999px !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.nd-global-gallery,
.nd-global-gallery *,
.nd-global-modal,
.nd-global-modal * {
  box-sizing: border-box;
}

.nd-global-gallery {
  --nd-green: #1c3b2d;
  --nd-text: #222622;
  --nd-line: #dedfdb;
  width: 100%;
  margin: 0 0 26px;
  color: var(--nd-text);
  font-family: "Urbanist", sans-serif;
}

.nd-global-main {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  border: 0;
  background: #fff;
  cursor: zoom-in;
}

.nd-global-main > img,
.nd-global-tile > img {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  object-fit: contain !important;
  object-position: center !important;
  transform: none !important;
  opacity: 1 !important;
  visibility: visible !important;
}

.nd-global-open,
.nd-global-video,
.nd-global-more {
  appearance: none;
  border: 1px solid var(--nd-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.97);
  color: var(--nd-text);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.nd-global-open {
  position: absolute;
  right: 15px;
  bottom: 15px;
  min-height: 45px;
  padding: 0 20px;
}

.nd-global-video {
  position: absolute;
  left: 15px;
  bottom: 15px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 45px;
  padding: 0 17px;
}

.nd-global-video::before {
  display: inline-grid;
  place-items: center;
  width: 25px;
  height: 25px;
  padding-left: 2px;
  border-radius: 50%;
  background: var(--nd-green);
  color: #fff;
  font-size: 10px;
  content: "▶";
}

.nd-global-counter {
  position: absolute;
  top: 12px;
  right: 12px;
  min-width: 50px;
  padding: 7px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  font-size: 13px;
  font-weight: 650;
  text-align: center;
  pointer-events: none;
}

.nd-global-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  margin-top: 4px;
}

.nd-global-tile {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border: 0;
  padding: 0;
  background: #fff;
  cursor: zoom-in;
}

.nd-global-actions {
  display: flex;
  justify-content: center;
  margin-top: 16px;
}

.nd-global-more {
  min-height: 46px;
  padding: 0 23px;
}

/* fullscreen modal */
.nd-global-modal {
  position: fixed;
  z-index: 2147483000;
  inset: 0;
  display: none;
  overflow: hidden;
  background: #fff;
  color: var(--nd-text);
  font-family: "Urbanist", sans-serif;
}

.nd-global-modal.is-open {
  display: grid;
  grid-template-rows: 58px minmax(0, 1fr);
}

.nd-global-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 46px;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 6px 10px 6px 18px;
  border-bottom: 1px solid var(--nd-line);
  background: #fff;
}

.nd-global-title {
  overflow: hidden;
  font-size: 14px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nd-global-modal-counter {
  font-size: 14px;
  font-weight: 650;
}

.nd-global-close {
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  color: var(--nd-text);
  font-size: 34px;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
}

.nd-global-body {
  display: grid;
  grid-template-columns: 106px minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.nd-global-thumbs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  min-width: 0;
  padding: 12px 10px;
  overflow-x: hidden;
  overflow-y: auto;
  border-right: 1px solid var(--nd-line);
  background: #fff;
}

.nd-global-thumb {
  flex: 0 0 76px;
  width: 76px;
  height: 76px;
  overflow: hidden;
  border: 1px solid #dedfdb;
  border-radius: 5px;
  padding: 3px;
  background: #fff;
  cursor: pointer;
}

.nd-global-thumb.is-active {
  border: 2px solid var(--nd-green);
  padding: 2px;
}

.nd-global-thumb img {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
}

.nd-global-thumb--video {
  display: grid;
  place-items: center;
  background: var(--nd-green);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.nd-global-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #fff;
}

.nd-global-media {
  position: absolute;
  inset: 12px 66px;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #fff;
}

.nd-global-media > img {
  display: block !important;
  width: auto !important;
  height: auto !important;
  max-width: 100% !important;
  max-height: 100% !important;
  min-width: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  object-fit: contain !important;
  object-position: center !important;
}

.nd-global-media > iframe {
  display: block;
  width: min(430px, 90vw);
  height: min(calc(100dvh - 90px), 760px);
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 9 / 16;
  border: 0;
  background: #111;
}

.nd-global-arrow {
  position: absolute;
  z-index: 2;
  top: 50%;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid #dedfdb;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.98);
  color: var(--nd-text);
  font-size: 27px;
  cursor: pointer;
  transform: translateY(-50%);
}

.nd-global-prev { left: 10px; }
.nd-global-next { right: 10px; }

body.nd-global-opened {
  overflow: hidden !important;
}

@media (max-width: 767px) {
  .nd-global-gallery {
    width: calc(100% + 30px);
    margin-top: 0;
    margin-right: -15px;
    margin-left: -15px;
  }

  /*
   * Na telefonu je hlavní fotka o něco nižší, aby mezi ní a dolními
   * náhledy nevznikalo tolik prázdného místa. Fotografie se stále
   * zobrazuje celá díky object-fit: contain.
   */
  .nd-global-main {
    aspect-ratio: 4 / 3;
  }

  .nd-global-main > img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    object-position: center top !important;
  }

  .nd-global-open,
  .nd-global-video {
    bottom: 8px;
    min-height: 40px;
    padding-right: 11px;
    padding-left: 11px;
    font-size: 12.5px;
  }

  .nd-global-open {
    right: 8px;
  }

  .nd-global-video {
    left: 8px;
    gap: 7px;
  }

  .nd-global-video::before {
    width: 21px;
    height: 21px;
  }

  .nd-global-counter {
    top: 8px;
    right: 8px;
    padding: 6px 9px;
    font-size: 12px;
  }

  .nd-global-grid {
    gap: 2px;
    margin-top: 2px;
  }

  .nd-global-actions {
    margin-top: 8px;
  }

  .nd-global-more {
    min-height: 42px;
    padding: 0 17px;
    font-size: 14px;
  }

  /* Menší hlavička = více místa pro fotografii a video. */
  .nd-global-modal.is-open {
    grid-template-rows: 50px minmax(0, 1fr);
  }

  .nd-global-header {
    grid-template-columns: minmax(0, 1fr) 40px;
    min-height: 50px;
    padding: 3px 4px 3px 10px;
  }

  .nd-global-title {
    font-size: 11px;
  }

  .nd-global-modal-counter {
    font-size: 12px;
  }

  .nd-global-close {
    width: 38px;
    height: 38px;
    font-size: 31px;
  }

  .nd-global-body {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) 76px;
  }

  .nd-global-stage {
    grid-row: 1;
  }

  /* Miniatury zůstávají dole, ale zabírají méně výšky. */
  .nd-global-thumbs {
    grid-row: 2;
    flex-direction: row;
    gap: 6px;
    align-items: center;
    padding: 6px 8px;
    overflow-x: auto;
    overflow-y: hidden;
    border-top: 1px solid var(--nd-line);
    border-right: 0;
    scroll-snap-type: x proximity;
  }

  .nd-global-thumb {
    flex: 0 0 62px;
    width: 62px;
    height: 62px;
    scroll-snap-align: center;
  }

  /*
   * Fotografie využije celý prostor mezi hlavičkou a miniaturami.
   * object-fit: contain stále zaručuje, že se nic neořízne.
   */
  .nd-global-media {
    inset: 1px 1px 45px;
  }

  .nd-global-media > img {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain !important;
  }

  /*
   * Vertikální Vimeo video se řídí výškou telefonu.
   * Na běžném telefonu vyplní téměř celou šířku.
   */
  .nd-global-media > iframe {
    width: min(100%, 430px) !important;
    height: auto !important;
    max-width: 100% !important;
    max-height: calc(100dvh - 130px) !important;
    aspect-ratio: 9 / 16 !important;
  }

  .nd-global-arrow {
    top: 50%;
    bottom: auto;
    width: 38px;
    height: 38px;
    font-size: 23px;
    transform: translateY(-50%);
  }

  .nd-global-prev {
    left: 5px;
  }

  .nd-global-next {
    right: 5px;
  }
}

/* Telefony na šířku */
@media (max-width: 900px) and (orientation: landscape) {
  .nd-global-modal.is-open {
    grid-template-rows: 44px minmax(0, 1fr);
  }

  .nd-global-body {
    grid-template-columns: 78px minmax(0, 1fr);
    grid-template-rows: 1fr;
  }

  .nd-global-thumbs {
    grid-column: 1;
    grid-row: 1;
    flex-direction: column;
    padding: 6px;
    overflow-x: hidden;
    overflow-y: auto;
    border-top: 0;
    border-right: 1px solid var(--nd-line);
  }

  .nd-global-stage {
    grid-column: 2;
    grid-row: 1;
  }

  .nd-global-thumb {
    flex: 0 0 58px;
    width: 58px;
    height: 58px;
  }

  .nd-global-media {
    inset: 3px 44px;
  }

  .nd-global-media > iframe {
    width: auto !important;
    height: calc(100dvh - 52px) !important;
    max-height: calc(100dvh - 52px) !important;
  }
}


/* v13: counters are intentionally removed */
.nd-global-counter,
.nd-global-modal-counter {
  display: none !important;
}


/* v13: only the button on the main image remains */
.nd-global-actions,
.nd-global-more {
  display: none !important;
}


/* v13: keep only bottom gallery button */
.nd-global-open { display: none !important; }
.nd-global-actions { display: flex !important; }
.nd-global-more { display: inline-flex !important; align-items: center; justify-content: center; }


/* v13: tighter desktop preview grid */
@media (min-width: 768px) {
  .nd-global-actions { margin-top: 10px; }
}


/* GLOBAL v3 final controls */
.nd-global-counter,
.nd-global-modal-counter,
.nd-global-open {
  display: none !important;
}

.nd-global-actions {
  display: flex !important;
}

.nd-global-more {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
}


/* GLOBAL v3: more compact desktop gallery */
@media (min-width: 768px) {
  .nd-global-main {
    aspect-ratio: 3 / 2;
  }

  .nd-global-grid {
    margin-top: 2px;
  }
}
