/* ============================================================
   indie-blog 樣式 — 閱讀導向、簡潔、響應式、支援深色模式
   ============================================================ */

:root {
  --bg: #fbfbf9;
  --surface: #ffffff;
  --text: #1f2328;
  --muted: #6b7280;
  --line: #e7e5e0;
  --accent: #2f6f6b;        /* 沉靜青綠 */
  --accent-soft: #e6f0ef;
  --code-bg: #f3f1ec;
  --maxw: 720px;
  --radius: 10px;
}

html[data-theme="dark"] {
  --bg: #15171a;
  --surface: #1d2024;
  --text: #e6e6e3;
  --muted: #9aa0a6;
  --line: #2c3036;
  --accent: #5fb3ad;
  --accent-soft: #1c2b2a;
  --code-bg: #23272c;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui,
    -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.75;
  font-size: 17px;
}

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- 頂欄 ---------- */
.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: saturate(1.1) blur(6px);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  max-width: 980px;
}
.brand {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: .5px;
}
.nav {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: .95rem;
}
.nav a {
  color: var(--muted);
  text-decoration: none;
}
.nav a:hover { color: var(--accent); }

.theme-toggle {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  width: 34px; height: 34px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}
.theme-toggle:hover { border-color: var(--accent); }

/* ---------- Hero / 首頁 ---------- */
.hero {
  padding: 56px 0 28px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
}
.hero h1 {
  font-size: 2.1rem;
  margin: 0 0 10px;
  letter-spacing: .5px;
}
.lede {
  color: var(--muted);
  font-size: 1.1rem;
  margin: 0;
  max-width: 60ch;
}

/* ---------- 文章卡片 ---------- */
.post-list { padding: 20px 0 40px; }
.post-item {
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
}
.post-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .85rem;
  color: var(--muted);
  margin-bottom: 6px;
}
.post-meta time { letter-spacing: .3px; }
.post-title {
  font-size: 1.35rem;
  margin: 0 0 8px;
  line-height: 1.4;
}
.post-title a {
  color: var(--text);
  text-decoration: none;
}
.post-title a:hover { color: var(--accent); }
.post-excerpt {
  margin: 0 0 10px;
  color: var(--muted);
}
.post-tags { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- chips ---------- */
.chip {
  display: inline-block;
  font-size: .8rem;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  text-decoration: none;
  border: 1px solid transparent;
  transition: .15s;
}
.chip.cat { font-weight: 600; }
a.chip:hover { border-color: var(--accent); }
.chip.filter {
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
}
.chip.filter:hover { border-color: var(--accent); }
.chip.filter.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.chip .count {
  opacity: .7;
  font-size: .75rem;
  margin-left: 2px;
}

/* ---------- 單篇文章 ---------- */
.post-page { padding: 36px 0 60px; }
.post-header { margin-bottom: 28px; }
.post-heading {
  font-size: 2rem;
  line-height: 1.35;
  margin: 10px 0 14px;
}
.post-body {
  position: relative;
}
.post-content { font-size: 1.075rem; line-height: 1.85; }
.post-content h2 {
  margin: 2.2em 0 .7em;
  font-size: 1.55rem;
  border-left: 4px solid var(--accent);
  padding-left: 12px;
  line-height: 1.4;
  scroll-margin-top: 80px;
}
.post-content h3 { margin: 1.6em 0 .6em; font-size: 1.2rem; }
.post-content p { margin: 0 0 1.25em; }
.post-content img { max-width: 100%; border-radius: var(--radius); }
.post-content blockquote {
  margin: 1.4em 0;
  padding: 12px 20px;
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  color: var(--text);
  border-radius: 0 var(--radius) var(--radius) 0;
  line-height: 1.8;
}
.post-content pre {
  background: var(--code-bg);
  padding: 14px 16px;
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: .92rem;
  line-height: 1.6;
}
.post-content code {
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: .9em;
}
.post-content pre code { background: none; padding: 0; }
.post-content ul, .post-content ol { padding-left: 1.4em; margin: 0 0 1.2em; line-height: 1.85; }
.post-content a { color: var(--accent); }
.post-content hr { border: none; border-top: 1px solid var(--line); margin: 2.2em 0; }

/* ---------- 表格（補格線） ---------- */
.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.6em 0;
  font-size: .97rem;
  line-height: 1.7;
}
.post-content th, .post-content td {
  border: 1px solid var(--line);
  padding: 9px 14px;
  text-align: left;
  vertical-align: top;
}
.post-content thead th {
  background: var(--accent-soft);
  font-weight: 700;
  color: var(--text);
}
.post-content tbody tr:nth-child(even) td { background: var(--bg); }
.post-content table caption { color: var(--muted); font-size: .85rem; margin-top: .6em; }

