/* === Reset / Base === */
body {
  font-family: 'Noto Sans TC', sans-serif;
  margin: 0;
  padding: 0;
  background: #fff;
  color: #333;
}

header {
  padding: 16px;
  text-align: center;
  border-bottom: 1px solid #eee;
  background-color: #fff;
}

.loading {
  font-size: 14px;
  color: #888;
  padding: 20px 10px;
}

/* === 搜尋框 (T092303) === */
.search-header {
  padding: 10px 16px;
  background: #fff;
  border-bottom: 1px solid #eee;
}
.search-form {
  position: relative;
  display: flex;
  align-items: center;
}
#query {
  width: 100%;
  padding: 10px 40px 10px 14px;
  font-size: 16px;
  border-radius: 0;
  border: 1px solid #ddd;
  background: transparent;
  box-sizing: border-box;
}
.search-button {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: #666;
  padding: 0;
  display: flex;
  align-items: center;
}

/* === Tabs (T092304/T092308/...) === */
.tabs {
  display: flex;
  overflow-x: auto;
  background-color: #fff;
  padding: 8px 16px;
  gap: 16px;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  all: unset;
  display: inline-block;
  padding: 8px 0;
  cursor: pointer;
  font-size: 15px;
  color: #666;
  white-space: nowrap;
  border-bottom: 1px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}
