/* 單篇文章頁（knowledge/_item.html）：讀起來舒服最重要。
   深底文章頭 → 封面（或字當封面）壓在深淺交界 → 淺底內文＋左側目錄 → 深色玻璃預約 → 繼續讀 → 頁尾 */

/* ---------- 文章頭 ---------- */
.ar-head { position: relative; padding: clamp(132px, 18vh, 196px) 0 clamp(56px, 8vh, 88px); background: var(--dark); }
.ar-crumb { display: flex; flex-wrap: wrap; align-items: center; font: 400 12px/1.4 var(--mono); letter-spacing: .16em; color: rgba(242, 240, 236, .7); margin-bottom: clamp(26px, 4vh, 40px); animation: fade 1s var(--ease) both; }
.ar-crumb a { color: inherit; text-decoration: none; border-bottom: 1px solid transparent; padding: 4px 0; transition: color .3s var(--ease), border-color .3s var(--ease); }
.ar-crumb a:hover { color: #fff; border-bottom-color: var(--red); }
.ar-crumb i { font-style: normal; color: #FF4A4F; margin: 0 10px; }
.ar-crumb span span { color: #F2F0EC; }

/* 標題是後台的字，沒辦法手動斷行：keep-all 讓它只在空格和標點後面斷，再用 balance 把兩行拉平 */
.ar-title {
  max-width: 17em; font-size: clamp(34px, 4.6vw, 70px); line-height: 1.24; font-weight: 700; letter-spacing: 0; color: #F2F0EC;
  text-wrap: balance; line-break: strict; word-break: keep-all; overflow-wrap: anywhere;
  animation: fade 1.1s var(--ease) .08s both;
}
.ar-sub { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px clamp(32px, 6vw, 96px); align-items: end; margin-top: clamp(30px, 4.4vh, 48px); padding-top: 26px; border-top: 1px solid rgba(242, 240, 236, .14); animation: fade 1.1s var(--ease) .22s both; }
.ar-sum { max-width: 36em; font-size: clamp(17px, 1.3vw, 19px); line-height: 1.9; color: #C9C6BE; text-wrap: pretty; }
.ar-meta { display: flex; flex-wrap: wrap; gap: 6px 20px; font: 400 12px/1.6 var(--mono); letter-spacing: .12em; color: rgba(242, 240, 236, .6); white-space: nowrap; }
.ar-meta span::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 10px; vertical-align: .1em; background: var(--red); }

/* ---------- 封面：壓在深淺交界（上半截後面是一條深色帶） ---------- */
.ar-read { position: relative; isolation: isolate; padding-bottom: clamp(88px, 12vh, 140px); }
.ar-fig { position: relative; margin: 0; }
.ar-fig::before { content: ""; position: absolute; z-index: -1; top: 0; left: 50%; width: 100vw; height: 50%; transform: translateX(-50%); background: var(--dark); }
.ar-cover img { width: 100%; height: auto; aspect-ratio: 21 / 9; object-fit: cover; border-radius: 22px; background: #17171B; }

/* 字當封面：跟列表頁同一個語言（深色玻璃底＋超大分類名＋紅方塊） */
.ar-word {
  height: clamp(220px, 27vw, 400px); overflow: hidden; border-radius: 22px; color: #F2F1EE;
  background: linear-gradient(180deg, #17171B, #0F0F12); border: 1px solid rgba(255, 255, 255, .09);
  box-shadow: 0 60px 120px -60px rgba(14, 15, 18, .55), inset 0 1px 0 rgba(255, 255, 255, .07);
}
.ar-word::after { content: ""; position: absolute; inset: -30% -10% auto 35%; height: 90%; background: radial-gradient(closest-side, rgba(237, 28, 36, .16), transparent); pointer-events: none; }
.aw-k { position: absolute; z-index: 1; left: clamp(22px, 3vw, 40px); top: clamp(20px, 2.6vw, 34px); display: flex; align-items: center; gap: 12px; font: 400 12px/1 var(--mono); letter-spacing: .16em; color: rgba(242, 241, 238, .7); }
.aw-k .ai-dot { width: 8px; height: 8px; }
.aw-k i { font-style: normal; color: #FF4A4F; margin: 0 -4px; }
.aw-big {
  position: absolute; z-index: 1; left: clamp(16px, 2.4vw, 34px); bottom: 0; display: flex; align-items: flex-end; white-space: nowrap;
  font-family: var(--wide); font-stretch: 125%; font-variation-settings: "wdth" 125; font-weight: 800;
  font-size: clamp(104px, 23vw, 350px); line-height: .78; letter-spacing: -.035em; color: #F2F1EE;
  transform: translate3d(var(--wx, 0px), .08em, 0);
}
.aw-t { display: block; animation: aw-rise 1.3s var(--ease) .15s both; }
.aw-big b { flex: none; width: .2em; height: .2em; margin: 0 0 .26em .08em; background: var(--red); animation: aw-pop .7s cubic-bezier(.3, 1.6, .5, 1) 1s both; }
@keyframes aw-rise { from { transform: translateY(70%); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes aw-pop { from { transform: scale(0); } to { transform: none; } }

/* ---------- 內文與目錄 ---------- */
.ar-grid { display: grid; grid-template-columns: minmax(170px, 1fr) minmax(0, 660px) minmax(0, 1fr); gap: 0 clamp(32px, 4vw, 64px); margin-top: clamp(64px, 9vh, 104px); }
.prose { grid-column: 2; min-width: 0; }
.toc { grid-column: 1; grid-row: 1; align-self: start; position: sticky; top: 112px; max-width: 250px; padding-top: 6px; }
.toc[hidden] { display: none; }
.toc-k { font: 400 12px/1 var(--mono); letter-spacing: .16em; color: var(--mute); padding-bottom: 16px; }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line-2); counter-reset: t; }
.toc a {
  position: relative; display: block; padding: 9px 0 9px 18px;
  font-size: 14px; line-height: 1.6; color: var(--mute); text-decoration: none; word-break: keep-all; overflow-wrap: anywhere;
  transition: color .35s var(--ease);
}
/* 讀到哪一節：目錄細線上一顆紅色小方塊，不用側邊粗線 */
.toc a::before { content: ""; position: absolute; left: -4px; top: calc(9px + .8em); width: 7px; height: 7px; translate: 0 -50%; background: var(--red); scale: 0; transition: scale .35s var(--ease); }
.toc a:hover { color: var(--ink); }
.toc a.on { color: var(--ink); font-weight: 700; }
.toc a.on::before { scale: 1; }

/* 中文內文：18px、行高 1.95、一行約 36 字 */
.prose { --p: #24272D; font-size: 18px; line-height: 1.95; letter-spacing: .02em; color: var(--p); }
.prose > :first-child { margin-top: 0; }
.prose p { margin: 0 0 1.35em; text-wrap: pretty; }
.prose h2 {
  scroll-margin-top: 110px;
  margin: 2.9em 0 .9em; font-size: clamp(25px, 2.2vw, 32px); line-height: 1.42; font-weight: 700; letter-spacing: .01em; color: var(--ink);
  text-wrap: balance; word-break: keep-all; overflow-wrap: anywhere;
}
.prose h3 { scroll-margin-top: 110px; margin: 2em 0 .6em; font-size: 21px; line-height: 1.5; color: var(--ink); }
.prose strong, .prose b { font-weight: 700; color: var(--ink); }
.prose em { font-style: normal; font-weight: 700; }
.prose a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--red); text-decoration-thickness: 1.5px; text-underline-offset: .32em; transition: color .3s var(--ease), text-decoration-thickness .3s var(--ease); }
.prose a:hover { color: var(--red-text); text-decoration-thickness: 3px; }
.prose ul, .prose ol { margin: 0 0 1.5em; padding: 0; list-style: none; }
.prose li { position: relative; padding-left: 1.5em; margin: 0 0 .7em; }
.prose ul > li::before { content: ""; position: absolute; left: .2em; top: .82em; width: 6px; height: 6px; background: var(--red); }
.prose ol { counter-reset: li; }
.prose ol > li { counter-increment: li; padding-left: 2.2em; }
.prose ol > li::before { content: counter(li, decimal-leading-zero); position: absolute; left: 0; top: .52em; font: 400 12px/1 var(--mono); letter-spacing: .08em; color: var(--red-text); }
.prose li > p { margin: 0; }
.prose blockquote { position: relative; margin: 2.4em 0 2em; padding: 30px 0 0; font-size: 20px; line-height: 1.8; color: var(--ink); }
.prose blockquote::before { content: "「"; position: absolute; left: -.1em; top: -.32em; font: 900 64px/1 var(--zh); color: var(--red); }
.prose blockquote p:last-child { margin-bottom: 0; }
.prose code { font: 400 .86em/1.5 var(--mono); padding: .14em .42em; border-radius: 6px; background: rgba(14, 15, 18, .07); }
.prose pre { margin: 1.8em 0; padding: 20px 22px; overflow-x: auto; border-radius: 14px; background: #111113; color: #ECEAE4; font-size: 14px; line-height: 1.7; }
.prose pre code { padding: 0; background: none; color: inherit; }
.prose img { width: 100%; height: auto; border-radius: 14px; margin: 2em 0; }
.prose hr { border: 0; height: 1px; margin: 3em 0; background: var(--line-2); }

/* 表格：白色卡片、深色表頭；手機可以左右捲（沒有 JS 時表格本身捲） */
.prose table { display: block; max-width: 100%; overflow-x: auto; margin: 2em 0; border-collapse: collapse; font-size: 16px; line-height: 1.7; letter-spacing: .01em; }
.table-wrap { margin: 2.2em 0 2.4em; max-width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 16px; background: rgba(255, 255, 255, .72); box-shadow: 0 30px 60px -44px rgba(14, 15, 18, .4); -webkit-overflow-scrolling: touch; }
.table-wrap:focus-visible { outline: 2px solid var(--red-text); outline-offset: 3px; }
.table-wrap table { display: table; width: 100%; min-width: 540px; max-width: none; margin: 0; overflow: visible; }
.prose th, .prose td { padding: 16px 20px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.prose thead th { background: #0E0F12; color: #F2F0EC; font-size: 15px; font-weight: 700; letter-spacing: .04em; border-bottom: 0; white-space: nowrap; }
.prose thead th + th { border-left: 1px solid rgba(255, 255, 255, .08); }
.prose tbody td:first-child, .prose tbody th:first-child { width: 7.5em; font-size: 14px; font-weight: 700; color: var(--mute); white-space: nowrap; }
.prose tbody tr:last-child td { border-bottom: 0; }
.prose tbody td + td { border-left: 1px solid var(--line); color: var(--ink); }
.prose tbody tr:hover td { background: rgba(237, 28, 36, .03); }

/* ---------- 文末：深色玻璃，預約診斷 ---------- */
.ar-cta {
  position: relative; overflow: hidden; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 32px clamp(32px, 6vw, 96px);
  margin-top: clamp(80px, 12vh, 136px); padding: clamp(32px, 4.4vw, 64px); border-radius: 22px; color: #F2F1EE;
  background: linear-gradient(180deg, #17171B, #0F0F12); border: 1px solid rgba(255, 255, 255, .08);
  box-shadow: 0 60px 120px -50px rgba(237, 28, 36, .4), inset 0 1px 0 rgba(255, 255, 255, .07);
}
.ar-cta::before { content: ""; position: absolute; inset: -40% -10% auto 45%; height: 110%; background: radial-gradient(closest-side, rgba(237, 28, 36, .15), transparent); pointer-events: none; }
.ac-txt { position: relative; }
.ac-k { display: flex; align-items: center; gap: 12px; font: 400 12px/1 var(--mono); letter-spacing: .16em; color: rgba(242, 241, 238, .72); margin-bottom: 24px; }
.ac-k .ai-dot { width: 8px; height: 8px; }
.ac-h { font-size: clamp(30px, 3.4vw, 52px); line-height: 1.25; font-weight: 300; color: #F2F1EE; }
.ac-p { margin-top: 18px; max-width: 30em; font-size: 17px; line-height: 1.85; color: rgba(242, 241, 238, .72); }
.ar-cta .btn { margin-top: 34px; min-width: 300px; }
/* 右邊：紅方塊往外擴三圈回聲＝「找到你在哪裡」 */
.ac-ping { position: relative; width: clamp(180px, 20vw, 280px); aspect-ratio: 1; display: grid; place-items: center; }
.ac-ping::before { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 1px dashed rgba(242, 241, 238, .14); }
.ac-ping::after { content: ""; position: absolute; inset: 22%; border-radius: 50%; border: 1px solid rgba(242, 241, 238, .08); }
.ac-ping b { position: relative; width: 16px; height: 16px; background: var(--red); box-shadow: 0 0 24px rgba(255, 74, 79, .6); }
.ac-ping i { position: absolute; left: 50%; top: 50%; width: clamp(180px, 20vw, 280px); aspect-ratio: 1; border: 1px solid rgba(255, 74, 79, .65); border-radius: 50%; transform: translate(-50%, -50%) scale(.06); opacity: 0; animation: ac-echo 3.6s cubic-bezier(.2, .6, .3, 1) infinite; pointer-events: none; }
.ac-ping i:nth-child(2) { animation-delay: 1.2s; }
.ac-ping i:nth-child(3) { animation-delay: 2.4s; }
@keyframes ac-echo { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.06); } 12% { opacity: .9; } 100% { opacity: 0; transform: translate(-50%, -50%) scale(1); } }

/* ---------- 繼續讀（沿用首頁「最新文章」的樣子） ---------- */
.ar-more { padding: clamp(96px, 13vh, 150px) 0 0; background: var(--dark); }
.ar-more .fm-head { padding-bottom: 22px; }
.ar-more .fm-t { font-size: clamp(26px, 2.6vw, 38px); }
.ar-more .fm-title { word-break: keep-all; overflow-wrap: anywhere; }
.rd-list li:nth-child(n+4) { display: none; }
.rd-all { margin-top: 28px; display: flex; justify-content: flex-end; border-top: 1px solid rgba(255, 255, 255, .08); padding-top: 14px; }
.ar-more[hidden] { display: none; }
.ar-more ~ .finale .fin-in, main:has(.ar-more) + .finale .fin-in { padding-top: clamp(72px, 10vh, 120px); }

/* ---------- 閱讀進度：頁首下緣一條細紅線（程式加進頁首） ---------- */
.ar-prog { position: absolute; left: 0; right: 0; bottom: -2px; height: 2px; background: var(--red); transform: scaleX(0); transform-origin: left center; opacity: 0; transition: opacity .3s var(--ease); pointer-events: none; }
.ar-prog.on { opacity: 1; }

/* ---------- 平板與手機 ---------- */
@media (max-width: 1080px) {
  .ar-grid { grid-template-columns: minmax(0, 1fr); }
  .prose { grid-column: 1; width: 100%; max-width: 660px; margin-inline: auto; }
  .toc, .toc:not([hidden]) { display: none; }
  .ar-sub { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .ar-head { padding: 112px 0 44px; }
  .ar-title { font-size: clamp(29px, 8vw, 36px); line-height: 1.32; }
  .ar-sub { margin-top: 24px; padding-top: 20px; gap: 16px; }
  .ar-sum { font-size: 16.5px; }
  .ar-word { height: 200px; border-radius: 16px; }
  .aw-big { font-size: clamp(88px, 27vw, 120px); }
  .ar-cover img { aspect-ratio: 16 / 10; border-radius: 16px; }
  .ar-grid { margin-top: 52px; }
  .prose { font-size: 17px; line-height: 1.9; letter-spacing: .015em; }
  .prose h2 { margin-top: 2.5em; font-size: 23px; }
  .prose th, .prose td { padding: 13px 14px; }
  .table-wrap { max-width: none; margin-inline: calc(var(--pad) * -1); border-radius: 0; border-left: 0; border-right: 0; }
  .ar-cta { grid-template-columns: minmax(0, 1fr); padding: 30px 22px 34px; border-radius: 18px; }
  .ac-ping { display: none; }
  .ar-cta .btn { width: 100%; min-width: 0; }
  .ar-more { padding-top: 80px; }
  .rd-all { justify-content: flex-start; }
}

/* ---------- 減少動態：全部靜止在最後的樣子 ---------- */
@media (prefers-reduced-motion: reduce) {
  .aw-big { transform: translate3d(0, .08em, 0); }
  .ac-ping i { animation: none; opacity: .5; }
  .ac-ping i:nth-child(1) { transform: translate(-50%, -50%) scale(.3); }
  .ac-ping i:nth-child(2) { transform: translate(-50%, -50%) scale(.62); opacity: .3; }
  .ac-ping i:nth-child(3) { transform: translate(-50%, -50%) scale(.95); opacity: .15; }
  .ar-prog { transition: none; }
}
