/* ============================================================
   寰宇 · TERRA — 深空观测站风格
   ============================================================ */

:root {
  --bg: #04060d;
  --ink: #e9eef7;
  --ink-dim: #8fa0b8;
  --ink-faint: #55647c;
  --accent: #6fd8ff;
  --accent-soft: rgba(111, 216, 255, 0.16);
  --gold: #ffc76b;
  --gold-soft: rgba(255, 199, 107, 0.18);
  --line: rgba(148, 190, 255, 0.12);
  --panel: rgba(9, 14, 24, 0.55);
  --serif: "Songti SC", "Noto Serif SC", "STSong", "SimSun", serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: "SF Mono", "JetBrains Mono", "Cascadia Code", "Menlo", monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.mono { font-family: var(--mono); }

#app, #app canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

#app canvas { cursor: grab; }
#app canvas.dragging { cursor: grabbing; }
#app canvas.hovering { cursor: pointer; }

/* ---------- HUD 通用 ---------- */

.hud {
  position: fixed;
  z-index: 10;
  opacity: 0;
  transform: translateY(12px);
  transition:
    opacity 0.9s var(--ease),
    transform 0.9s var(--ease);
}

body.ready .hud:not(.info-card) {
  opacity: 1;
  transform: translateY(0);
}/* ---------- 标题 ---------- */

.hud-title {
  top: 34px;
  left: 38px;
  transition-delay: 0.15s;
  user-select: none;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.seal {
  width: 10px;
  height: 10px;
  background: var(--gold);
  box-shadow: 0 0 12px rgba(255, 199, 107, 0.8);
  transform: rotate(45deg);
}

.hud-title h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 34px;
  letter-spacing: 0.42em;
  margin-right: -0.42em; /* 抵消末字间距 */
  color: var(--ink);
  text-shadow: 0 0 30px rgba(111, 216, 255, 0.25);
}

.subtitle {
  margin-top: 10px;
  font-size: 10px;
  letter-spacing: 0.34em;
  color: var(--ink-faint);
}

/* ---------- 自动旋转状态 ---------- */

.chip {
  top: 38px;
  right: 38px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 14px;
  font-size: 10.5px;
  letter-spacing: 0.14em;
  color: var(--ink-dim);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  transition-delay: 0.3s;
}

.chip .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  animation: breathe 2.4s ease-in-out infinite;
}

.chip.paused .dot {
  background: var(--ink-faint);
  box-shadow: none;
  animation: none;
}

.chip.locked .dot {
  background: var(--gold);
  box-shadow: 0 0 10px var(--gold);
  animation: none;
}

@keyframes breathe {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ---------- 地点列表面板 ---------- */

.panel {
  top: 0;
  bottom: 0;
  right: 38px;
  margin-block: auto;
  height: fit-content;
  width: 248px;
  max-height: min(560px, calc(100vh - 180px));
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  backdrop-filter: blur(18px) saturate(1.35);
  -webkit-backdrop-filter: blur(18px) saturate(1.35);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
  transition-delay: 0.25s;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.22em;
}

.panel-count {
  font-size: 9px;
  letter-spacing: 0.16em;
  color: var(--ink-faint);
}

.panel-count b { color: var(--accent); font-weight: 500; }

#place-list {
  list-style: none;
  overflow-y: auto;
  padding: 6px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 190, 255, 0.18) transparent;
}

#place-list::-webkit-scrollbar { width: 4px; }
#place-list::-webkit-scrollbar-thumb {
  background: rgba(148, 190, 255, 0.18);
  border-radius: 2px;
}

#place-list button {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  padding: 9px 20px;
  background: none;
  border: none;
  border-left: 2px solid transparent;
  color: var(--ink-dim);
  text-align: left;
  cursor: pointer;
  font-family: var(--sans);
  transition: background 0.25s, color 0.25s, border-color 0.25s, transform 0.25s var(--ease);
}

#place-list button:hover {
  background: rgba(111, 216, 255, 0.06);
  color: var(--ink);
  transform: translateX(3px);
}

#place-list button.active {
  background: var(--gold-soft);
  border-left-color: var(--gold);
  color: var(--gold);
  transform: none;
}

#place-list .idx {
  font-size: 10px;
  color: var(--ink-faint);
  transition: color 0.25s;
}

#place-list button:hover .idx { color: var(--accent); }
#place-list button.active .idx { color: var(--gold); }

#place-list .name {
  font-size: 14px;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

#place-list .en {
  font-size: 8.5px;
  letter-spacing: 0.12em;
  color: var(--ink-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 86px;
}

.panel-foot {
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  font-size: 8.5px;
  letter-spacing: 0.2em;
  color: var(--ink-faint);
  text-align: center;
}

/* ---------- 信息卡 ---------- */

.info-card {
  left: 38px;
  bottom: 38px;
  width: 316px;
  padding: 22px 24px 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  backdrop-filter: blur(18px) saturate(1.35);
  -webkit-backdrop-filter: blur(18px) saturate(1.35);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
  /* 选中态由 .show 控制，未选中时整体下沉隐藏 */
  opacity: 0;
  transform: translateY(18px) scale(0.98);
  pointer-events: none;
  transition:
    opacity 0.55s var(--ease),
    transform 0.55s var(--ease);
}

.info-card.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.info-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 28px;
  height: 28px;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--ink-faint);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}

.info-close:hover { color: var(--ink); background: rgba(255, 255, 255, 0.06); }

.info-index {
  font-size: 9.5px;
  letter-spacing: 0.28em;
  color: var(--accent);
}

