/* ============================================================
   中国各地美食地图 · 样式 (app.css)
   结构：设计变量 → 基础 → 布局 → 组件 → 响应式
   颜色全部走 CSS 变量，深色模式只改变量，不改组件。
   ============================================================ */

/* ---------- 1. 设计变量 ---------- */
:root {
  color-scheme: light dark;
  --bg: #faf5ec;
  --surface: #fffdf7;
  --surface-2: #f3ecdd;
  --ink: #2a251d;
  --muted: #6f6656;
  --line: #e3d9c6;
  --accent: #b03627;        /* 朱红：主强调 */
  --accent-ink: #ffffff;
  --accent-soft: #f7e3dc;
  --gold: #a97b24;
  --gold-soft: #f3e8cf;
  --green: #3f6b4f;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(74, 54, 20, .08);
  --font-body: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-display: "Noto Serif SC", "Songti SC", "SimSun", serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17140f;
    --surface: #221e17;
    --surface-2: #2b271e;
    --ink: #f0e8d8;
    --muted: #b0a68f;
    --line: #3d372a;
    --accent: #e0684f;
    --accent-ink: #1d1712;
    --accent-soft: #452a23;
    --gold: #d3a94f;
    --gold-soft: #3a3220;
    --shadow: 0 2px 10px rgba(0, 0, 0, .35);
  }
}

/* ---------- 2. 基础 ---------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: 16px; line-height: 1.65;
  overflow-wrap: break-word; /* 长网址/代码断行，不把页面撑宽 */
}
/* 表格按内容最小宽度定列宽：break-word 不影响该宽度，须用 anywhere */
th, td { overflow-wrap: anywhere; }
img { max-width: 100%; display: block; }
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
button, select, input[type="search"], a.btn { min-height: 40px; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.3; margin: 0; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }

/* ---------- 3. 顶部导航 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-in { display: flex; align-items: center; gap: 10px; padding: 10px 16px; max-width: 1180px; margin: 0 auto; flex-wrap: wrap; }
.brand { font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand .seal { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 6px; background: var(--accent); color: #fff; font-size: .85rem; margin-right: 8px; vertical-align: -6px; }
.nav { display: flex; gap: 2px; flex-wrap: wrap; }
.nav a {
  color: var(--ink); text-decoration: none; padding: 8px 12px; border-radius: 999px;
  min-height: 40px; display: inline-flex; align-items: center; font-size: .95rem;
}
.nav a[aria-current="page"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.top-search { flex: 1 1 180px; max-width: 340px; margin-left: auto; }
.top-search input {
  width: 100%; padding: 9px 14px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); min-height: 40px;
}

/* ---------- 4. 通用组件 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 9px 18px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); text-decoration: none; cursor: pointer;
  font-size: .95rem; min-height: 40px;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.ghost { background: transparent; }
.btn:active { transform: translateY(1px); }
.chip {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); font-size: .8rem; white-space: nowrap;
}
.chip.flavor { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.chip.type { background: var(--gold-soft); color: var(--gold); font-weight: 600; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
}
.fav-btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  width: 40px; height: 40px; min-height: 40px; display: inline-grid; place-items: center; cursor: pointer; flex: none;
}
.fav-btn svg { width: 19px; height: 19px; fill: none; stroke: var(--muted); stroke-width: 2; }
.fav-btn[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.fav-btn[aria-pressed="true"] svg { fill: var(--accent); stroke: var(--accent); }
.crumbs { font-size: .9rem; color: var(--muted); margin: 18px 0 10px; }
.crumbs a { color: var(--muted); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 34px 0 14px; flex-wrap: wrap; }
.section-head h2 { font-size: 1.45rem; }

/* 菜品卡 */
.dish-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.dish-card { display: flex; flex-direction: column; text-decoration: none; color: var(--ink); }
.dish-card .ph { aspect-ratio: 4 / 3; background: var(--surface-2); overflow: hidden; text-decoration: none; }
.dish-card .ph img { width: 100%; height: 100%; object-fit: cover; }
.dish-card .ph-none { display: grid; place-items: center; align-content: center; gap: 4px; height: 100%; font-family: var(--font-display); font-size: 2.6rem; color: var(--gold); background: radial-gradient(circle at 30% 20%, var(--gold-soft), var(--surface-2)); }
.ph-note { font-family: var(--font-body); font-size: .78rem; color: var(--muted); }
.dish-card .bd { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 7px; flex: 1; }
.dish-card h3 { font-size: 1.08rem; }
.dish-card .loc { font-size: .85rem; color: var(--muted); }
.dish-card .desc { font-size: .88rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dish-card .row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }

