/* 食在南得 — 共用元件樣式
 * 原則：只有「浮在紙上」的東西才有陰影（拍立得、彈出視窗、主要按鈕），
 *       其他內容直接寫在方格紙上；轉場只動 transform／opacity。
 */

/* ───────── 頁首（桌機）───────── */
.app-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
body.scrolled .app-header { box-shadow: 0 6px 18px rgba(90, 60, 20, .07); }
.app-header .wrap { height: 100%; display: flex; align-items: center; gap: 20px; }
.brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand img { width: 40px; height: 40px; border-radius: 10px; background: #fff; object-fit: contain; border: 1px solid var(--line); }
.brand span { font-family: var(--font-hand); font-weight: 700; font-size: var(--fs-1); color: var(--red-deep); }
.top-nav { display: flex; gap: 2px; }
.top-nav a { position: relative; padding: 8px 12px; color: var(--ink-2); font-weight: 500; }
.top-nav a:hover { color: var(--ink); }
.top-nav a::after { /* 目前所在頁：底下一筆紅筆畫 */
  content: ""; position: absolute; left: 12px; right: 12px; bottom: 2px; height: 3px; border-radius: 3px;
  background: var(--red); transform: scaleX(0); transform-origin: left; transition: transform var(--t) var(--ease);
}
.top-nav a:hover::after { transform: scaleX(.4); }
.top-nav a[aria-current="page"] { color: var(--ink); font-weight: 700; }
.top-nav a[aria-current="page"]::after { transform: scaleX(1); }
.header-search {
  margin-left: auto; display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; min-width: 240px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line); color: var(--ink-3);
}
.header-search:hover { border-color: var(--ink-3); color: var(--ink-2); }
.header-search kbd {
  margin-left: auto; font: var(--fs-xs) var(--font-body); padding: 1px 6px; border-radius: 6px;
  background: var(--paper-2); color: var(--ink-2); border: 1px solid var(--line);
}
@media (max-width: 760px) {
  .top-nav, .header-search kbd { display: none; }
  .header-search { min-width: 0; padding: 8px 10px; border-radius: 12px; }
  .header-search .label { display: none; }
}

/* ───────── 底部分頁列（手機）───────── */
.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 60;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  display: none; grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--card) 94%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11px; color: var(--ink-3); font-weight: 500;
}
.tabbar svg { width: 24px; height: 24px; transition: transform var(--t) var(--ease-bounce); }
.tabbar a:active svg { transform: scale(.9); }
.tabbar a[aria-current="page"] { color: var(--red-deep); font-weight: 700; }
.tabbar a[aria-current="page"] svg { transform: translateY(-2px); }
@media (max-width: 760px) {
  .tabbar { display: grid; }
  body { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
}

/* ───────── 按鈕 ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border-radius: 999px; border: 0; font-weight: 700; font-size: 15px;
  transition: transform var(--t-fast) var(--ease);
  white-space: nowrap;
}
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--red); color: #fff; box-shadow: 0 3px 0 var(--red-deep); }
.btn-primary:hover { background: var(--red-deep); }
.btn-yolk { background: var(--yolk); color: var(--ink); box-shadow: 0 3px 0 #c98f14; }
.btn-yolk:hover { background: #e6a91f; }
.btn-ghost { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { border-color: var(--ink-2); }
.btn.is-on { background: var(--red-tint); color: var(--red-deep); border-color: transparent; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); display: grid; place-items: center;
  background: var(--card); color: var(--ink); transition: transform var(--t-fast) var(--ease);
}
.icon-btn:hover { border-color: var(--ink-2); }
.icon-btn:active { transform: scale(.9); }
.icon-btn svg { width: 20px; height: 20px; }

/* 收藏愛心 */
.save-btn[aria-pressed="true"] { color: var(--red); }
.save-btn[aria-pressed="true"] svg { animation: pop .35s var(--ease-bounce); }

/* ───────── 橫向捲動列：手機用手滑，電腦顯示細捲軸讓滑鼠也能拖 ───────── */
.chip-row, .rail, .guide-rail { scrollbar-width: none; overscroll-behavior-x: contain; }
.chip-row::-webkit-scrollbar, .rail::-webkit-scrollbar, .guide-rail::-webkit-scrollbar { display: none; }
@media (pointer: fine) {
  .rail, .guide-rail { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
  .rail::-webkit-scrollbar, .guide-rail::-webkit-scrollbar { display: block; height: 8px; }
  .rail::-webkit-scrollbar-thumb, .guide-rail::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }
}

/* ───────── 篩選標籤 ───────── */
/* scroll-padding：滑動對齊時留 16px，第一個標籤才不會貼到螢幕邊緣 */
.chip-row { display: flex; gap: 8px; overflow-x: auto; padding: 4px 16px; margin: 0 -16px; scroll-snap-type: x proximity; scroll-padding-inline: 16px; }
@media (pointer: fine) { .chip-row { flex-wrap: wrap; overflow: visible; } }
.chip {
  flex-shrink: 0; scroll-snap-align: start; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); font-size: var(--fs-s); font-weight: 500; color: var(--ink-2);
}
.chip:hover { border-color: var(--ink-2); color: var(--ink); }
.chip svg { width: 15px; height: 15px; flex-shrink: 0; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.chip[data-cat]::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--cat); flex-shrink: 0; }
.chip[data-cat][aria-pressed="true"]::before { box-shadow: 0 0 0 2px var(--paper); }
.chip .count { font-size: var(--fs-xs); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] .count { color: inherit; opacity: .8; }
select.chip {
  appearance: none; padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat;
}

