/* 饮食页样式 */
.food-hero {
  padding: 60px 0 0;
}

.food-hero h1 {
  font-family: var(--serif);
  font-size: clamp(32px, 4.6vw, 50px);
  line-height: 1.18;
  margin-top: 16px;
}

.food-hero .lead {
  margin-top: 18px;
  font-size: 16px;
  color: var(--ink-2);
  max-width: 56ch;
}

/* 工具栏 */
.toolbar {
  margin-top: 40px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 68px;
  z-index: 30;
}

.search-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-box svg {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--ink-3);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 11px 14px 11px 38px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--bg-soft);
  font-size: 14.5px;
  font-family: inherit;
  color: var(--ink);
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.search-box input::placeholder { color: var(--ink-3); }

.search-box input:focus {
  outline: none;
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(185, 86, 60, .12);
}

.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  line-height: 1;
}

.search-clear:hover { background: var(--bg); color: var(--ink); }
.search-box.has-value .search-clear { display: flex; }

.sort-box {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-2);
  white-space: nowrap;
}

.sort-box select {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--bg-soft);
  font-family: inherit;
  font-size: 13.5px;
  color: var(--ink);
  cursor: pointer;
}

.sort-box select:focus {
  outline: none;
  border-color: var(--brand);
}

/* 分类 chips */
.cat-row {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  padding-top: 2px;
}

/* 窄屏时横向滚动而不是换行挤压 */
@media (max-width: 1100px) {
  .cat-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .cat-row::-webkit-scrollbar { display: none; }
}

.cat-chip {
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: transparent;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  transition: all .16s ease;
  white-space: nowrap;
}

.cat-chip:hover { background: var(--brand-soft); border-color: #e8c7bb; color: var(--brand-ink); }

.cat-chip[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
  font-weight: 600;
}

.cat-chip .num {
  opacity: .55;
  font-size: 11.5px;
  margin-left: 3px;
}

.cat-chip[aria-pressed="true"] .num { opacity: .7; }

/* 结果概要 */
.result-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin: 28px 0 18px;
  font-size: 13.5px;
  color: var(--ink-3);
}

.result-bar strong {
  font-family: var(--serif);
  font-size: 17px;
  color: var(--ink);
}

/* 食物网格 */
.food-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
  scroll-margin-top: 220px;
}

.food-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  text-align: left;
  padding: 0;
  transition: transform .2s cubic-bezier(.22,.61,.36,1), box-shadow .2s ease, border-color .2s ease;
  position: relative;
}

.food-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--line-strong);
}

.food-thumb {
  position: relative;
  aspect-ratio: 4 / 3;
  background: linear-gradient(140deg, #f2ece0, #eae4d4);
  overflow: hidden;
}

.food-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .45s cubic-bezier(.22,.61,.36,1);
}

.food-card:hover .food-thumb img { transform: scale(1.045); }

.food-thumb .no-photo {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 40px;
  letter-spacing: .05em;
  color: #b9ad96;
  background-image:
    linear-gradient(135deg, rgba(255, 255, 255, .5) 25%, transparent 25%,
      transparent 50%, rgba(255, 255, 255, .5) 50%,
      rgba(255, 255, 255, .5) 75%, transparent 75%);
  background-size: 18px 18px;
}

.food-thumb .no-photo::after {
  content: "暂无实拍";
  position: absolute;
  left: 0; right: 0; bottom: 9px;
  text-align: center;
  font-family: var(--font);
  font-size: 10.5px;
  letter-spacing: .12em;
  color: #a89d89;
}

.food-kcal-badge {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(6px);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .12);
}

.food-body {
  padding: 13px 14px 15px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}

.food-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.01em;
  line-height: 1.4;
}

.food-source {
  font-size: 11.5px;
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-height: 1.5em;
}

.food-macros {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  padding-top: 9px;
  border-top: 1px dashed var(--line);
  font-size: 11.5px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.food-macros span { display: inline-flex; align-items: center; gap: 3px; }

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex: none;
}