/* 省份卡 */
.prov-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 14px; }
.prov-card { padding: 16px; text-decoration: none; color: var(--ink); display: block; }
.prov-card h3 { font-size: 1.12rem; margin-bottom: 4px; }
.prov-card h3 .short { color: var(--accent); font-size: .85rem; margin-left: 6px; }
.prov-card p { margin: 6px 0 10px; font-size: .88rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.prov-card .meta { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- 5. 首页 ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); gap: 26px; align-items: center; padding: 34px 0 6px; }
.hero h1 { font-size: clamp(1.9rem, 4.5vw, 3rem); font-weight: 900; }
.hero h1 .accent { color: var(--accent); }
.hero .lede { color: var(--muted); margin: 14px 0 20px; font-size: 1.02rem; }
.hero .cta { display: flex; gap: 10px; flex-wrap: wrap; }
.hero figure { margin: 0; border-radius: 18px; overflow: hidden; box-shadow: var(--shadow); }
.hero figure img { aspect-ratio: 4 / 3; object-fit: cover; width: 100%; }
.hero figcaption { font-size: .8rem; color: var(--muted); padding-top: 6px; }
.stats { display: flex; gap: 22px; flex-wrap: wrap; margin: 18px 0 0; }
.stats div { min-width: 84px; }
.stats b { font-family: var(--font-display); font-size: 1.5rem; display: block; }
.stats span { color: var(--muted); font-size: .85rem; }
.random-box { margin-top: 26px; padding: 18px; display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.random-box img { width: 120px; height: 92px; object-fit: cover; border-radius: 10px; }
.random-box .grow { flex: 1 1 220px; }

/* ---------- 6. 浏览页工具栏 ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin: 20px 0 16px; align-items: center; }
.toolbar input[type="search"], .toolbar select {
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); min-height: 40px;
}
.toolbar input[type="search"] { flex: 1 1 200px; }
.result-note { color: var(--muted); margin: 4px 0 14px; }
.empty { padding: 44px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); background: var(--surface); }

/* ---------- 7. 地图页 ---------- */
.map-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; margin: 18px 0 30px; align-items: start; }
#mapEl { height: 520px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); }
#mapEl.map-big { height: 620px; }
#mapFallback img { border-radius: var(--radius); border: 1px solid var(--line); width: 100%; height: auto; }
/* 首页全国图 */
.home-map { margin: 0 0 10px; }
#homeMapEl { height: 460px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); }
#homeMapFallback img { border-radius: var(--radius); border: 1px solid var(--line); width: 100%; height: auto; }
.map-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: 520px; overflow: auto; }
.map-list li { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.map-list li.map-selected { border-color: var(--accent); background: var(--accent-soft); }
.map-list .pin { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; font-size: .75rem; margin-right: 8px; }
.map-list li.pin--on { border-color: var(--accent); }
.map-list .sub { display: block; font-size: .82rem; color: var(--muted); margin-left: 30px; }
/* v2.2 行政边界：地图上的驻地图钉（运行时渲染的小号编号点，位于面层之上，与右侧列表同号） */
#mapEl .pin, #homeMapEl .pin, #placeMapEl .pin {
  display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: .72rem; font-weight: 700; line-height: 1;
  border: 2px solid #fff; box-shadow: 0 1px 5px rgba(0, 0, 0, .4); cursor: pointer;
}
#mapEl .pin--on, #homeMapEl .pin--on, #placeMapEl .pin--on { background: var(--gold); }
/* 省级面着色图例（全国图/地图页） */
.bnd-legend { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: .85rem; margin: 8px 0 0; }
.bnd-scale { width: 110px; height: 10px; border-radius: 5px; background: linear-gradient(90deg, #f3e8cf, #b03627); border: 1px solid var(--line); flex: none; }

/* ---------- 8. 详情页 ---------- */
.detail-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; margin: 8px 0 24px; align-items: start; }
.detail-head .ph { border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); }
.detail-head .ph img { aspect-ratio: 4 / 3; object-fit: cover; width: 100%; }
.detail-head .ph-none { aspect-ratio: 4 / 3; display: grid; place-items: center; align-content: center; gap: 6px; font-family: var(--font-display); font-size: 4rem; color: var(--gold); background: radial-gradient(circle at 30% 20%, var(--gold-soft), var(--surface-2)); border-radius: 16px; }
.detail-head h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); margin: 6px 0 10px; }
.fact-table { width: 100%; border-collapse: collapse; margin: 14px 0; }
.fact-table th, .fact-table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.fact-table th { width: 92px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.history-box { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--gold); border-radius: 10px; padding: 16px 18px; margin: 18px 0; }
.history-box h2 { font-size: 1.15rem; margin-bottom: 8px; }
.title-row { display: flex; align-items: flex-start; gap: 12px; }
.title-row .grow { flex: 1; }

