/* 所有站共用的版面；各站的主色由 site.yaml 的 theme.primary_color 注入 --primary */

:root {
  --primary: #1f6feb;
  --link: var(--primary);
  --text: #1c1e21;
  --muted: #5b6168;
  --bg: #ffffff;
  --surface: #f5f6f8;
  --border: #e3e5e8;
  --measure: 46rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --link: color-mix(in srgb, var(--primary) 45%, #ffffff);
    --text: #e6e8eb;
    --muted: #a3a9b0;
    --bg: #15171a;
    --surface: #1e2125;
    --border: #2e3237;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  font-size: 1.0625rem;
  line-height: 1.8;
  text-rendering: optimizeLegibility;
}

a { color: var(--link); text-underline-offset: 0.2em; }
a:hover { text-decoration-thickness: 2px; }
img { max-width: 100%; height: auto; }

.wrap { width: 100%; max-width: var(--measure); margin-inline: auto; padding-inline: 1.25rem; }

.skip-link { position: absolute; left: -999px; top: 0.5rem; padding: 0.5rem 1rem; background: var(--bg); z-index: 10; }
.skip-link:focus { left: 0.5rem; }

/* ---- 頁首、頁尾 ---- */

.site-header { border-bottom: 1px solid var(--border); }
.site-header .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1.5rem; padding-block: 0.875rem; }
.brand { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--text); font-weight: 700; font-size: 1.125rem; text-decoration: none; }
.site-header ul, .site-footer ul { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; margin: 0; padding: 0; list-style: none; }
.site-header nav a { display: inline-block; padding-block: 0.25rem; color: var(--muted); text-decoration: none; }
.site-header nav a:hover { color: var(--link); }

main { padding-block: 2rem 3rem; }

.site-footer { border-top: 1px solid var(--border); color: var(--muted); font-size: 0.875rem; }
.site-footer .wrap { padding-block: 1.5rem; }
.site-footer a { color: var(--muted); display: inline-block; padding-block: 0.25rem; }
.site-footer p { margin: 0.5rem 0 0; }

/* ---- 列表頁 ---- */

.listing-header h1 { margin: 0 0 0.25rem; font-size: 1.875rem; line-height: 1.35; }
.listing-header p { margin: 0; color: var(--muted); }

.post-list { margin: 1.5rem 0 0; padding: 0; list-style: none; }
.post-list li { padding-block: 1.25rem; border-bottom: 1px solid var(--border); }
.post-list h2 { margin: 0 0 0.375rem; font-size: 1.25rem; line-height: 1.5; }
.post-list h2 a { color: var(--text); text-decoration: none; }
.post-list h2 a:hover { color: var(--link); }
.post-list p { margin: 0; }

.post-meta { color: var(--muted); font-size: 0.875rem; }
.post-meta span + span::before { content: "·"; margin-inline: 0.5rem; }
.post-list .post-meta { margin-top: 0.375rem; }
.post-meta a { color: var(--muted); }

.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 2rem; color: var(--muted); font-size: 0.9375rem; }
.pager a { padding: 0.5rem 0; }
.empty { color: var(--muted); padding-block: 2rem; }

/* ---- 文章 ---- */

.breadcrumb ol { display: flex; flex-wrap: wrap; margin: 0 0 1rem; padding: 0; list-style: none; font-size: 0.875rem; color: var(--muted); }
.breadcrumb li:not(:last-child)::after { content: "›"; margin-inline: 0.5rem; }
.breadcrumb a { color: var(--muted); }

.post h1 { margin: 0 0 0.5rem; font-size: 2rem; line-height: 1.4; }
.post > header { margin-bottom: 1.5rem; }
.cover { display: block; width: 100%; border-radius: 0.5rem; margin-bottom: 1.5rem; }

.toc { background: var(--surface); border-radius: 0.5rem; padding: 1rem 1.25rem; margin-bottom: 2rem; font-size: 0.9375rem; }
.toc-title { margin: 0 0 0.25rem; font-weight: 700; }
.toc ol { margin: 0; padding-left: 1.25rem; }
.toc .toc-h3 { margin-left: 1rem; list-style: circle; }

.content h2 { margin: 2.5rem 0 0.75rem; font-size: 1.5rem; line-height: 1.45; scroll-margin-top: 1rem; }
.content h3 { margin: 2rem 0 0.5rem; font-size: 1.25rem; line-height: 1.5; scroll-margin-top: 1rem; }
.content p, .content ul, .content ol { margin: 0 0 1.25rem; }
.content li + li { margin-top: 0.25rem; }
.content blockquote { margin: 1.5rem 0; padding: 0.25rem 1.25rem; border-left: 4px solid var(--primary); background: var(--surface); color: var(--muted); }
.content code { background: var(--surface); padding: 0.1em 0.35em; border-radius: 0.25rem; font-size: 0.9em; }
.content pre { background: var(--surface); padding: 1rem; border-radius: 0.5rem; overflow-x: auto; line-height: 1.6; }
.content pre code { background: none; padding: 0; }
.content table { display: block; overflow-x: auto; border-collapse: collapse; margin: 1.5rem 0; font-size: 0.9375rem; }
.content th, .content td { border: 1px solid var(--border); padding: 0.5rem 0.75rem; text-align: left; vertical-align: top; }
.content th { background: var(--surface); }
.content hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }
.content .footnotes { font-size: 0.875rem; color: var(--muted); }

.faq, .sources, .related { margin-top: 2.5rem; }
.faq h2, .sources h2, .related h2 { font-size: 1.375rem; margin: 0 0 0.75rem; }
.faq h3 { font-size: 1.0625rem; margin: 1.25rem 0 0.25rem; }
.faq p { margin: 0; }
.sources ol { padding-left: 1.25rem; font-size: 0.9375rem; }
.sources li { overflow-wrap: anywhere; }

.notice { margin-top: 2rem; padding: 1rem 1.25rem; border: 1px solid var(--border); border-radius: 0.5rem; color: var(--muted); font-size: 0.875rem; }

.tags { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 2rem; }
.tags a { padding: 0.25rem 0.75rem; background: var(--surface); border-radius: 999px; font-size: 0.875rem; text-decoration: none; }

.author-box { margin-top: 2rem; padding: 1rem 1.25rem; background: var(--surface); border-radius: 0.5rem; font-size: 0.9375rem; }
.author-box p { margin: 0; }
.author-box .author-name { font-weight: 700; }

.related ul { padding-left: 1.25rem; }
.related li { padding-block: 0.25rem; }

.error-page h1 { font-size: 1.875rem; }
