/* ==========================================================================
   1. 基础重置与变量定义
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none; /* 防止用户在拖拽全景时误选文字 */
}

:root {
    --primary-color: #2d9cff;
    --primary-glow: rgba(45, 156, 255, 0.4);
    --text-main: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.7);
    --bg-glass: rgba(10, 22, 41, 0.45);
    --bg-glass-hover: rgba(10, 22, 41, 0.65);
    --border-glass: rgba(255, 255, 255, 0.12);
    --blur-effect: blur(12px);
    --radius-main: 16px;
    --radius-btn: 12px;
    --transition-fast: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #000;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ==========================================================================
   2. 核心分层架构 (Marzipano 与 UI 层隔离)
   ========================================================================== */
#viewer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none; /* 关键：穿透点击，允许拖拽全景 */
    display: grid;
    grid-template-columns: 320px 1fr 300px;
    grid-template-rows: auto 1fr auto;
    padding: 20px;
    gap: 20px;
}

/* 恢复 UI 元素的点击拦截 */
.glass-panel, .tool-btn, .mode-btn, .scene-card, .cat-tab {
    pointer-events: auto;
}

/* 通用玻璃拟态面板基类 */
.glass-panel {
    background: var(--bg-glass);
    backdrop-filter: var(--blur-effect);
    -webkit-backdrop-filter: var(--blur-effect);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-main);
    color: var(--text-main);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    transition: var(--transition-fast);
}

.intro-modal {
    position: fixed;
    inset: 0;
    z-index: 10100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.55);
    pointer-events: auto;
}

.intro-modal-panel {
    width: min(420px, calc(100vw - 40px));
    max-height: min(680px, calc(100vh - 40px));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 12px;
}

.intro-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border-glass);
}

.intro-modal-header h2 {
    font-size: 20px;
    font-weight: 700;
}

.intro-close-btn {
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 50%;
    background: rgba(255,255,255,.08);
    color: #fff;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.intro-close-btn:hover {
    background: var(--primary-color);
}

.intro-modal-body {
    padding: 18px;
    overflow-y: auto;
    color: rgba(255,255,255,.88);
    font-size: 14px;
    line-height: 1.75;
    -webkit-overflow-scrolling: touch;
}

.intro-modal-body p + p,
.intro-modal-body h3 {
    margin-top: 14px;
}

.intro-modal-body h3 {
    color: #fff;
    font-size: 15px;
}

.intro-modal-body ul {
    padding-left: 20px;
}

/* ==========================================================================
   3. 各区域 UI 样式设计
   ========================================================================== */

/* --- 左上角信息区 --- */
.info-panel {
    grid-column: 1;
    grid-row: 1;
    padding: 16px 20px;
    align-self: start;
}

.platform-title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 1px;
    background: linear-gradient(135deg, #fff 30%, var(--primary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 6px;
}

.scene-title-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.current-scene {
    font-size: 16px;
    font-weight: 500;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background-color: #26e6a4;
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(38, 230, 164, 0.7);
    animation: pulse 1.8s infinite;
}

.operation-tips {
    font-size: 11px;
    color: var(--text-muted);
}

/* --- 顶部横向滚动信息条 --- */
.top-marquee-bar {
    grid-column: 2;
    grid-row: 1;
    align-self: start;
    justify-self: center;
    max-width: 500px;
    width: 100%;
    height: 38px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    overflow: hidden;
    border-radius: 30px; /* 胶囊形 */
}

.marquee-wrapper {
    width: 100%;
    overflow: hidden;
}

.marquee-content {
    display: inline-block;
    white-space: nowrap;
    font-size: 13px;
    animation: marquee 25s linear infinite;
}

/* --- 右上角小地图面板 --- */
#mapPanel {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 280px;
    overflow: hidden;
    z-index: 40;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-glass);
}

.panel-title {
    font-size: 14px;
    font-weight: bold;
}

.panel-toggle-btn {
    background: none;
    border: none;
    color: var(--text-main);
    cursor: pointer;
    font-size: 16px;
}

.map-fallback-bg {
    width: 100%;
    height: 100%;
    /* 生产环境中可用真实校园简图替换 */
    background: radial-gradient(circle at center, #1b3459 0%, #0a1424 100%); 
}


/* --- 右侧竖向工具栏 --- */
#toolbar {
    grid-column: 3;
    grid-row: 2;
    align-self: center;
    justify-self: end;
    display: flex;
    flex-direction: column;
    padding: 8px;
    gap: 8px;
    border-radius: 30px; /* 胶囊纵向 */
}

