/* ================================================================
   WoT Shop — Лайтбокс CSS v4
   ================================================================ */

/* ── Сетка превью ────────────────────────────────────────────── */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(430px, 1fr));
  gap: 16px;
}
@media (max-width: 768px) { .gallery-grid { grid-template-columns: 1fr 1fr; gap: 10px; } }
@media (max-width: 480px) { .gallery-grid { grid-template-columns: 1fr; } }

.gallery-thumb {
  position: relative;
  aspect-ratio: 16/9;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  /*background: var(--bg-card);
  border: 1px solid var(--border);*/
  transition: border-color var(--transition);
}
/*.gallery-thumb:hover { border-color: rgba(245,197,24,0.3); transform: scale(1.02); }*/
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; }

.gallery-thumb-num {
  position: absolute; bottom: 8px; right: 8px;
  background: rgba(0,0,0,0.6); color: #fff; font-size: 11px;
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; backdrop-filter: blur(4px);
  flex-shrink: 0;
}
.gallery-thumb-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.3); opacity: 0;
  transition: opacity var(--transition);
  display: flex; align-items: center; justify-content: center;
}
.gallery-thumb:hover .gallery-thumb-overlay { opacity: 1; }
.gallery-thumb-overlay svg {
  color: white;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.gallery-thumb:hover .gallery-thumb-overlay svg {
  opacity: 1;
  transform: scale(1);
}

/* ══════════════════════════════════════════════════════════════
   ЛАЙТБОКС
══════════════════════════════════════════════════════════════ */
.lightbox {
  display: none;
  position: fixed; inset: 0; z-index: 1100;
  background: #000;
}

/* Скрываем панели лайтбокса пока он закрыт (предотвращает "фигню снизу") */
.lightbox:not(.open) .lb-thumbnails,
.lightbox:not(.open) .lb-toolbar { display: none; }
.lightbox.open { display: block; }

.lightbox-bg {
  position: absolute; inset: 0; z-index: 0;
}

/* ── Кнопка назад — левый верхний угол ──────────────────────── */
.lb-back {
  position: absolute; top: 16px; left: 16px; z-index: 30;
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 50%;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  color: white;
  opacity: 0.75;
  outline: none;
  cursor: pointer;
}
.lb-back:focus { outline: none; }

/* ── Кнопка закрыть — всегда видима ─────────────────────────── */
.lb-close {
  position: absolute; top: 16px; right: 16px; z-index: 30;
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 50%;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  color: white;
  transition: background 0.2s, opacity 0.2s;
  opacity: 0.75;
  outline: none;
}
.lb-close:focus { outline: none; }
.lb-close:hover { background: rgba(255,255,255,0.18); opacity: 1; }

/* ── Стрелки ─────────────────────────────────────────────────── */
.lb-arrow {
  position: absolute;
  top: 50%; transform: translateY(-50%);
  z-index: 20;
  background: none; border: none;
  width: 56px; height: 56px;
  display: flex; align-items: center; justify-content: center;
  color: white; cursor: pointer;
  -webkit-appearance: none;
  padding: 0;
  outline: none;
}
.lb-arrow:focus { outline: none; }
.lb-arrow:focus-visible { outline: none; }
/* Круглый фон — через псевдоэлемент на самой кнопке */
.lb-arrow::after {
  content: '';
  position: absolute; inset: 0;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.14);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.lb-arrow:hover::after  { background: rgba(255,255,255,0.16); }
.lb-arrow:active::after { background: rgba(255,255,255,0.22); }
.lb-arrow:disabled      { opacity: 0.2; pointer-events: none; }
.lb-arrow svg           { position: relative; z-index: 1; filter: drop-shadow(0 1px 4px rgba(0,0,0,0.9)); }
.lightbox.ui-visible .lb-arrow::after { opacity: 1; }

.lb-prev { left: 14px; }
.lb-next { right: 14px; }

@media (max-width: 600px) {
  .lb-prev { left: 6px; } .lb-next { right: 6px; }
  .lb-arrow { width: 44px; height: 44px; }
}

/* ── Сцена ───────────────────────────────────────────────────── */
.lb-stage {
  position: absolute; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  touch-action: none; /* жесты обрабатываются нашим кодом */
}
.lb-img-wrap {
  display: flex; align-items: center; justify-content: center;
  cursor: default; user-select: none;
  /* GPU-слой на обёртке (не на img) — фиксит ghosting/полосы без потери качества.
     translateZ(0) изолирует compositing-слой, img рендерится в полном разрешении */
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}
.lb-img-wrap.zoomed { cursor: grab; }

#lb-img {
  display: block;
  max-width: 100vw; max-height: 100vh;
  width: auto; height: auto;
  object-fit: contain;
  user-select: none; -webkit-user-drag: none;
  transform-origin: center center;
  transition: none;
  border-radius: 0;
  /* НЕ добавляем will-change/backface — они снижают качество рендера */
}

