/* Design System v1.1 — components.
   Inverse Tag / Confidence Tag / Tabs / Drawer / 状态四件套 / KPI 条 / Toast。
   组件即语言：出处标记、空/错/载状态一律用这里的类，禁止各页手写。

   ⚠ 可信度规则（不可违例）：
   - .inv-tag（黑底白字）只用于「结构性强调」：SECTION 索引、地图场景级水印。
   - 行内的 SYNTHETIC / UNVALIDATED 一律 .conf-tag（琥珀字 + 10% 浅底）。
   - 反白标签绝对不能用于标识 SYNTHETIC / UNVALIDATED。 */

/* ── Inverse Tag（结构强调）────────────────────────────────── */
.inv-tag {
  display: inline-block;
  background: var(--bg-inverse);
  color: var(--text-inverse);
  font-size: var(--fs-xs);
  line-height: var(--lh-xs);
  letter-spacing: var(--track-aux);
  text-transform: uppercase;
  font-weight: 600;
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--radius-tag);
}

/* ── Confidence Tag（出处 / 可信度，组件化）───────────────── */
.conf-tag {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 2px var(--sp-2);
  border-radius: var(--radius-tag);
  font-size: var(--fs-xs);
  line-height: var(--lh-xs);
  letter-spacing: var(--track-aux);
  text-transform: uppercase;
  font-weight: 600;
  white-space: nowrap;
}
.conf-tag--real { color: var(--success); background: transparent; }
.conf-tag--synthetic,
.conf-tag--unvalidated { color: var(--warning); background: var(--warning-bg); }
.conf-tag--stale { color: var(--text-tertiary); background: var(--line-subtle); }
/* 合成 fixture 名降级为琥珀小字次行（真实街名永远主位） */
.syn-sub {
  color: var(--warning);
  font-size: var(--fs-xs);
  line-height: var(--lh-xs);
  font-weight: var(--fw-aux);
}

/* ── Tabs（纯文字，选中 = 1px 近黑下划线）──────────────────── */
.tabs {
  display: flex;
  gap: var(--sp-5);
  border-bottom: 1px solid var(--line-subtle);
  margin: var(--sp-5) 0 0;
}
.tab {
  appearance: none;
  background: none;
  border: 0;
  border-bottom: 1px solid transparent;
  margin-bottom: -1px;
  padding: var(--sp-2) 0 var(--sp-3);
  font-family: inherit;
  font-size: var(--fs-sm);
  color: var(--text-tertiary);
  cursor: pointer;
  border-radius: 0;
  transition: color var(--dur) var(--ease),
              border-color var(--dur) var(--ease);
}
.tab:hover { color: var(--text-primary); opacity: 1; background: none; }
.tab.is-active {
  color: var(--text-primary);
  font-weight: 600;
  border-bottom-color: var(--line-strong);
}

/* ── Drawer（右侧抽屉 — 取代居中 Modal）────────────────────── */
.drawer-scrim {
  position: fixed;
  inset: 0;
  background: rgba(26, 26, 26, 0.1);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease);
}
.drawer-scrim.is-open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(440px, 92vw);
  background: var(--bg-surface);
  border-left: 1px solid var(--line-subtle);
  box-shadow: var(--shadow-float);
  z-index: 101;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform var(--dur) var(--ease);
}
.drawer.is-open { transform: translateX(0); }
.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-5) var(--sp-3);
  border-bottom: 1px solid var(--line-subtle);
  position: sticky;
  top: 0;
  background: var(--bg-surface);
}
.drawer-title { font-size: var(--fs-lg); line-height: var(--lh-lg); font-weight: var(--fw-title); }
.drawer-close {
  appearance: none;
  background: none;
  border: 0;
  color: var(--text-tertiary);
  font-size: var(--fs-lg);
  line-height: 1;
  padding: 0;
  margin: 0;
  cursor: pointer;
}
.drawer-close:hover { color: var(--text-primary); opacity: 1; background: none; }
.drawer-body { padding: var(--sp-5); }
.drawer-body .kv {
  display: grid;
  grid-template-columns: minmax(96px, 34%) 1fr;
  gap: var(--sp-2) var(--sp-4);
  margin: 0 0 var(--sp-5);
  font-size: var(--fs-sm);
}
.drawer-body .kv dt {
  color: var(--text-tertiary);
  font-size: var(--fs-xs);
  letter-spacing: var(--track-aux);
  text-transform: uppercase;
}
.drawer-body .kv dd {
  margin: 0;
  color: var(--text-primary);
  overflow-wrap: anywhere;
}

