/* ============ Cat & Délice 貓與美食 ============ */
:root {
  --bg: #faf8f5;
  --card: #ffffff;
  --fg: #24272b;
  --muted: #6b7078;
  --line: #e7e2da;
  --accent: #ad4c18;          /* 暖橘：美食調性主色（對比 5.18:1，達 WCAG AA） */
  --code-bg: #f1ede6;
  --c-food: #ad4c18;
  --c-cats: #a16207;
  --c-tech: #2563eb;
  --c-life: #16803c;
}
/* 深色：暖棕咖啡色系（espresso），配合貓與美食的調性 */
:root[data-theme="dark"] {
  --bg: #171310;
  --card: #211b16;
  --fg: #ede6dd;
  --muted: #a69c8f;
  --line: #362d24;
  --accent: #e8a45c;
  --code-bg: #2a221b;
  --c-food: #e8a45c;
  --c-cats: #dbb95a;
  --c-tech: #8fb4f2;
  --c-life: #8bc98f;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171310;
    --card: #211b16;
    --fg: #ede6dd;
    --muted: #a69c8f;
    --line: #362d24;
    --accent: #e8a45c;
    --code-bg: #2a221b;
    --c-food: #e8a45c;
    --c-cats: #dbb95a;
    --c-tech: #8fb4f2;
    --c-life: #8bc98f;
  }
}

