/* ================================================================
   視覺化文章元件 — 重排版文章專用，沿用 tokens.css 的色與間距
   ================================================================ */
#article .lede {
  font-size: 1.125rem; line-height: 1.9;
  border-left: 4px solid var(--accent);
  /* 色調疊在不透明底上。只寫半透明色的話，背景網格會穿到字後面 */
  background: linear-gradient(rgb(0 187 167 / .06), rgb(0 187 167 / .06)), var(--surface);
  padding: 1.25rem 1.5rem; border-radius: 0 .625rem .625rem 0;
  margin-block: 2rem;
}
#article .lede ul { margin-bottom: 0; }
#article .lede li { line-height: 1.9; }

/* 卡片格 */
#article .cards { display: grid; gap: 1rem; margin-block: 2rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); }
#article .card {
  border: 1px solid var(--border); border-radius: .625rem;
  padding: 1.125rem 1.25rem; background: var(--popover);
}
#article .card h4 { margin: 0 0 .5rem; font-size: 1rem; font-weight: 700; color: var(--accent-deep); }
.dark #article .card h4 { color: var(--accent-text); }
#article .card p, #article .card ul { margin-bottom: 0; font-size: .9375rem; line-height: 1.7; }
#article .card code { font-size: .875rem; }

/* 左右對照 */
#article .versus { display: grid; gap: 1rem; margin-block: 2rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); }
#article .versus > div { border: 1px solid var(--border); border-radius: .625rem; overflow: hidden; background: var(--surface); }
#article .versus h4 {
  margin: 0; padding: .625rem 1rem; font-size: .875rem; font-weight: 600;
  background: var(--divider); color: var(--foreground);
}
#article .versus .vs-body { padding: 1rem 1.25rem; }
#article .versus p:last-child { margin-bottom: 0; }
/* 舊做法那欄的赤陶色標題。#b4533c 配上同色系 12% 的底只有 4.2:1（深色模式 3.2:1），
   兩邊各自往深／往淺推一階才過 AA。 */
#article .versus .before h4 { background: rgb(180 83 60 / .12); color: #a34832; }
.dark #article .versus .before h4 { color: #d98a72; }
#article .versus .after h4 { background: rgb(0 187 167 / .14); color: var(--accent-deep); }
.dark #article .versus .after h4 { color: var(--accent-text); }

/* 提醒框 */
#article .note {
  border: 1px solid var(--border); border-left: 4px solid #c49845;
  background: linear-gradient(rgb(196 152 69 / .08), rgb(196 152 69 / .08)), var(--surface);
  border-radius: 0 .625rem .625rem 0; padding: 1rem 1.25rem; margin-block: 1.5rem;
}
#article .note h4 { margin: 0 0 .5rem; font-size: .9375rem; font-weight: 700; }
#article .note p:last-child, #article .note ul:last-child { margin-bottom: 0; }

/* 步驟流程 */
#article .flow { display: grid; gap: .625rem; margin-block: 2rem; counter-reset: step; }
#article .flow > li {
  display: grid; grid-template-columns: 1.75rem 1fr; gap: .875rem; align-items: start;
  border: 1px solid var(--border); border-radius: .625rem; padding: .875rem 1rem; list-style: none;
  background: var(--surface);
}
#article .flow > li::before {
  counter-increment: step; content: counter(step);
  display: grid; place-items: center;
  width: 1.75rem; height: 1.75rem; border-radius: 9999px;
  background: var(--accent); color: #fff; font-size: .8125rem; font-weight: 700;
}
#article .flow ul { margin: .5rem 0 0; }
#article .flow li li { font-size: .9375rem; }

/* 收合區 */
#article details.reveal {
  border: 1px solid var(--border); border-radius: .625rem;
  padding: .875rem 1.125rem; margin-block: 1.25rem;
  background: var(--surface);
}
#article details.reveal > summary {
  cursor: pointer; font-weight: 600; font-size: .9375rem; list-style: none;
}
#article details.reveal > summary::-webkit-details-marker { display: none; }
#article details.reveal > summary::before { content: "▸ "; color: var(--accent-text); }
#article details.reveal[open] > summary::before { content: "▾ "; }
#article details.reveal > summary .hint { font-weight: 400; color: var(--muted-fg); font-size: .875rem; }
#article details.reveal[open] > summary { margin-bottom: .875rem; }
#article details.reveal pre { margin-bottom: 0; }

