/* 知識文章列表（/knowledge/）。規則一律 .kn- 開頭；文章頁在 article.css。
   主線：字當封面。首屏一排巨大的主題字就是篩選鈕，下面每篇文章的封面是深色玻璃上的分類大字＋紅方塊，
   四個分類各有自己的構圖；滑過時大字微移、紅方塊往右滑。 */

/* ---------- 首屏 ---------- */
.kn-hero { min-height: 0; padding: clamp(128px, 17vh, 168px) 0 clamp(48px, 7vh, 72px); align-items: stretch; content-visibility: visible; }
.kn-hero::after { content: ""; position: absolute; right: -10%; top: -30%; width: 70%; height: 90%; background: radial-gradient(closest-side, rgba(237, 28, 36, .10), transparent); pointer-events: none; }
.kn-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 470px); gap: clamp(32px, 5vw, 80px); align-items: end; }
.kn-hero h1 { font-size: clamp(46px, 6.3vw, 104px); line-height: 1.08; letter-spacing: -.01em; font-weight: 900; }
.kn-hero h1 > span { display: block; animation: fade 1.2s var(--ease) both; }
.kn-hero h1 .kn-l2 { animation-delay: .12s; }
.kn-hero h1 em { font-style: normal; font-weight: 300; color: rgba(242, 240, 236, .42); }
.kn-dot { display: inline-block; width: .17em; height: .17em; margin-left: .08em; background: var(--red); vertical-align: baseline; }
.kn-lead { font-size: clamp(16px, 1.2vw, 18.5px); animation: fade 1.2s var(--ease) .3s both; }

