/* ============================================================
 * 全球能源项目世界地图 —— 3D 地球版样式
 * 暗色「指挥球」风格：全屏星空 + 浮层面板
 * ============================================================ */
:root {
  --bg: #04070f;
  --panel: rgba(13, 22, 44, 0.78);
  --panel-solid: #0c152a;
  --border: rgba(120, 160, 220, 0.18);
  --border-strong: rgba(120, 160, 220, 0.4);
  --txt: #e8eefb;
  --txt-dim: #93a4c4;
  --txt-faint: #7b8ca6; /* 辅助文字：暗底对比度 ≥5:1（WCAG AA），勿调暗 */
  --accent: #21c7ff;
  --good: #2ee6a6;
  --warn: #ffb02e;
  --shadow: 0 14px 50px rgba(0, 0, 0, 0.55);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--txt);
  font-family: "PingFang SC", "Microsoft YaHei", "HarmonyOS Sans SC", "Segoe UI", system-ui, sans-serif; font-size: 14px; }

/* 背景星空（canvas 之后是放射状辉光）*/
#stars { position: fixed; inset: 0; z-index: 0; display: block;
  background:
    radial-gradient(1100px 760px at 76% -8%, rgba(33, 150, 255, 0.16), transparent 60%),
    radial-gradient(900px 700px at 6% 112%, rgba(46, 230, 166, 0.10), transparent 60%),
    var(--bg);
}
#globe { position: fixed; inset: 0; z-index: 1; cursor: grab; }
#globe:active { cursor: grabbing; }

/* ---------- 顶栏 ---------- */
.topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  display: flex; align-items: center; gap: 20px; padding: 12px 20px;
  background: linear-gradient(180deg, rgba(6, 11, 24, 0.92), rgba(6, 11, 24, 0.0));
  pointer-events: none; }
.topbar > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand .logo { width: 40px; height: 40px; flex: none; border-radius: 11px; display: grid; place-items: center; font-size: 21px;
  background: linear-gradient(135deg, rgba(33,199,255,0.28), rgba(46,230,166,0.20));
  border: 1px solid var(--border-strong); box-shadow: inset 0 0 20px rgba(33,199,255,0.22); }
.brand h1 { font-size: 17px; margin: 0; font-weight: 800; letter-spacing: .4px; white-space: nowrap; }
.brand .sub { font-size: 11px; color: var(--txt-dim); margin-top: 3px; white-space: nowrap; letter-spacing: .6px; }

