/* Галерея фото в карточке и просмотр на весь экран (2.Ф5), к shared/gallery.js */

.kg {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

.kg__stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

/* Кнопка-фото: выглядит как прежнее фото, открывает просмотр */
.kg__open {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
  touch-action: pan-y;
  -webkit-tap-highlight-color: transparent;
}
.kg__open:focus-visible { outline: 3px solid #a17a32; outline-offset: -3px; }

.kg__track {
  display: flex;
  width: 100%;
  height: 100%;
  transition: transform 0.35s ease;
}
.kg__slide { flex: 0 0 100%; height: 100%; }
.kg__slide img { width: 100%; height: 100%; object-fit: cover; display: block; user-select: none; }

/* Одно фото: прежний <img> карточки, по нажатию — просмотр */
.kg-zoomable { cursor: zoom-in; }
.kg-zoomable:focus-visible { outline: 3px solid #a17a32; outline-offset: -3px; }

.kg__arrow,
.kg-viewer__arrow,
.kg-viewer__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}
.kg__arrow svg,
.kg-viewer__arrow svg,
.kg-viewer__close svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.kg__arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 251, 246, 0.88);
  color: #2c241e;
  box-shadow: 0 2px 10px rgba(44, 36, 30, 0.18);
}
.kg__arrow--prev { left: 12px; }
.kg__arrow--next { right: 12px; }
.kg__arrow:hover { background: #fff; }
.kg__arrow:focus-visible { outline: 3px solid #a17a32; outline-offset: 2px; }

.kg__counter {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(44, 36, 30, 0.6);
  color: #fff;
  font-size: 13px;
  line-height: 1.4;
  pointer-events: none;
}

.kg__thumbs {
  display: flex;
  gap: 8px;
  padding: 10px;
  overflow-x: auto;
  scrollbar-width: thin;
  flex: 0 0 auto;
}
.kg__thumb {
  flex: 0 0 64px;
  width: 64px;
  height: 64px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.06);
  cursor: pointer;
  opacity: 0.7;
}
.kg__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.kg__thumb.is-active { border-color: #a17a32; opacity: 1; }
.kg__thumb:hover { opacity: 1; }
.kg__thumb:focus-visible { outline: 3px solid #a17a32; outline-offset: 1px; }

/* ── Просмотр на весь экран ── */
.kg-locked,
.kg-locked body { overflow: hidden; }

.kg-viewer {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 16, 13, 0.94);
  animation: kg-fade 0.2s ease;
}
.kg-viewer__frame {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 56px 64px;
  touch-action: pan-y;
}
.kg-viewer__img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
  user-select: none;
}
.kg-viewer__close,
.kg-viewer__arrow {
  position: absolute;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}
.kg-viewer__close:hover,
.kg-viewer__arrow:hover { background: rgba(255, 255, 255, 0.26); }
.kg-viewer__close:focus-visible,
.kg-viewer__arrow:focus-visible { outline: 3px solid #e2c47c; outline-offset: 2px; }
.kg-viewer__close { top: 12px; right: 12px; }
.kg-viewer__arrow { top: 50%; transform: translateY(-50%); }
.kg-viewer__arrow--prev { left: 12px; }
.kg-viewer__arrow--next { right: 12px; }
.kg-viewer__counter {
  position: absolute;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.85);
  font-size: 14px;
}

@keyframes kg-fade { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 700px) {
  .kg__thumb { flex-basis: 52px; width: 52px; height: 52px; }
  .kg__arrow { width: 40px; height: 40px; }
  .kg-viewer__frame { padding: 56px 8px 72px; }
  /* на телефоне листают свайпом, стрелки — внизу, чтобы не закрывать фото */
  .kg-viewer__arrow { top: auto; bottom: 14px; transform: none; }
  .kg-viewer__arrow--prev { left: calc(50% - 56px); }
  .kg-viewer__arrow--next { right: calc(50% - 56px); }
}

@media (prefers-reduced-motion: reduce) {
  .kg__track { transition: none; }
  .kg-viewer { animation: none; }
}