/* 主題字＝篩選鈕：暗的是沒選的，選到的變白、後面跟一顆紅方塊 */
.kn-filter { margin-top: clamp(56px, 9vh, 104px); padding-top: 22px; border-top: 1px solid var(--line); display: grid; grid-template-columns: 150px minmax(0, 1fr); grid-template-rows: auto 1fr; gap: 10px 32px; align-items: start; }
.kn-filter[hidden] { display: none; }
.kn-fk, .kn-status { grid-column: 1; font: 400 12px/1.4 var(--mono); letter-spacing: .16em; color: var(--mute); }
.kn-fk { padding-top: .9em; }
.kn-status { color: rgba(242, 240, 236, .62); white-space: nowrap; }
.kn-fs { grid-column: 2; grid-row: 1 / span 2; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px clamp(22px, 2.6vw, 44px); }
.kn-f {
  position: relative; display: inline-flex; align-items: flex-start; gap: 6px; padding: 4px 0 10px; margin: 0;
  background: none; border: 0; cursor: pointer; color: rgba(242, 240, 236, .22);
  font-family: var(--wide); font-stretch: 125%; font-variation-settings: "wdth" 125; font-weight: 800;
  font-size: clamp(34px, 4.4vw, 72px); line-height: .95; letter-spacing: -.03em;
  transition: color .45s var(--ease);
  animation: fade 1s var(--ease) both;
}
.kn-f:nth-child(1) { animation-delay: .4s; } .kn-f:nth-child(2) { animation-delay: .48s; } .kn-f:nth-child(3) { animation-delay: .56s; }
.kn-f:nth-child(4) { animation-delay: .64s; } .kn-f:nth-child(5) { animation-delay: .72s; }
.kn-f[hidden] { display: none; }
.kn-fw { position: relative; }
/* 紅方塊：選到的那個字的句點 */
.kn-fw::after { content: ""; display: inline-block; width: .17em; height: .17em; margin-left: .06em; background: var(--red); vertical-align: baseline; transform: scale(0); transform-origin: left bottom; transition: transform .5s cubic-bezier(.3, 1.5, .5, 1); }
.kn-fn { font: 400 12px/1 var(--mono); letter-spacing: .06em; color: rgba(242, 240, 236, .4); margin-top: .5em; transition: color .45s var(--ease); }
.kn-fn:empty { display: none; }
.kn-f:hover { color: rgba(242, 240, 236, .55); }
.kn-f[aria-pressed="true"] { color: #F2F0EC; }
.kn-f[aria-pressed="true"] .kn-fw::after { transform: none; }
.kn-f[aria-pressed="true"] .kn-fn { color: #FF7A7D; }
.kn-f:focus-visible { outline: 2px solid var(--red-text); outline-offset: 4px; }

/* ---------- 文章 ---------- */
.kn-sec { min-height: 0; padding: clamp(72px, 11vh, 120px) 0 clamp(80px, 12vh, 140px); align-items: stretch; }
.kn-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(56px, 7vh, 80px) clamp(20px, 2.2vw, 32px); counter-reset: kn; }
.kn-item { counter-increment: kn; min-width: 0; }
.kn-item[hidden] { display: none; }
.kn-card { position: relative; display: flex; flex-direction: column; height: 100%; }

/* 封面：深色玻璃 */
.kn-cover {
  position: relative; overflow: hidden; container-type: inline-size; aspect-ratio: 16 / 9; border-radius: 18px;
  background: linear-gradient(180deg, #18181C, #0E0E11); border: 1px solid rgba(14, 15, 18, .9);
  box-shadow: 0 34px 60px -40px rgba(20, 8, 8, .55), inset 0 1px 0 rgba(255, 255, 255, .08);
  transition: box-shadow .5s var(--ease);
}
.kn-cover::before { content: ""; position: absolute; width: 90%; height: 90%; left: var(--gx, 40%); top: var(--gy, -30%); background: radial-gradient(closest-side, rgba(237, 28, 36, .2), transparent); pointer-events: none; }
.kn-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.kn-type { position: absolute; inset: 0; color: #F2F1EE; }
/* 編號：第幾篇 */
.kn-type::before { content: counter(kn, decimal-leading-zero); position: absolute; left: 7cqw; top: 6.5cqw; font: 400 max(11px, 2.4cqw)/1 var(--mono); letter-spacing: .14em; color: rgba(242, 241, 238, .45); }
.kn-word {
  position: absolute; left: 6.5cqw; bottom: -.1em; white-space: nowrap;
  font-family: var(--wide); font-stretch: 125%; font-variation-settings: "wdth" 125; font-weight: 800;
  font-size: 22cqw; line-height: .8; letter-spacing: -.04em; color: #F2F1EE;
  transition: translate .7s var(--ease);
}
.kn-sq { position: absolute; right: 7cqw; top: 7cqw; width: 4.6cqw; height: 4.6cqw; background: var(--red); transition: translate .7s cubic-bezier(.65, 0, .35, 1); }
.kn-line { position: absolute; display: none; background: rgba(255, 90, 94, .5); }

/* GEO：大字壓在左下角，紅方塊是它的句點 */
[data-cat="GEO"] .kn-word { font-size: 34cqw; left: 5.5cqw; }
[data-cat="GEO"] .kn-word::after { content: ""; display: inline-block; width: .15em; height: .15em; margin-left: .05em; background: var(--red); transition: translate .7s cubic-bezier(.65, 0, .35, 1); }
[data-cat="GEO"] .kn-sq { display: none; }
[data-cat="GEO"] .kn-cover { --gx: 30%; --gy: 40%; }

/* SEO：大字在上，紅方塊在底下一條排名線的起點，滑過時往右爬 */
[data-cat="SEO"] .kn-word { font-size: 34cqw; top: 15cqw; bottom: auto; }
[data-cat="SEO"] .kn-line { display: block; left: 7cqw; right: 7cqw; bottom: 9cqw; height: 1px; }
[data-cat="SEO"] .kn-sq { top: auto; right: auto; left: 7cqw; bottom: calc(9cqw - 2.3cqw); }
[data-cat="SEO"] .kn-cover { --gx: -20%; --gy: 30%; }

/* 官網：直排靠右，像網頁的側欄；紅方塊在左下 */
[data-cat="官網"] .kn-word { font-family: var(--zh); font-weight: 900; letter-spacing: 0; writing-mode: vertical-rl; font-size: 25cqw; line-height: 1; left: auto; right: 6cqw; top: 6cqw; bottom: auto; }
[data-cat="官網"] .kn-sq { top: auto; right: auto; left: 7cqw; bottom: 7cqw; width: 6cqw; height: 6cqw; }
[data-cat="官網"] .kn-cover { --gx: 50%; --gy: 20%; }

/* 卡大師：工程圖紙的格線＋紅色掃描線，大字靠右下；紅方塊沿著掃描線走 */
[data-cat="卡大師"] .kn-word { font-family: var(--zh); font-weight: 900; letter-spacing: 0; font-size: 25cqw; line-height: 1; left: auto; right: 6cqw; bottom: -.08em; }
[data-cat="卡大師"] .kn-line { display: block; left: 0; right: 0; top: 33cqw; height: 1px; background: linear-gradient(90deg, rgba(255, 90, 94, .7), rgba(255, 90, 94, .15)); }
[data-cat="卡大師"] .kn-sq { right: auto; left: 7cqw; top: calc(33cqw - 2.3cqw); }
[data-cat="卡大師"] .kn-cover { --gx: -10%; --gy: -40%; background-image: linear-gradient(rgba(255, 255, 255, .03) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .03) 1px, transparent 1px), linear-gradient(180deg, #18181C, #0E0E11); background-size: 6cqw 6cqw, 6cqw 6cqw, auto; }

/* 文字 */
.kn-body { display: flex; flex-direction: column; flex: 1; padding-top: 24px; }
.kn-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 18px; font: 400 12px/1.4 var(--mono); letter-spacing: .12em; color: var(--mute); }
.kn-cat { color: var(--red-text); }
.kn-t { margin-top: 12px; font-size: clamp(19px, 1.5vw, 22px); line-height: 1.5; font-weight: 700; color: var(--ink); text-wrap: pretty; }
.kn-t a { text-decoration: none; color: inherit; background: linear-gradient(var(--ink), var(--ink)) no-repeat 0 100% / 0 1px; transition: background-size .5s var(--ease); }
/* 整張卡都能點 */
.kn-t a::after { content: ""; position: absolute; inset: 0; z-index: 2; border-radius: 18px; }
.kn-t a:focus-visible { outline: none; }
.kn-t a:focus-visible::after { outline: 2px solid var(--red-text); outline-offset: 6px; }
.kn-sum { margin-top: 10px; font-size: 15.5px; line-height: 1.8; color: var(--ink-2); display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; }
.kn-go { margin-top: auto; padding-top: 20px; font-size: 14.5px; font-weight: 700; letter-spacing: .04em; color: var(--ink); }
.kn-go span { display: inline-block; margin-left: 6px; color: var(--red-text); font-family: var(--mono); font-weight: 400; transition: translate .4s var(--ease); }

/* 滑過：大字微移、紅方塊往右滑、標題劃線 */
.kn-card:hover .kn-word { translate: -1.6cqw 0; }
.kn-card:hover .kn-sq { translate: 12cqw 0; }
[data-cat="SEO"] .kn-card:hover .kn-sq { translate: 62cqw 0; }
[data-cat="卡大師"] .kn-card:hover .kn-sq { translate: 34cqw 0; }
[data-cat="官網"] .kn-card:hover .kn-sq { translate: 16cqw 0; }
[data-cat="GEO"] .kn-card:hover .kn-word { translate: -1cqw 0; }
[data-cat="GEO"] .kn-card:hover .kn-word::after { translate: .3em 0; }
.kn-card:hover .kn-cover { box-shadow: 0 44px 70px -40px rgba(120, 10, 14, .55), inset 0 1px 0 rgba(255, 255, 255, .1); }
.kn-card:hover .kn-t a { background-size: 100% 1px; }
.kn-card:hover .kn-go span { translate: 6px 0; }

/* 最新一篇：橫跨整排，左邊大封面、右邊大標題 */
.kn-list:not(.kn-ready) > .kn-item:first-child,
.kn-list.kn-ready > .kn-item.is-lead { grid-column: 1 / -1; }
.kn-list:not(.kn-ready) > .kn-item:first-child .kn-card,
.kn-list.kn-ready > .kn-item.is-lead .kn-card { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: clamp(32px, 5vw, 80px); align-items: center; padding-bottom: clamp(56px, 7vh, 80px); border-bottom: 1px solid var(--line-2); }
.kn-list:not(.kn-ready) > .kn-item:first-child .kn-cover,
.kn-list.kn-ready > .kn-item.is-lead .kn-cover { aspect-ratio: 16 / 9; border-radius: 22px; }
.kn-list:not(.kn-ready) > .kn-item:first-child .kn-body,
.kn-list.kn-ready > .kn-item.is-lead .kn-body { padding-top: 0; }
.kn-list:not(.kn-ready) > .kn-item:first-child .kn-t,
.kn-list.kn-ready > .kn-item.is-lead .kn-t { margin-top: 18px; font-size: clamp(28px, 2.7vw, 42px); line-height: 1.34; }
.kn-list:not(.kn-ready) > .kn-item:first-child .kn-sum,
.kn-list.kn-ready > .kn-item.is-lead .kn-sum { margin-top: 18px; font-size: clamp(16px, 1.2vw, 18px); -webkit-line-clamp: 4; line-clamp: 4; max-width: 30em; }
.kn-list:not(.kn-ready) > .kn-item:first-child .kn-go,
.kn-list.kn-ready > .kn-item.is-lead .kn-go { margin-top: 36px; padding-top: 0; font-size: 16px; }
.kn-list:not(.kn-ready) > .kn-item:first-child .kn-t a::after,
.kn-list.kn-ready > .kn-item.is-lead .kn-t a::after { border-radius: 22px; inset: 0 0 clamp(56px, 7vh, 80px); }
.kn-list:not(.kn-ready) > .kn-item:first-child .kn-meta::before,
.kn-list.kn-ready > .kn-item.is-lead .kn-meta::before { content: "最新"; color: var(--ink); }

/* 捲進來：卡片升起、封面大字從左邊展開（只有程式在、沒有減少動態時） */
.kn-anim .kn-item .kn-card { transition: opacity .8s var(--ease), transform .8s var(--ease); transition-delay: var(--d, 0s); }
.kn-anim .kn-item .kn-type { transition: clip-path 1s cubic-bezier(.65, 0, .35, 1); transition-delay: calc(var(--d, 0s) + .1s); }
.kn-anim .kn-item:not(.in) .kn-card { opacity: 0; transform: translateY(28px); }
.kn-anim .kn-item:not(.in) .kn-type { clip-path: inset(0 100% 0 0); }
.kn-anim .kn-item.in .kn-type { clip-path: inset(0 0 0 0); }

/* 空的、分頁 */
.kn-empty { display: none; font-size: 18px; color: var(--ink-2); }
.kn-empty a { color: var(--ink); text-underline-offset: 4px; }
.kn-list[data-ditto-empty] { display: none; }
.kn-list[data-ditto-empty] + .kn-empty { display: block; }
.kn-pager { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: clamp(56px, 8vh, 88px); padding-top: 22px; border-top: 1px solid var(--line-2); font: 400 13px/1 var(--mono); letter-spacing: .1em; color: var(--mute); }
.kn-pager:not(:has(a)) { display: none; }
.kn-pg { display: inline-flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 4px; text-decoration: none; color: var(--ink); font: 700 15px/1 var(--zh); letter-spacing: .04em; }
.kn-pg span { color: var(--red-text); font-family: var(--mono); font-weight: 400; transition: translate .4s var(--ease); }
.kn-pg.prev:hover span { translate: -5px 0; } .kn-pg.next:hover span { translate: 5px 0; }
.kn-pg.prev { order: -1; }
.kn-pg.next { margin-left: auto; }

/* ---------- 底部一條：深色玻璃 ---------- */
.kn-cta {
  position: relative; overflow: hidden; margin-top: clamp(88px, 13vh, 150px);
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 32px clamp(32px, 5vw, 80px); align-items: center;
  padding: clamp(36px, 4.4vw, 64px) clamp(28px, 4.4vw, 64px) clamp(36px, 4.4vw, 64px) clamp(56px, 6vw, 96px);
  border-radius: 22px; color: #F2F1EE; background: linear-gradient(180deg, #17171B, #0F0F12); border: 1px solid rgba(255, 255, 255, .08);
  box-shadow: 0 50px 90px -60px rgba(20, 8, 8, .6), inset 0 1px 0 rgba(255, 255, 255, .07);
}
.kn-cta::before { content: ""; position: absolute; left: 35%; right: -10%; top: -60%; height: 140%; background: radial-gradient(closest-side, rgba(237, 28, 36, .16), transparent); pointer-events: none; }
.kn-cta-sq { position: absolute; left: clamp(28px, 3vw, 48px); top: clamp(48px, 5.2vw, 78px); width: 12px; height: 12px; background: var(--red); }
.kn-cta-t { position: relative; font-size: clamp(26px, 2.8vw, 42px); line-height: 1.35; font-weight: 300; color: #F2F1EE; }
.kn-cta-t .nw { font-weight: 900; }
.kn-cta-b { position: relative; display: grid; grid-template-columns: repeat(2, minmax(0, 260px)); gap: 12px; }
.kn-cta-b .btn { width: 100%; }
[data-ground="light"] .kn-cta .btn-ghost { --fill: rgba(255, 255, 255, .1); --arr: #F2F0EC; background: rgba(255, 255, 255, .04); border-color: rgba(255, 255, 255, .26); color: #F2F0EC; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08); }
[data-ground="light"] .kn-cta .btn-ghost:hover { border-color: rgba(255, 255, 255, .55); }
.kn-cta .btn:focus-visible { outline-color: #F2F0EC; }

/* ---------- 平板 ---------- */
@media (max-width: 1080px) {
  .kn-top { grid-template-columns: minmax(0, 1fr); align-items: start; gap: 24px; }
  .kn-filter { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto; }
  .kn-fk { grid-column: 1; grid-row: 1; padding-top: 0; }
  .kn-status { grid-column: 2; grid-row: 1; }
  .kn-fs { grid-column: 1 / -1; grid-row: 2; justify-content: flex-start; }
  .kn-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kn-cta { grid-template-columns: minmax(0, 1fr); }
}
/* ---------- 手機 ---------- */
@media (max-width: 760px) {
  .kn-hero { padding: 104px 0 40px; }
  .kn-hero h1 { font-size: clamp(38px, 10.6vw, 52px); }
  .kn-lead { font-size: 15.5px; }
  .kn-filter { margin-top: 44px; }
  .kn-fs { gap: 2px 22px; }
  .kn-f { font-size: clamp(30px, 9vw, 40px); }
  .kn-sec { padding: 56px 0 72px; }
  .kn-list { grid-template-columns: minmax(0, 1fr); gap: 52px; }
  .kn-list:not(.kn-ready) > .kn-item:first-child .kn-card,
  .kn-list.kn-ready > .kn-item.is-lead .kn-card { grid-template-columns: minmax(0, 1fr); gap: 24px; padding-bottom: 52px; }
  .kn-list:not(.kn-ready) > .kn-item:first-child .kn-t,
  .kn-list.kn-ready > .kn-item.is-lead .kn-t { margin-top: 12px; font-size: 25px; }
  .kn-list:not(.kn-ready) > .kn-item:first-child .kn-go,
  .kn-list.kn-ready > .kn-item.is-lead .kn-go { margin-top: 24px; }
  .kn-list:not(.kn-ready) > .kn-item:first-child .kn-t a::after,
  .kn-list.kn-ready > .kn-item.is-lead .kn-t a::after { inset: 0 0 52px; }
  .kn-cover, .kn-list:not(.kn-ready) > .kn-item:first-child .kn-cover, .kn-list.kn-ready > .kn-item.is-lead .kn-cover { border-radius: 16px; }
  .kn-cta { padding: 36px 22px 24px; border-radius: 18px; }
  .kn-cta-sq { left: 22px; top: 22px; width: 10px; height: 10px; }
  .kn-cta-t { padding-top: 16px; font-size: 25px; }
  .kn-cta-b { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .kn-hero h1 > span, .kn-lead, .kn-f { animation: none; }
  .kn-word, .kn-sq, .kn-go span, .kn-t a, .kn-fw::after, .kn-word::after { transition: none; }
}