/* ── 状态四件套（loading / empty / error / forbidden）─────────
   最容易被忽略、最暴露 demo 感的三个态 — 全站统一走这里。 */
.state-box {
  border: 1px dashed var(--line-subtle);
  border-radius: var(--radius-card);
  padding: var(--sp-7) var(--sp-5);
  text-align: center;
  color: var(--text-tertiary);
  font-size: var(--fs-sm);
}
.state-box .state-title {
  font-size: var(--fs-xs);
  letter-spacing: var(--track-aux);
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: var(--sp-2);
}
.state-box .state-action { margin-top: var(--sp-4); }
.state-box .state-action.btn, .state-box .state-action button { margin-top: 0; }
.state-error { color: var(--error); }
.state-error .state-title { color: var(--error); }
.state-loading { color: var(--text-tertiary); }
.skeleton {
  height: var(--sp-7);
  background: var(--bg-surface);
  border: 1px solid var(--line-subtle);
  border-radius: var(--radius-tag);
  margin: 0 0 -1px;
}

/* 消息页（error / forbidden / not_found）：巨号状态码 + 标题 + 说明 */
.msg-card {
  text-align: center;
  margin-top: var(--sp-7);
  margin-bottom: var(--sp-7);
}
.msg-code {
  font-size: var(--fs-display);
  line-height: var(--lh-display);
  font-weight: 900;
  letter-spacing: var(--track-title);
  color: var(--text-tertiary);
  margin-bottom: var(--sp-2);
}
.msg-card h1 { margin-bottom: var(--sp-2); }
.msg-card p { margin: 0 0 var(--sp-3); }
.msg-card .actions { justify-content: center; }

/* ── KPI 条（图下 1px 近黑线 + 横排数据，取代浮动卡片）────── */
.kpi-strip {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-6);
  padding: var(--sp-3) 0 0;
  border-top: 1px solid var(--line-strong);
  margin-top: var(--sp-3);
}
.kpi-item { min-width: 96px; }
.kpi-label {
  display: block;
  font-size: var(--fs-xs);
  line-height: var(--lh-xs);
  letter-spacing: var(--track-aux);
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.kpi-val {
  font-size: var(--fs-lg);
  line-height: var(--lh-lg);
  font-weight: var(--fw-title);
  font-variant-numeric: tabular-nums;
}
.kpi-val small {
  font-size: var(--fs-xs);
  font-weight: var(--fw-aux);
  color: var(--text-tertiary);
  letter-spacing: var(--track-aux);
}

/* ── Toast（浮层，唯一允许的阴影之一）──────────────────────── */
#toast-container {
  position: fixed;
  top: var(--sp-4);
  right: var(--sp-4);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  pointer-events: none;
}
.toast {
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-card);
  border: 1px solid var(--line-subtle);
  background: var(--bg-surface);
  box-shadow: var(--shadow-float);
  font-size: var(--fs-sm);
  opacity: 0;
  transform: translateX(var(--sp-5));
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
  pointer-events: auto;
  max-width: 360px;
}
.toast-show { opacity: 1; transform: translateX(0); }
.toast-success { color: var(--success); background: var(--success-bg); }
.toast-error { color: var(--error); background: var(--error-bg); }
.toast-info { color: var(--text-primary); }

/* ── card / 标签芯片（旧组件换新皮，类名不变）──────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--line-subtle);
  border-radius: var(--radius-card);
  padding: var(--sp-5);
  margin: var(--sp-3) 0;
}
/* .narrow 在 base.css 定义自动边距；.card 的 margin 简写会覆盖它（同权重后到胜），在此恢复 */
.card.narrow { margin-left: auto; margin-right: auto; }
.card h1 { margin-bottom: var(--sp-2); }
.card h3 { margin: var(--sp-1) 0 var(--sp-2); }
.card p { margin: var(--sp-1) 0; color: var(--text-secondary); font-size: var(--fs-sm); }
.card-actions { margin-top: var(--sp-2); }
.card-locked { opacity: 0.85; }