.dot-p { background: #b9563c; }
.dot-f { background: #b8862f; }
.dot-c { background: #4f7f52; }

/* 详情面板 */
.detail-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(36, 30, 24, .42);
  backdrop-filter: blur(3px);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity .24s ease;
}

.detail-backdrop.is-open { opacity: 1; pointer-events: auto; }

.detail-panel {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: min(460px, 100%);
  background: var(--bg-soft);
  z-index: 101;
  transform: translateX(100%);
  transition: transform .32s cubic-bezier(.22,.61,.36,1);
  display: flex;
  flex-direction: column;
  box-shadow: -20px 0 60px rgba(36, 30, 24, .18);
}

.detail-panel.is-open { transform: none; }

.detail-head {
  padding: 20px 22px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.detail-close {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  color: var(--ink-2);
  transition: background .16s ease, color .16s ease;
}

.detail-close:hover { background: var(--brand-soft); color: var(--brand-ink); }
.detail-close svg { width: 15px; height: 15px; }

.detail-scroll {
  overflow-y: auto;
  padding: 18px 22px 32px;
  flex: 1;
}

.detail-img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg);
}

.detail-cat {
  margin-top: 18px;
  display: inline-block;
  padding: 3px 11px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-size: 12px;
  font-weight: 600;
}

.detail-panel h2 {
  font-family: var(--serif);
  font-size: 28px;
  margin-top: 8px;
  line-height: 1.3;
}

.detail-sub {
  font-size: 12.5px;
  color: var(--ink-3);
  margin-top: 4px;
}

.detail-energy {
  margin-top: 20px;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.detail-energy .num {
  font-family: var(--serif);
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
}

.detail-energy .u { font-size: 13px; opacity: .72; }
.detail-energy .alt { margin-left: auto; font-size: 12px; opacity: .68; }

.nutri-list {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
}

.nutri-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 16px;
  font-size: 13.5px;
  border-bottom: 1px solid var(--line);
}

.nutri-row:last-child { border-bottom: 0; }

.nutri-row .k { color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.nutri-row .v { font-weight: 600; font-variant-numeric: tabular-nums; }
.nutri-row .v small { font-weight: 400; color: var(--ink-3); font-size: 11.5px; margin-left: 2px; }

.nutri-bar {
  height: 4px;
  border-radius: 2px;
  background: var(--bg);
  overflow: hidden;
  margin-top: 4px;
  width: 100%;
}

.nutri-bar i {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: var(--brand);
  transition: width .5s cubic-bezier(.22,.61,.36,1);
}

.detail-note {
  margin-top: 18px;
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.7;
  padding: 12px 14px;
  border-left: 2px solid var(--line-strong);
  background: rgba(228, 220, 205, .22);
  border-radius: 0 8px 8px 0;
}

/* 加载更多 */
.load-more {
  display: flex;
  justify-content: center;
  margin-top: 30px;
}

.load-more button {
  padding: 12px 30px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease;
}

.load-more button:hover { background: #fff; border-color: var(--ink-3); }
.load-more button:disabled { opacity: .5; cursor: default; }

.no-result {
  padding: 64px 24px;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  color: var(--ink-3);
}

.no-result strong {
  display: block;
  font-family: var(--serif);
  font-size: 19px;
  color: var(--ink-2);
  margin-bottom: 6px;
}

.no-result button {
  margin-top: 16px;
  padding: 9px 20px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: #fff;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
}

@media (max-width: 820px) {
  /* 移动端工具栏占屏太高，不再吸顶，避免遮挡卡片 */
  .toolbar { position: static; padding: 14px; }
  .food-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 11px; scroll-margin-top: 80px; }
  .food-body { padding: 10px 11px 12px; }
  .food-name { font-size: 14px; }
  .food-macros { gap: 7px; font-size: 10.5px; }
  .detail-panel { width: 100%; top: auto; height: 88vh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; transform: translateY(100%); }
  .detail-panel.is-open { transform: none; }
}

@media (max-width: 480px) {
  .sort-box { width: 100%; }
  .sort-box select { flex: 1; }
}
