/* 3D Tour page — chrome design-v2 «Чертёж» вокруг WebGL-модуля.
   tour.js, assets и поведение тура не затрагиваются. */

.tour-page {
  background: var(--bg-dark);
  color: var(--ink-inv);
  overflow: hidden;
  height: 100vh;
  height: 100svh;
  display: flex;
  flex-direction: column;
}

/* Шапка — светлая, по общей системе (LAYOUTS.md) */
.tour-header {
  flex: 0 0 auto;
}

.tour-nav {
  display: flex !important;
}

.tour-nav .is-active {
  color: var(--brand);
}

.tour-nav .is-active::after {
  transform: scaleX(1);
}

.tour-main {
  flex: 1 1 auto;
  min-height: 0;
}

.tour-stage {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#tour-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
  touch-action: none;
}

/* Start overlay */

.tour-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: var(--space-lg);
  padding: 0 var(--gutter);
  background:
    repeating-linear-gradient(0deg, rgba(247, 248, 249, 0.04) 0 1px, transparent 1px 64px),
    repeating-linear-gradient(90deg, rgba(247, 248, 249, 0.04) 0 1px, transparent 1px 64px),
    var(--bg-dark);
  transition:
    opacity 400ms var(--ease-out),
    visibility 0s linear 400ms;
}

.tour-overlay.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Mono-аннотация над заголовком (существующая строка «// 3D») */
.tour-kicker {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  font-weight: 500;
  letter-spacing: 0.14em;
  color: var(--brand-on-dark);
}

.tour-overlay h1 {
  margin: 0;
  font-size: var(--fs-display);
  font-weight: 700;
  letter-spacing: var(--ls-display);
  line-height: var(--lh-display);
}

.tour-start-btn {
  min-height: 52px;
  font-size: 1.0625rem;
}

.tour-hints {
  list-style: none;
  margin: var(--space-md) 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
  color: var(--text-muted-on-dark);
  font-size: var(--fs-small);
}

.tour-hints kbd {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  padding: 2px 7px;
  border: 1px solid var(--rule-inv);
  background: transparent;
  color: var(--ink-inv);
}

.tour-hint-touch {
  display: none;
}

@media (pointer: coarse) {
  .tour-hints li {
    display: none;
  }

  .tour-hint-touch {
    display: block;
  }
}

/* The hidden attribute must always win: class display rules (flex/grid)
   otherwise override the UA's [hidden] { display: none } and the panels
   render on top of the canvas from page load. */
.tour-loading[hidden],
.tour-fallback[hidden],
.tour-fallback-reason[hidden],
.hotspot-card[hidden] {
  display: none !important;
}

/* Loading state (while Three.js chunk is fetched) */

.tour-loading {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  background: var(--bg-dark);
}

/* Линия-прелоадер на тёмной сцене: видимые инверсные цвета */
.tour-loading .preloader-bar {
  background: var(--rule-inv);
}

.tour-loading .preloader-bar::after {
  background: var(--brand-on-dark);
}

.tour-progress {
  font-family: var(--font-mono);
  font-size: var(--fs-mono-label);
  letter-spacing: 0.12em;
  color: var(--accent);
}

/* WebGL fallback */

.tour-fallback {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);
  background: var(--bg-dark);
  text-align: center;
  padding: 0 var(--gutter);
}

.tour-fallback p {
  margin: 0;
  font-size: 1.25rem;
  color: var(--text-muted-on-dark);
}

.tour-fallback-reason {
  max-width: 560px;
  font-size: var(--fs-small) !important;
  font-family: var(--font-mono);
  color: var(--brand-on-dark) !important;
}

/* Hotspot card (stage 5) */

.hotspot-card {
  position: absolute;
  right: var(--space-lg);
  bottom: var(--space-lg);
  z-index: 8;
  width: min(380px, calc(100% - var(--space-lg) * 2));
  padding: 24px 28px;
  background: rgba(20, 23, 29, 0.96);
  border: 1px solid var(--rule-inv);
  border-top: 2px solid var(--brand);
}

.hotspot-card h2 {
  margin: 0 0 10px;
  font-size: var(--fs-h3);
  letter-spacing: var(--ls-h3);
  padding-right: 32px;
}

.hotspot-card p {
  margin: 0 0 16px;
  font-size: var(--fs-small);
  line-height: 1.6;
  color: var(--ink-inv-soft);
}

.hotspot-card p:empty {
  display: none;
}

.hotspot-card .pill {
  border-color: var(--rule-inv);
  color: var(--ink-inv);
}

.hotspot-card .pill:hover {
  background: var(--brand);
  border-color: var(--brand);
  color: #ffffff;
}

.hotspot-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  background: none;
  color: var(--text-muted-on-dark);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out);
}

.hotspot-close:hover {
  color: var(--c-white);
}

/* Hotspot markers — design-v2 «Чертёж» (wagon-v4, Д5).
   Квадратный маркер, mono-код HSP-xx, цвет --brand, пульс тонким кольцом. */

.hsp-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.hsp-marker {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  padding: 6px;
  margin: 0;
  border: 0;
  background: none;
  cursor: pointer;
  color: #ffffff;
  will-change: transform;
}

.hsp-marker.is-offscreen {
  display: none;
}

.hsp-marker::before {
  content: "";
  width: 14px;
  height: 14px;
  background: var(--brand);
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 1px rgba(20, 23, 29, 0.35);
  flex: 0 0 auto;
}

.hsp-ring {
  position: absolute;
  left: 6px;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  border: 1px solid var(--brand-on-dark);
  animation: hsp-pulse 2.4s var(--ease-out) infinite;
  pointer-events: none;
}

@keyframes hsp-pulse {
  0% { transform: scale(1); opacity: 0.9; }
  70% { transform: scale(2.4); opacity: 0; }
  100% { transform: scale(2.4); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .hsp-ring { animation: none; opacity: 0; }
}

.hsp-code {
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  font-weight: 600;
  letter-spacing: 0.1em;
  color: #ffffff;
  background: rgba(20, 23, 29, 0.78);
  border-left: 2px solid var(--brand);
  padding: 3px 8px;
  opacity: 0;
  transform: translateX(-4px);
  transition:
    opacity var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}

.hsp-marker:hover .hsp-code,
.hsp-marker:focus-visible .hsp-code {
  opacity: 1;
  transform: translateX(0);
}

.hsp-marker:focus-visible {
  outline: var(--focus-ring);
  outline-color: var(--brand-on-dark);
  outline-offset: var(--focus-offset);
}

@media (pointer: coarse) {
  .hsp-code {
    opacity: 1;
    transform: none;
  }
}

/* Crosshair shown while pointer is locked */

.tour-stage.is-locked::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border: 1px solid var(--brand-on-dark);
  border-radius: 50%;
  z-index: 4;
  pointer-events: none;
}

@media (max-width: 1020px) {
  .tour-nav {
    gap: 16px;
  }
}