/* ── Миниатюры снизу с навигацией — скрыты по умолчанию ─────── */
.lb-thumbnails {
  position: absolute; bottom: 0; left: 50%;
  transform: translateX(-50%) translateY(110%);
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 120px);
  padding: 12px 16px 20px;
  background: none;
  transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}
.lightbox.ui-visible .lb-thumbnails {
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

/* Строка миниатюр */
.lb-tn-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  max-width: 100%;
}
.lb-tn-row::-webkit-scrollbar { display: none; }

/* Счётчик в панели навигации */
.lb-nav-counter {
  font-size: 12px;
  color: rgba(255,255,255,0.5);
  background: rgba(20,22,28,0.85);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  padding: 3px 10px;
  backdrop-filter: blur(8px);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
}

.lb-tn {
  flex-shrink: 0; width: 64px; height: 42px;
  border-radius: 6px; overflow: hidden; cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.2s, opacity 0.2s;
  opacity: 0.5;
}
.lb-tn:hover  { opacity: 0.8; }
.lb-tn.active { border-color: var(--accent); opacity: 1; }
.lb-tn img    { width: 100%; height: 100%; object-fit: cover; }

/* ── Тулбар снизу — только зум, над панелью навигации ───────── */
.lb-toolbar {
  position: absolute; bottom: 108px; left: 50%;
  transform: translateX(-50%) translateY(0);
  z-index: 25;
  display: flex; align-items: center; gap: 4px;
  transition: opacity 0.32s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  opacity: 0;
}
.lightbox.ui-visible .lb-toolbar {
  opacity: 1;
  pointer-events: auto;
}

/* Таблетка-обёртка для кнопок зума */
.lb-toolbar-pill {
  display: flex; align-items: center; gap: 0;
  background: rgba(20,22,28,0.92);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 40px;
  padding: 5px 6px;
  backdrop-filter: blur(12px);
}

.lb-tool {
  background: none; border: none;
  color: rgba(255,255,255,0.75);
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  border-radius: 20px;
  transition: background 0.18s, color 0.18s;
  cursor: pointer;
  outline: none;
}
.lb-tool:focus { outline: none; }
.lb-tool:hover { background: rgba(255,255,255,0.1); color: white; }

.lb-divider {
  width: 0.1px; height: 20px;
  background: rgba(255,255,255,0.12);
  margin: 0 10px;
}

.lb-counter {
  display: none;
}

/* ── Анимации слайдов ────────────────────────────────────────── */
/* lb-slide-in-* классы удалены — используется crossfade через JS-клон */

/* ── Отключаем hover-эффекты на touch-устройствах ────────────── */
@media (hover: none) {
  .gallery-thumb:hover .gallery-thumb-overlay { opacity: 0; }
  .gallery-thumb:hover .gallery-thumb-overlay svg { opacity: 0; transform: scale(0.8); }
  .lb-close:hover { background: rgba(0,0,0,0.55); opacity: 0.75; }
  .lb-arrow:hover::after { background: rgba(255,255,255,0.08); }
  .lb-tn:hover { opacity: 0.5; }
  .lb-tn.active { opacity: 1; }
  .lb-tool:hover { background: none; color: rgba(255,255,255,0.7); }
}
