/* ============================================================
   数字太湖 · 饮用水源地水华动态监测原型
   视觉世界：Google Earth Web 扁平浅色界面（用户指定，2026-11-17 重构）
   原则：满屏地图 + 浮于其上的白色卡片；中性灰阶 + Google 蓝单强调色；
   状态色只承载数据语义并始终配文字标签。
   ============================================================ */
:root {
  /* 中性灰阶 */
  --ink: #202124;          /* 标题 */
  --ink-2: #3c4043;        /* 正文 */
  --ink-3: #5f6368;        /* 次要文字（白底对比 5.9:1） */
  --line: #dadce0;         /* 发丝线 */
  --line-2: #e8eaed;
  --surface: #ffffff;
  --surface-hover: #f1f3f4;
  --surface-2: #f8f9fa;

  /* Google 蓝单强调色 */
  --accent: #1a73e8;
  --accent-deep: #1967d2;
  --accent-soft: #e8f0fe;

  /* 状态色（只用于数据语义，配文字） */
  --ok: #188038;      --ok-soft: #e6f4ea;    --ok-ink: #137333;
  --warn: #f9ab00;    --warn-soft: #fef7e0;  --warn-ink: #995000;
  --bad: #d93025;     --bad-soft: #fce8e6;   --bad-ink: #c5221f;
  --purple: #9334e6;  --purple-soft: #f3e8fd; --purple-ink: #7627bb;

  /* 深度（带偏移的柔和投影，GE 卡片制式） */
  --shadow-1: 0 1px 2px rgba(60, 64, 67, 0.30), 0 1px 3px 1px rgba(60, 64, 67, 0.15);
  --shadow-2: 0 1px 2px 0 rgba(60, 64, 67, 0.30), 0 2px 6px 2px rgba(60, 64, 67, 0.15);
  --shadow-3: 0 2px 4px rgba(60, 64, 67, 0.30), 0 4px 12px rgba(60, 64, 67, 0.20);

  --radius: 8px;
  --font: "Google Sans", "Product Sans", Roboto, "Helvetica Neue", Arial,
          "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  height: 100%;
  background: #fff;
  color: var(--ink-2);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}
button { font-family: inherit; font-size: inherit; }
button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- 左上：品牌卡 ---------- */
#topbar {
  position: absolute; top: 12px; left: 12px; z-index: 500;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  padding: 8px 14px 8px 10px;
  display: flex; align-items: center;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo .mark { display: inline-flex; color: var(--accent); }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-name { font-size: 15px; font-weight: 500; color: var(--ink); letter-spacing: 0.02em; }
.brand-sub { font-size: 10.5px; color: var(--ink-3); }

/* ---------- 右上：数据 chips ---------- */
#chips {
  position: absolute; top: 12px; right: 12px; z-index: 500;
  display: flex; gap: 8px; align-items: stretch;
}
.chip {
  min-width: 116px; padding: 6px 12px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  display: flex; flex-direction: column; justify-content: center;
}
.chip .k { font-size: 10.5px; color: var(--ink-3); }
.chip .v { font-size: 15px; font-weight: 500; color: var(--ink-2); line-height: 1.25; font-variant-numeric: tabular-nums; }
.chip .s { font-size: 10px; color: var(--ink-3); }
#chipClock .v { color: var(--accent-deep); }

/* ---------- 地图 ---------- */
#map { position: absolute; inset: 0; z-index: 1; background: var(--line-2); }
.leaflet-container { background: var(--line-2); font-family: var(--font); }
.leaflet-bar {
  border: none; border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow-2);
}
.leaflet-bar a {
  width: 36px; height: 36px; line-height: 36px;
  background: #fff; color: var(--ink-2); font-size: 17px;
  border-bottom: none;
}
.leaflet-bar a:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.leaflet-bar a:last-child { border-radius: 0 0 var(--radius) var(--radius); }
.leaflet-bar a:hover, .leaflet-bar a:focus { background: var(--surface-hover); color: var(--ink); }
.leaflet-bar a:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
/* 详情面板展开时，给右下缩放控件与归属文字让位（D1 修复） */
body.detail-open .leaflet-bottom.leaflet-right { margin-right: 420px; }
body.detail-open #attribution { right: 420px; }
.leaflet-tooltip {
  background: #fff; color: var(--ink);
  border: none; box-shadow: var(--shadow-2);
  border-radius: 6px; padding: 6px 10px;
  font-size: 12px; line-height: 1.6;
}
.leaflet-tooltip-top:before { display: none; }
.leaflet-tooltip b { color: var(--ink); }

/* ---------- 左侧：模式切换卡 ---------- */
#modeRail {
  position: absolute; left: 12px; top: 82px; z-index: 400;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  overflow: hidden;
  display: flex; flex-direction: column;
  width: 188px;
}
#modeRail button {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; cursor: pointer;
  background: transparent; color: var(--ink-3);
  border: none; border-bottom: 1px solid var(--line-2);
  font-size: 13px; letter-spacing: 0.01em; text-align: left;
  transition: background-color 0.15s ease;
}
#modeRail button:last-child { border-bottom: none; }
#modeRail button svg { color: var(--ink-3); flex: none; transition: color 0.15s ease; }
#modeRail button:hover { background: var(--surface-hover); }
#modeRail button.active {
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-weight: 500;
}
#modeRail button.active svg { color: var(--accent); }