/* 檔案樹 */
#article .filetree {
  font-family: var(--font-mono); font-size: .8125rem; line-height: 1.9;
  background: linear-gradient(var(--divider), var(--divider)), var(--surface);
  border-radius: .625rem; padding: 1rem 1.25rem;
  margin-block: 1.5rem; white-space: pre; overflow-x: auto;
}

/* 圖說 */
#article figure.shot { margin-block: 2.5rem; background: var(--surface); border-radius: .625rem; }
#article figure.shot img { margin-top: 0; }

/* ================================================================
   結構圖（內嵌 SVG）— 取代原本 Mermaid 產的暗底點陣圖
   窄螢幕橫向捲動、不縮字；深淺色靠 CSS 變數切換
   ================================================================ */
:root {
  --dg-paper:  #ffffff;
  --dg-node:   #ffffff;
  --dg-stroke: #71717b;
  --dg-ink:    #27272a;
  --dg-muted:  #52525c;
  --dg-hair:   #d4d4d8;
  --dg-accent: #00bba7;
  --dg-accent-soft: #e6f9f6;
  --dg-accent-ink:  #00786f;
  --dg-zone:   rgba(39,39,42,.03);
}
.dark {
  --dg-paper:  #18181b;
  --dg-node:   #212124;
  --dg-stroke: #9f9fa9;
  --dg-ink:    #e4e4e7;
  --dg-muted:  #b0b0b8;
  --dg-hair:   #3f3f46;
  --dg-accent: #00d5be;
  --dg-accent-soft: rgba(0,213,190,.14);
  --dg-accent-ink:  #46ecd5;
  --dg-zone:   rgba(255,255,255,.03);
}
#article .figure {
  position: relative;
  width: 100%; max-width: 100%; min-width: 0;
  background: var(--dg-paper);
  border: 1px solid var(--dg-hair);
  border-radius: .625rem;
  margin-block: 2rem;
}
#article .figure {
  /* 整塊都要不透明。只給捲動區的話，下面的圖說與提示還是坐在網格上 */
  background: var(--surface); border-radius: .625rem;
}
#article .figure .scroller {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  border-radius: .625rem .625rem 0 0;
  background: var(--surface);
}
/* 可橫向捲動時，右緣淡出提示還有內容 */
#article .figure[data-scrollable="true"] .scroller::after {
  content: ""; position: sticky; right: 0; top: 0;
  display: block; width: 2.5rem; height: 100%;
  pointer-events: none;
}
#article .figure .hint {
  display: none;
  font-size: .75rem; color: var(--muted-fg);
  padding: 0 .875rem .5rem; margin: 0;
  font-family: var(--font-mono);
}
#article .figure[data-scrollable="true"] .hint { display: block; }
#article .figure svg { display: block; width: 100%; height: auto; }
#article .figure figcaption {
  padding: .625rem .875rem; margin: 0;
  border-top: 1px solid var(--dg-hair);
  font-size: .8125rem; text-align: left; color: var(--muted-fg);
}
#article .figure svg text { font-family: var(--font-sans); font-size: 12px; fill: var(--dg-muted); }
#article .figure svg text.n { font-size: 13px; font-weight: 600; fill: var(--dg-ink); }
#article .figure svg text.mono { font-family: var(--font-mono); }
#article .figure svg text.acc { fill: var(--dg-accent-ink); }
#article .figure svg .box { fill: var(--dg-node); stroke: var(--dg-stroke); stroke-width: 1.2; }
#article .figure svg .box.acc { fill: var(--dg-accent-soft); stroke: var(--dg-accent); stroke-width: 1.5; }
#article .figure svg .box.term { fill: var(--dg-zone); stroke: var(--dg-stroke); }
#article .figure svg .ln { fill: none; stroke: var(--dg-stroke); stroke-width: 1.4; }
#article .figure svg .ln.dash { stroke-dasharray: 5,4; }
#article .figure svg .ln.acc { stroke: var(--dg-accent); }
#article .figure svg .mask { fill: var(--dg-paper); }
#article .figure svg .hair { stroke: var(--dg-hair); stroke-width: .8; }
/* 甘特條 */
#article .figure svg .bar-old { fill: #b4533c; }
#article .figure svg .bar-new { fill: var(--dg-accent); }
#article .figure svg text.bar-l { fill: #fff; font-size: 11.5px; font-weight: 600; }
.dark #article .figure svg text.bar-l { fill: #0b1a18; }
/* 各圖的最小寬度：窄螢幕橫向捲動而不是縮字 */
#article .figure svg.w720 { min-width: 720px; }
#article .figure svg.w900 { min-width: 900px; }