/* ───────── 營業狀態 ───────── */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.status.open { color: var(--scallion); }
.status.closing { color: var(--yolk-deep); }
.status.shut { color: var(--ink-3); }
.status.closed { color: var(--red-deep); }
.status.unknown { color: var(--ink-3); }
.status.unknown::before { background: none; box-shadow: inset 0 0 0 2px currentColor; }
.not-tried { color: var(--yolk-deep); font-weight: 700; }
.not-tried-pill {
  display: inline-flex; align-items: center; gap: 4px; margin-left: 10px; padding: 2px 10px; border-radius: 999px;
  border: 1.5px dashed var(--yolk); background: var(--yolk-tint); color: var(--yolk-deep); font-size: 13px; font-weight: 700;
}
.not-tried-pill .ico { width: 14px; height: 14px; }
.status small { font-weight: 500; color: var(--ink-2); }

/* 特別推薦印章 */
.stamp {
  display: inline-grid; place-items: center;
  font-family: var(--font-hand); font-weight: 700; font-size: 13px; line-height: 1.1; text-align: center;
  color: var(--red); border: 2px solid var(--red); border-radius: 8px;
  padding: 3px 6px; transform: rotate(-8deg);
  background: color-mix(in srgb, #fff 80%, transparent);
  box-shadow: inset 0 0 0 2px #fff, inset 0 0 0 3px var(--red);
}

/* ───────── 菜色標籤 ───────── */
.dishes { display: flex; flex-wrap: wrap; gap: 6px; }
.dish { font-size: var(--fs-xs); padding: 1px 8px; border-radius: 6px; color: var(--ink-2); border: 1px dashed var(--line); background: var(--card); }
.dish.lg { font-size: 15px; padding: 4px 12px; border-radius: 8px; background: var(--yolk-tint); color: var(--yolk-deep); border: 1px solid color-mix(in srgb, var(--yolk) 50%, transparent); }

/* ───────── 店家卡片：照片＋文字直接寫在紙上，不再包一層框 ───────── */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 28px 20px; }
@media (max-width: 560px) { .card-grid { grid-template-columns: 1fr 1fr; gap: 20px 12px; } }
.card-grid > .card { content-visibility: auto; contain-intrinsic-size: auto 300px; }   /* 長列表只畫看得到的部分 */

.card { position: relative; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.card-photo {
  position: relative; aspect-ratio: 4 / 3; overflow: hidden;
  border-radius: var(--radius); background: var(--paper-2); border: 1px solid var(--line);
}
.card-photo img { width: 100%; height: 100%; object-fit: cover; }
.card-photo .save-btn { position: absolute; top: 8px; right: 8px; z-index: 2; width: 36px; height: 36px; border: 0; }
.card-photo .stamp { position: absolute; left: 10px; bottom: 10px; }
.cat-dot {
  position: absolute; left: 8px; top: 8px; display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px; background: color-mix(in srgb, #fff 92%, transparent);
  color: var(--ink); font-size: var(--fs-xs); font-weight: 700;
}
.cat-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--cat); }
.card-body { display: grid; gap: 4px; min-width: 0; padding: 0 2px; }
.card-body h3 {
  font-size: var(--fs-1); line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere;
}
.card:hover h3, .card:has(.card-link:focus-visible) h3 {  /* 只有鍵盤選到卡片才畫底線，按完愛心不會留著 */ text-decoration: underline; text-decoration-color: var(--red); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.card-body .meta { display: flex; flex-wrap: wrap; gap: 2px 12px; align-items: center; font-size: 13px; color: var(--ink-3); }
.card.is-closed .card-photo img { filter: grayscale(1); opacity: .6; }
.card-link { position: absolute; inset: 0; z-index: 1; border-radius: var(--radius); }
@media (max-width: 560px) {
  .card-body h3 { font-size: 16px; }
  .card .dishes { display: none; }
}

/* 橫向卡片列 */
.rail {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 260px); gap: 20px;
  overflow-x: auto; scroll-snap-type: x mandatory;
  padding: 4px 16px 16px; margin: 0 -16px;
}
.rail > * { scroll-snap-align: start; }
@media (max-width: 560px) { .rail { grid-auto-columns: 68%; } .rail .card .dishes { display: flex; } }