.badge, .tag {
  display: inline-block;
  padding: 2px var(--sp-2);
  border-radius: var(--radius-tag);
  border: 1px solid var(--line-subtle);
  background: var(--bg-page);
  color: var(--text-secondary);
  font-size: var(--fs-xs);
  line-height: var(--lh-xs);
  letter-spacing: var(--track-aux);
  text-transform: uppercase;
  margin-right: var(--sp-1);
}
.tag-row { margin-top: var(--sp-2); display: flex; flex-wrap: wrap; gap: var(--sp-1); }
.tag-row .tag { margin-right: 0; }
/* 语义变体 = 同一套语义色文字 + 10% 浅底 */
.tag-active { color: var(--success); background: var(--success-bg); border-color: transparent; }
.badge-used { color: var(--text-tertiary); background: var(--line-subtle); border-color: transparent; }
.badge-expired { color: var(--error); background: var(--error-bg); border-color: transparent; }

.warn {
  font-size: var(--fs-sm);
  color: var(--warning);
  background: var(--warning-bg);
  padding: var(--sp-3);
  border-radius: var(--radius-card);
  margin: var(--sp-4) 0;
}
.err {
  font-size: var(--fs-sm);
  color: var(--error);
  background: var(--error-bg);
  padding: var(--sp-3);
  border-radius: var(--radius-card);
  margin: var(--sp-3) 0;
}

/* ── js-slot 加载遮罩（浅色版）──────────────────────────────── */
.js-slot[data-auto="1"] { position: relative; }
.js-slot.is-loading::after {
  content: "Loading…";
  position: absolute;
  inset: 0;
  background: rgba(242, 242, 239, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: inherit;
  color: var(--text-tertiary);
  font-size: var(--fs-xs);
  letter-spacing: var(--track-aux);
  text-transform: uppercase;
}

/* ── 页头（大标题 + 极小次级操作）──────────────────────────── */
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--sp-5);
  flex-wrap: wrap;
  margin: var(--sp-3) 0 0;
}
.page-head-side {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.page-head-side label { margin: 0; }
.select-sm { width: auto; min-width: 160px; }

/* ── 地图场景（水印 / 图例 / 署名）──────────────────────────
   .map-watermark 的 .inv-tag = 场景级出处水印（全视图通栏），
   是反白标签仅有的两处用途之一（另一处 = SECTION 索引）。 */
.map-watermark {
  position: absolute;
  top: var(--sp-3);
  right: var(--sp-3);
  z-index: 2;
}
.map-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
}
.map-svg-wrap {           /* SVG 无 WebGL 回退层（route_map.js renderSvg） */
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: auto;
}
.svg-fill {
  width: 100%;
  height: auto;
  display: block;
}
/* MapLibre 容器层（route_map.js / route_wizard.js / heat_map.js）。
   用 div+class 提高权重：maplibre-gl.css 最后加载，其
   .maplibregl-map{position:relative} 同权重后到会赢 —— 容器塌成 0 高。 */
div.map-canvas-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
}
.map-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2) var(--sp-3);
  margin-top: var(--sp-2);
  font-size: var(--fs-xs);
  letter-spacing: var(--track-aux);
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.legend-chip {
  display: inline-block;
  width: 20px;
  height: 6px;
  border-radius: var(--radius-tag);
  vertical-align: middle;
}
.chip-p1 { background: var(--band-p1); }
.chip-p2 { background: var(--band-p2); }
.chip-p3 { background: var(--band-p3); }
.chip-none { background: var(--band-none); opacity: 0.55; }

/* ── tab 面板 ───────────────────────────────────────────────── */
.tab-panel[hidden] { display: none; }
.tab-panel { padding-top: var(--sp-4); }