.info-index i { font-style: normal; margin: 0 6px; color: var(--ink-faint); }

.info-card h3 {
  margin-top: 8px;
  font-family: var(--serif);
  font-size: 27px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--ink);
}

.info-en {
  margin-top: 5px;
  font-size: 9px;
  letter-spacing: 0.22em;
  color: var(--ink-faint);
}

.info-lm {
  margin-top: 9px;
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--gold);
  opacity: 0.9;
}

.info-desc {
  margin-top: 13px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  line-height: 1.85;
  color: var(--ink-dim);
}

.info-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 15px;
  font-size: 9.5px;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
}

.info-meta .meta-sep {
  flex: 1;
  height: 1px;
  background: var(--line);
}

#info-time { color: var(--gold); }

/* ---------- 街区视角 ---------- */

.street-hint {
  margin-top: 12px;
  font-size: 9px;
  letter-spacing: 0.18em;
  color: var(--gold);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.45s var(--ease), transform 0.45s var(--ease);
}

body.street .street-hint {
  opacity: 0.9;
  transform: translateY(0);
}

.map-attrib {
  position: fixed;
  right: 14px;
  bottom: 10px;
  z-index: 7;
  font-size: 8.5px;
  letter-spacing: 0.08em;
  color: rgba(233, 238, 247, 0.34);
  opacity: 0;
  transition: opacity 0.5s ease;
  pointer-events: none;
  user-select: none;
}

body.street .map-attrib { opacity: 1; }

body.street .marker-label.selected::before {
  width: 9px;
  height: 9px;
  animation: street-pulse 1.6s ease-out infinite;
}

@keyframes street-pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 199, 107, 0.55); }
  100% { box-shadow: 0 0 0 14px rgba(255, 199, 107, 0); }
}

/* ---------- 底部提示 ---------- */

.hints {
  bottom: 30px;
  left: 0;
  right: 0;
  margin-inline: auto;
  width: fit-content;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 10px;
  letter-spacing: 0.24em;
  color: var(--ink-faint);
  transition-delay: 0.4s;
  user-select: none;
  white-space: nowrap;
}

.hints i {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--ink-faint);
  opacity: 0.6;
}

/* ---------- 标记标签 ---------- */

#labels {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  overflow: hidden;
}

.marker-label {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 8px;
  opacity: 0; /* 由 JS 逐帧控制 */
  background: rgba(6, 10, 18, 0.55);
  border: 1px solid rgba(111, 216, 255, 0.22);
  border-radius: 999px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  color: rgba(222, 234, 248, 0.82);
  white-space: nowrap;
  cursor: pointer;
  pointer-events: auto;
  will-change: transform, opacity;
}

.marker-label::before {
  content: "";
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
}

.marker-label:hover { border-color: rgba(111, 216, 255, 0.55); color: var(--ink); }

.marker-label.selected {
  border-color: rgba(255, 199, 107, 0.6);
  color: var(--gold);
}

.marker-label.selected::before {
  background: var(--gold);
  box-shadow: 0 0 6px var(--gold);
}

/* ---------- 加载屏 ---------- */

#loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 26px;
  background: radial-gradient(ellipse at 50% 60%, #0a1220 0%, var(--bg) 70%);
  transition: opacity 0.9s ease;
}

#loader.done { opacity: 0; pointer-events: none; }

.loader-orb {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  position: relative;
  background: radial-gradient(circle at 38% 34%, #2b6a9e 0%, #123252 45%, #060d1a 100%);
  box-shadow:
    0 0 34px rgba(111, 216, 255, 0.35),
    inset -10px -12px 26px rgba(0, 0, 0, 0.65);
  animation: orb-breathe 2.2s ease-in-out infinite;
}

.loader-orb i {
  position: absolute;
  inset: -9px;
  border-radius: 50%;
  border: 1px solid rgba(111, 216, 255, 0.3);
  border-top-color: rgba(111, 216, 255, 0.9);
  animation: orb-spin 1.3s linear infinite;
}

@keyframes orb-spin { to { transform: rotate(360deg); } }

@keyframes orb-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.045); }
}

#loader p {
  font-size: 10.5px;
  letter-spacing: 0.3em;
  color: var(--ink-faint);
}

#loader #load-pct { color: var(--accent); }

/* ---------- 氛围层 ---------- */

.vignette {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  background:
    radial-gradient(ellipse 120% 90% at 50% 45%, transparent 52%, rgba(2, 4, 10, 0.62) 100%);
}

.grain {
  position: fixed;
  inset: -100px;
  z-index: 6;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain-shift 0.7s steps(6) infinite;
}

@keyframes grain-shift {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-34px, 22px); }
  50% { transform: translate(18px, -40px); }
  75% { transform: translate(-22px, -14px); }
  100% { transform: translate(30px, 26px); }
}

/* ---------- 响应式 ---------- */

@media (max-width: 860px) {
  .hud-title { top: 22px; left: 22px; }
  .hud-title h1 { font-size: 25px; }
  .chip { top: 24px; right: 22px; padding: 7px 11px; font-size: 9px; }

  .panel {
    right: 14px;
    width: 200px;
    max-height: calc(100vh - 210px);
  }
  #place-list .en { display: none; }

  .info-card {
    left: 14px;
    right: 14px;
    bottom: 14px;
    width: auto;
    padding: 18px 18px 16px;
  }
  .info-card h3 { font-size: 22px; }

  .hints { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .grain { animation: none; }
  .chip .dot { animation: none; }
}