/* 深色模式下橫幅遮罩加深，維持文字對比 */
:root[data-theme="dark"] .site-hero {
  background:
    linear-gradient(rgba(14,7,3,.58), rgba(14,7,3,.68)),
    url("/static/images/banner.svg") center / cover no-repeat;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .site-hero {
    background:
      linear-gradient(rgba(14,7,3,.58), rgba(14,7,3,.68)),
      url("/static/images/banner.svg") center / cover no-repeat;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  line-height: 1.8;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- 站名橫幅（背景圖） ---- */
.site-hero {
  background:
    linear-gradient(rgba(32,15,7,.38), rgba(32,15,7,.52)),
    url("/static/images/banner.svg") center / cover no-repeat;
  text-align: center;
  padding: 3.2rem 1.2rem 2.8rem;
}
.site-hero .site-name {
  display: inline-block; font-size: 2.1rem; font-weight: 700;
  color: #fff; text-shadow: 0 1px 8px rgba(0,0,0,.35);
}
.site-hero .site-name:hover { text-decoration: none; color: #ffd9ae; }
.site-hero .site-zh {
  display: block; font-size: 1.05rem; font-weight: 500;
  color: rgba(255,255,255,.92); margin-top: .2rem; letter-spacing: .35em; text-indent: .35em;
}
.site-tagline { margin: .5rem 0 0; color: rgba(255,255,255,.8); font-size: .92rem; }

/* ---- 導覽列 ---- */
.site-nav-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1.2rem;
  max-width: none; margin: 0; padding: .55rem 1.5rem;
  border-bottom: 1px solid var(--line);
}
.site-nav { display: flex; flex-wrap: wrap; gap: .2rem; }
.site-nav a { color: var(--muted); padding: .25rem .6rem; border-radius: 6px; }
.site-nav a:hover { color: var(--accent); text-decoration: none; }
.site-nav a.on { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.header-tools { display: flex; align-items: center; gap: .5rem; margin-left: auto; }
.search input {
  background: var(--card); color: var(--fg);
  border: 1px solid var(--line); border-radius: 999px;
  padding: .35rem .9rem; width: 9.5rem; font-size: .9rem;
}
.search input:focus { outline: 2px solid var(--accent); border-color: transparent; }
#theme-toggle {
  background: none; border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; width: 2rem; height: 2rem; cursor: pointer; font-size: 1rem;
}
#theme-toggle:hover { color: var(--accent); border-color: var(--accent); }

/* ---- 版面：左側欄 + 主欄 ---- */
.shell {
  display: flex; align-items: flex-start; gap: 2.5rem;
  max-width: none; margin: 0; padding: 1.5rem 1.5rem 3rem;
}
.sidebar { width: 10.5rem; flex-shrink: 0; position: sticky; top: 1rem; }
.sidebar-title {
  font-size: .8rem; font-weight: 600; color: var(--muted);
  letter-spacing: .08em; margin: 0 0 .5rem; padding-left: .6rem;
}
.months { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .15rem; }
.months a {
  display: flex; justify-content: space-between; align-items: baseline;
  color: var(--muted); padding: .3rem .6rem; border-radius: 8px;
  font-size: .92rem; font-variant-numeric: tabular-nums;
}
.months a:hover { color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); text-decoration: none; }
.months a.on { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.months .count { font-size: .8rem; }
main { flex: 1; min-width: 0; max-width: 46rem; }

.page-title { margin: .5rem 0 .2rem; font-size: 1.6rem; }
.muted { color: var(--muted); font-size: .9rem; }

/* ---- 文章卡片 ---- */
.post-list { display: flex; flex-direction: column; gap: .9rem; margin-top: 1rem; }
.post-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 1rem 1.25rem;
}
.post-card h2 { margin: .3rem 0 .2rem; font-size: 1.15rem; }
.post-card h2 a { color: var(--fg); }
.post-card h2 a:hover { color: var(--accent); text-decoration: none; }
.excerpt { margin: .35rem 0 .5rem; color: var(--muted); font-size: .92rem; }
.more { font-size: .88rem; }
.meta { display: flex; align-items: center; gap: .6rem; font-size: .8rem; color: var(--muted); }
.badge {
  border: 1px solid currentColor; border-radius: 999px;
  padding: 0 .55rem; font-size: .75rem; line-height: 1.5;
}
.badge-food { color: var(--c-food); }
.badge-cats { color: var(--c-cats); }
.badge-tech { color: var(--c-tech); }
.badge-life { color: var(--c-life); }

/* ---- 文章內頁 ---- */
.post-header h1 { margin: .4rem 0 .3rem; font-size: 1.7rem; line-height: 1.4; }
.tags { display: flex; flex-wrap: wrap; gap: .4rem; }
.tag { color: var(--muted); font-size: .82rem; }
.post-body { margin-top: 1.2rem; }
.post-body h2 { font-size: 1.3rem; margin: 1.8rem 0 .6rem; border-bottom: 1px solid var(--line); padding-bottom: .3rem; }
.post-body h3 { font-size: 1.1rem; margin: 1.4rem 0 .5rem; }
.post-body p { margin: .9rem 0; }
.post-body img { max-width: 100%; border-radius: 10px; }
.post-body blockquote {
  margin: 1rem 0; padding: .1rem 1rem;
  border-left: 3px solid var(--accent); color: var(--muted);
  background: var(--card); border-radius: 0 8px 8px 0;
}
.post-body pre {
  background: var(--code-bg); border: 1px solid var(--line);
  border-radius: 10px; padding: .9rem 1rem; overflow-x: auto;
  font-size: .88rem; line-height: 1.6;
}
.post-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--code-bg); border-radius: 4px; padding: .1rem .35rem; font-size: .88em;
}
.post-body pre code { background: none; padding: 0; }
.post-body table {
  border-collapse: collapse; width: 100%;
  font-size: .84rem; line-height: 1.55; margin: 1rem 0;
}
.post-body th {
  background: var(--code-bg); text-align: left;
  white-space: nowrap; font-weight: 600;
}
.post-body th, .post-body td { border: 1px solid var(--line); padding: .38rem .55rem; vertical-align: top; }
.post-body td:first-child { white-space: nowrap; font-weight: 600; }
.post-body tbody tr:nth-child(even) { background: color-mix(in srgb, var(--code-bg) 45%, transparent); }
@media (max-width: 720px) {
  .post-body table { display: block; overflow-x: auto; }
}
.post-body hr { border: none; border-top: 1px solid var(--line); margin: 2rem 0; }

