/* 全国宜家分布图 · 样式（复用 cn-rivers 暗色玻璃体系，适配门店点 + 开业阶段） */
:root {
  --panel-bg: rgba(13, 27, 42, 0.88);
  --bg-3: rgba(255, 255, 255, 0.07);
  --bg-2: rgba(255, 255, 255, 0.04);
  --border: rgba(255, 255, 255, 0.12);
  --text: #d7e3f0;
  --text-strong: #f4f8fc;
  --text-muted: #8fa3b8;
  --accent: #2f80ed;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  --motion-fast: 0.16s;
  --motion-base: 0.28s;
  --ease-out: cubic-bezier(0.22, 0.9, 0.3, 1);
  --pioneer: #ffd400;       /* 拓荒期 1998–2008 */
  --expansion: #4ea8de;     /* 扩张期 2009–2016 */
  --acceleration: #34d399;  /* 加速期 2017–2022 */
  --surge: #f87171;         /* 转型期 2023–2026 */
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  color: var(--text);
  background: #0b1220;
}
#map { position: absolute; inset: 0; background: #0b1220; }
.maplibregl-ctrl-group { background: var(--panel-bg) !important; border: 1px solid var(--border) !important; }
.maplibregl-ctrl-attrib { background: rgba(13, 27, 42, 0.7) !important; color: var(--text-muted) !important; font-size: 10px; }
.maplibregl-ctrl-attrib a { color: var(--text-muted) !important; }

/* ---------- 顶部标题 ---------- */
.topbar {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  z-index: 2; text-align: center; pointer-events: none;
}
.topbar h1 { font-size: 17px; font-weight: 600; color: var(--text-strong); text-shadow: 0 1px 6px rgba(0,0,0,0.8); }
.topbar .sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; text-shadow: 0 1px 4px rgba(0,0,0,0.8); }

/* ---------- 左侧目录 ---------- */
.side-panel {
  position: absolute; top: 12px; left: 12px; bottom: 12px; width: 304px;
  display: flex; flex-direction: column;
  background: var(--panel-bg); backdrop-filter: blur(14px);
  border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
  z-index: 6; transition: transform 0.25s ease;
}
.side-panel.collapsed { transform: translateX(calc(-100% - 16px)); }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 13px 14px 9px; }
.panel-head h2 { font-size: 15px; color: var(--text-strong); font-weight: 600; }
.panel-close { background: none; border: none; color: var(--text-muted); font-size: 20px; cursor: pointer; line-height: 1; padding: 2px 6px; }
.panel-close:hover { color: var(--text-strong); }

.panel-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 0 14px 12px; border-bottom: 1px solid var(--border); }
.panel-stats > div { display: flex; flex-direction: column; align-items: center; background: var(--bg-3); border-radius: 9px; padding: 7px 4px; }
.panel-stats b { font-size: 15px; font-weight: 600; color: var(--accent); font-variant-numeric: tabular-nums; }
.panel-stats span { font-size: 10px; color: var(--text-muted); margin-top: 2px; }

/* 目录内工具区：拓店阶段图例 + 省份筛选 */
.panel-tools { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.pt-group { display: flex; flex-direction: column; gap: 7px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 9px 10px; }
.pt-label { font-size: 10.5px; color: var(--text-muted); letter-spacing: 0.4px; }
.era-filter { display: flex; flex-direction: column; gap: 5px; }
.era-check { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text); cursor: pointer; user-select: none; transition: opacity var(--motion-fast) ease; }
.era-check.off { opacity: 0.4; }
.era-check input { accent-color: var(--accent); width: 13px; height: 13px; cursor: pointer; }
.era-check .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.era-check .era-count { margin-left: auto; font-variant-numeric: tabular-nums; font-size: 10px; color: var(--text-muted); }
.prov-select { width: 100%; background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 12.5px; padding: 6px 8px; font-family: inherit; outline: none; }
.prov-select:focus { border-color: var(--accent); }

