/**
 * Kalama Product Gallery
 */

.kpg {
  --kpg-active: #c49316;
  --kpg-thumbs: 6;
  --kpg-thumb-size: 76px;
  --kpg-gap: 10px;
  --kpg-ratio: 1;
  --kpg-bg: #fff;
  --kpg-line: #e8e3da;
  --kpg-ink: #2b2a28;
  --kpg-radius: 8px;
  --kpg-stage-max: none;
  position: relative;
  width: 100%;
  min-width: 0;
}

/* ---------- main image ---------- */

.kpg-stage {
  position: relative;
  width: 100%;
  aspect-ratio: var(--kpg-ratio);
  max-height: var(--kpg-stage-max);
  overflow: hidden;
  background: var(--kpg-bg);
  border-radius: var(--kpg-radius);
  contain: layout paint;
}

.kpg-stage .product-flags {
  z-index: 3;
  pointer-events: none;
}

.kpg-track {
  display: flex;
  width: 100%;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}

.kpg-track::-webkit-scrollbar {
  display: none;
}

.kpg-slide {
  position: relative;
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

/* Before the script runs only the active image is laid out (no jump to it on init). */
.kpg:not(.kpg--ready) .kpg-slide:not(.is-active) {
  display: none;
}

.kpg-slide__open {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

.kpg button.kpg-slide__open:not(:disabled) {
  cursor: zoom-in;
}

button.kpg-slide__open:focus-visible {
  outline: 2px solid var(--kpg-active);
  outline-offset: -3px;
  border-radius: var(--kpg-radius);
}

.kpg-slide__open picture {
  display: block;
  width: 100%;
  height: 100%;
}

.kpg-slide__img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: contain;
  object-position: center;
  user-select: none;
  -webkit-user-drag: none;
}

.kpg-arrow {
  position: absolute;
  top: 50%;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-top: -22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 2px 10px rgba(30, 25, 15, 0.14);
  color: var(--kpg-ink);
  cursor: pointer;
  opacity: 0.8;
  transition: opacity 0.18s ease, background-color 0.18s ease, color 0.18s ease;
}

.kpg-arrow--prev {
  left: 12px;
}

.kpg-arrow--next {
  right: 12px;
}

.kpg-stage:hover .kpg-arrow,
.kpg-arrow:focus-visible {
  opacity: 1;
}

.kpg-arrow:hover {
  background: #fff;
  color: var(--kpg-active);
}

.kpg-arrow:focus-visible,
.kpg-thumbs__nav:focus-visible {
  outline: 2px solid var(--kpg-active);
  outline-offset: 2px;
}

.kpg-stage__hint {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 2px 8px rgba(30, 25, 15, 0.12);
  color: var(--kpg-ink);
  pointer-events: none;
  opacity: 0.85;
}

/* ---------- thumbnails ---------- */

.kpg-thumbs {
  --kpg-thumb-w: var(--kpg-thumb-size);
  position: relative;
  margin-top: 12px;
}

.kpg-thumbs__viewport {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 0;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}

.kpg-thumbs__viewport::-webkit-scrollbar {
  display: none;
}

.kpg-thumbs--overflow .kpg-thumbs__viewport {
  cursor: grab;
}

.kpg-thumbs__viewport.is-dragging {
  cursor: grabbing;
  user-select: none;
}

.kpg-thumbs__viewport.is-dragging .kpg-thumb {
  pointer-events: none;
}

.kpg-thumbs__list {
  display: flex;
  gap: var(--kpg-gap);
  margin: 0;
  padding: 0;
  list-style: none;
}

.kpg-thumbs__item {
  flex: 0 0 var(--kpg-thumb-w);
  width: var(--kpg-thumb-w);
  min-width: 0;
  margin: 0;
  padding: 0;
}

.kpg-thumb {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: var(--kpg-ratio);
  margin: 0;
  padding: 4px;
  overflow: hidden;
  border: 1px solid var(--kpg-line);
  border-radius: 6px;
  background: var(--kpg-bg);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.kpg-thumbs--overflow .kpg-thumb {
  cursor: inherit;
}

.kpg-thumb picture {
  display: block;
  width: 100%;
  height: 100%;
}

.kpg-thumb__img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.kpg-thumb:hover {
  border-color: #cfc5b4;
}

.kpg-thumb.is-active {
  border-color: var(--kpg-active);
  box-shadow: inset 0 0 0 1px var(--kpg-active);
}

.kpg-thumb:focus-visible {
  outline: 2px solid var(--kpg-active);
  outline-offset: 2px;
}

.kpg-thumbs__nav {
  position: absolute;
  top: 50%;
  z-index: 2;
  display: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin-top: -16px;
  padding: 0;
  border: 1px solid var(--kpg-line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 2px 8px rgba(30, 25, 15, 0.12);
  color: var(--kpg-ink);
  cursor: pointer;
  transition: opacity 0.18s ease, color 0.18s ease;
}

.kpg-thumbs__nav--prev {
  left: -6px;
}

.kpg-thumbs__nav--next {
  right: -6px;
}

.kpg-thumbs--overflow .kpg-thumbs__nav {
  display: flex;
}

.kpg-thumbs__nav:hover {
  color: var(--kpg-active);
}

.kpg-thumbs__nav[disabled] {
  opacity: 0;
  pointer-events: none;
}

@media (min-width: 992px) {
  .kpg {
    --kpg-stage-max: min(calc(100vh - 220px), 680px);
  }

  .kpg-thumbs {
    --kpg-thumb-w: calc((100% - (var(--kpg-thumbs) - 1) * var(--kpg-gap)) / var(--kpg-thumbs));
  }

  .kpg-stage {
    min-height: 360px;
  }
}

@media (min-width: 768px) and (max-width: 991.98px) {
  .kpg {
    --kpg-stage-max: 520px;
  }
}

@media (max-width: 767.98px) {
  .kpg-arrow {
    width: 36px;
    height: 36px;
    margin-top: -18px;
  }

  .kpg-arrow--prev {
    left: 6px;
  }

  .kpg-arrow--next {
    right: 6px;
  }

  .kpg-thumbs {
    margin-top: 10px;
  }

  .kpg-thumbs__nav {
    display: none !important;
  }
}

@media (hover: none) {
  .kpg-arrow {
    opacity: 0.9;
  }

  .kpg-thumbs--overflow .kpg-thumbs__viewport {
    cursor: auto;
  }
}

/* In the quickview modal the gallery is narrower and must not grow taller than the modal. */
.quickview .kpg {
  --kpg-stage-max: min(60vh, 520px);
}

/* ---------- lightbox ---------- */

html.kpg-lock,
html.kpg-lock body {
  overflow: hidden !important;
}

html.kpg-lock body {
  padding-right: var(--kpg-scrollbar, 0px);
}

.kpg-lb {
  --kpg-active: #c49316;
  --kpg-ink: #2b2a28;
  position: fixed;
  inset: 0;
  z-index: 2050;
  display: block;
  background: #fff;
  color: var(--kpg-ink);
  font-family: inherit;
  opacity: 0;
  transition: opacity 0.2s ease;
  touch-action: none;
  overscroll-behavior: contain;
}

.kpg-lb[hidden] {
  display: none;
}

.kpg-lb.is-open {
  opacity: 1;
}

.kpg-lb__viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.kpg-lb__slide {
  position: absolute;
  inset: 0;
  will-change: transform;
}

.kpg-lb.is-animating .kpg-lb__slide {
  transition: transform 0.32s cubic-bezier(0.22, 0.7, 0.2, 1);
}

.kpg-lb__img {
  position: absolute;
  top: 0;
  left: 0;
  max-width: none;
  max-height: none;
  transform-origin: 0 0;
  user-select: none;
  -webkit-user-drag: none;
  will-change: transform;
  cursor: zoom-in;
}

.kpg-lb--no-zoom .kpg-lb__img {
  cursor: default;
}

.kpg-lb.is-zoomed .kpg-lb__img {
  cursor: grab;
}

.kpg-lb.is-panning .kpg-lb__img {
  cursor: grabbing;
}

.kpg-lb__spinner {
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: 22px;
  height: 22px;
  border: 2px solid rgba(43, 42, 40, 0.15);
  border-top-color: var(--kpg-active);
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.2s ease;
  animation: kpg-spin 0.8s linear infinite;
  pointer-events: none;
}

.kpg-lb__slide.is-loading .kpg-lb__spinner {
  opacity: 1;
}

@keyframes kpg-spin {
  to {
    transform: rotate(360deg);
  }
}

.kpg-lb__bar {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  pointer-events: none;
}

.kpg-lb__bar > * {
  pointer-events: auto;
}

.kpg-lb__counter {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(244, 241, 236, 0.92);
  font-size: 0.875rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.kpg-lb__tools {
  display: flex;
  gap: 8px;
}

.kpg-lb__btn,
.kpg-lb__nav {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--kpg-ink);
  cursor: pointer;
  transition: background-color 0.18s ease, color 0.18s ease, opacity 0.18s ease;
}

.kpg-lb__btn {
  width: 44px;
  height: 44px;
  background: rgba(244, 241, 236, 0.92);
}

.kpg-lb__btn:hover,
.kpg-lb__nav:hover {
  color: var(--kpg-active);
}

.kpg-lb__btn:hover {
  background: #ebe6dd;
}

.kpg-lb__btn[disabled] {
  opacity: 0.35;
  cursor: default;
}

.kpg-lb__close {
  background: var(--kpg-ink);
  color: #fff;
}

.kpg-lb__close:hover {
  background: #000;
  color: #fff;
}

.kpg-lb__nav {
  position: absolute;
  top: 50%;
  z-index: 3;
  width: 52px;
  height: 52px;
  margin-top: -26px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 2px 12px rgba(30, 25, 15, 0.16);
}

.kpg-lb__nav--prev {
  left: 16px;
}

.kpg-lb__nav--next {
  right: 16px;
}

.kpg-lb--single .kpg-lb__nav {
  display: none;
}

.kpg-lb__btn:focus-visible,
.kpg-lb__nav:focus-visible {
  outline: 2px solid var(--kpg-active);
  outline-offset: 2px;
}

.kpg-lb__caption {
  position: absolute;
  right: 80px;
  bottom: 14px;
  left: 80px;
  z-index: 2;
  margin: 0;
  overflow: hidden;
  font-size: 0.8125rem;
  line-height: 1.4;
  text-align: center;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: #6d6a64;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.kpg-lb.is-zoomed .kpg-lb__caption {
  opacity: 0;
}

@media (max-width: 767.98px) {
  .kpg-lb__bar {
    padding: 10px;
  }

  .kpg-lb__nav {
    width: 40px;
    height: 40px;
    margin-top: -20px;
    background: rgba(255, 255, 255, 0.85);
  }

  .kpg-lb__nav--prev {
    left: 8px;
  }

  .kpg-lb__nav--next {
    right: 8px;
  }

  .kpg-lb__zoom-in,
  .kpg-lb__zoom-out {
    display: none;
  }

  .kpg-lb__caption {
    right: 16px;
    left: 16px;
  }

  .kpg-lb.is-zoomed .kpg-lb__nav {
    opacity: 0;
    pointer-events: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .kpg-lb,
  .kpg-lb.is-animating .kpg-lb__slide,
  .kpg-arrow,
  .kpg-thumb {
    transition: none;
  }
}