/* ---------- 顶部居中：图层时间横幅（诚实性核心） ---------- */
#layerBanner {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 390;
  max-width: 640px; padding: 10px 16px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
}
.b-title { font-size: 14px; font-weight: 500; color: var(--ink); letter-spacing: 0.01em; }
.b-lines { margin-top: 4px; display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
#bannerBadges { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
  font-size: 10.5px; padding: 2px 8px; border-radius: 999px; letter-spacing: 0.02em;
  background: var(--accent-soft); color: var(--accent-deep);
}
.badge.warn { background: var(--warn-soft); color: var(--warn-ink); }
.badge.replay { background: var(--purple-soft); color: var(--purple-ink); }

/* ---------- 左下：图例卡 ---------- */
#legend {
  position: absolute; left: 12px; bottom: 16px; z-index: 390;
  padding: 10px 12px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  font-size: 12px; color: var(--ink-3);
  max-width: 218px;
}
.legend-row { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.legend-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.legend-dot.dashed { background: transparent !important; border: 1.5px dashed currentColor; }
.base-switch {
  margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line-2);
  display: flex; align-items: center; gap: 6px;
}
.base-switch .bs-k { margin-right: 2px; }
.base-switch button {
  min-height: 36px; padding: 0 14px; cursor: pointer; font-size: 11.5px;
  display: inline-flex; align-items: center;
  background: var(--surface); color: var(--ink-3);
  border: 1px solid var(--line); border-radius: 999px;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.base-switch button:hover { background: var(--surface-hover); }
.base-switch button.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-deep); }

/* ---------- 底部居中：回放条 ---------- */
#replayBar {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 430;
  min-width: min(432px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  padding: 12px 16px 10px;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow-3);
}
#replayBar.hidden { display: none; }
.rp-top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.rp-badge {
  font-size: 11px; font-weight: 500; padding: 2px 10px; border-radius: 999px; letter-spacing: 0.04em;
  background: var(--purple-soft); color: var(--purple-ink);
}
.rp-title { font-size: 13px; color: var(--ink-2); letter-spacing: 0.01em; }
.controls { display: flex; align-items: center; gap: 8px; }
.controls button {
  width: 36px; height: 36px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface); color: var(--ink-3);
  border: 1px solid var(--line); border-radius: 50%;
  transition: background-color 0.15s ease;
}
.controls button:hover { background: var(--surface-hover); color: var(--ink-2); }
.controls button svg { width: 16px; height: 16px; }
#rpPlay .ic-pause { display: none; }
#rpPlay.paused .ic-play { display: none; }
#rpPlay.paused .ic-pause { display: block; }
.dots { display: flex; gap: 6px; align-items: center; }
.dots .dot { width: 34px; height: 6px; border-radius: 3px; background: var(--line-2); cursor: pointer; }
.dots .dot.active { background: var(--purple); }
.prog { margin-top: 8px; height: 4px; border-radius: 2px; background: var(--line-2); overflow: hidden; }
#rpProgress { height: 100%; width: 0; background: var(--accent); }
.rp-note { margin-top: 6px; font-size: 11px; color: var(--ink-3); }

