/* ==========================================================================
   article：部落格文章深度閱讀版型
   ========================================================================== */

/* 閱讀進度條 */
.read-progress { position: fixed; inset: 0 0 auto; height: 3px; z-index: 65; pointer-events: none; }
.read-progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand-deep), var(--brand)); transform: scaleX(0); transform-origin: left; }

/* 主視覺 */
.article-hero.hero { min-height: min(84svh, 820px); padding-bottom: clamp(88px, 10vw, 150px); }
.article-hero__inner { display: grid; gap: 16px; }
.article-hero__inner > * { max-width: min(100%, 62vw); }
@media (max-width: 899px) { .article-hero__inner > * { max-width: 100%; } }
.article-hero .hero__kicker a { color: inherit; }
.article-hero__title { font-family: var(--font-serif); font-weight: 900; font-size: clamp(2.1rem, 5vw, 4.6rem); line-height: 1.16; letter-spacing: -.015em; max-width: 18em; }
.article-hero__dek { max-width: 40em; color: var(--muted); font-size: var(--fs-lead); line-height: 1.8; }
.article-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; margin-top: 8px; }
.article-meta__avatar {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--brand); color: var(--ink); font-family: var(--font-serif); font-weight: 900; font-size: 1.2rem;
}
.article-meta__who { display: grid; line-height: 1.4; }
.article-meta__who b { font-weight: 700; font-size: .95rem; }
.article-meta__who span { font-size: .78rem; color: var(--faint); }
.article-meta__facts { display: flex; flex-wrap: wrap; gap: 4px 16px; font-family: var(--font-mono); font-size: .72rem; letter-spacing: .08em; color: var(--muted); }
@media (min-width: 768px) { .article-meta__facts { padding-left: 18px; border-left: 1px solid var(--line); } }

/* 封面：壓在主視覺下緣、不裁切（封面圖常有字） */
.article-body { padding-bottom: var(--section-y); }
.article-cover {
  position: relative; z-index: 2; max-width: 1100px; margin: calc(clamp(60px, 8vw, 120px) * -1) auto clamp(48px, 6vw, 88px);
  border-radius: var(--radius); overflow: hidden; background: #fff;
  box-shadow: 0 40px 100px rgba(11, 24, 48, .22);
}
.article-cover img { width: 100%; height: auto; display: block; }

/* 三欄 */
.article-grid { display: grid; gap: 40px; grid-template-columns: minmax(0, 1fr); }
.article-toc, .article-rail { display: none; }
@media (min-width: 1200px) {
  .article-grid { grid-template-columns: 220px minmax(0, 46rem) 220px; justify-content: space-between; align-items: start; }
  .article-toc, .article-rail { display: block; position: sticky; top: calc(var(--header-h) + 28px); }
  .article-entry #ez-toc-container { display: none; }
}
.article-aside__title { font-family: var(--font-mono); font-size: var(--fs-mono); letter-spacing: .16em; color: var(--faint); margin-bottom: 14px; }
.toc { display: grid; gap: 2px; border-left: 1px solid var(--line); counter-reset: toc; }
.toc a {
  position: relative; display: block; padding: 8px 0 8px 18px; margin-left: -1px;
  border-left: 2px solid transparent; font-size: .875rem; line-height: 1.55; color: var(--muted);
  transition: color var(--m-fast) var(--m-ease), border-color var(--m-base) var(--m-ease);
}
.toc a::before { counter-increment: toc; content: counter(toc, decimal-leading-zero); display: block; font-family: var(--font-mono); font-size: .65rem; letter-spacing: .1em; color: var(--faint); }
.toc a.is-active { color: var(--fg); border-left-color: var(--brand); }
.toc a.is-active::before { color: var(--accent-text); }
@media (hover: hover) { .toc a:hover { color: var(--fg); } }

.share { display: grid; gap: 8px; margin-bottom: 28px; }
.share__btn {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 14px; border-radius: 12px;
  box-shadow: inset 0 0 0 1px var(--line); font-size: .875rem; color: var(--muted); text-align: left;
  transition: color var(--m-fast) var(--m-ease), box-shadow var(--m-fast) var(--m-ease), background var(--m-fast) var(--m-ease);
}
@media (hover: hover) { .share__btn:hover { color: var(--fg); box-shadow: inset 0 0 0 1px var(--fg); } }
.rail-card { border-radius: var(--radius); padding: 22px; display: grid; gap: 10px; background: var(--bg); color: var(--fg); }
.rail-card__kicker { font-family: var(--font-mono); font-size: .68rem; letter-spacing: .14em; color: var(--brand); }
.rail-card__title { font-family: var(--font-serif); font-weight: 900; font-size: 1.3rem; line-height: 1.3; }
.rail-card__text { font-size: .85rem; line-height: 1.75; color: var(--muted); }
.rail-card .btn { justify-self: start; margin-top: 4px; }