/* 城市排名列表 */
.city-list { flex: 1; min-height: 0; overflow-y: auto; padding: 10px; scrollbar-width: thin; scrollbar-color: var(--bg-3) transparent; display: flex; flex-direction: column; gap: 7px; }
.city-item {
  position: relative; isolation: isolate; display: block; width: 100%; text-align: left;
  background: var(--bg-2); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: 10px; padding: 8px 11px; cursor: pointer; color: var(--text); font-family: inherit;
  transition: transform var(--motion-fast) var(--ease-out), border-color var(--motion-fast) var(--ease-out), background-color var(--motion-fast) var(--ease-out);
}
.city-item:hover, .city-item:focus-visible, .city-item.is-selected { background: var(--bg-3); border-color: var(--accent); transform: translateX(2px); }
.city-item.is-selected { outline: 1px solid color-mix(in srgb, var(--accent) 70%, transparent); outline-offset: -1px; }
.ci-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.ci-name { font-size: 14px; font-weight: 600; color: var(--text-strong); }
.ci-count { font-size: 13px; font-weight: 600; color: var(--accent); font-variant-numeric: tabular-nums; }
.ci-meta { margin-top: 2px; font-size: 11px; color: var(--text-muted); }
.list-empty { padding: 24px 12px; text-align: center; color: var(--text-muted); font-size: 13px; }
.list-count { padding: 9px 14px 0; border-top: 1px solid var(--border); font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.panel-foot { padding: 9px 14px 12px; }
.ctrl-nav { display: flex; gap: 8px; }
.ctrl-nav a { flex: 1 1 0; display: flex; align-items: center; justify-content: center; padding: 6px 8px; border-radius: 8px; text-decoration: none; font-size: 12.5px; font-weight: 600; color: var(--text); background: var(--bg-2); border: 1px solid var(--border); transition: color .15s, border-color .15s, background .15s; }
.ctrl-nav a:hover { color: var(--accent); border-color: var(--accent); background: rgba(47,128,237,0.18); }

.panel-open { position: absolute; top: 12px; left: 12px; z-index: 2; background: var(--panel-bg); backdrop-filter: blur(14px); border: 1px solid var(--border); border-radius: 9px; color: var(--text); font-size: 13px; padding: 8px 14px; cursor: pointer; display: none; }
.side-panel.collapsed + .panel-open { display: block; }

/* ---------- 右上角搜索 + 设置 ---------- */
.top-right { position: absolute; top: 12px; right: 12px; z-index: 7; display: flex; align-items: flex-start; gap: 8px; }
.top-search { position: relative; width: 250px; padding: 3px; background: rgba(2,6,23,0.45); border: 1.5px solid rgba(148,197,235,0.55); border-radius: 11px; backdrop-filter: blur(14px); }
.top-search input { width: 100%; background: var(--bg-2); border: none; border-radius: 8px; padding: 7px 10px; color: var(--text); font-size: 13px; outline: none; }
.top-search input:focus { background: rgba(47,128,237,0.12); }
.top-search input::placeholder { color: var(--text-muted); }
#searchResult { list-style: none; position: absolute; left: 0; right: 0; top: 100%; margin-top: 6px; padding: 4px; max-height: 300px; overflow: auto; background: var(--panel-bg); backdrop-filter: blur(14px); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); z-index: 8; display: none; }
#searchResult.has-hits { display: block; }
#searchResult li { padding: 7px 10px; border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--text); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
#searchResult li > span:first-child { color: #f8fafc; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#searchResult li:hover { background: rgba(47,128,237,0.16); }
#searchResult li .tag { font-size: 10px; padding: 1px 6px; border-radius: 999px; flex: none; }
#searchResult li .tag.pioneer { background: rgba(251,191,36,0.22); color: #fde68a; }
#searchResult li .tag.expansion { background: rgba(96,165,250,0.22); color: #bfdbfe; }
#searchResult li .tag.acceleration { background: rgba(52,211,153,0.22); color: #bbf7d0; }
#searchResult li .tag.surge { background: rgba(248,113,113,0.22); color: #fecaca; }
#searchResult .empty { color: var(--text-muted); cursor: default; }

.map-opts-btn { flex: none; width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--panel-bg); backdrop-filter: blur(14px); border: 1.5px solid rgba(148,197,235,0.55); box-shadow: var(--shadow); color: var(--accent); font-size: 17px; cursor: pointer; line-height: 1; transition: color var(--motion-fast) ease, border-color var(--motion-fast) ease, transform var(--motion-fast) var(--ease-out); }
.map-opts-btn:hover { color: var(--text-strong); border-color: var(--accent); }
.map-opts-btn[aria-expanded="true"] { transform: rotate(30deg); border-color: var(--accent); }
.map-opts { display: none; position: absolute; top: calc(100% + 8px); right: 0; width: 280px; flex-direction: column; gap: 10px; background: var(--panel-bg); backdrop-filter: blur(14px); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 12px; z-index: 8; }
.map-opts.open { display: flex; }
.mo-group { display: flex; flex-direction: column; gap: 6px; }
.mo-label { font-size: 11px; color: var(--text-muted); letter-spacing: 0.4px; }
.mo-row { display: flex; gap: 6px; flex-wrap: wrap; }
.tool-btn { background: var(--bg-3); border: 1px solid var(--border); border-radius: 8px; color: var(--text-muted); font-size: 12px; padding: 7px 9px; cursor: pointer; white-space: nowrap; font-family: inherit; transition: color var(--motion-fast) ease, border-color var(--motion-fast) ease, opacity var(--motion-fast) ease; }
.tool-btn:hover { color: var(--text-strong); border-color: var(--accent); }
.tool-btn[aria-pressed="false"] { opacity: 0.5; }
.bm-seg { display: flex; gap: 5px; }
.bm-opt { flex: 1 1 auto; white-space: nowrap; display: flex; align-items: center; justify-content: center; gap: 4px; padding: 6px 5px; font-size: 11.5px; cursor: pointer; color: var(--text-muted); background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px; }
.bm-opt input { accent-color: var(--accent); margin: 0; }
.bm-opt.active { color: var(--text); border-color: var(--accent); background: rgba(47,128,237,0.18); }
.drawer-handle { display: none; }