.tool-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid transparent;
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.tool-btn .icon {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.tool-btn span {
    font-size: 9px;
    margin-top: 2px;
    display: none; /* 默认隐藏文字，保持极简，Hover 弹出或需要时开启 */
}

.tool-btn:hover {
    background: var(--primary-color);
    box-shadow: 0 0 15px var(--primary-glow);
    transform: scale(1.05);
}

.tool-btn.active {
    background: var(--primary-color);
    box-shadow: 0 0 15px var(--primary-glow);
}

/* --- 左下角快捷模式按钮 --- */
.mode-container {
    grid-column: 1;
    grid-row: 3;
    align-self: end;
    display: flex;
    padding: 6px;
    gap: 6px;
    border-radius: var(--radius-btn);
}

.mode-btn {
    padding: 8px 14px;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition-fast);
}

.mode-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.08);
}

.mode-btn.active {
    background: var(--primary-color);
    color: var(--text-main);
    box-shadow: 0 4px 12px var(--primary-glow);
}

/* --- 底部分类导航栏 --- */
#bottomScenePanel {
    grid-column: 2;
    grid-row: 3;
    align-self: end;
    width: 100%;
    max-width: 800px;
    justify-self: center;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* 分类标签 */
.category-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    overflow-x: auto;
    white-space: nowrap;
    padding: 4px 6px 10px;
}

.category-bar::-webkit-scrollbar {
    display: none; /* 隐藏滚动条 */
}

.filter-btn {
    flex: 0 0 auto;
    border: 1px solid rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.88);
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: all 0.2s ease;
}

.filter-btn:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.18);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
}

.filter-btn.active {
    color: #fff;
    background: linear-gradient(135deg, rgba(43, 148, 255, 0.95), rgba(38, 208, 206, 0.78));
    border-color: rgba(255, 255, 255, 0.45);
    box-shadow: 0 8px 24px rgba(33, 150, 243, 0.35);
}

/* 场景缩略图容器 */
#sceneButtons {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 4px 0;
}

/* 优化横向滚动条样式 */
#sceneButtons::-webkit-scrollbar {
    height: 4px;
}
#sceneButtons::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

/* 场景卡片 */
.scene-card {
    flex: 0 0 110px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 6px;
    text-align: center;
    transition: var(--transition-fast);
}

.thumb-box {
    width: 110px;
    height: 70px;
    border-radius: var(--radius-btn);
    overflow: hidden;
    border: 2px solid transparent;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    transition: var(--transition-fast);
}

.thumb-placeholder {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    filter: brightness(0.85);
    transition: var(--transition-fast);
}