.tab:hover { color: #000; }
.tab.active { color: #000; font-weight: 600; border-bottom: 1px solid #000; }

/* === Sort & Layout Toggle Row === */
.sort-layout-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background-color: #fff;
  border-bottom: 1px solid #eee;
  flex-wrap: wrap;
}
.sort-options {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 14px;
  color: #444;
}
.sort-options span { font-weight: 500; color: #111; }
.sort-button {
  all: unset;
  cursor: pointer;
  font-size: 14px;
  color: #666;
  padding: 4px 0;
  border-bottom: 1px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.sort-button:hover { color: #000; }
.sort-button.active { color: #000; font-weight: 600; border-bottom: 1px solid #000; }

/* === Main === */
main { padding: 20px 16px; background-color: #fff; }
.category { margin-bottom: 40px; }
.category h2 {
  font-size: 16px;
  font-weight: 500;
  color: #111;
  margin-bottom: 12px;
}

/* === Scroll containers === */
.scroll-container {
  display: flex;
  overflow-x: auto;
  gap: 16px;
  padding-bottom: 6px;
  scrollbar-width: thin;
  scrollbar-color: #ccc transparent;
}
.scroll-container::-webkit-scrollbar { height: 3px; }
.scroll-container::-webkit-scrollbar-thumb { background: #ccc; border-radius: 2px; }
.scroll-container.vertical {
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
  margin-bottom: 16px;
  gap: 12px;
}

/* === Card (shared) (T092306/T092311/...) === */
.card {
  flex: 0 0 auto;
  width: 100%;
  max-width: 540px;
  border-radius: 0;
  overflow: hidden;
  background: #fff;
  border: none;
  box-shadow: none;
  display: flex;
  flex-direction: column;
}

.card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  height: auto;
  object-fit: cover;
  background-color: #f0f0f0;
  display: block;
}

.card-content {
  padding: 16px 12px;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.card-title {
  font-size: 15px;
  font-weight: 600;
  color: #222;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-subtitle {
  font-size: 13px;
  color: #777;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* === card meta 資訊列（新增）=== */
.card-meta-row {
  font-size: 13px;
  color: #666;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* list 模式下允許換行 */
.card--list .card-meta-row {
  white-space: normal;
}
/* 地址顏色稍淡 */
.card-address {
  font-size: 12px;
  color: #999;
}

/* grid 模式最多顯示 2 行 meta（title=child1, meta1=child2, meta2=child3, meta3+=隱藏）*/
.card-content:not(.card-content--list) .card-meta-row:nth-child(n+4) {
  display: none;
}

/* === 橫式（list）：左圖右文 === */
.card--list {
  flex-direction: row;
  align-items: stretch;
  max-width: 100%;
}
.card--list .card-img-wrapper {
  position: relative;
  flex: 0 0 42%;
  max-width: 380px;
}
.card--list img {
  width: 100%;
  height: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}
.card--list img.card-img--xl {
  height: 100%;
}
.card--list .card-content {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
}
.card--list .card-actions {
  margin-top: auto;
}
.card--list .card-content--list .card-subtitle {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* === meta list & pills === */
.meta-list {
  margin: 4px 0 0;
  padding: 0 0 2px 18px;
  color: #666;
  font-size: 12px;
}
.meta-list li { margin: 4px 0; }

.pill-row { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
  display: inline-block;
  border-radius: 999px;
  font-size: 12px;
  padding: 4px 8px;
  line-height: 1;
}
.pill--accent { background: #111; color: #fff; }
.pill--ghost { background: #f1f1f1; color: #666; }

/* === Heart & actions === */
.card-img-wrapper { position: relative; }
.card-icon-btn.heart {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255,255,255,0.9);
  border: none;
  border-radius: 50%;
  padding: 6px;
  font-size: 16px;
  cursor: pointer;
  color: #999;
  transition: color 0.2s ease;
}
.card-icon-btn.heart:hover { color: red; }

.card-actions {
  display: flex;
  gap: 12px;
  margin-top: 2px;
  flex-wrap: wrap;
}
.card-action-btn {
  all: unset;
  cursor: pointer;
  font-size: 13px;
  color: #333;
  padding: 6px 10px;
  transition: color 0.2s ease;
}
.card-action-btn:hover { color: #000; }

/* === Footer === */
footer {
  text-align: center;
  padding: 20px;
  font-size: 14px;
  background: #fafafa;
  color: #888;
  border-top: 1px solid #eee;
}

/* === 尺寸優化（平板與桌面） === */
@media (min-width: 640px) {
  .card { max-width: 620px; }
  .card--list .card-img-wrapper { flex-basis: 38%; }
}

@media (min-width: 1024px) {
  .card { max-width: 720px; }
  .card--list .card-img-wrapper { flex-basis: 34%; max-width: 420px; }
}

/* === 版型切換按鈕 (T092309/T092313/...) === */
.layout-toggle { display: flex; gap: 8px; }
.layout-btn {
  all: unset;
  cursor: pointer;
  padding: 4px 8px;
  display: inline-flex;
  align-items: center;
  color: #aaa;
}
.layout-btn i { font-size: 18px; line-height: 1; }
.layout-btn:hover { color: #333; }
.layout-btn.is-active { color: #111; }

.card-img-wrapper.clickable { cursor: pointer; }

/* === 根節點模式控制 === */
.mode-all .layout-toggle { display: none; }
.mode-single .layout-toggle { display: flex; }
.mode-single.view-grid .card img {
  aspect-ratio: 4 / 3;
  height: auto;
  min-height: unset;
}

/* === 篩選按鈕指示器 === */
#btnFilter.has-filter { color: #201F21; position: relative; }
#btnFilter.has-filter::after {
  content: '';
  position: absolute; top: 2px; right: 2px;
  width: 6px; height: 6px; border-radius: 50%;
  background: #201F21;
}

/* === 進階篩選遮罩 === */
.filter-backdrop {
  display: none;
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.4);
}
.filter-backdrop.open { display: block; }

/* === 進階篩選面板 === */
.filter-panel {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 201;
  max-width: 480px; margin: 0 auto;
  background: #fff; border-radius: 12px 12px 0 0;
  padding: 0 0 80px;
  transform: translateY(100%);
  transition: transform 0.28s ease;
}
.filter-panel.open { transform: translateY(0); }

.filter-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid #e6e6e6;
}
.filter-panel-title { font-size: 15px; font-weight: 700; }
.filter-panel-close {
  background: none; border: none; cursor: pointer;
  font-size: 18px; color: #757575; padding: 4px;
}

.filter-section { padding: 16px 20px 0; }
.filter-section-label {
  font-size: 12px; color: #757575; margin-bottom: 10px;
}
.filter-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.filter-chip {
  background: none; border: 1px solid #D9D9D9; border-radius: 999px;
  font-size: 13px; color: #201F21; padding: 6px 14px;
  cursor: pointer; font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
}
.filter-chip.active {
  background: #201F21; border-color: #201F21; color: #fff;
}

.filter-panel-footer {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px 0;
  border-top: 1px solid #e6e6e6;
  margin-top: 16px;
}
.filter-btn-clear {
  background: none; border: none; font-size: 14px;
  color: #757575; cursor: pointer; text-decoration: underline;
  font-family: inherit;
}
.filter-btn-apply {
  background: #201F21; color: #fff;
  border: none; border-radius: 4px;
  font-size: 14px; font-weight: 600; font-family: inherit;
  padding: 10px 28px; cursor: pointer;
}
/* ── Active filter tags ── */
.active-filter-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #201F21;
  color: #fff;
  border-radius: 999px;
  font-size: 12px;
  padding: 4px 10px;
}
.af-tag-close {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 0;
  font-size: 11px;
  line-height: 1;
  opacity: .7;
}
.af-tag-close:hover { opacity: 1; }