/* ---- 廣告位 ---- */
.ad-slot {
  border: 1px dashed var(--line); border-radius: 10px;
  color: var(--muted); text-align: center;
  padding: 1.4rem 1rem; margin: 1.6rem 0; font-size: .85rem;
}

/* ---- footer ---- */
.site-footer {
  border-top: 1px solid var(--line);
  text-align: center; color: var(--muted); font-size: .85rem;
  padding: 1.2rem; margin-top: 2rem;
}
.site-footer a { color: var(--muted); text-decoration: underline; }

/* ---- 手機：側欄收成主欄上方的橫向列 ---- */
/* 寬螢幕：文章置中於視窗，不跟著左側欄排版 */
@media (min-width: 1101px) {
  .shell { display: grid; grid-template-columns: 1fr 46rem 1fr; column-gap: 2rem; }
  .sidebar { grid-column: 1; justify-self: start; }
  .shell > main { grid-column: 2; width: 100%; max-width: 46rem; }
}

@media (max-width: 840px) {
  .shell { flex-direction: column; gap: 1.2rem; }
  .sidebar { position: static; width: 100%; }
  .months { flex-direction: row; flex-wrap: wrap; gap: .3rem; }
  .months a { border: 1px solid var(--line); gap: .3rem; }
  main { max-width: none; }
}
@media (max-width: 640px) {
  .site-hero { padding: 2.2rem 1rem 1.9rem; }
  .site-hero .site-name { font-size: 1.65rem; }
  .header-tools { margin-left: 0; width: 100%; }
  .search { flex: 1; display: flex; }
  .search input { flex: 1; width: auto; }
}

/* ---- 文章標題背景圖（front matter: image:） ---- */
.post-hero {
  background-size: cover;
  background-position: center;
  border-radius: 14px;
  padding: 2.6rem 1.6rem 1.6rem;
  margin-top: .5rem;
}
.post-hero h1 { color: #fff; text-shadow: 0 1px 8px rgba(0,0,0,.4); }
.post-hero .meta, .post-hero time { color: rgba(255,255,255,.88); }
.post-hero .tag { color: rgba(255,255,255,.75); }
.post-hero .badge { color: #fff; border-color: rgba(255,255,255,.7); }

/* ---- 語言切換鈕 ---- */
.lang-switch {
  display: flex; flex-wrap: wrap; align-items: center; gap: .35rem;
  margin: 1rem 0 0; padding: .5rem .7rem;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  font-size: .88rem;
}
.lang-icon { margin-right: .15rem; }
.lang-switch a {
  color: var(--muted); padding: .15rem .6rem; border-radius: 999px;
}
.lang-switch a:hover { color: var(--accent); text-decoration: none; background: color-mix(in srgb, var(--accent) 10%, transparent); }
.lang-switch a.on { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); font-weight: 600; }

/* ---- 表格冠軍列上色 ---- */
.post-body tbody tr:has(.tw) {
  background: color-mix(in srgb, var(--accent) 15%, transparent);
}
.post-body tbody tr:has(.tw) td:first-child { color: var(--accent); }
.tw { margin-right: .2rem; font-size: .9em; }

/* ============ 無障礙（a11y） ============ */

/* 跳至主要內容：平時隱藏，鍵盤 Tab 聚焦時才出現 */
.skip-link {
  position: absolute; left: .5rem; top: -3rem;
  background: var(--accent); color: #fff;
  padding: .5rem 1rem; border-radius: 0 0 8px 8px;
  z-index: 100; transition: top .15s;
}
.skip-link:focus { top: 0; text-decoration: none; }
main:focus { outline: none; }

/* 統一的鍵盤聚焦樣式：只在鍵盤操作時出現，滑鼠點擊不顯示 */
a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

/* 尊重「減少動態效果」的系統設定 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* 高對比模式：確保邊框看得見 */
@media (prefers-contrast: more) {
  :root { --muted: #4a4f56; --line: #9aa0a8; }
  :root[data-theme="dark"] { --muted: #c8c2ba; --line: #6b6560; }
}