/* 內文：導言、章節編號、加寬圖片、表格、FAQ */
.article-entry { counter-reset: sec; font-size: 1.08rem; }
.article-entry > p:first-of-type { font-size: 1.22rem; line-height: 1.95; color: var(--fg); }
.article-entry h2 {
  counter-increment: sec; position: relative;
  padding-top: 1.1em; border-top: 1px solid var(--line); margin-top: 2.6em;
}
.article-entry h2::before {
  content: counter(sec, decimal-leading-zero); display: block; margin-bottom: .5em;
  font-family: var(--font-mono); font-weight: 500; font-size: .8rem; letter-spacing: .16em; color: var(--accent-text);
}
.article-entry h2 .ez-toc-section, .article-entry h2 .ez-toc-section-end { display: none; }
@media (min-width: 1200px) {
  .article-entry > figure, .article-entry > p > img:only-child, .article-entry .wp-block-image { margin-inline: -8%; max-width: none; width: 116%; }
}
.article-entry img { border-radius: var(--radius-sm); box-shadow: 0 20px 60px rgba(11, 24, 48, .1); }
.article-entry table { display: table; width: 100%; border-collapse: separate; border-spacing: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; font-size: .95rem; }
@media (max-width: 767px) { .article-entry table { display: block; overflow-x: auto; } }
/* 區塊編輯器表格對儲存格設了 word-break: break-word，會蓋掉依詞斷行（inc/typography.php），這裡改回 */
.zh-wbr .article-entry :is(td, th) { word-break: keep-all; overflow-wrap: break-word; }
.article-entry th { background: var(--ink); color: var(--paper); font-weight: 700; border-bottom: 0; }
.article-entry tr:nth-child(even) td { background: var(--paper-2); }
.article-entry h3.is-faq {
  position: relative; padding: 18px 0 0 44px; margin-top: 1.4em; border-top: 1px dashed var(--line); font-size: 1.15rem;
}
.article-entry h3.is-faq::before {
  content: "Q"; position: absolute; left: 0; top: 16px; width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center; background: var(--brand-deep); color: #fff; font-family: var(--font-mono); font-size: .8rem;
}
.article-entry p.is-faq-a { padding-left: 44px; }
.article-entry blockquote { background: var(--paper-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; padding: 18px 24px; }

/* 文末：標籤、作者卡 */
.article-end { max-width: 46rem; margin: clamp(48px, 6vw, 80px) auto 0; display: grid; gap: 28px; }
@media (min-width: 1200px) { .article-end { margin-left: calc(220px + (100% - 220px * 2 - 46rem) / 2); } }
.author-card { display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: start; padding: clamp(20px, 3vw, 32px); border-radius: var(--radius); border: 1px solid var(--line); background: #fff; }
.author-card__logo { width: 120px; }
.author-card__name { font-weight: 700; font-size: 1.05rem; }
.author-card__text { margin-top: 6px; color: var(--muted); font-size: .925rem; line-height: 1.85; }
@media (max-width: 600px) { .author-card { grid-template-columns: 1fr; } }

/* 上一篇／下一篇 */
.post-nav { display: grid; background: var(--ink); color: var(--paper); }
@media (min-width: 900px) { .post-nav { grid-template-columns: 1fr 1fr; } }
.post-nav__item { position: relative; isolation: isolate; overflow: hidden; display: grid; gap: 14px; align-content: end; min-height: 280px; padding: clamp(28px, 4vw, 56px) var(--gutter); border-top: 1px solid rgba(245, 247, 250, .12); }
@media (min-width: 900px) { .post-nav__item--next { text-align: right; justify-items: end; border-left: 1px solid rgba(245, 247, 250, .12); } }
.post-nav__item--empty { display: none; }
@media (min-width: 900px) { .post-nav__item--empty { display: block; } }
.post-nav__title { font-family: var(--font-serif); font-weight: 900; font-size: clamp(1.4rem, 2.4vw, 2.2rem); line-height: 1.3; max-width: 20em; text-wrap: balance; }
.post-nav__bg { position: absolute; inset: 0; z-index: -1; opacity: .14; }
.post-nav__bg img { width: 100%; height: 100%; object-fit: cover; filter: grayscale(1); transform: scale(1.06); transition: transform 1200ms var(--ease-wind), opacity var(--m-slow) var(--m-ease); }
@media (hover: hover) { .post-nav__item:hover .post-nav__bg { opacity: .3; } .post-nav__item:hover .post-nav__bg img { transform: scale(1); } }

/* 相關文章卡 */
.post-cards { display: grid; gap: clamp(20px, 3vw, 36px); }
@media (min-width: 900px) { .post-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.post-card a { display: grid; gap: 12px; }
.post-card__img { display: block; aspect-ratio: 16 / 10; border-radius: var(--radius); overflow: hidden; background: var(--paper-2); }
.post-card__img img { width: 100%; height: 100%; object-fit: cover; transition: transform 900ms var(--ease-wind); }
.post-card__meta { font-family: var(--font-mono); font-size: .72rem; letter-spacing: .08em; color: var(--faint); }
.post-card__title { font-family: var(--font-serif); font-weight: 900; font-size: clamp(1.1rem, 1.6vw, 1.4rem); line-height: 1.4; text-wrap: balance; transition: color var(--m-base) var(--m-ease); }
@media (hover: hover) { .post-card a:hover img { transform: scale(1.05); } .post-card a:hover .post-card__title { color: var(--accent-text); } }

/* 內文中的 Easy TOC：改成全站統一的目錄樣式 */
.article-entry #ez-toc-container nav ul, .article-entry #ez-toc-container ul.ez-toc-list { list-style: none !important; padding: 0 !important; margin: 10px 0 0 !important; counter-reset: ezt; }
.article-entry #ez-toc-container li { margin: 0 !important; padding: 0 !important; }
.article-entry #ez-toc-container li::before { display: none !important; }
.article-entry #ez-toc-container a { display: block; padding: 8px 0 8px 34px; position: relative; color: var(--fg) !important; font-size: .95rem; border-top: 1px solid var(--line); text-decoration: none !important; }
.article-entry #ez-toc-container > nav > ul > li > a::before, .article-entry #ez-toc-container ul.ez-toc-list > li > a::before { counter-increment: ezt; content: counter(ezt, decimal-leading-zero); position: absolute; left: 0; top: 10px; font-family: var(--font-mono); font-size: .7rem; color: var(--accent-text); }
.article-entry #ez-toc-container .ez-toc-title-toggle { display: none; }

/* 手機目錄按鈕＋底部選單 */
.toc-fab { display: none; }
@media (max-width: 1199px) {
  .toc-fab {
    display: inline-flex; align-items: center; gap: 8px; position: fixed; left: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 55;
    height: 48px; padding: 0 18px; border-radius: 999px; background: var(--ink-2); color: var(--paper); font-weight: 700; font-size: .9rem;
    box-shadow: 0 0 0 1px rgba(245, 247, 250, .14), 0 12px 32px rgba(4, 10, 22, .35);
    transition: transform var(--m-base) var(--ease-wind), opacity var(--m-base) var(--m-ease);
  }
  .toc-fab.is-tucked { transform: translateY(140%); opacity: 0; }
}
.toc-overlay { z-index: 72; }
.toc-sheet { z-index: 73; padding: 18px 20px calc(20px + env(safe-area-inset-bottom)); background: var(--paper); color: var(--ink); --fg: var(--ink); --muted: #4f5a6b; --line: rgba(11, 24, 48, .12); --accent-text: var(--brand-deep); --faint: rgba(11, 24, 48, .45); }
.toc-sheet__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 1.05rem; }
.toc-sheet__head button { width: 44px; height: 44px; display: grid; place-items: center; }
.toc-sheet .toc { max-height: 52vh; overflow-y: auto; }
.toc-sheet__share { margin-top: 16px; }

/* 文章圖片點擊放大（手機看資訊圖用） */
.article-entry img { cursor: zoom-in; }
.lightbox { position: fixed; inset: 0; z-index: 96; display: grid; place-items: center; padding: 16px; background: rgba(4, 10, 22, .92); }
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 100%; max-height: 92svh; width: auto; height: auto; border-radius: 10px; touch-action: pinch-zoom; }
.lightbox__close { position: absolute; top: 12px; right: 12px; width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: rgba(255, 255, 255, .12); }
/* 文章頁手機：已有目錄浮鈕，收起 LINE 浮鈕避免兩顆壓在內文上 */
@media (max-width: 1199px) { .single-post .line-float { display: none; } }

.table-hint { font-size: .78rem; color: var(--muted); margin-bottom: 6px; letter-spacing: .04em; }
@media (min-width: 768px) { .table-hint { display: none; } }
.article-entry table.is-scrollable { -webkit-mask-image: linear-gradient(90deg, #000 82%, transparent); mask-image: linear-gradient(90deg, #000 82%, transparent); }
.article-entry table.is-scrollable.is-end { -webkit-mask-image: none; mask-image: none; }