/* ---------- 右侧：点位详情卡（GE knowledge card 制式） ---------- */
#detailPanel {
  position: absolute; right: 12px; top: 16px; bottom: 16px; width: 396px; z-index: 450;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow-3);
  transition: transform 0.24s cubic-bezier(0.2, 0, 0, 1), visibility 0s;
  visibility: visible;
}
#detailPanel.hidden {
  transform: translateX(115%);
  visibility: hidden;           /* 移出 Tab 序与无障碍树 */
  transition: transform 0.24s cubic-bezier(0.2, 0, 0, 1), visibility 0s 0.24s;
}
.d-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line-2);
}
.d-title { font-size: 15px; font-weight: 500; color: var(--ink); letter-spacing: 0.01em; }
.d-sub { margin-top: 3px; font-size: 11px; color: var(--ink-3); }
#dClose {
  width: 36px; height: 36px; cursor: pointer; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; color: var(--ink-3);
  border: none; border-radius: 50%;
  transition: background-color 0.15s ease;
}
#dClose:hover { background: var(--surface-hover); color: var(--ink); }
.d-body { flex: 1; overflow-y: auto; padding: 2px 16px 16px; }
.d-body::-webkit-scrollbar { width: 6px; }
.d-body::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
.d-sec { padding: 14px 0; border-bottom: 1px solid var(--line-2); }
.d-sec:last-child { border-bottom: none; }
.d-sec h3 {
  font-size: 12px; font-weight: 500; color: var(--ink-3);
  letter-spacing: 0.04em; margin-bottom: 10px;
  display: flex; align-items: center; gap: 8px;
}
.tag { font-size: 10px; padding: 1px 8px; border-radius: 999px; letter-spacing: 0.02em; font-weight: 400; }
.tag.demo { background: var(--warn-soft); color: var(--warn-ink); }
.d-rank { font-size: 13px; color: var(--ink-2); margin-bottom: 12px; }
.d-rank b { color: var(--accent-deep); font-size: 15px; font-weight: 700; }
.bars { display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: flex; align-items: center; gap: 8px; font-size: 11px; }
.bar-row .y { width: 34px; color: var(--ink-3); flex: none; }
.bar-row .track { flex: 1; height: 10px; border-radius: 5px; background: var(--surface-hover); overflow: hidden; }
.bar-row .fill { height: 100%; border-radius: 5px; background: var(--accent); }
.bar-row .v { width: 34px; text-align: right; color: var(--ink-2); font-variant-numeric: tabular-nums; flex: none; }
.d-basis-label { margin-top: 14px; font-size: 11px; color: var(--ink-3); letter-spacing: 0.02em; }
.d-basis { margin-top: 4px; font-size: 11.5px; color: var(--ink-2); line-height: 1.7; }
.cov-row { display: flex; align-items: baseline; gap: 12px; }
.cov-k { font-size: 12.5px; color: var(--ink-3); }
.val { font-size: 26px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.val.warn { color: var(--bad-ink); font-size: 16px; }
.line { margin-top: 8px; font-size: 12px; color: var(--ink-2); line-height: 1.6; }
.ev { width: 100%; border-collapse: collapse; font-size: 12px; }
.ev tr:hover td { background: var(--surface-2); }
.ev td { padding: 6px 4px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.ev td:first-child { color: var(--ink-3); width: 96px; white-space: nowrap; }
.ev td:last-child { color: var(--ink-2); }

/* ---------- 右下：数据小面板（天气 / 水位） ---------- */
#sidePanels {
  position: absolute; right: 12px; bottom: 96px; z-index: 420;
  display: flex; flex-direction: column; gap: 10px; width: 300px;
}
#sidePanels.hidden { display: none; }
.sp-card {
  padding: 10px 12px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
}
.sp-head { display: flex; justify-content: space-between; font-size: 12.5px; font-weight: 500; color: var(--ink-2); letter-spacing: 0.01em; margin-bottom: 6px; }
.sp-src { font-size: 10.5px; color: var(--ink-3); font-weight: 400; }
.sp-rows { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--ink-2); }
.sp-rows b { color: var(--accent-deep); font-weight: 700; }
.sp-foot { margin-top: 6px; font-size: 10.5px; color: var(--ink-3); }
#wlChart { display: block; margin: 2px 0; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 6px; }

/* ---------- 归属与提示 ---------- */
#attribution {
  position: absolute; right: 60px; bottom: 6px; z-index: 300;
  font-size: 10.5px; color: var(--ink-3); text-shadow: 0 0 3px #fff;
  pointer-events: none;
}
#notice {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 600;
  max-width: min(900px, calc(100vw - 24px));
  padding: 8px 8px 8px 14px;
  display: flex; align-items: center; gap: 8px;
  background: var(--accent-soft); color: var(--accent-deep);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  font-size: 11.5px; line-height: 1.6;
}
#notice.hidden { display: none; }
#notice button {
  width: 36px; height: 36px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: none; color: inherit; cursor: pointer;
  opacity: 0.75; border-radius: 50%;
}
#notice button:hover { opacity: 1; background: rgba(0, 0, 0, 0.06); }
#notice.warn { background: var(--warn-soft); color: var(--warn-ink); }
#notice.bad { background: var(--bad-soft); color: var(--bad-ink); }
/* 回放条出现时把提示条抬离底部，避免遮挡（D10） */
#replayBar:not(.hidden) ~ #notice { bottom: 168px; }

/* ---------- 响应式 ---------- */
@media (max-width: 1000px) {
  .brand-sub { display: none; }
  #chips { flex-wrap: wrap; justify-content: flex-end; max-width: 52vw; }
  #layerBanner { left: 12px; right: 12px; transform: none; max-width: none; top: 70px; }
  #modeRail { top: 170px; width: 168px; }
}
@media (max-width: 700px) {
  #detailPanel { width: min(396px, 92vw); }
  #sidePanels { display: none; }
  #legend { display: none; }
  #modeRail { flex-direction: row; width: auto; top: 12px; left: 148px; }
  #modeRail button { border-bottom: none; border-right: 1px solid var(--line-2); padding: 8px 10px; }
  #modeRail button:last-child { border-right: none; }
  #modeRail button span { display: none; }   /* 可访问名称由 aria-label 提供 */
  #chips { display: none; }
  #layerBanner { top: 60px; }
}

/* ---------- 动效收敛 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
  #detailPanel { transition: none; }
}
