/* ============================================================
 * 杭州宝藏餐馆 · 样式
 * 移动端优先 + 暖色调美食感
 * ============================================================ */

:root {
  --bg: #fdf6ee;              /* 暖米色背景 */
  --card-bg: #ffffff;
  --primary: #c1440e;        /* 辣椒红/砖红 主色 */
  --primary-soft: #f6d9c9;   /* 主色的浅色 */
  --accent: #e8871e;         /* 橙黄点缀 */
  --text: #3a2d26;           /* 深棕文字 */
  --text-soft: #8a7a6f;      /* 次要文字 */
  --border: #eaddd0;
  --price: #c1440e;
  --fav: #c1440e;            /* 收藏(与主色统一) */
  --shadow: 0 2px 12px rgba(120, 72, 40, 0.08);
  --radius: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* 确保 hidden 属性始终生效(优先级高于下方 .modal-mask/.img-mask 的 display:flex) */
[hidden] { display: none !important; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 顶部 ---------- */
.site-header {
  background: transparent;
  padding: 22px 14px 8px;
}
.header-inner {
  max-width: 900px;
  margin: 0 auto;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
}
.site-title {
  /* 艺术字体:优先系统行楷/楷体,网络加载「霞鹜文楷」增强,回退到楷体 */
  font-family: "LXGW WenKai", "华文行楷", "STXingkai", "华文楷体", "STKaiti",
    "楷体", "KaiTi", "PingFang SC", serif;
  font-size: 29px;
  font-weight: 700;
  letter-spacing: 1px;
  text-align: center;
  padding: 0 52px;   /* 给右上角收藏按钮留出空间,标题仍居中 */
  color: var(--primary);
}
/* 收藏入口:banner 右上角(链接,跳转收藏夹页) */
.fav-entry {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 7px 13px;
  font-size: 15px;
  font-weight: 700;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: #b7a89c;                 /* 默认浅灰(无收藏) */
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  box-shadow: var(--shadow);
  text-decoration: none;
}
.fav-entry.has-fav { color: var(--fav); }  /* 有收藏时暖橙,与卡片一致 */
.fav-entry:hover {
  border-color: var(--fav);
  background: var(--primary-soft);
}
/* .fav-heart 尺寸统一在下方与 .heart-icon 一起定义 */

/* 返回按钮(收藏页左上角) */
.back-btn {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  padding: 6px 14px 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
  border-radius: 999px;
  transition: background 0.15s;
}
.back-btn:hover { background: var(--primary-soft); }
.go-home-link {
  color: var(--primary);
  text-decoration: underline;
}
.count-suffix {
  font-size: 12px;
  opacity: 0.85;
  margin-left: 1px;
}

/* ---------- 容器 ---------- */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 16px 14px 40px;
}

/* ---------- 搜索行 ---------- */
.top-row {
  margin: 6px 0 12px;
}
.searchbar {
  flex: 1;
  min-width: 0;
  position: relative;
}
.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 15px;
  opacity: 0.55;
  pointer-events: none;
}
#searchInput {
  width: 100%;
  padding: 12px 14px 12px 40px;   /* 左侧留出图标位置 */
  font-size: 15px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
#searchInput:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
#searchInput::placeholder { color: #b9a89c; }

/* ---------- 随机推荐:独立主按钮 ---------- */
.random-btn {
  width: 100%;
  padding: 13px;
  margin-bottom: 12px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  border: none;
  border-radius: 12px;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(193, 68, 14, 0.25);
  transition: transform 0.12s, box-shadow 0.15s;
}
.random-btn:hover { box-shadow: 0 4px 14px rgba(193, 68, 14, 0.35); }
.random-btn:active { transform: scale(0.99); }

/* ---------- 工具行:筛选 + 排序 + 定位 ---------- */
.tool-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 14px;
  font-size: 13.5px;
  font-weight: 600;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.tool-btn:hover { border-color: var(--accent); }
.tool-btn:active { transform: scale(0.97); }
.tool-btn.located {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}
/* 自定义排序下拉 */
.sort-wrap { position: relative; }
.sort-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 20;
  min-width: 160px;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(120, 72, 40, 0.14);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sort-option {
  text-align: left;
  padding: 9px 12px;
  font-size: 13.5px;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}
.sort-option:hover { background: var(--bg); }
.sort-option.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
}
/* 筛选按钮上的数量红点 */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
  border-radius: 999px;
}
/* 定位状态提示(单独一行) */
.locate-status-row { min-height: 0; }
.locate-status {
  display: inline-block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-soft);
}
.locate-status:empty { display: none; }
.locate-status.ok { color: var(--primary); }
.locate-status.err { color: var(--primary); }

/* ---------- 可折叠筛选面板 ---------- */
.filter-panel {
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 14px 14px 4px;
  margin-top: 8px;
}
.filter-group { margin-bottom: 12px; }
.filter-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-soft);
  margin-bottom: 8px;
}
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
/* 地铁站按线路分组 */
/* 地铁两级选择:线路行 + 站点行 */
.metro-line-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.metro-station-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
/* 线路 chip:选中态更醒目(实心) */
.line-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}
.chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  font-size: 13px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.chip:hover { border-color: var(--accent); }
.chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}

/* ---------- 结果栏 ---------- */
.result-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 16px 2px 12px;
}
.result-count {
  font-size: 13px;
  color: var(--text-soft);
}
.result-count strong { color: var(--primary); font-size: 15px; }
.reset-btn {
  font-size: 13px;
  color: var(--text-soft);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  padding: 4px;
}
.reset-btn:hover { color: var(--primary); }

