/* ============================================================
   建筑模型 3D 游览系统 — 全局样式
   ============================================================ */

/* --- CSS 变量 --- */
:root {
  --bg: #0a0a0f;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-hover: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.08);
  --border-active: rgba(255, 255, 255, 0.2);
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.6);
  --text-tertiary: rgba(255, 255, 255, 0.35);
  --accent: #4da6ff;
  --accent-glow: rgba(77, 166, 255, 0.3);
  --glass-bg: rgba(15, 15, 25, 0.7);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-blur: 16px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 20px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --vh: 1vh;
}

/* --- Reset --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: pan-x pan-y;
}

/* ============================================================
   加载画面
   ============================================================ */
#loading-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

#loading-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-content {
  text-align: center;
}

.loading-icon {
  margin-bottom: 24px;
  color: var(--accent);
}

.loading-bar {
  animation: loadingPulse 1.2s ease-in-out infinite;
}

@keyframes loadingPulse {
  0%, 100% { opacity: 0.3; transform: scaleY(0.6); }
  50%      { opacity: 1;   transform: scaleY(1); }
}

.loading-title {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 20px;
  letter-spacing: 0.05em;
}

.progress-track {
  width: 200px;
  height: 3px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
  margin: 0 auto 12px;
}

.progress-fill {
  width: 0%;
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   3D 画布
   ============================================================ */
#canvas-container {
  position: fixed;
  inset: 0;
  z-index: 1;
}

#three-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ============================================================
   滚动导览层
   ============================================================ */
#scroll-container {
  position: fixed;
  inset: 0;
  z-index: 10;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

#scroll-container::-webkit-scrollbar {
  display: none;
}

.scroll-spacer {
  height: 5vh;
}

.tour-section {
  min-height: 85vh;
  display: flex;
  align-items: flex-end;
  padding: 0 8vw 12vh;
  pointer-events: none;
}

.tour-section:last-of-type {
  min-height: 100vh;
  align-items: center;
  padding-bottom: 15vh;
}

.section-content {
  max-width: 500px;
  pointer-events: auto;
}

.section-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  background: var(--accent-glow);
  padding: 4px 12px;
  border-radius: 100px;
  margin-bottom: 16px;
  border: 1px solid rgba(77, 166, 255, 0.2);
}

.tour-section h1,
.tour-section h2 {
  font-size: clamp(1.6rem, 4vw, 2.8rem);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}

.tour-section p {
  font-size: clamp(0.9rem, 2vw, 1.1rem);
  color: var(--text-secondary);
  line-height: 1.6;
}

.scroll-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 24px;
  color: var(--text-tertiary);
  font-size: 0.85rem;
  animation: floatHint 2s ease-in-out infinite;
}

@keyframes floatHint {
  0%, 100% { transform: translateY(0); opacity: 0.5; }
  50%      { transform: translateY(8px); opacity: 1; }
}

/* CTA Section */
.cta-section .section-content {
  text-align: center;
  margin: 0 auto;
}

.btn-glass {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  margin-top: 20px;
}

.btn-glass:hover {
  background: var(--surface-hover);
  border-color: var(--border-active);
  transform: translateY(-1px);
}

.btn-glass:active {
  transform: scale(0.97);
}

/* ============================================================
   侧边导航点
   ============================================================ */
#section-dots {
  position: fixed;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-tertiary);
  cursor: pointer;
  transition: all var(--transition);
  border: 2px solid transparent;
}

.dot.active {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
  transform: scale(1.4);
}

.dot:hover {
  background: var(--text-secondary);
}

/* ============================================================
   底部控制栏
   ============================================================ */
#control-bar {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
}

.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--text-tertiary);
  white-space: nowrap;
}

.control-label svg {
  opacity: 0.6;
}

/* 爆炸滑块 */
#explode-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 80px;
  height: 4px;
  background: rgba(255,255,255,0.12);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

#explode-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  cursor: pointer;
  box-shadow: 0 0 8px var(--accent-glow);
  transition: transform 0.15s ease;
}

#explode-slider::-webkit-slider-thumb:active {
  transform: scale(1.2);
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-icon:hover {
  background: var(--surface-hover);
  border-color: var(--border-active);
  color: var(--text-primary);
}

.btn-icon.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.label-text {
  font-size: 0.8rem;
}

@media (max-width: 600px) {
  .label-text {
    display: none;
  }
}

/* ============================================================
   QR 模态框
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  background: #16161e;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
  max-width: 380px;
  width: 90%;
  position: relative;
  transform: scale(0.92);
  transition: transform 0.3s ease;
}

.modal-overlay.active .modal-card {
  transform: scale(1);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  transition: color 0.2s;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-card h3 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 20px;
}

#qr-code-container {
  width: 220px;
  height: 220px;
  margin: 0 auto 16px;
  background: #fff;
  border-radius: var(--radius);
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#qr-code-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.qr-hint {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.qr-url-row {
  display: flex;
  gap: 8px;
}

.qr-url-row input {
  flex: 1;
  padding: 8px 12px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-family: var(--font);
  outline: none;
}

.qr-url-row .btn-glass {
  margin-top: 0;
  padding: 8px 16px;
  font-size: 0.8rem;
  white-space: nowrap;
}

/* ============================================================
   3D 标注
   ============================================================ */
#annotations-layer {
  position: fixed;
  inset: 0;
  z-index: 15;
  pointer-events: none;
}

.annotation {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  cursor: pointer;
}

.annotation-dot {
  width: 10px;
  height: 10px;
  background: var(--accent);
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent-glow);
  animation: dotPulse 2s ease-in-out infinite;
}

@keyframes dotPulse {
  0%, 100% { box-shadow: 0 0 6px var(--accent-glow); }
  50%      { box-shadow: 0 0 16px var(--accent-glow), 0 0 24px rgba(77,166,255,0.2); }
}

.annotation-label {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-size: 0.8rem;
  white-space: nowrap;
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  opacity: 0;
  transform: translateY(-50%) translateX(-4px);
  transition: all 0.25s ease;
  pointer-events: none;
}

.annotation:hover .annotation-label {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

/* ============================================================
   响应式设计
   ============================================================ */
@media (max-width: 768px) {
  #control-bar {
    bottom: 12px;
    padding: 8px 12px;
    gap: 8px;
    border-radius: var(--radius);
  }

  #explode-slider {
    width: 50px;
  }

  #section-dots {
    right: 10px;
    gap: 12px;
  }

  .dot {
    width: 6px;
    height: 6px;
  }

  .tour-section {
    padding: 0 6vw 16vh;
  }

  .section-content {
    max-width: 100%;
  }

  .modal-card {
    padding: 24px;
  }

  #qr-code-container {
    width: 180px;
    height: 180px;
  }
}

@media (max-width: 400px) {
  #control-bar {
    bottom: 8px;
    padding: 6px 10px;
    gap: 4px;
    border-radius: var(--radius-sm);
  }

  .control-label {
    font-size: 0.65rem;
  }

  .control-label svg {
    display: none;
  }

  #explode-slider {
    width: 40px;
  }

  .btn-icon {
    width: 28px;
    height: 28px;
  }

  .btn-glass {
    padding: 8px 12px;
    font-size: 0.75rem;
  }
}

/* ============================================================
   辅助
   ============================================================ */
/* 隐藏但可访问 */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

/* 选中样式 */
::selection {
  background: var(--accent);
  color: #fff;
}
