/* =========================================================
   COMILE 網路行銷 · 部落格 / 文章模組
   依附於 comile.css 的設計令牌，僅部落格前台載入
   ========================================================= */

/* ---------- 版面：主內容 + 側欄 ---------- */
.blog-wrap { background: var(--bg-light); padding: 64px 0 96px; }
.blog-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 40px;
  align-items: start;
}
.blog-main { min-width: 0; }

/* ---------- 工具列：結果數 + 搜尋 ---------- */
.blog-bar {
  display: flex; flex-wrap: wrap; gap: 16px;
  align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.blog-bar .result-info { color: var(--text-muted); font-size: 14px; }
.blog-bar .result-info strong { color: var(--text-dark); font-weight: 700; }

.searchbox { display: flex; gap: 8px; }
.searchbox input {
  width: 240px; height: 44px; padding: 0 14px;
  border: 1px solid var(--border-light); border-radius: var(--radius-sm);
  background: var(--card-light); font-family: inherit; font-size: 14px; color: var(--text-dark);
}
.searchbox input::placeholder { color: #9A9A9F; }
.searchbox input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.searchbox button {
  height: 44px; padding: 0 20px; border: 0; cursor: pointer;
  border-radius: var(--radius-sm); background: var(--accent); color: #fff;
  font-size: 14px; font-weight: 700; transition: background .2s ease;
}
.searchbox button:hover { background: var(--accent-hover); }

/* ---------- 分類膠囊 ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 28px; }
.chip {
  display: inline-block; padding: 7px 16px; border-radius: 999px;
  border: 1px solid var(--border-light); background: var(--card-light);
  font-size: 13px; color: var(--text-muted); transition: border-color .2s ease, color .2s ease;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.active { background: var(--text-dark); border-color: var(--text-dark); color: #fff; }

/* ---------- 文章卡片網格 ---------- */
.post-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.post-card {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--card-light); border: 1px solid var(--border-light);
  border-radius: var(--radius);
  color: inherit; text-decoration: none;
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}
.post-card:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 140, 66, .45);
  box-shadow: 0 14px 34px rgba(22, 22, 24, .10);
}
.post-card .cover { position: relative; aspect-ratio: 16 / 9; overflow: hidden; background: #EFEDE6; }
.post-card .cover img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s ease; }
.post-card:hover .cover img { transform: scale(1.04); }
.post-card .body { padding: 20px 22px 22px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.post-card h3 {
  font-size: 17px; font-weight: 700; line-height: 1.5; color: var(--text-dark);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  transition: color .2s ease;
}
.post-card:hover h3 { color: var(--accent); }
.post-card .excerpt {
  font-size: 14px; color: var(--text-muted); line-height: 1.7;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.post-meta {
  display: flex; flex-wrap: wrap; gap: 14px; align-items: center;
  margin-top: auto; padding-top: 12px;
  font-size: 12.5px; color: #8A8A90; border-top: 1px solid var(--border-light);
}
.post-meta span { display: inline-flex; align-items: center; gap: 5px; }
.post-meta svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; flex: none; }

/* 置頂標記 */
.pin-flag {
  position: absolute; top: 12px; left: 12px; z-index: 2;
  padding: 4px 10px; border-radius: 999px;
  background: var(--accent); color: #fff; font-size: 11.5px; font-weight: 700;
}

/* 空狀態 */
.empty-state {
  padding: 72px 24px; text-align: center;
  background: var(--card-light); border: 1px dashed var(--border-light); border-radius: var(--radius);
}
.empty-state svg { width: 44px; height: 44px; stroke: #C9C4B8; fill: none; stroke-width: 1.6; margin: 0 auto 14px; }
.empty-state p { color: var(--text-muted); font-size: 15px; }

/* ---------- 分頁 ---------- */
.pagination { margin-top: 40px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pagination .info { margin-right: auto; font-size: 13px; color: var(--text-muted); }
.pagination a,
.pagination span,
.pagination b {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 40px; height: 40px; padding: 0 12px;
  border: 1px solid var(--border-light); border-radius: var(--radius-sm);
  background: var(--card-light); color: var(--text-muted);
  font-family: var(--font-en); font-size: 14px; font-weight: 600;
  transition: border-color .2s ease, color .2s ease, background .2s ease;
}
.pagination .info { border: 0; background: none; min-width: 0; padding: 0; height: auto; font-family: var(--font-zh); }
.pagination a:hover { border-color: var(--accent); color: var(--accent); }
.pagination span.current,
.pagination b {
  background: var(--accent); border-color: var(--accent); color: #fff;
}

/* ---------- 側欄 ---------- */
.blog-side { display: flex; flex-direction: column; gap: 20px; position: sticky; top: calc(var(--header-h) + 20px); }
.side-card {
  background: var(--card-light); border: 1px solid var(--border-light);
  border-radius: var(--radius); padding: 22px;
}
.side-card h4 {
  font-size: 15px; font-weight: 800; color: var(--text-dark);
  padding-bottom: 12px; margin-bottom: 14px; border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; gap: 8px;
}
.side-card h4::before { content: ""; width: 3px; height: 15px; border-radius: 2px; background: var(--accent); flex: none; }
.side-card ul li { padding: 9px 0; border-bottom: 1px dashed var(--border-light); }
.side-card ul li:last-child { border-bottom: 0; padding-bottom: 0; }
.side-card ul li a { font-size: 14px; color: var(--text-muted); line-height: 1.6; transition: color .2s ease; }
.side-card ul li a:hover { color: var(--accent); }
.side-card ul li i { font-style: normal; font-size: 12px; color: #A9A9AE; }
.side-card ul.topic li,
.side-card ul.comment li { display: block; }

/* 側欄 CTA */
.side-cta { background: var(--bg-dark); border-color: var(--bg-dark); color: var(--text-invert); text-align: center; }
.side-cta h4 { color: var(--text-invert); border-bottom-color: var(--border-dark); justify-content: center; }
.side-cta p { font-size: 14px; color: var(--text-muted-invert); line-height: 1.7; margin-bottom: 16px; }
.side-cta .btn { width: 100%; justify-content: center; }
.side-cta .side-tel {
  display: block; margin-top: 12px; font-family: var(--font-en);
  font-size: 15px; font-weight: 700; color: var(--accent);
}

/* ---------- 麵包屑 ---------- */
.breadcrumb {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-muted-invert); margin-bottom: 18px;
}
.breadcrumb a { color: var(--text-muted-invert); transition: color .2s ease; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { opacity: .45; }
.breadcrumb .current { color: var(--text-invert); }

/* ---------- 文章詳情 ---------- */
.article-hero { background: var(--bg-dark); color: var(--text-invert); padding: 44px 0 56px; }
.article-hero h1 {
  font-size: clamp(26px, 3.4vw, 40px); font-weight: 900;
  line-height: 1.32; letter-spacing: -0.01em; max-width: 900px;
}
.article-meta {
  display: flex; flex-wrap: wrap; gap: 18px; margin-top: 20px;
  font-size: 13.5px; color: var(--text-muted-invert);
}
.article-meta span { display: inline-flex; align-items: center; gap: 6px; }
.article-meta svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; flex: none; }

.article-card {
  background: var(--card-light); border: 1px solid var(--border-light);
  border-radius: var(--radius); padding: 40px;
}

/* 文章正文（使用者產生內容） */
.article-body { color: #2C2C31; font-size: 16.5px; line-height: 1.9; overflow-wrap: break-word; }
.article-body p { margin: 0 0 18px; }
.article-body h1, .article-body h2, .article-body h3, .article-body h4 {
  color: var(--text-dark); font-weight: 800; line-height: 1.4; margin: 34px 0 14px;
}
.article-body h1 { font-size: 26px; }
.article-body h2 { font-size: 22px; padding-left: 14px; border-left: 4px solid var(--accent); }
.article-body h3 { font-size: 18px; }
.article-body a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.article-body img { border-radius: var(--radius-sm); margin: 18px auto; height: auto; }
.article-body ul, .article-body ol { margin: 0 0 18px; padding-left: 22px; }
.article-body ul li { list-style: disc; margin-bottom: 8px; }
.article-body ol li { list-style: decimal; margin-bottom: 8px; }
.article-body blockquote {
  margin: 20px 0; padding: 16px 20px; border-left: 4px solid var(--accent);
  background: var(--bg-light); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--text-muted);
}
.article-body table { width: 100%; border-collapse: collapse; margin: 20px 0; font-size: 15px; }
.article-body th, .article-body td { border: 1px solid var(--border-light); padding: 10px 12px; text-align: left; }
.article-body th { background: var(--bg-light); font-weight: 700; }
.article-body pre {
  background: var(--bg-dark); color: var(--text-invert); padding: 18px;
  border-radius: var(--radius-sm); overflow-x: auto; font-size: 14px; margin: 18px 0;
}
.article-body code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .92em; }
.article-body hr { border: 0; border-top: 1px solid var(--border-light); margin: 28px 0; }

/* 上下篇 */
.post-nav {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  margin-top: 32px; padding-top: 26px; border-top: 1px solid var(--border-light);
}
.post-nav .nav-cell {
  display: block; padding: 16px 18px; border-radius: var(--radius-sm);
  background: var(--bg-light); border: 1px solid var(--border-light);
  font-size: 14px; color: var(--text-muted); line-height: 1.6;
  transition: border-color .2s ease;
}
.post-nav .nav-cell:hover { border-color: var(--accent); }
.post-nav .nav-cell a { color: var(--text-dark); transition: color .2s ease; }
.post-nav .nav-cell:hover a { color: var(--accent); }
.post-nav small { display: block; font-size: 12px; color: #9A9A9F; margin-bottom: 4px; }
.post-nav .nav-cell.disabled { opacity: .55; }

/* 螢幕閱讀器專用文字 */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.admin-tools { margin-top: 22px; padding-top: 16px; border-top: 1px dashed var(--border-light); font-size: 13px; color: var(--text-muted); }
.admin-tools a { color: var(--accent); margin-right: 14px; }

/* 文章內密碼提示 */
.article-body .search-text {
  height: 44px; padding: 0 14px; border: 1px solid var(--border-light);
  border-radius: var(--radius-sm); font-family: inherit; font-size: 14px;
}
.article-body .search-submit {
  height: 44px; padding: 0 20px; border: 0; cursor: pointer;
  border-radius: var(--radius-sm); background: var(--accent); color: #fff; font-weight: 700;
}

/* ---------- 歸檔 ---------- */
.archive-list h2 { font-size: 22px; font-weight: 800; margin: 30px 0 12px; color: var(--text-dark); font-family: var(--font-en); }
.archive-list h2:first-child { margin-top: 0; }
.archive-list ul { padding-left: 0; }
.archive-list > ul > li,
.archive-list li { list-style: none; }
.archive-list span b { display: inline-block; font-size: 14px; color: var(--accent); margin: 10px 0 6px; font-family: var(--font-en); }
.archive-list ul ul li {
  padding: 8px 0; border-bottom: 1px dashed var(--border-light);
  font-size: 14.5px; color: var(--text-muted);
}
.archive-list ul ul li a { color: var(--text-dark); }
.archive-list ul ul li a:hover { color: var(--accent); }
.archive-list em { font-style: normal; font-size: 12.5px; color: #A9A9AE; }

/* ---------- 評論列表 ---------- */
.comment-list li {
  background: var(--card-light); border: 1px solid var(--border-light);
  border-radius: var(--radius-sm); padding: 18px 20px; margin-bottom: 14px; list-style: none;
}
.comment-meta {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  font-size: 13px; color: #9A9A9F; margin-bottom: 8px;
}
.comment-meta cite { font-style: normal; font-weight: 700; color: var(--text-dark); }
.comment-meta a { color: inherit; }
.comment-meta .reply a { color: var(--accent); }
.comment-list p { font-size: 15px; color: var(--text-muted); line-height: 1.7; }
.comment-list .re {
  margin-top: 10px; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--bg-light); font-size: 14px;
}
.comment-list .re strong { color: var(--accent); }

/* ---------- 友情連結 ---------- */
.flinks { display: flex; flex-wrap: wrap; gap: 10px 20px; }
.flinks a { font-size: 13.5px; color: var(--text-muted); transition: color .2s ease; }
.flinks a:hover { color: var(--accent); }

/* ---------- 回頂部 ---------- */
.to-top {
  position: fixed; right: 24px; bottom: 24px; z-index: 60;
  width: 46px; height: 46px; border: 0; cursor: pointer;
  border-radius: 50%; background: var(--text-dark); color: #fff;
  display: none; align-items: center; justify-content: center;
  box-shadow: 0 8px 22px rgba(22, 22, 24, .22); transition: background .2s ease;
}
.to-top:hover { background: var(--accent); }
.to-top.show { display: flex; }
.to-top svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2.2; }

/* ---------- 響應式 ---------- */
@media (max-width: 980px) {
  .blog-layout { grid-template-columns: 1fr; gap: 32px; }
  .blog-side { position: static; }
  .article-card { padding: 28px; }
}
@media (max-width: 640px) {
  .blog-wrap { padding: 40px 0 64px; }
  .post-grid { grid-template-columns: 1fr; }
  .post-nav { grid-template-columns: 1fr; }
  .blog-bar { flex-direction: column; align-items: stretch; }
  .searchbox { width: 100%; }
  .searchbox input { flex: 1; width: auto; }
  .article-card { padding: 20px; }
  .article-body { font-size: 16px; }
  .pagination .info { width: 100%; margin-bottom: 8px; }
  .to-top { right: 16px; bottom: 16px; }
}