/* 模拟一些渐变做缩略图占位，开发阶段替换成 background-image: url(...) */
.tmp-1 { background: linear-gradient(135deg, #1e3c72, #2a5298); }
.tmp-2 { background: linear-gradient(135deg, #243b55, #141e30); }
.tmp-3 { background: linear-gradient(135deg, #11998e, #38ef7d); }
.tmp-4 { background: linear-gradient(135deg, #fc4a1a, #f7b733); }
.tmp-5 { background: linear-gradient(135deg, #00c6ff, #0072ff); }

.card-title {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: var(--transition-fast);
}

/* 悬浮与激活态 */
.scene-card:hover .thumb-box {
    border-color: rgba(255,255,255,0.5);
    transform: translateY(-2px);
}
.scene-card:hover .thumb-placeholder {
    filter: brightness(1);
}

.scene-card.active .thumb-box {
    border-color: var(--primary-color);
    box-shadow: 0 0 12px var(--primary-glow);
}
.scene-card.active .card-title {
    color: var(--primary-color);
    font-weight: bold;
}

.hidden {
  display: none !important;
}

#groundRouteBar {
  display: flex;
  gap: 8px;
  align-items: center;
}

#groundRouteBar input {
  width: 180px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  padding: 0 10px;
  outline: none;
  cursor: pointer;
}

#groundRouteBar button {
  height: 32px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  cursor: pointer;
}

#groundRouteBar input.picking {
  outline: 2px solid rgba(43,148,255,.95);
  box-shadow: 0 0 0 4px rgba(43,148,255,.18);
}

.route-toast {
  position: fixed;
  left: 50%;
  top: 86px;
  transform: translateX(-50%) translateY(-8px);
  z-index: 10080;
  max-width: min(520px, calc(100vw - 32px));
  padding: 10px 16px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  border-radius: 999px;
  background: rgba(20, 30, 45, 0.78);
  border: 1px solid rgba(255,255,255,0.24);
  box-shadow: 0 10px 28px rgba(0,0,0,.28);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}

.route-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.neighbor-hotspot {
  position: relative;
  transform: translate(-50%, -50%);
  cursor: pointer;
  user-select: none;
  text-align: center;
  pointer-events: auto;
}

.neighbor-label {
  display: inline-block;
  padding: 4px 10px;
  margin-bottom: 6px;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  border-radius: 999px;
  background: rgba(20, 30, 45, 0.72);
  border: 1px solid rgba(255,255,255,0.32);
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  white-space: nowrap;
}

.neighbor-arrow {
  width: 54px;
  height: 36px;
  margin: 0 auto;
  color: rgba(255,255,255,.92);
  font-size: 36px;
  font-weight: 700;
  line-height: 32px;
  text-shadow: 0 3px 10px rgba(0,0,0,.45);
  transform: rotate(180deg);
  transition: transform 0.2s ease;
}

.neighbor-hotspot:hover .neighbor-label {
  background: rgba(43,148,255,.9);
}

.neighbor-hotspot:hover .neighbor-arrow {
  transform: rotate(180deg) scale(1.08);
}

.route-next-hotspot .neighbor-label {
  background: linear-gradient(135deg, rgba(43,148,255,.96), rgba(34,197,94,.92));
  color: #fff;
  border-color: rgba(255,255,255,.75);
  box-shadow:
    0 0 0 3px rgba(43,148,255,.25),
    0 10px 28px rgba(43,148,255,.45);
  font-size: 15px;
  padding: 6px 14px;
}

.route-next-hotspot .neighbor-arrow {
  color: #fff;
  font-size: 46px;
  text-shadow:
    0 0 12px rgba(43,148,255,.95),
    0 6px 18px rgba(0,0,0,.55);
  animation: routeNextPulse 1.2s infinite ease-in-out;
}

.thumb-placeholder {
  background-size: cover;
  background-position: center;
}


/* ==========================================================================
   4. 动画定义
   ========================================================================== */
@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(38, 230, 164, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(38, 230, 164, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(38, 230, 164, 0); }
}

@keyframes pointPulse {
    0% { box-shadow: 0 0 4px #e74c3c; }
    100% { box-shadow: 0 0 14px #e74c3c; border-color: rgba(255,255,255,0.6); }
}

@keyframes marquee {
    0% { transform: translate3d(100%, 0, 0); }
    100% { transform: translate3d(-100%, 0, 0); }
}

@keyframes routeNextPulse {
  0% { transform: rotate(180deg) scale(1); opacity: .85; }
  50% { transform: rotate(180deg) scale(1.18); opacity: 1; }
  100% { transform: rotate(180deg) scale(1); opacity: .85; }
}

/* ==========================================================================
   5. 响应式微调 (针对小屏手机做精简)
   ========================================================================== */
@media (max-width: 768px) {
    .ui-overlay {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto 1fr auto;
        padding: 10px;
        gap: 10px;
    }
    .info-panel { grid-column: 1; grid-row: 1; width: 100%; }
    .top-marquee-bar { display: flex; }
    #mapPanel { top: 10px; right: 10px; width: min(280px, calc(100vw - 20px)); }
    #toolbar { grid-column: 1; grid-row: 3; justify-self: end; align-self: center; }
    .mode-container { grid-column: 1; grid-row: 3; align-self: start; }
    #bottomScenePanel { grid-column: 1; grid-row: 4; width: 100%; }
}

#miniMap {
  width: 100%;
  height: 200px;
  position: relative;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.2);
}

#miniMapInner {
  position: relative;
  width: 100%;
  height: 100%;
}

#miniMapImg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  display: block;
  pointer-events: none;
  z-index: 1;
}

#routeSvg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  overflow: visible;
}

.route-line {
  fill: none;
  stroke: #ff3b30;
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 6px rgba(255, 59, 48, 0.9));
}

.map-point {
  position: absolute;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: #2d9cff;
  box-shadow: 0 0 8px rgba(45,156,255,.8);
  transform: translate(-50%, -50%);
  cursor: pointer;
  z-index: 3;
}

.map-point.air {
  background: #f39c12;
}

.map-point.current {
  background: #e74c3c;
  box-shadow: 0 0 12px #e74c3c;
}

.map-point.route-point {
  background: #ffcc00;
  box-shadow: 0 0 12px #ffcc00;
}

.map-point.route-start-point {
  background: #22c55e !important;
  border-color: #fff !important;
  box-shadow: 0 0 0 3px rgba(34,197,94,.35), 0 0 18px rgba(34,197,94,.8) !important;
}

.map-point.route-end-point {
  background: #ef4444 !important;
  border-color: #fff !important;
  box-shadow: 0 0 0 3px rgba(239,68,68,.35), 0 0 18px rgba(239,68,68,.8) !important;
}

.mapZoomBtns {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: flex;
  gap: 4px;
  z-index: 20;
}

.mapZoomBtns button {
  border: 0;
  border-radius: 8px;
  padding: 4px 8px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  cursor: pointer;
}

#mapPanel.map-expanded {
  position: fixed;
  left: 50%;
  top: 50%;
  right: auto;
  width: min(760px, 82vw);
  height: min(680px, 82vh);
  transform: translate(-50%, -50%);
  z-index: 10050;
  overflow: visible;
}

#mapPanel.map-expanded #miniMap {
  height: calc(100% - 46px);
}

