/* Страница тура: сцена во весь экран, панели — «дымчатое стекло»,
   единственный акцент — зелёный луч лазерного уровня. Одна тема (тёмная)
   выбрана намеренно: 3D смотрится в темноте. */
:root {
  --stage: #101213;
  --on: #f2f3ef;
  --on-muted: #a9aea8;
  --glass: rgba(16, 18, 19, .74);
  --glass-line: rgba(242, 243, 239, .14);
  --laser: #2fd27f;
  --laser-ink: #072d1a;
  --danger: #ff8a75;
  --font: "Geologica", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Martian Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --gutter: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--stage); color: var(--on); font: 400 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; overflow: hidden; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--laser); outline-offset: 3px; }
[hidden] { display: none !important; }

.tour { position: fixed; inset: 0; }
.stage { position: absolute; inset: 0; outline: none; touch-action: none; cursor: grab; }
.stage:active { cursor: grabbing; }
.stage canvas { display: block; width: 100% !important; height: 100% !important; }
.poster { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

/* Фирменный момент: луч лазерного уровня проходит по сцене, пока она появляется */
.stage::after {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--laser) 18%, var(--laser) 82%, transparent); opacity: 0;
}
.tour.revealed .stage::after { animation: level 1.6s var(--ease-out) forwards; }
@keyframes level { 0% { opacity: 0; transform: translateY(8vh); } 15% { opacity: 1; } 85% { opacity: 1; } 100% { opacity: 0; transform: translateY(92vh); } }

.loader { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: grid; justify-items: center; gap: 14px; color: var(--on-muted); font: 400 12px var(--mono); letter-spacing: .02em; transition: opacity .3s; }
.loader.done { opacity: 0; pointer-events: none; }
.loader-line { width: 180px; height: 1px; background: linear-gradient(90deg, transparent, var(--laser), transparent); background-size: 200% 100%; animation: scan 1.4s linear infinite; }
@keyframes scan { to { background-position: -200% 0; } }