.kpis { display: flex; gap: 22px; margin-left: auto; }
.kpi { text-align: right; }
.kpi .num { font-size: 20px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi .lab { font-size: 10.5px; color: var(--txt-dim); margin-top: 4px; white-space: nowrap; }
.kpi .num.accent { color: var(--accent); }
.kpi .num.good { color: var(--good); }
.kpi .num.warn { color: var(--warn); }

.top-actions { display: flex; gap: 8px; align-items: center; }
.tbtn { padding: 8px 12px; font-size: 12px; font-weight: 600; color: var(--txt-dim); text-decoration: none;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; cursor: pointer;
  backdrop-filter: blur(8px); box-shadow: var(--shadow); white-space: nowrap; transition: all .15s; }
.tbtn:hover { color: var(--txt); border-color: var(--border-strong); }

/* ---------- 左侧筛选面板 ---------- */
.left-panel { position: fixed; top: 74px; left: 16px; z-index: 25; width: 252px; max-height: calc(100vh - 96px);
  overflow-y: auto; padding: 14px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--border); backdrop-filter: blur(12px); box-shadow: var(--shadow);
  scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.left-panel::-webkit-scrollbar { width: 7px; }
.left-panel::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
.left-panel.collapsed { display: none; }
.block { margin-bottom: 15px; }
.block:last-child { margin-bottom: 4px; }
.block-title { font-size: 11px; font-weight: 700; letter-spacing: 1px; color: var(--txt-dim); text-transform: uppercase; margin-bottom: 9px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.cat-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px; font-size: 12px; color: var(--txt-dim);
  background: rgba(255,255,255,0.04); border: 1px solid var(--border); border-radius: 16px; cursor: pointer; user-select: none; transition: all .15s; }
.chip:hover { color: var(--txt); border-color: var(--border-strong); }
.chip.on { color: #fff; border-color: var(--accent); background: rgba(33,199,255,0.16); }
.cat-chip i { width: 9px; height: 9px; border-radius: 50%; flex: none; opacity: .45; transition: opacity .15s; }
.cat-chip.on i { opacity: 1; box-shadow: 0 0 7px currentColor; }

.year-presets { display: flex; gap: 6px; }
.yp { flex: 1; padding: 6px 4px; font-size: 11px; color: var(--txt-dim); background: rgba(255,255,255,0.04);
  border: 1px solid var(--border); border-radius: 9px; cursor: pointer; white-space: nowrap; transition: all .15s; }
.yp:hover { color: var(--txt); }
.yp.on { color: #fff; border-color: var(--accent); background: rgba(33,199,255,0.16); }

.toggle-row { display: flex; flex-direction: column; gap: 8px; }
.tgl { width: 100%; text-align: left; padding: 9px 12px; font-size: 12.5px; font-weight: 600; color: var(--txt-dim);
  background: rgba(255,255,255,0.04); border: 1px solid var(--border); border-radius: 10px; cursor: pointer; transition: all .15s; }
.tgl:hover { color: var(--txt); border-color: var(--border-strong); }
.tgl.on { color: #cdeeff; border-color: var(--accent); background: rgba(33,199,255,0.16); box-shadow: inset 0 0 14px rgba(33,199,255,0.12); }
.btn-reset2 { width: 100%; margin-top: 4px; padding: 9px; font-size: 12.5px; font-weight: 600; color: var(--txt-dim);
  background: transparent; border: 1px dashed var(--border-strong); border-radius: 10px; cursor: pointer; transition: all .15s; }
.btn-reset2:hover { color: var(--warn); border-color: var(--warn); }

/* ---------- 底部图例 + 提示 ---------- */
.legend { position: fixed; left: 16px; bottom: 16px; z-index: 20; max-width: min(62vw, 560px);
  padding: 10px 14px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--border);
  backdrop-filter: blur(10px); box-shadow: var(--shadow); pointer-events: none; user-select: none; }
.legend .lg-head { display: flex; gap: 14px; font-size: 11px; color: var(--txt-dim); margin-bottom: 8px; }
.legend .lg-head b { color: var(--txt); }
.legend .lg-head .bar-ico { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; margin-right: 5px; vertical-align: -1px; }
.legend .lg-head .bar-ico i { width: 3px; background: var(--good); border-radius: 1px; }
.legend .lg-cats { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.lg-item { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--txt-dim); }
.lg-item i { width: 9px; height: 9px; border-radius: 50%; box-shadow: 0 0 6px currentColor; }
.lg-item b { color: var(--txt); font-variant-numeric: tabular-nums; }

.hint { position: fixed; right: 16px; bottom: 16px; z-index: 20; display: flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: 20px; background: rgba(6,11,24,0.6); border: 1px solid var(--border);
  backdrop-filter: blur(6px); box-shadow: var(--shadow); font-size: 11px; color: var(--txt-dim);
  pointer-events: none; user-select: none; white-space: nowrap; }
.credit { position: fixed; right: 16px; bottom: 54px; z-index: 20; padding: 5px 12px; border-radius: 20px;
  background: rgba(6,11,24,0.5); border: 1px solid var(--border); backdrop-filter: blur(6px);
  font-size: 11px; letter-spacing: .5px; color: var(--txt-dim); pointer-events: none; white-space: nowrap; }
.credit .mc-by { color: var(--txt-faint); }

/* ---------- 详情卡 ---------- */
.detail { position: fixed; top: 74px; right: 16px; z-index: 26; width: 318px; max-width: calc(100vw - 32px);
  max-height: calc(100vh - 150px); overflow-y: auto; padding: 18px; border-radius: var(--radius);
  background: var(--panel-solid); border: 1px solid var(--border-strong); box-shadow: var(--shadow);
  opacity: 0; transform: translateY(-8px) scale(.98); pointer-events: none; transition: all .2s; }
.detail.on { opacity: 1; transform: none; pointer-events: auto; }
.d-close { position: absolute; top: 12px; right: 12px; padding: 4px 9px; font-size: 11px; color: var(--txt-dim);
  background: rgba(255,255,255,0.05); border: 1px solid var(--border); border-radius: 14px; cursor: pointer; }
.d-close:hover { color: var(--txt); border-color: var(--border-strong); }
.d-cat { font-size: 12px; font-weight: 700; letter-spacing: .5px; margin-bottom: 6px; }
.d-star { color: var(--warn); }
.d-new { color: var(--warn); }
.d-name { font-size: 17px; font-weight: 800; line-height: 1.3; margin-bottom: 3px; padding-right: 48px; }
.d-alt { font-size: 12px; color: var(--txt-faint); margin-bottom: 12px; }
.d-grid { display: grid; gap: 7px; margin-bottom: 12px; }
.d-row { display: flex; justify-content: space-between; gap: 12px; font-size: 12.5px; }
.d-row > span { color: var(--txt-dim); flex: none; }
.d-row > b { color: var(--txt); font-weight: 600; text-align: right; }
.d-inv { color: var(--good); font-weight: 800; }
.d-org { color: var(--txt-faint); font-weight: 400; font-size: 11px; }
.d-desc { font-size: 12.5px; line-height: 1.62; color: #cdd8ee; border-top: 1px solid var(--border); padding-top: 11px; }
.d-prog { margin-top: 11px; font-size: 12px; line-height: 1.6; color: var(--txt-dim); background: rgba(33,199,255,0.07);
  border-left: 2px solid var(--accent); padding: 8px 11px; border-radius: 0 8px 8px 0; }
.d-prog b { color: var(--accent); }

/* ---------- globe.gl 悬浮提示 ---------- */
.globe-tip { padding: 9px 12px; border-radius: 10px; background: rgba(6,11,24,0.94); border: 1px solid var(--border-strong);
  box-shadow: var(--shadow); max-width: 280px; font-family: inherit; }
.gt-cat { font-size: 11px; font-weight: 700; letter-spacing: .5px; }
.gt-name { font-size: 13.5px; font-weight: 700; color: var(--txt); margin: 2px 0; line-height: 1.3; }
.gt-meta { font-size: 11px; color: var(--txt-dim); }
.gt-inv { font-size: 12px; color: var(--good); font-weight: 700; margin-top: 3px; }
.gt-inv span { color: var(--txt-faint); font-weight: 400; }

/* ---------- 加载态 ---------- */
.globe-loader { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; gap: 16px;
  background: radial-gradient(circle at 50% 45%, #0a1530, #04070f 70%); transition: opacity .6s; }
.globe-loader.hide { opacity: 0; pointer-events: none; }
.gl-logo { font-size: 46px; animation: gl-spin 3.4s linear infinite; }
.gl-ring { width: 46px; height: 46px; border-radius: 50%; border: 3px solid rgba(33,199,255,0.18); border-top-color: var(--accent); animation: gl-spin .9s linear infinite; }
.gl-text { text-align: center; font-size: 14px; font-weight: 700; letter-spacing: .5px; }
.gl-text span { display: block; font-size: 11px; font-weight: 400; color: var(--txt-dim); margin-top: 5px; }
@keyframes gl-spin { to { transform: rotate(360deg); } }

/* ---------- 移动端 ---------- */
.panel-toggle { display: none; }
@media (max-width: 820px) {
  /* 顶栏：隐藏品牌文字只留 logo，KPI 紧跟其后，操作按钮靠右，避免标题与 KPI 数字重叠 */
  .topbar { gap: 8px; padding: 9px 10px; align-items: center; }
  .brand { gap: 8px; }
  .brand > div:not(.logo) { display: none; }
  .brand .logo { width: 34px; height: 34px; font-size: 18px; }
  .kpis { gap: 13px; margin-left: 4px; }
  .kpi .num { font-size: 15px; }
  .kpi .lab { font-size: 9px; }
  .top-actions { gap: 6px; margin-left: auto; }
  .tbtn { padding: 7px 9px; font-size: 12px; }
  /* 平面地图按钮在窄屏收成图标，省出横向空间 */
  #btn-flat { font-size: 0; }
  #btn-flat::before { content: "🗺️"; font-size: 15px; }
  /* 面板高度用 dvh（动态视口，自动扣掉手机浏览器上下工具栏），保证尾部控件在可视区内、可滚动到底 */
  .left-panel { top: 56px; left: 10px; width: 212px; padding: 11px;
    max-height: calc(100vh - 68px); max-height: calc(100dvh - 68px); -webkit-overflow-scrolling: touch; }
  .left-panel.collapsed { display: none; }
  .panel-toggle { display: inline-flex; }
  .detail { top: auto; bottom: 0; right: 0; left: 0; width: 100%; max-width: 100%; border-radius: 16px 16px 0 0;
    max-height: 64dvh; }
  .legend { max-width: calc(100vw - 20px); left: 10px; bottom: 10px; }
  .hint { display: none; }
  .credit { bottom: 10px; right: 10px; }
}
@media (max-width: 480px) {
  /* 极窄屏：KPI 仅留数字（彩色已足够区分），进一步防溢出 */
  .kpis { gap: 10px; }
  .kpi .lab { display: none; }
  .kpi .num { font-size: 14px; }
}