/* ───────── 區塊標題 ───────── */
.section { margin-top: 56px; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.section-head h2 { font-size: var(--fs-2); }
.section-head p { margin: 4px 0 0; color: var(--ink-2); font-size: var(--fs-s); }
.more {
  font-size: var(--fs-s); color: var(--red-deep); font-weight: 700; white-space: nowrap;
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px;
}
.more:hover { text-decoration-thickness: 2px; }

/* ───────── 覆蓋層：搜尋、今天吃什麼 ───────── */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(42, 31, 26, .45); backdrop-filter: blur(4px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 8vh 16px 16px; overscroll-behavior: contain;
  animation: fade .2s var(--ease);
}
.overlay[hidden] { display: none; }
.panel {
  width: 100%; max-width: 560px; max-height: 84vh; display: flex; flex-direction: column;
  background: var(--paper); border-radius: var(--radius-l); box-shadow: var(--shadow-l); overflow: hidden;
  animation: panel-in .3s var(--ease-bounce);
}
@keyframes panel-in { from { opacity: 0; transform: translateY(16px) scale(.97); } }
@media (max-width: 560px) {
  .overlay { padding: 0; align-items: flex-end; }
  .panel { max-height: 92vh; border-radius: var(--radius-l) var(--radius-l) 0 0; animation-name: sheet-in; padding-bottom: env(safe-area-inset-bottom); }
  @keyframes sheet-in { from { transform: translateY(100%); } }
}

.search-box { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); background: var(--card); }
.search-box:focus-within { box-shadow: inset 0 -3px 0 var(--red); }
.search-box svg { width: 22px; height: 22px; color: var(--ink-3); flex-shrink: 0; }
.search-box input { flex: 1; border: 0; outline: 0; background: transparent; font-size: var(--fs-1); min-width: 0; }
.search-results { overflow-y: auto; padding: 8px; overscroll-behavior: contain; }
.search-hint { padding: 14px 12px 6px; font-size: 13px; color: var(--ink-3); }
.result { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 12px; }
.result > div { min-width: 0; }
.result[aria-selected="true"], .result:hover { background: var(--paper-2); }
.result img { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; flex-shrink: 0; }
.result b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result small { display: block; color: var(--ink-3); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result mark { background: var(--yolk-tint); color: inherit; border-radius: 3px; padding: 0 2px; }
.quick-tags { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 10px 14px; }

/* ───────── 進度條（用 scaleX 動畫，不動到版面） ───────── */
.progress { height: 12px; border-radius: 999px; background: var(--paper-2); overflow: hidden; border: 1px solid var(--line); }
.progress > span {
  display: block; height: 100%;
  background: repeating-linear-gradient(-45deg, var(--red), var(--red) 8px, #e65a4f 8px, #e65a4f 16px);
  transform: scaleX(var(--p, 0)); transform-origin: left; transition: transform .8s var(--ease);
}

/* ───────── 提示訊息 ───────── */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom)); z-index: 200;
  transform: translateX(-50%); padding: 10px 18px; border-radius: 999px;
  background: var(--ink); color: var(--paper); font-size: var(--fs-s); font-weight: 500;
  box-shadow: var(--shadow-l); animation: toast 2.2s var(--ease) both; pointer-events: none;
}
@media (min-width: 761px) { .toast { bottom: 32px; } }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, 10px); } 12%, 85% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }

.empty { text-align: center; padding: 56px 16px; color: var(--ink-2); }
.empty p { margin-inline: auto; }
.empty-action { margin-top: 16px; }
.ate-mark { color: var(--scallion); font-weight: 700; }
.fav-mark { color: var(--yolk-deep); font-weight: 700; }
.fav-mark .ico { --icon-fill: currentColor; }
.fav-btn.is-on { background: var(--yolk-tint); color: var(--yolk-deep); }
.passport-fav { display: flex; align-items: center; gap: 4px; color: var(--yolk-deep); font-weight: 700; }
.passport-fav .ico { width: 16px; height: 16px; --icon-fill: currentColor; }
.fav-btn[hidden] { display: none; }
.result-status { margin-left: auto; flex-shrink: 0; }


/* ───────── 頁尾 ───────── */
.app-footer { margin-top: 80px; padding: 28px 0 36px; border-top: 1px solid var(--line); color: var(--ink-3); font-size: 13px; background: var(--paper); }
.app-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 20px; }
.app-footer .sign { font-family: var(--font-hand); font-size: 16px; color: var(--red-deep); }
.app-footer a { color: var(--red-deep); text-decoration: underline; text-underline-offset: 3px; }
.app-footer a:hover { text-decoration-thickness: 2px; }

/* ───────── 我的評分 ───────── */
.rating { color: var(--yolk); letter-spacing: 1px; white-space: nowrap; }
.rating .off { color: var(--line); }
.rating .half { background: linear-gradient(90deg, var(--yolk) 50%, var(--line) 50%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.rating.lg { font-size: 22px; display: inline-flex; align-items: center; gap: 2px; }
.rating.lg b { font-family: var(--font-body); font-size: 16px; color: var(--yolk-deep); margin-left: 8px; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.rating-mini { color: var(--yolk-deep); font-weight: 700; font-variant-numeric: tabular-nums; }

/* ───────── 口袋清單：拼貼照片＋標題，同樣直接放在紙上 ───────── */
.guide-rail {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 320px); gap: 20px;
  overflow-x: auto; scroll-snap-type: x mandatory; padding: 4px 16px 16px; margin: 0 -16px;
}
@media (max-width: 560px) { .guide-rail { grid-auto-columns: 78%; } }
.guide-card { scroll-snap-align: start; display: grid; gap: 10px; }
.guide-card:hover b, .guide-card:focus-visible b { text-decoration: underline; text-decoration-color: var(--red); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.guide-mosaic {
  display: grid; grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr; gap: 3px; aspect-ratio: 16 / 10;
  border-radius: var(--radius); overflow: hidden; background: var(--paper-2); border: 1px solid var(--line);
}
.guide-mosaic img { width: 100%; height: 100%; object-fit: cover; }
.guide-mosaic img:first-child { grid-row: 1 / 3; }
.guide-mosaic.n1 img, .guide-mosaic.n2 img:first-child { grid-column: 1 / 3; grid-row: 1 / 3; }
.guide-mosaic.n2 img:nth-child(2) { display: none; }
.guide-body { display: grid; gap: 0; padding: 0 2px; }
.guide-body b { font-family: var(--font-hand); font-size: var(--fs-1); }
.guide-body small { color: var(--ink-3); }
.new-badge { font-family: var(--font-body); font-size: var(--fs-xs); vertical-align: middle; padding: 1px 8px; border-radius: 999px; background: var(--red); color: #fff; }

/* ── 回到頁頂 ── */
.to-top {
  position: fixed; right: 16px; bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); z-index: 150;
  display: grid; place-items: center; width: 48px; height: 48px; padding: 0;
  border-radius: 50%; border: 2px solid var(--ink); background: var(--paper); color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink); cursor: pointer;
  opacity: 0; visibility: hidden; transform: translateY(10px);
  transition: opacity var(--t) var(--ease), transform var(--t) var(--ease), visibility 0s linear var(--t);
}
.to-top.show { opacity: 1; visibility: visible; transform: none; transition: opacity var(--t) var(--ease), transform var(--t) var(--ease); }
.to-top svg { width: 22px; height: 22px; }
.to-top:hover { color: var(--red); border-color: var(--red); box-shadow: 3px 3px 0 var(--red); }
.to-top:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
@media (min-width: 761px) { .to-top { right: 24px; bottom: 28px; } }
@media (prefers-reduced-motion: reduce) { .to-top, .to-top.show { transform: none; } }
/* 手機店家頁底部有操作列，按鈕放到它上面 */
@media (max-width: 760px) { body[data-page="store"] .to-top { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 94px); } }