/* ── 侧栏移动端折叠 ─────────────────────────────────────────── */
.sidebar-toggle {
  display: none;
  background: none;
  border: 1px solid var(--line-subtle);
  color: var(--text-primary);
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--radius-tag);
  font-size: var(--fs-xs);
  cursor: pointer;
  margin-top: 0;
}
@media (max-width: 800px) {
  .sidebar-toggle { display: inline-block; }
  .sidebar { display: none; }
  .sidebar.sidebar-open { display: block; }
}

/* ── 磨砂隐藏侧栏导航（⋮ 三点提示常驻左缘，指针靠近呼出）────────
   顶部导航栏已移除后的全站唯一导航入口。透明磨砂（0.5 α + blur 24），
   呼出态滑过左上角品牌（品牌在玻璃下虚化成影，刻意为之）。
   零圆角零阴影禁令同首页。 */
.nav-strip {
  position: fixed; left: 0; top: 0; bottom: 0; width: 56px; z-index: 40;
}
.nav-dots {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  font-size: 16px; line-height: 1; color: var(--text-tertiary);
  pointer-events: none; user-select: none;
}
.nav-panel {
  position: fixed; left: 0; top: 0; bottom: 0; width: 300px; z-index: 50;
  padding: 140px 40px 40px;
  display: flex; flex-direction: column;
  background: rgba(242, 242, 239, 0.5);
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
  border-right: 1px solid var(--line-subtle);
  transform: translateX(-102%);
  transition: transform 220ms ease-out;
}
.nav-panel.is-open { transform: translateX(0); }
.nav-list {
  display: flex; flex-direction: column; align-items: flex-start; gap: 18px;
}
.nav-link {
  font-size: 12px; font-weight: 500; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--text-tertiary); text-decoration: none;
  padding-bottom: 3px; border-bottom: 1px solid transparent;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.nav-link:hover,
.nav-link:focus-visible {
  color: var(--text-primary); border-bottom-color: var(--text-primary); outline: none;
}
.nav-link.is-active {
  color: var(--text-primary); border-bottom-color: var(--text-primary);
}
.nav-foot {
  margin-top: auto;
  display: flex; flex-direction: column; align-items: flex-start; gap: 10px;
}
.nav-meta {
  font-size: var(--fs-xs); line-height: var(--lh-xs); color: var(--text-tertiary);
}
.nav-meta strong { font-weight: 600; color: var(--text-secondary); }
.nav-meta-link {
  font-size: var(--fs-xs); letter-spacing: var(--track-aux);
  color: var(--text-tertiary); text-decoration: none;
}
.nav-meta-link:hover,
.nav-meta-link:focus-visible { color: var(--text-primary); outline: none; }
/* 登出是 CSRF 表单，但观感必须是纯文字控件（禁按钮背景色） */
.nav-foot form.logout { margin: 0; }
.nav-foot form.logout button {
  background: none; border: 0; padding: 0; cursor: pointer;
  font-family: inherit; font-size: 12px; font-weight: 500;
  letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-tertiary);
  transition: color var(--dur) var(--ease);
}
.nav-foot form.logout button:hover,
.nav-foot form.logout button:focus-visible {
  color: var(--text-primary); outline: none; opacity: 1; background: none;
}

/* ── 地图底图错误态（错误文字 + 重试动作，Design System v1.1）────────
   底图是装饰层，缺失时数据图层照常渲染；此条只负责诚实告知 + 重试。 */
.map-basemap-note {
  position: absolute; left: 8px; bottom: 8px; z-index: 5;
  display: flex; gap: var(--sp-3); align-items: baseline;
  background: var(--bg-page);
  border: 1px solid var(--line-subtle);
  padding: 6px 10px;
  font-size: var(--fs-xs); letter-spacing: var(--track-aux);
  text-transform: uppercase; color: var(--error);
}
.map-basemap-note button {
  background: none; border: 0; padding: 0; cursor: pointer;
  font: inherit; letter-spacing: inherit; text-transform: inherit;
  color: var(--error); text-decoration: underline;
}
.map-basemap-note button:hover { opacity: 0.75; }
.map-basemap-note button:focus-visible {
  outline: 1px solid var(--error); outline-offset: 2px;
}
