/* =========================================================
   viewer.css —— 3D 视口、热点标注、数据卡
   ========================================================= */

.viewport {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(255, 255, 255, 0.035), transparent 58%),
    linear-gradient(180deg, #0d1218, #080b0f);
}

.viewer-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.viewer-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 3;
}

.viewport__hint {
  position: absolute;
  left: 12px;
  bottom: 10px;
  z-index: 4;
  font-size: 11.5px;
  color: var(--muted);
  pointer-events: none;
  letter-spacing: 0.02em;
}

.viewport__error {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  padding: 24px;
  color: var(--text-dim);
  font-size: 13px;
  z-index: 6;
}

/* ---------------- 热点 ---------------- */

.hotspot {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  pointer-events: none;
  will-change: transform;
}

.hotspot__dot {
  position: absolute;
  left: 0;
  top: 0;
  width: 15px;
  height: 15px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: rgba(8, 11, 15, 0.72);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent);
  pointer-events: auto;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.hotspot__dot i {
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.9;
}

.hotspot__dot:hover {
  transform: translate(-50%, -50%) scale(1.28);
}

.hotspot__label {
  position: absolute;
  left: 16px;
  top: 0;
  transform: translateY(-50%);
  white-space: nowrap;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text);
  background: rgba(10, 14, 19, 0.78);
  border: 1px solid color-mix(in srgb, var(--accent) 34%, var(--border));
  border-radius: 999px;
  padding: 2px 9px;
  pointer-events: auto;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: opacity 0.2s ease, background 0.16s ease, color 0.16s ease;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hotspot__label::before {
  content: "";
  position: absolute;
  right: 100%;
  top: 50%;
  width: 16px;
  height: 1px;
  background: color-mix(in srgb, var(--accent) 60%, transparent);
}

.hotspot__label:hover {
  background: rgba(18, 24, 31, 0.95);
}

/* 右侧空间不足时标签翻到左边 */
.hotspot.is-flipped .hotspot__label {
  left: auto;
  right: 16px;
}

.hotspot.is-flipped .hotspot__label::before {
  right: auto;
  left: 100%;
}

/* 被车体挡住 */
.hotspot.is-behind {
  opacity: 0.26;
}

.hotspot.is-behind .hotspot__dot,
.hotspot.is-behind .hotspot__label {
  pointer-events: none;
}

/* 视口外 */
.hotspot.is-offscreen {
  opacity: 0;
  pointer-events: none;
}

/* 选中态 */
.hotspot.is-active {
  z-index: 5;
}

.hotspot.is-active .hotspot__dot {
  transform: translate(-50%, -50%) scale(1.35);
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 20%, transparent);
}

.hotspot.is-active .hotspot__label {
  background: var(--accent);
  color: #10151b;
  border-color: var(--accent);
  font-weight: 600;
}

.hotspot.is-active .hotspot__label::before {
  background: var(--accent);
}

/* 关闭标注 */
.viewer-overlay.labels-hidden .hotspot__label {
  opacity: 0;
  pointer-events: none;
}

/* ---------------- 数据卡 ---------------- */

.card {
  position: absolute;
  left: 0;
  top: 0;
  width: min(348px, calc(100% - 20px));
  max-height: calc(100% - 20px);
  overflow-y: auto;
  padding: 14px 15px 12px;
  background: rgba(15, 20, 26, 0.965);
  border: 1px solid var(--border);
  border-left: 3px solid var(--card-accent, var(--accent));
  border-radius: var(--radius);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(12px);
  opacity: 0;
  transition: opacity 0.18s ease;
  will-change: transform;
  z-index: 8;
}

.card.is-open {
  opacity: 1;
}

.card.is-detached {
  opacity: 0.18;
  pointer-events: none;
}

.card.is-pinned {
  left: auto;
  right: 12px;
  top: 12px;
  transform: none !important;
}

/* 视口太小时卡片改为贴底展开 */
.card.is-docked {
  left: 10px;
  right: 10px;
  top: auto;
  bottom: 10px;
  width: auto;
  max-height: 66%;
  transform: none !important;
}

.card__close {
  position: absolute;
  right: 8px;
  top: 8px;
  width: 24px;
  height: 24px;
  display: grid;
  place-content: center;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
  font-size: 17px;
  line-height: 1;
  transition: background 0.15s ease, color 0.15s ease;
}

.card__close:hover {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
}

.card__inner .ans__title {
  padding-right: 26px;
}

@media (max-width: 980px) {
  .card {
    width: calc(100% - 20px);
  }
  .hotspot__label {
    font-size: 11px;
    max-width: 150px;
  }
}