/* ---------- 9. 数据页 / 页脚 ---------- */
.doc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin: 16px 0; }
.doc h2 { font-size: 1.25rem; margin-bottom: 10px; }
.doc pre { background: var(--surface-2); border-radius: 10px; padding: 14px; overflow-x: auto; font-size: .82rem; line-height: 1.55; }
.doc code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.doc table { border-collapse: collapse; width: 100%; font-size: .92rem; }
.doc th, .doc td { border-bottom: 1px solid var(--line); text-align: left; padding: 7px 8px; vertical-align: top; }
footer { border-top: 1px solid var(--line); margin-top: 44px; padding: 22px 0 34px; color: var(--muted); font-size: .88rem; }
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 99; font-size: .92rem;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 9b. v2 深度组件 ---------- */
.chip.ev { font-weight: 600; }
.chip.ev-ok { background: #e2efe4; color: #2f5d3a; }
.chip.ev-warn { background: #fbeed3; color: #8a5a12; }
.chip.ev-legend { background: var(--accent-soft); color: var(--accent); }
.chip.ev-unknown { background: var(--surface-2); color: var(--muted); }
@media (prefers-color-scheme: dark) {
  .chip.ev-ok { background: #24382a; color: #9fd3ab; }
  .chip.ev-warn { background: #40351c; color: #e8c37a; }
}
.deep-grid, .culture-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.deep-card { padding: 16px; text-decoration: none; color: var(--ink); display: block; }
.deep-card h3, .culture-card h3 { font-size: 1.12rem; margin: 8px 0 2px; }
.deep-card .loc, .culture-card .loc { font-size: .85rem; color: var(--muted); }
.deep-card p, .culture-card p { font-size: .9rem; color: var(--muted); margin: 8px 0; }
.deep-card .row { display: flex; gap: 6px; flex-wrap: wrap; }
.culture-card { padding: 16px; }
.culture-card .culture-kind { font-size: .8rem; font-weight: 600; color: var(--gold); }
.culture-card .cph { margin: -16px -16px 12px; overflow: hidden; }
.culture-card .cph img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: none; }
.timeline b { flex: 0 0 128px; font-family: var(--font-display); color: var(--accent); }
.timeline span { flex: 1; }
.evidence-box { border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; margin: 14px 0; background: var(--surface); }
.evidence-box h2 { font-size: 1.1rem; margin-bottom: 8px; }
.evidence-box.fact { border-left: 4px solid var(--green); }
.evidence-box.legend { border-left: 4px solid var(--accent); }
.evidence-box.dispute { border-left: 4px solid var(--gold); }
.verify-box { border-left: 4px solid var(--green); }
.shallow-note { border-style: dashed; }
.tier-list { display: flex; flex-direction: column; gap: 14px; }
.tier h3 { font-size: 1.02rem; }
.tier p { margin: 6px 0 0; color: var(--muted); font-size: .93rem; }
.lead-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.lead { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.lead h3 { font-size: 1rem; margin-bottom: 6px; }
.lead p { margin: 4px 0; font-size: .9rem; }

/* ---------- 9c. v3 地图导航 / 定位 / 相关导览 ---------- */
.chip.rel { background: var(--gold-soft); color: var(--gold); font-weight: 600; }
.prov-card .loc { font-size: .85rem; color: var(--muted); }
/* 地方页定位小地图 */
.loc-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 18px; align-items: start; }
#placeMapEl { height: 340px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); }
.loc-side .map-list.loc-list { max-height: 264px; margin: 0 0 12px; }
#placeMapFallback img { border-radius: 10px; border: 1px solid var(--line); width: 100%; height: auto; }
.loc-side p { margin: 0 0 10px; }
/* 相关导览 */
.tour-index { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0 4px; }
button.tour-jump { cursor: pointer; border: 1px solid var(--line); min-height: 34px; }
button.tour-jump:hover { border-color: var(--gold); color: var(--gold); }
.tour { margin-bottom: 10px; }
.tour-route { font-size: .95rem; margin: 0 0 14px; line-height: 2; }
.tour-route a { font-weight: 600; }
.tour-route span { color: var(--muted); margin: 0 2px; }

/* ---------- 9d. v2.4 补全进度（框架） ---------- */
.fw-track { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-top: 10px; }
.fw-track i { display: block; height: 100%; background: var(--accent); }
.fw-list { display: flex; flex-direction: column; gap: 8px; }
.fw-row { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.fw-row a { color: var(--ink); }

/* ---------- 10. 响应式 ---------- */
@media (max-width: 860px) {
  .hero, .detail-head { grid-template-columns: minmax(0, 1fr); }
  .map-layout, .loc-layout { grid-template-columns: minmax(0, 1fr); }
  #placeMapEl { height: 280px; }
  #mapEl { height: 380px; }
  #mapEl.map-big { height: 440px; }
  #homeMapEl { height: 340px; }
  .map-list { max-height: none; }
  .top-search { order: 3; flex-basis: 100%; max-width: none; }
  .dish-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .toast { transition: none; }
}