/* ---------- 卡片列表 ---------- */
.card-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.card {
  position: relative;
  min-width: 0;   /* 防止卡片被内部横向滚动内容撑宽,保证多列时等宽 */
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 16px 14px;
  border: 1px solid var(--border);
  transition: transform 0.15s, box-shadow 0.15s;
}
.card:active { transform: scale(0.995); }

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding-right: 34px;   /* 整行给右上角收藏按钮留位,避免价格与红心重合 */
}
.card-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}
.card-price {
  font-size: 15px;
  font-weight: 700;
  color: var(--price);
  white-space: nowrap;
}
.card-price small { font-size: 11px; font-weight: 400; color: var(--text-soft); }

/* 收藏按钮(卡片右上角) */
.fav-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border: none;
  background: none;
  cursor: pointer;
  color: #d8c6ba;
  transition: transform 0.15s, color 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.fav-btn:hover { transform: scale(1.15); }
.fav-btn.faved { color: var(--fav); }

/* 爱心图标:两处(卡片 + 顶部)用同一套渲染,固定盒子消除空心/实心宽度差异 */
.heart-icon,
.fav-heart {
  display: inline-block;
  width: 1em;
  text-align: center;
  font-family: "Segoe UI Symbol", "Apple Color Emoji", "Noto Sans Symbols2", sans-serif;
  font-weight: 400;
  line-height: 1;
}
.heart-icon { font-size: 22px; }
.fav-heart { font-size: 22px; }

/* 元信息标签行:菜系/区/地铁 */
.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.meta-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 6px;
  background: #fbf0e6;
  color: #a95a2a;
}
.meta-tag.distance { font-weight: 600; }

/* 推荐菜(图片 + 菜名) */
.card-dishes {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;                       /* Firefox:细滚动条常显,提示可滑动 */
  scrollbar-color: var(--primary-soft) transparent;
}
/* Chrome/Safari:细滚动条常显,作为"可左右滑动"的提示 */
.card-dishes::-webkit-scrollbar { height: 6px; }
.card-dishes::-webkit-scrollbar-thumb {
  background: var(--primary-soft);
  border-radius: 999px;
}
.card-dishes::-webkit-scrollbar-track { background: transparent; }
.dish {
  flex-shrink: 0;
  width: 92px;
  text-align: center;
}
.dish img {
  width: 92px;
  height: 92px;
  object-fit: cover;
  border-radius: 10px;
  cursor: pointer;
  background: #f3e9df;
  display: block;
}
.dish-noimg {
  width: 92px;
  height: 92px;
  border-radius: 10px;
  background: #f3e9df;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
}
.dish-name {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dishes-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  margin-top: 12px;
}
.dishes-title + .card-dishes { margin-top: 6px; }

.card-address {
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-soft);
  line-height: 1.6;
}
.card-address .pin { margin-right: 4px; }
.card-address .addr-text { }
/* 地址旁的外链图标(跳高德),紧跟地址末字 */
.addr-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-left: 3px;
  vertical-align: -3px;
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  border-radius: 5px;
  transition: all 0.15s;
}
.addr-nav:hover { background: var(--primary-soft); }

/* 点评区 */
.card-reviews {
  margin-top: 12px;
  border-top: 1px dashed var(--border);
  padding-top: 10px;
  display: grid;
  gap: 6px;
}
.review-row {
  font-size: 13px;
  display: flex;
  gap: 6px;
}
.review-key {
  flex-shrink: 0;
  font-weight: 600;
  color: var(--accent);
  width: 34px;
}
.review-val { color: var(--text); }

/* 自定义标签 */
.card-tags {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.food-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
}

/* ---------- 空状态 ---------- */
.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-soft);
}
.empty-emoji { font-size: 44px; margin-bottom: 10px; }

/* ---------- 随机推荐弹层 ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(58, 45, 38, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
  animation: fade 0.2s ease;
}
.modal-box {
  background: var(--bg);
  border-radius: 18px;
  width: 100%;
  max-width: 380px;
  padding: 18px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
  animation: pop 0.22s ease;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.modal-title { font-size: 16px; font-weight: 700; color: var(--primary); }
.modal-close {
  border: none; background: none; font-size: 18px;
  color: var(--text-soft); cursor: pointer; padding: 4px;
}
.modal-body .card { box-shadow: none; margin: 0; }

/* ---------- 图片放大弹层 ---------- */
.img-mask {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 60;
  animation: fade 0.2s ease;
}
.img-mask img {
  max-width: 100%;
  max-height: 90vh;
  border-radius: 8px;
}
.img-close {
  position: absolute;
  top: 16px; right: 16px;
  width: 40px; height: 40px;
  border: none; border-radius: 50%;
  background: rgba(255,255,255,0.2);
  color: #fff; font-size: 20px; cursor: pointer;
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- 页脚 ---------- */
.site-footer {
  text-align: center;
  padding: 24px 20px 30px;
  font-size: 12px;
  color: var(--text-soft);
}

/* ---------- 桌面端:多列卡片 ---------- */
@media (min-width: 640px) {
  .card-list { grid-template-columns: 1fr 1fr; }
  .site-title { font-size: 30px; }
}
@media (min-width: 900px) {
  .card-list { grid-template-columns: 1fr 1fr 1fr; }
}