#mapPanel.map-expanded::before {
  content: "";
  position: fixed;
  inset: -100vh -100vw;
  background: rgba(0, 0, 0, 0.45);
  z-index: -1;
}

@media (max-width: 768px) {
  .info-panel {
    position: fixed;
    top: 56px;
    left: 10px;
    width: min(44vw, 190px);
    padding: 10px 12px;
  }

  .platform-title {
    font-size: 16px;
  }

  .current-scene {
    font-size: 13px;
  }

  .operation-tips {
    font-size: 10px;
    line-height: 1.35;
  }

  #mapPanel {
    width: min(42vw, 180px);
    right: 10px;
    top: 56px;
  }

  #miniMap {
    height: 130px;
  }

  #mapPanel.map-expanded {
    width: 95vw;
    height: 60vh;
    left: 50%;
    right: auto;
    top: 50%;
    transform: translate(-50%, -50%);
  }

  #toolbar {
    position: fixed;
    right: 10px;
    top: 52%;
    transform: translateY(-50%);
    z-index: 60;
    padding: 6px;
    gap: 6px;
  }

  .tool-btn {
    width: 42px;
    height: 42px;
  }

  .mode-container {
    position: fixed;
    left: 10px;
    bottom: 12px;
    width: min(52vw, 230px);
    padding: 4px;
    gap: 4px;
    z-index: 55;
  }

  .mode-btn {
    flex: 1;
    min-width: 0;
    padding: 7px 8px;
    font-size: 12px;
    justify-content: center;
  }

  #bottomScenePanel {
    position: fixed;
    left: 2.5vw;
    right: auto;
    bottom: 66px;
    width: 95vw;
    max-width: none;
    max-height: 34vh;
    padding: 10px;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .category-bar {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
  }

  .filter-btn {
    flex: 0 0 auto;
    padding: 7px 12px;
    font-size: 13px;
  }

  .route-toast {
    top: 72px;
    font-size: 13px;
    border-radius: 12px;
  }

  .neighbor-label {
    font-size: 12px;
    padding: 4px 8px;
  }

  .neighbor-arrow {
    width: 44px;
    height: 30px;
    font-size: 30px;
  }

  .route-next-hotspot .neighbor-label {
    font-size: 13px;
    padding: 5px 10px;
  }

  .route-next-hotspot .neighbor-arrow {
    font-size: 38px;
  }

  #groundRouteBar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
    overflow: visible;
  }

  #groundRouteBar input {
    width: 100%;
    min-width: 0;
    flex: 1 1 100%;
  }

  #groundRouteBar button {
    flex: 1 1 calc(50% - 4px);
    min-width: 96px;
  }

  #sceneButtons {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    width: 100%;
    padding: 4px 0 6px;
    -webkit-overflow-scrolling: touch;
  }

  .scene-card {
    flex: 0 0 auto;
    min-width: 120px;
  }

  .thumb-box {
    width: 120px;
    height: 76px;
  }

  .top-marquee-bar {
    display: flex !important;
    position: fixed !important;
    top: 12px !important;
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
    width: 92vw !important;
    max-width: none !important;
    height: 32px !important;
    padding: 0 12px !important;
    font-size: 12px !important;
    border-radius: 999px !important;
    z-index: 80 !important;
    overflow: hidden !important;
  }

  .marquee-wrapper {
    width: 100%;
    overflow: hidden;
  }

  .marquee-content {
    white-space: nowrap;
    font-size: 12px !important;
    line-height: 32px !important;
    animation-duration: 22s;
  }

  .intro-modal {
    padding: 5vw;
  }

  .intro-modal-panel {
    width: 90vw;
    max-height: 82vh;
  }

  .intro-modal-header {
    padding: 13px 14px;
  }

  .intro-modal-header h2 {
    font-size: 17px;
  }

  .intro-modal-body {
    padding: 14px;
    font-size: 13px;
  }
}