/* ---------- 城市标注（HTML 叠层） ---------- */
#labels { position: absolute; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
.city-lbl { position: absolute; transform: translate(-50%, -50%); font-size: 12px; line-height: 1; white-space: nowrap; padding: 2px 7px; border-radius: 999px; pointer-events: auto; cursor: pointer; background: rgba(2,6,23,0.62); color: #fff; font-weight: 600; text-shadow: 0 1px 2px #000; will-change: transform; border: 1px solid rgba(255,255,255,0.18); transition: background .15s; }
.city-lbl:hover { background: rgba(47,128,237,0.40); }
.city-lbl .cc { color: var(--accent); margin-left: 4px; font-variant-numeric: tabular-nums; }

/* 门店名标注（缩放到城市级时始终显示，无需点击；与城市标注共用碰撞网格） */
.store-lbl { position: absolute; transform: translate(-50%, -50%); font-size: 11px; line-height: 1; white-space: nowrap; padding: 1px 6px; border-radius: 6px; pointer-events: auto; cursor: pointer; background: rgba(2,6,23,0.72); color: #e8eef6; font-weight: 500; text-shadow: 0 1px 2px #000; border: 1px solid rgba(255,255,255,0.14); will-change: transform; transition: background .15s, color .15s; }
.store-lbl:hover { background: rgba(47,128,237,0.48); color: #fff; }

/* ---------- 详情卡（玻璃质感 + 入场动效 + 左缘色条） ---------- */
.maplibregl-popup { z-index: 30 !important; }
.ikea-popup .maplibregl-popup-content { background: var(--panel-bg); backdrop-filter: blur(10px); border: none; border-radius: 12px; padding: 0; overflow: hidden; color: var(--text); box-shadow: var(--shadow); font-size: 13px; min-width: 200px; transform-origin: center bottom; animation: ikea-popup-in var(--motion-base) var(--ease-out) both; }
@keyframes ikea-popup-in { from { opacity: 0; transform: translate3d(0,5px,0) scale(0.97); } to { opacity: 1; transform: translate3d(0,0,0) scale(1); } }
.ikea-popup .maplibregl-popup-close-button { color: var(--text-muted); font-size: 17px; padding: 5px 9px; z-index: 2; }
.ikea-popup .maplibregl-popup-close-button:hover { color: var(--text-strong); }
.ikea-popup .maplibregl-popup-tip { display: none !important; }
.pop { padding: 12px 14px; border-left: 3px solid var(--c, var(--accent)); }
.pop h3 { margin: 0 0 6px; font-size: 15px; color: var(--text-strong); padding-right: 16px; line-height: 1.35; }
.pop .era-tag { font-size: 11px; padding: 1px 7px; border-radius: 999px; margin-left: 6px; white-space: nowrap; }
.pop .era-tag.pioneer { background: rgba(251,191,36,0.25); color: #fde68a; }
.pop .era-tag.expansion { background: rgba(96,165,250,0.25); color: #bfdbfe; }
.pop .era-tag.acceleration { background: rgba(52,211,153,0.25); color: #bbf7d0; }
.pop .era-tag.surge { background: rgba(248,113,113,0.25); color: #fecaca; }
.pop table { border-collapse: collapse; margin-top: 4px; width: 100%; }
.pop td { padding: 2px 0; vertical-align: top; }
.pop td.k { color: var(--text-muted); padding-right: 10px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pop td:not(.k) { font-variant-numeric: tabular-nums; max-width: 200px; word-break: break-word; }
.pop .note { margin-top: 8px; color: var(--text-muted); font-size: 12px; line-height: 1.6; }
.pop .store-row { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; border-top: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.pop .store-row:first-of-type { border-top: none; }
.pop .store-row .sn { color: var(--text-strong); }
.pop .store-row .sy { color: var(--text-muted); font-size: 12px; }
@keyframes ikea-popup-in { from { opacity: 0; transform: translate3d(0,5px,0) scale(0.97); } to { opacity: 1; transform: translate3d(0,0,0) scale(1); } }
@media (prefers-reduced-motion: reduce) { .ikea-popup .maplibregl-popup-content { animation: none; } }

/* ---------- 底部拓店时间轴 ---------- */
.timeline { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 6; display: flex; align-items: center; gap: 12px; background: var(--panel-bg); backdrop-filter: blur(14px); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 9px 14px; width: min(620px, calc(100% - 360px)); }
.tl-play { flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--accent); border: none; color: #1a1206; font-size: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: transform var(--motion-fast) var(--ease-out), background .15s; }
.tl-play:hover { transform: scale(1.06); }
.tl-play.playing { background: #f87171; color: #2a0d0d; }
.tl-slider-wrap { flex: 1 1 auto; display: flex; flex-direction: column; gap: 2px; }
.tl-top { display: flex; align-items: baseline; justify-content: space-between; }
.tl-year { font-size: 14px; font-weight: 700; color: var(--text-strong); font-variant-numeric: tabular-nums; }
.tl-cum { font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.tl-cum b { color: var(--accent); font-size: 13px; }
.tl-slider { -webkit-appearance: none; appearance: none; width: 100%; height: 5px; border-radius: 999px; background: linear-gradient(90deg, var(--pioneer), var(--expansion), var(--acceleration), var(--surge)); outline: none; cursor: pointer; }
.tl-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); cursor: pointer; }
.tl-slider::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); cursor: pointer; }
.tl-scale { display: flex; justify-content: space-between; font-size: 9px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ---------- 移动端 ---------- */
@media (max-width: 760px) {
  .topbar { top: 10px; } .topbar h1 { font-size: 15px; } .topbar .sub { display: none; }
  .top-right { top: 42px; left: 12px; right: 12px; }
  .top-search { flex: 1 1 auto; width: auto; }
  .map-opts { left: 0; right: 0; width: auto; }
  .panel-open, .side-panel.collapsed + .panel-open { display: none; }
  .side-panel { top: auto; left: 12px; right: 12px; bottom: 12px; width: auto; max-width: none; max-height: 70vh; overflow: hidden; }
  /* 固定区不参与伸缩，城市列表（.city-list）独占剩余空间并可内部滚动 */
  .drawer-handle, .panel-head, .panel-stats, .panel-tools, .list-count, .panel-foot { flex: none; }
  .side-panel.collapsed { transform: translateY(calc(100% - 28px)); }
  .drawer-handle { display: flex; align-items: center; justify-content: center; width: 100%; height: 26px; flex: none; background: none; border: none; cursor: pointer; padding: 0; }
  .drawer-handle i { width: 44px; height: 4px; border-radius: 999px; background: rgba(255,255,255,0.28); }
  .drawer-handle:hover i { background: rgba(255,255,255,0.45); }
  .maplibregl-ctrl-bottom-right { bottom: 16px; }
  .timeline { left: 12px; right: 12px; transform: none; width: auto; bottom: calc(70vh + 20px); }
  .side-panel:not(.collapsed) ~ .timeline { bottom: calc(70vh + 20px); }
}