/* ---------- 系列閱讀路徑 ---------- */
.series-path {
  margin: 0 0 32px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
}
.series-path-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--line);
}
.series-path-label {
  font-size: .78rem;
  letter-spacing: .5px;
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
}
.series-path-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}
.series-path-progress {
  margin-left: auto;
  font-size: .82rem;
  color: var(--muted);
  padding: 2px 10px;
  background: var(--accent-soft);
  border-radius: 999px;
}
.series-path-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 2px;
}
.series-path-list li { margin: 0; }
.series-path-list a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: .93rem;
  transition: background .12s;
}
.series-path-list a:hover { background: var(--accent-soft); color: var(--text); }
.series-path-list .current a {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.series-path-list .current a::after {
  content: '· 本文';
  margin-left: auto;
  font-size: .78rem;
  font-weight: 400;
  opacity: .75;
}
.series-idx {
  display: inline-block;
  min-width: 26px;
  text-align: center;
  font-size: .78rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 4px;
  background: var(--bg);
}
.series-path-list .current .series-idx {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ---------- 本文目錄 TOC ---------- */
.toc {
  float: right;
  width: 220px;
  margin: 0 0 24px 24px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: .88rem;
}
.toc-title {
  margin: 0 0 8px;
  font-size: .82rem;
  letter-spacing: .5px;
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
}
.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.toc-list li { margin: 4px 0; }
.toc-list a {
  color: var(--muted);
  text-decoration: none;
  display: block;
  padding: 3px 0;
  border-left: 2px solid transparent;
  padding-left: 8px;
  line-height: 1.45;
}
.toc-list a:hover {
  color: var(--accent);
  border-left-color: var(--accent);
}

.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 48px 0 16px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: .95rem;
}
.post-nav a { color: var(--accent); text-decoration: none; }
.post-nav span:last-child { text-align: right; }
.post-nav a:hover { text-decoration: underline; }
.back { margin-top: 8px; }
.back a { color: var(--muted); text-decoration: none; }

/* ---------- 文章列表 / 分類頁 ---------- */
.page-title { font-size: 1.8rem; margin: 36px 0 6px; }
.archive { padding-bottom: 60px; }
.year-block { margin: 28px 0; }
.year-block h2 { color: var(--accent); border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.archive-list { list-style: none; padding: 0; }
.archive-list li {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
  flex-wrap: wrap;
}
.archive-list time { color: var(--muted); font-size: .85rem; min-width: 92px; }
.archive-list a { color: var(--text); text-decoration: none; flex: 1; }
.archive-list a:hover { color: var(--accent); }

/* ---------- 系列總覽（archive 頁頂） ---------- */
.series-overview {
  margin: 8px 0 36px;
  padding: 20px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
}
.series-overview-h {
  margin: 0 0 4px;
  font-size: 1.15rem;
  color: var(--accent);
}
.series-card {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}
.series-card:first-of-type { border-top: none; padding-top: 4px; }
.series-card h3 {
  margin: 0 0 8px;
  font-size: 1rem;
  color: var(--text);
}
.series-card h3 .muted { font-weight: 400; font-size: .85rem; margin-left: 4px; }
.series-card .archive-list li {
  font-size: .95rem;
  padding: 7px 0;
}

.topics { padding-bottom: 60px; }
.filter-group { margin: 18px 0; }
.filter-group h3 { font-size: 1.05rem; margin: 0 0 8px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.filter-status { margin: 14px 0; font-size: .9rem; color: var(--accent); min-height: 1.2em; }

.more { margin: 26px 0; }
.more a { color: var(--accent); text-decoration: none; font-weight: 600; }
.muted { color: var(--muted); }

/* ---------- 跨站 banner ---------- */
.cross-banner {
  margin: 20px 0 12px;
  padding: 14px 20px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: .95rem;
}
.cross-banner-text { color: var(--text); }
.cross-banner-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
.cross-banner-link:hover { text-decoration: underline; }

.footer-crosslink { margin: 8px 0 0; font-size: .9rem; }
.footer-crosslink a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
.footer-crosslink a:hover { text-decoration: underline; }

/* ---------- 頁尾 ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  margin-top: 40px;
  padding: 26px 0;
  color: var(--muted);
  font-size: .88rem;
}
.site-footer p { margin: 4px 0; }

/* ---------- 響應式 ---------- */
@media (max-width: 860px) {
  .toc {
    float: none;
    width: auto;
    margin: 0 0 22px;
    font-size: .9rem;
  }
  .toc-title { margin-bottom: 6px; }
  .toc-list { columns: 2; column-gap: 16px; }
  .toc-list li { break-inside: avoid; }
}
@media (max-width: 600px) {
  body { font-size: 16px; }
  .header-inner { height: 54px; }
  .nav { gap: 11px; font-size: .85rem; }
  .hero { padding: 36px 0 20px; }
  .hero h1 { font-size: 1.7rem; }
  .post-heading { font-size: 1.6rem; }
  .post-content { font-size: 1.025rem; }
  .series-path { padding: 14px 14px; }
  .series-path-head { gap: 6px; }
  .series-path-progress { margin-left: 0; }
  .toc-list { columns: 1; }
}

/* ---------- 無障礙：減少動畫偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- 留言區 ---------- */
.comments {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}
.comments-title {
  font-size: 1.25rem;
  margin: 0 0 16px;
  color: var(--text);
}
.comments-list { margin-bottom: 28px; }
.comments-loading { margin: 0; }
.comment-card {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 12px;
}
.comment-meta {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
}
.comment-name { font-weight: 600; color: var(--accent); }
.comment-time { font-size: .8rem; color: var(--muted); }
.comment-body {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

.comment-form { display: block; }
.form-row { margin-bottom: 14px; }
.form-row label {
  display: block;
  font-size: .9rem;
  color: var(--muted);
  margin-bottom: 6px;
}
.form-row .req { color: #c0563f; margin-left: 2px; }
.comment-form input[type="text"],
.comment-form textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.6;
}
.comment-form input[type="text"]:focus,
.comment-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.comment-form textarea { resize: vertical; }
.form-error {
  color: #c0563f;
  font-size: .85rem;
  margin: 6px 0 0;
  min-height: 1.1em;
}
/* 蜜罐：正常人看不見也不會填 */
.hp-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.chars-hint { font-size: .8rem; color: var(--muted); }
.btn-primary {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  padding: 9px 20px;
  border-radius: var(--radius);
  font-size: .95rem;
  cursor: pointer;
  transition: .15s;
}
.btn-primary:hover { opacity: .92; }
.btn-primary:disabled { opacity: .55; cursor: default; }

@media (max-width: 600px) {
  .form-actions { flex-direction: column-reverse; align-items: stretch; }
  .btn-primary { width: 100%; }
  .chars-hint { text-align: right; }
}
