/* =========================================================
   AI 面試官教學站  —  共用樣式
   面試情境教學風格 · 繁體中文 · 友善初學者
   ========================================================= */

:root {
  /* 字型 */
  --font-sans: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei",
    system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", "Cascadia Code", Consolas,
    "Courier New", monospace;

  /* 基礎色 */
  --bg: #f3f5fa;
  --bg-soft: #eaeef6;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --ink: #1c2430;
  --ink-soft: #46566a;
  --muted: #6b7a8d;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;

  /* 主題色（可被分類覆蓋） */
  --cat: #4f46e5;
  --cat-soft: #eef0ff;
  --cat-ink: #3730a3;

  /* 語意色 */
  --tldr: #0d9488;
  --tldr-soft: #ecfdf6;
  --tip: #059669;
  --tip-soft: #ecfdf3;
  --warn: #d97706;
  --warn-soft: #fff7ed;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --info: #2563eb;
  --info-soft: #eff6ff;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, .12);
  --maxw: 860px;
}

/* 分類主題色 */
body[data-cat="path"]     { --cat:#0d9488; --cat-soft:#e6fbf6; --cat-ink:#0f766e; }
body[data-cat="rag"]      { --cat:#4f46e5; --cat-soft:#eef0ff; --cat-ink:#3730a3; }
body[data-cat="agent"]    { --cat:#7c3aed; --cat-soft:#f4ecff; --cat-ink:#5b21b6; }
body[data-cat="prompt"]   { --cat:#db2777; --cat-soft:#fdeef6; --cat-ink:#9d174d; }
body[data-cat="core"]     { --cat:#ea580c; --cat-soft:#fff1e8; --cat-ink:#9a3412; }
body[data-cat="dialog"]   { --cat:#0891b2; --cat-soft:#e6f8fd; --cat-ink:#155e75; }
body[data-cat="deploy"]   { --cat:#059669; --cat-soft:#e7f9f0; --cat-ink:#065f46; }

* { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.8;
  font-size: 17px;
  letter-spacing: .01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* 閱讀進度條 */
#progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0%;
  background: linear-gradient(90deg, var(--cat), color-mix(in srgb, var(--cat) 50%, #22d3ee));
  z-index: 100; transition: width .1s linear;
}

/* ---------- 頂部導覽 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.86);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 10px 20px;
  display: flex; align-items: center; gap: 14px;
}
.brand {
  display: inline-flex; align-items: center; gap: 9px;
  font-weight: 800; color: var(--ink); text-decoration: none; font-size: 15px;
  white-space: nowrap;
}
.brand .logo {
  width: 28px; height: 28px; border-radius: 8px; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--cat), color-mix(in srgb,var(--cat) 55%, #0ea5e9));
  color: #fff; display: grid; place-items: center; font-size: 15px;
}
.topbar .spacer { flex: 1; }
.topbar a.nav-link {
  color: var(--ink-soft); text-decoration: none; font-size: 14px; font-weight: 600;
  padding: 6px 12px; border-radius: 999px; white-space: nowrap;
}
.topbar a.nav-link:hover { background: var(--cat-soft); color: var(--cat-ink); }

/* ---------- 版心 ---------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px 96px; }

/* ---------- Hero ---------- */
.hero { padding: 40px 0 20px; }
.crumbs { font-size: 13.5px; color: var(--muted); margin-bottom: 18px; }
.crumbs a { color: var(--cat-ink); text-decoration: none; font-weight: 600; }
.crumbs a:hover { text-decoration: underline; }

.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.tag {
  font-size: 12.5px; font-weight: 700; padding: 4px 12px; border-radius: 999px;
  background: var(--cat-soft); color: var(--cat-ink); border: 1px solid transparent;
}
.tag.diff { background: var(--surface); border-color: var(--line-strong); color: var(--ink-soft); }
.tag.diff::before { content: "●  "; color: var(--cat); }
.tag.diff.d2::before { content: "●●  "; }
.tag.diff.d3::before { content: "●●●  "; }

.hero h1 {
  font-size: clamp(26px, 4.4vw, 38px); line-height: 1.32; margin: 6px 0 18px;
  letter-spacing: -.01em; font-weight: 800;
}
.hero h1 .q-mark {
  display: inline-grid; place-items: center; width: 1.5em; height: 1.5em; margin-right: .35em;
  border-radius: 12px; background: var(--cat); color: #fff; font-size: .62em; vertical-align: middle;
  box-shadow: var(--shadow);
}
.lede {
  font-size: 18.5px; color: var(--ink-soft); margin: 0; font-weight: 500;
  padding: 16px 20px; background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--line); border-left: 5px solid var(--cat); box-shadow: var(--shadow);
}

/* 面試官提問框 */
.interviewer {
  display: flex; gap: 14px; align-items: flex-start; margin: 26px 0 8px;
  padding: 18px 20px; background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.interviewer .avatar {
  flex: 0 0 auto; width: 46px; height: 46px; border-radius: 50%;
  background: linear-gradient(135deg, var(--cat), color-mix(in srgb,var(--cat) 50%, #1e293b));
  color: #fff; display: grid; place-items: center; font-size: 22px; box-shadow: var(--shadow);
}
.interviewer .bubble { flex: 1; }
.interviewer .who { font-size: 12.5px; font-weight: 800; color: var(--cat-ink); letter-spacing: .06em; }
.interviewer .say { margin: 3px 0 0; font-size: 17.5px; font-weight: 600; color: var(--ink); }

/* ---------- 內容區塊 ---------- */
section.block { margin-top: 34px; }
.h2 {
  display: flex; align-items: center; gap: 11px; font-size: 22px; font-weight: 800;
  margin: 0 0 6px; letter-spacing: -.01em;
}
.h2 .ic {
  width: 34px; height: 34px; flex: 0 0 auto; border-radius: 10px; display: grid; place-items: center;
  background: var(--cat-soft); color: var(--cat-ink); font-size: 18px;
}
.h2 + .sub { color: var(--muted); font-size: 14.5px; margin: 0 0 16px 45px; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 24px; box-shadow: var(--shadow); margin-top: 14px;
}
.card p:first-child { margin-top: 0; }
.card p:last-child { margin-bottom: 0; }

p { margin: 14px 0; }
strong { color: var(--ink); font-weight: 700; }
mark {
  background: color-mix(in srgb, var(--cat-soft) 70%, #fff); color: var(--cat-ink);
  padding: 1px 5px; border-radius: 5px; font-weight: 600;
}
a.inline { color: var(--cat-ink); text-decoration: underline; text-underline-offset: 3px; }

/* 名詞在內文 → 可點 */
.term {
  border-bottom: 2px dotted var(--cat); cursor: help; font-weight: 600;
  color: var(--cat-ink); text-decoration: none;
}
/* 已強調但無對應詞條 → 不可點，避免死連結 */
.term-flat { font-weight: 700; color: var(--cat-ink); }

/* ---------- Callout ---------- */
.callout {
  border-radius: var(--radius); padding: 16px 20px 16px 18px; margin: 16px 0;
  border: 1px solid var(--line); background: var(--surface); position: relative;
  border-left: 5px solid var(--muted);
}
.callout .ctitle { font-weight: 800; font-size: 15px; margin: 0 0 4px; display: flex; gap: 8px; align-items:center; }
.callout p { margin: 6px 0; }
.callout p:last-child { margin-bottom: 0; }
.callout.tldr   { border-left-color: var(--tldr);   background: var(--tldr-soft); }
.callout.tldr   .ctitle { color: var(--tldr); }
.callout.tip    { border-left-color: var(--tip);    background: var(--tip-soft); }
.callout.tip    .ctitle { color: var(--tip); }
.callout.warn   { border-left-color: var(--warn);   background: var(--warn-soft); }
.callout.warn   .ctitle { color: #b45309; }
.callout.danger { border-left-color: var(--danger); background: var(--danger-soft); }
.callout.danger .ctitle { color: var(--danger); }
.callout.info   { border-left-color: var(--info);   background: var(--info-soft); }
.callout.info   .ctitle { color: var(--info); }

/* ---------- 類比小盒 ---------- */
.analogy {
  background: linear-gradient(180deg,#fffdf5,#fff9e9); border: 1px dashed #f0c26b;
  border-radius: var(--radius); padding: 16px 20px; margin: 16px 0;
}
.analogy .ctitle { color:#b45309; font-weight:800; display:flex; gap:8px; align-items:center; margin-bottom:4px; }

/* ---------- 步驟流程 ---------- */
.steps { counter-reset: st; margin: 16px 0; padding: 0; list-style: none; }
.steps > li {
  position: relative; padding: 4px 0 18px 52px; margin: 0;
}
.steps > li::before {
  counter-increment: st; content: counter(st);
  position: absolute; left: 0; top: 0; width: 34px; height: 34px; border-radius: 50%;
  background: var(--cat); color: #fff; font-weight: 800; display: grid; place-items: center; font-size: 15px;
  box-shadow: var(--shadow);
}
.steps > li:not(:last-child)::after {
  content: ""; position: absolute; left: 16px; top: 36px; bottom: 2px; width: 2px; background: var(--line-strong);
}
.steps > li b { color: var(--ink); }

/* ---------- 對照表 ---------- */
.table-wrap { overflow-x: auto; margin: 16px 0; border-radius: var(--radius); border: 1px solid var(--line); }
table.cmp { border-collapse: collapse; width: 100%; font-size: 15.5px; background: var(--surface); }
table.cmp th, table.cmp td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
table.cmp thead th { background: var(--cat-soft); color: var(--cat-ink); font-weight: 800; border-bottom: 2px solid var(--cat); position: sticky; top: 0; }
table.cmp tbody tr:last-child td { border-bottom: none; }
table.cmp tbody tr:nth-child(even) td { background: var(--surface-2); }
table.cmp td:first-child { font-weight: 700; color: var(--ink); }

/* ---------- 名詞小百科 ---------- */
.glossary { display: grid; gap: 10px; margin-top: 14px; }
.gterm {
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface);
  overflow: hidden; box-shadow: var(--shadow);
}
.gterm > button {
  width: 100%; text-align: left; background: none; border: 0; cursor: pointer;
  padding: 15px 18px; font-family: inherit; font-size: 16.5px; font-weight: 700; color: var(--ink);
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
}
.gterm > button:hover { background: var(--cat-soft); }
.gterm .gname { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.gterm .gen { font-size: 12.5px; color: var(--muted); font-weight: 600; font-family: var(--font-mono); }
.gterm .chev { color: var(--cat); transition: transform .25s; flex: 0 0 auto; font-size: 14px; }
.gterm.open .chev { transform: rotate(90deg); }
.gterm .gbody {
  max-height: 0; overflow: hidden; transition: max-height .3s ease;
  padding: 0 18px; color: var(--ink-soft); font-size: 15.5px;
}
.gterm.open .gbody { max-height: 600px; padding-bottom: 16px; }
.gterm .gbody .kmeta { font-size: 13.5px; color: var(--muted); margin-top: 8px; }

/* ---------- 自我檢測 ---------- */
.quiz { margin-top: 14px; display: grid; gap: 14px; }
.qitem { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); padding: 16px 18px; box-shadow: var(--shadow); }
.qitem .qq { font-weight: 700; margin: 0 0 6px; }
.qitem .qq .num { color: var(--cat); font-weight: 800; margin-right: 6px; }
.qitem .reveal-btn {
  border: 1px solid var(--cat); color: var(--cat-ink); background: var(--cat-soft);
  font-family: inherit; font-weight: 700; font-size: 14px; padding: 6px 14px; border-radius: 999px; cursor: pointer;
}
.qitem .reveal-btn:hover { background: var(--cat); color: #fff; }
.qitem .qa {
  display: none; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line-strong);
  color: var(--ink-soft); font-size: 15.5px;
}
.qitem.show .qa { display: block; }
.qitem.show .reveal-btn { display: none; }

/* ---------- 模範答案 ---------- */
.model {
  background: linear-gradient(180deg, #0f172a, #111827); color: #e5edf7; border-radius: var(--radius);
  padding: 22px 24px; margin-top: 14px; box-shadow: var(--shadow-lg); position: relative;
  border: 1px solid #1f2937;
}
.model .mh { display: flex; align-items: center; gap: 8px; font-weight: 800; color: #7dd3fc; margin-bottom: 10px; font-size: 15px; }
.model p { color: #dbe4f0; margin: 10px 0; }
.model strong { color: #fff; }
.model .copy {
  position: absolute; top: 16px; right: 16px; background: #1e293b; color: #cbd5e1; border: 1px solid #334155;
  border-radius: 8px; padding: 5px 12px; font-size: 12.5px; font-family: inherit; cursor: pointer; font-weight: 600;
}
.model .copy:hover { background: #334155; color: #fff; }

/* ---------- 金句 / 口訣 ---------- */
.mantra {
  text-align: center; font-size: 19px; font-weight: 800; color: var(--cat-ink);
  background: var(--cat-soft); border-radius: var(--radius); padding: 22px; margin: 18px 0;
  border: 1px dashed var(--cat);
}
.mantra .qm { opacity: .35; font-size: 26px; }

/* ---------- 上下篇 ---------- */
.pager { display: flex; gap: 14px; margin-top: 46px; flex-wrap: wrap; }
.pager a {
  flex: 1 1 240px; text-decoration: none; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
  transition: transform .12s, box-shadow .12s;
}
.pager a:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--cat); }
.pager .dir { font-size: 12.5px; color: var(--muted); font-weight: 700; }
.pager .ttl { font-weight: 700; margin-top: 3px; color: var(--cat-ink); font-size: 15.5px; }
.pager a.next { text-align: right; }

/* ---------- 頁尾 ---------- */
.foot { max-width: var(--maxw); margin: 0 auto; padding: 30px 20px 60px; color: var(--muted); font-size: 13.5px; text-align: center; border-top: 1px solid var(--line); }
.foot a { color: var(--cat-ink); text-decoration: none; }

/* =========================================================
   首頁 index
   ========================================================= */
.home-hero {
  background:
    radial-gradient(1200px 400px at 80% -50%, rgba(99,102,241,.18), transparent),
    linear-gradient(180deg, #0f172a, #131c31);
  color: #eaf1fb; padding: 64px 20px 54px; text-align: center;
}
.home-hero .kicker { color: #7dd3fc; font-weight: 800; letter-spacing: .12em; font-size: 13px; text-transform: uppercase; }
.home-hero h1 { font-size: clamp(30px, 6vw, 50px); margin: 12px 0 14px; font-weight: 900; letter-spacing: -.02em; line-height:1.2; }
.home-hero p { color: #b7c4d8; font-size: 18px; max-width: 640px; margin: 0 auto; }
.home-stats { display: flex; gap: 30px; justify-content: center; margin-top: 26px; flex-wrap: wrap; }
.home-stats .s { }
.home-stats .n { font-size: 30px; font-weight: 900; color: #fff; }
.home-stats .l { font-size: 13px; color: #93a4bd; }

.searchbar { max-width: 560px; margin: 24px auto 0; position: relative; }
.searchbar input {
  width: 100%; padding: 14px 18px 14px 46px; border-radius: 999px; border: 1px solid #2b3a55;
  background: rgba(255,255,255,.06); color: #fff; font-size: 16px; font-family: inherit; outline: none;
}
.searchbar input::placeholder { color: #8595ad; }
.searchbar input:focus { border-color: #7dd3fc; background: rgba(255,255,255,.1); }
.searchbar .si { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); color: #8595ad; }

.home-wrap { max-width: 1080px; margin: 0 auto; padding: 40px 20px 90px; }

.filterbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; justify-content: center; }
.chip {
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-soft);
  border-radius: 999px; padding: 7px 15px; font-size: 13.5px; font-weight: 700; cursor: pointer;
  font-family: inherit; transition: all .12s;
}
.chip:hover { border-color: var(--cat); }
.chip.active { background: var(--cat); color: #fff; border-color: var(--cat); }

.cat-section { margin-top: 40px; }
.cat-head { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.cat-head .dot { width: 14px; height: 14px; border-radius: 4px; }
.cat-head h2 { font-size: 22px; font-weight: 800; margin: 0; }
.cat-head .cnt { color: var(--muted); font-weight: 700; font-size: 14px; }
.cat-desc { color: var(--muted); font-size: 14.5px; margin: 0 0 16px 26px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: 16px; }
.pcard {
  display: flex; flex-direction: column; text-decoration: none; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 18px 16px; box-shadow: var(--shadow); transition: transform .12s, box-shadow .12s, border-color .12s;
  border-top: 4px solid var(--pc, var(--cat));
}
.pcard:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--pc, var(--cat)); }
.pcard .pc-cat { font-size: 12px; font-weight: 800; color: var(--pc, var(--cat)); letter-spacing: .04em; }
.pcard .pc-title { font-weight: 700; font-size: 16.5px; line-height: 1.5; margin: 7px 0 10px; color: var(--ink); }
.pcard .pc-desc { font-size: 13.5px; color: var(--muted); line-height: 1.7; margin: 0 0 14px; flex: 1; }
.pcard .pc-foot { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-soft); }
.pcard .pc-diff { font-weight: 700; }
.pcard .pc-diff .d { color: var(--pc, var(--cat)); }
.pcard .pc-go { margin-left: auto; color: var(--pc, var(--cat)); font-weight: 800; }
.no-result { text-align: center; color: var(--muted); padding: 40px; display: none; }

/* ---------- RWD ---------- */
@media (max-width: 640px) {
  body { font-size: 16px; }
  .wrap { padding: 0 16px 70px; }
  .hero { padding: 26px 0 10px; }
  .card { padding: 18px; }
  .topbar a.nav-link.hide-sm { display: none; }
  .home-stats { gap: 20px; }
}

@media print {
  .topbar, #progress, .pager, .foot, .searchbar, .filterbar { display: none !important; }
  body { background: #fff; font-size: 12pt; }
  .card, .callout, .model { box-shadow: none; break-inside: avoid; }
  .model { background: #fff; color: #000; border: 1px solid #ccc; }
  .model p, .model strong, .model .mh { color: #000; }
  .gterm .gbody { max-height: none !important; padding: 0 18px 16px !important; }
}
