/* ═══════════════════════════════════════════════════════════════
   Прогулка по квартире (static/js/tour.js): фото объявления «склеены» в плавный
   проход по комнатам. Сцена — как кинозал: тёмная в ОБЕИХ темах сайта, поэтому у неё
   свои токены (ниже), а акцент — общий токен --brand.
   ═══════════════════════════════════════════════════════════════ */

.tour, .tour-open {
  --tour-bg: #000;
  --tour-ink: #fff;
  --tour-ink-2: rgba(255, 255, 255, .78);
  --tour-glass: rgba(10, 12, 30, .62);
  --tour-glass-2: rgba(255, 255, 255, .14);
  --tour-track: rgba(255, 255, 255, .32);
  --tour-shade: rgba(0, 0, 0, .55);
}

/* ── кнопка поверх галереи (рядом с «Все N фото», который справа) ── */
.gallery .tour-open {
  position: absolute; left: 12px; bottom: 12px; z-index: 3; max-width: calc(100% - 120px);
  background: var(--tour-glass); color: var(--tour-ink); border: 0;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 8px 22px -10px var(--tour-shade);
}
.gallery .tour-open:hover { background: var(--brand); }
.gallery .tour-open span { overflow: hidden; text-overflow: ellipsis; }
.gallery .tour-open svg { width: 16px; height: 16px; fill: currentColor; }

/* ── слой прогулки ── */
.tour {
  position: fixed; inset: 0; z-index: 160; background: var(--tour-bg); color: var(--tour-ink);
  display: flex; flex-direction: column; overflow: hidden; touch-action: none; user-select: none;
  -webkit-user-select: none; font-family: var(--font); outline: none; animation: fade .2s;
}
.tour [hidden] { display: none !important; }
.tour > canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.tour button { font-family: inherit; }
.tour-stage { position: absolute; inset: 0; z-index: 1; cursor: pointer; }

.tour-top {
  position: relative; z-index: 2; padding: calc(10px + env(safe-area-inset-top)) 14px 28px;
  background: linear-gradient(to bottom, var(--tour-shade), transparent);
  pointer-events: none;
}
.tour-top > * { pointer-events: auto; }
.tour-bars { display: flex; gap: 4px; width: min(100%, 720px); margin: 0 auto; }
.tour-bars i { flex: 1; height: 3px; border-radius: 2px; background: var(--tour-track); overflow: hidden; }
.tour-bars i b { display: block; height: 100%; width: 100%; background: var(--tour-ink); transform: scaleX(0);
  transform-origin: left center; }
.tour-head { display: flex; align-items: center; gap: 10px; }
.tour-titles { flex: 1; min-width: 0; }
.tour-title { font-weight: 800; font-size: 15px; line-height: 1.25; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; }
.tour-room { font-size: 13px; color: var(--tour-ink-2); min-height: 18px; margin-top: 2px; transition: opacity .35s; }
.tour-room.out { opacity: 0; }

.tour .t-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--tour-glass-2); color: var(--tour-ink);
  display: inline-grid; place-items: center; cursor: pointer; flex: none; transition: background .15s;
}
.tour .t-btn:hover { background: var(--tour-track); }
.tour .t-btn:focus-visible, .tour .t-pill:focus-visible { outline: 2px solid var(--tour-ink); outline-offset: 2px; }
.tour .t-btn svg { width: 22px; height: 22px; }
.tour .t-btn.play svg { fill: currentColor; }
.tour .t-btn.big { width: 56px; height: 56px; }
.tour .t-pill {
  display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 16px; border-radius: 22px; border: 0;
  background: var(--tour-glass-2); color: var(--tour-ink); font-weight: 700; font-size: 14px; cursor: pointer;
  white-space: nowrap;
}
.tour .t-pill:hover { background: var(--tour-track); }
.tour .t-pill.primary { background: var(--brand); }
.tour .t-pill svg { width: 18px; height: 18px; }

.tour-bottom {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  padding: 36px 14px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--tour-shade), transparent);
  display: flex; flex-direction: column; gap: 14px; pointer-events: none;
}
.tour-row { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; }
/* Пустые поля полосы касания не ловят: они — та же левая/правая треть сцены */
.tour-row > * { pointer-events: auto; }
.tour-ctrls { display: flex; align-items: center; gap: 10px; }
.tour-count { min-width: 64px; text-align: center; font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; }
/* На телефоне «Скачать видео» — второй строкой под кнопками, а не в ряд с ними */
@media (max-width: 479px) { .tour-row { flex-direction: column; gap: 10px; } }

/* ожидание, пустой и конечный экраны — по центру поверх сцены */
.tour-center {
  position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; padding: 24px; text-align: center;
  pointer-events: none;
}
.tour-center > * { pointer-events: auto; }
.tour-center p { color: var(--tour-ink-2); max-width: 340px; margin: 10px auto 0; }
.tour-center .row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
.tour-end { background: var(--tour-shade); animation: fade .35s; }
.tour-end h3 { color: var(--tour-ink); font-size: 22px; margin: 0; }
.tour-spin { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--tour-track); border-top-color: var(--tour-ink);
  animation: spin .8s linear infinite; margin: 0 auto; }
.tour-buffer { position: absolute; z-index: 3; left: 50%; top: 50%; margin: -17px 0 0 -17px; pointer-events: none;
  opacity: 0; transition: opacity .2s .4s; }
.tour-buffer.on { opacity: 1; }

/* ── панель выгрузки видео для Reels и TikTok ── */
.tour-export {
  position: absolute; z-index: 4; left: 50%; bottom: 0; transform: translateX(-50%); width: min(100%, 460px);
  background: var(--surface); color: var(--ink); border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 22px 20px calc(20px + env(safe-area-inset-bottom)); box-shadow: var(--shadow-lg);
  /* fade, а не pop: pop анимирует transform и сбил бы центровку translateX */ animation: fade .2s;
  max-height: 88vh; overflow-y: auto; touch-action: auto; user-select: text; -webkit-user-select: text;
}
@media (min-width: 640px) {
  .tour-export { bottom: 50%; transform: translate(-50%, 50%); border-radius: var(--radius-xl); }
}
.tour-export h3 { margin: 0 0 6px; padding-right: 40px; font-size: 19px; }
.tour-export .sub { color: var(--muted); font-size: 14px; margin: 0 0 14px; }
.tour-export .x { position: absolute; top: 12px; right: 12px; }
.tour-export .note { font-size: 13px; color: var(--muted); margin: 12px 0 0; }
.tour-export .note.warn { color: var(--warn); font-weight: 600; }
.tour-export .note.err { color: var(--danger); font-weight: 600; }
.tour-export .note.ok { color: var(--good); font-weight: 600; }
.tour-export .progress { margin-top: 14px; }
.tour-export .progress i { width: 0; transition: none; }
.tour-export .acts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.tour-export .acts .btn { flex: 1 1 auto; }
.tour-export .preview { display: flex; gap: 12px; align-items: center; margin-bottom: 4px; }
.tour-export canvas.rec { display: block; width: 54px; height: 96px; border-radius: 8px; background: var(--tour-bg); }
.tour-export .preview .ratio { flex: none; width: 36px; height: 64px; border-radius: 8px; border: 2px solid var(--brand);
  display: grid; place-items: center; font-size: 11px; font-weight: 800; color: var(--brand); background: var(--brand-50); }

@media (prefers-reduced-motion: reduce) {
  .tour, .tour-end, .tour-export { animation: none; }
  .tour-room { transition: none; }
  .tour-spin { animation-duration: 2.4s; }
}