/* Шапка */
.top {
  position: fixed; inset: 0 0 auto 0; z-index: 5; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 16px;
  padding: calc(14px + env(safe-area-inset-top, 0px)) var(--gutter-r) 36px var(--gutter);
  background: linear-gradient(to bottom, rgba(16, 18, 19, .82), rgba(16, 18, 19, 0)); pointer-events: none;
}
.top > * { pointer-events: auto; min-width: 0; }
.brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: var(--on); font-weight: 500; letter-spacing: -.01em; }
.mark { width: 22px; height: 9px; border: 1.5px solid var(--laser); border-radius: 50%; position: relative; }
.mark::after { content: ""; position: absolute; left: 50%; top: 50%; width: 3px; height: 3px; border-radius: 50%; background: var(--laser); transform: translate(-50%, -50%); }
.title { margin: 0; font-size: 16px; font-weight: 400; color: var(--on-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.actions { display: flex; gap: 8px; }

.btn {
  min-height: 40px; padding: 0 16px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--on); color: var(--stage); font-weight: 500; font-size: 14px; white-space: nowrap;
  transition: transform .15s ease-out, background-color .2s ease, opacity .2s ease;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.ghost { background: var(--glass); color: var(--on); box-shadow: inset 0 0 0 1px var(--glass-line); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.btn.wide { width: 100%; background: var(--laser); color: var(--laser-ink); }
@media (hover: hover) and (pointer: fine) {
  .btn:hover:not(:disabled) { background: #fff; }
  .btn.ghost:hover:not(:disabled) { background: rgba(40, 44, 46, .85); }
  .btn.wide:hover { background: #4be39a; }
}
@media (max-width: 560px) {
  .brand-name { display: none; }
  .title { font-size: 15px; color: var(--on); }
  .btn { padding: 0 14px; }
}

/* Точки обзора */
.stops {
  position: fixed; inset: auto 0 0 0; z-index: 5; display: grid; gap: 10px;
  padding: 48px var(--gutter-r) calc(16px + env(safe-area-inset-bottom, 0px)) var(--gutter);
  background: linear-gradient(to top, rgba(16, 18, 19, .86), rgba(16, 18, 19, 0)); pointer-events: none;
}
.stops > * { pointer-events: auto; min-width: 0; }
.stops ol { list-style: none; margin: 0; padding: 0; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.stops ol::-webkit-scrollbar { display: none; }
.stops li { flex: 0 0 auto; }
.stop {
  display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 16px 0 12px; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--glass); color: var(--on-muted); box-shadow: inset 0 0 0 1px var(--glass-line); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: color .2s ease, box-shadow .2s ease;
}
.stop .n { font: 500 11px var(--mono); color: var(--on-muted); }
.stop[aria-current="true"] { color: var(--on); box-shadow: inset 0 0 0 1.5px var(--laser); }
.stop[aria-current="true"] .n { color: var(--laser); }
@media (hover: hover) and (pointer: fine) { .stop:hover { color: var(--on); } }
.hint { margin: 0; font: 400 11px var(--mono); color: var(--on-muted); letter-spacing: .02em; }

/* «Шайбы» на полу — переходы между точками */
.hotspots { position: absolute; inset: 0; pointer-events: none; z-index: 2; overflow: hidden; }
.hotspot { position: absolute; left: 0; top: 0; display: grid; justify-items: center; gap: 6px; padding: 6px; border: 0; background: none; cursor: pointer; pointer-events: auto; color: var(--on); }
.hotspot::before { content: ""; width: 38px; height: 13px; border-radius: 50%; border: 2px solid var(--on); background: rgba(242, 243, 239, .16); box-shadow: 0 0 0 4px rgba(16, 18, 19, .25); transition: background-color .2s ease, border-color .2s ease; }
.hotspot span { font: 500 11px var(--mono); padding: 3px 7px; border-radius: 6px; background: rgba(16, 18, 19, .7); white-space: nowrap; }
@media (hover: hover) and (pointer: fine) { .hotspot:hover::before { background: var(--laser); border-color: var(--laser); } }

/* Панель настройки: справа на компьютере, снизу на телефоне */
.panel {
  position: fixed; z-index: 8; top: calc(72px + env(safe-area-inset-top, 0px)); right: var(--gutter-r); width: min(380px, calc(100vw - 32px));
  max-height: calc(100% - 180px); overflow: auto; border-radius: 18px;
  background: rgba(20, 22, 23, .9); box-shadow: 0 24px 60px rgba(0, 0, 0, .45), inset 0 0 0 1px var(--glass-line); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  animation: sheet .24s var(--ease-out);
}
@keyframes sheet { from { opacity: 0; transform: translateY(8px); } }
@media (max-width: 640px) {
  .panel { top: auto; bottom: 0; left: 0; right: 0; width: auto; max-height: 78%; border-radius: 18px 18px 0 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
}
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 4px 20px; }
.panel-head h2 { margin: 0; font-size: 17px; font-weight: 500; }
.icon { width: 40px; height: 40px; border: 0; border-radius: 50%; background: transparent; cursor: pointer; color: var(--on-muted); }
@media (hover: hover) and (pointer: fine) { .icon:hover { background: rgba(242, 243, 239, .08); color: var(--on); } }
.panel-body { display: grid; gap: 14px; padding: 8px 20px 20px; }
.field { display: grid; gap: 6px; font-size: 13px; color: var(--on-muted); }
.field input { min-height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--glass-line); background: rgba(242, 243, 239, .05); color: var(--on); }
.field input:focus { border-color: var(--laser); outline: none; }
.row { display: flex; flex-wrap: wrap; gap: 8px; }
.note { margin: 0; font-size: 12px; color: var(--on-muted); }
.turns { margin: 4px 0 0; padding: 14px 0 0; border: 0; border-top: 1px solid var(--glass-line); display: grid; gap: 10px; }
.turns legend { padding: 0; font-size: 13px; color: var(--on); float: left; margin-bottom: 10px; }
.turns legend + * { clear: both; }
.danger { display: grid; gap: 10px; padding-top: 14px; border-top: 1px solid var(--glass-line); }
.danger-btn { justify-self: start; color: var(--danger) !important; }
.danger-fill { background: var(--danger); color: #2a0b05; }
.confirm p { margin: 0 0 10px; font-size: 13px; }

.toast {
  position: fixed; z-index: 9; left: 50%; bottom: calc(118px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 8px);
  padding: 10px 16px; border-radius: 999px; background: var(--on); color: var(--stage); font-size: 14px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: opacity .2s ease-out, transform .2s ease-out; max-width: calc(100vw - 32px); text-align: center;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* Чистый кадр для обложек и слайдов: ?clean=1 */
.clean .top, .clean .stops, .clean .hotspots, .clean .toast { display: none !important; }
.clean .stage::after { display: none; }

/* Запасной режим без 3D */
.fallback-note { position: absolute; left: 50%; top: calc(86px + env(safe-area-inset-top, 0px)); transform: translateX(-50%); z-index: 3; margin: 0; max-width: min(520px, calc(100% - 32px)); padding: 10px 14px; border-radius: 12px; background: var(--glass); font-size: 13px; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  .tour.revealed .stage::after, .loader-line, .panel { animation: none; }
  .btn, .stop, .toast, .hotspot::before { transition: none; }
}
