/* =====================================================================
 * fantaclient/codex/codex.css — 幻想國度・圖鑑（GUI AI 維護）
 * 2026-10-25 起掛在官網樣板裡（web/templates/website/codex.html extends website/base.html）：
 * 導覽列、頁尾、容器寬度、卡片、深色模式切換都由官網提供，這裡只管圖鑑自己的元件。
 * ⚠ 一律寫在 .cx-root 底下，不碰 body／a／button 這些全站元素，免得把官網其他地方一起改掉。
 * 配色變數掛在 .cx-root：官網首頁那套淺色／深色（值由 Backend AI 2026-10-25 對過 custom.css），
 * 變數名沿用 /g/ 的 --paper／--ink…，所以 fc_map.js 畫的地圖照吃。
 * ===================================================================== */
.cx-root {
  --paper: #f4f1eb;          /* 官網頁面底色 */
  --paper-deep: #e8dfca;
  --paper-panel: #fffdf7;    /* 官網卡片底 */
  --ink: #2c2c2c;
  --ink-soft: #4a3c2c;
  --ink-faint: #75694f;
  --line: #d4c9a8;           /* 官網卡片邊框 */
  --seal: #8b1a1a;           /* --fanta-red */
  --seal-soft: rgba(139, 26, 26, 0.10);
  --jade: #3f6b55;
  --river: #2a5286;
  --gold: #8a6a1f;           /* --fanta-gold-dark */
  --title: #8b1a1a;
  --fali: #6b4f8f;
  --shadow: rgba(0, 0, 0, 0.12);
  --map-line: #b9ab86;
  font-size: 15px;
  line-height: 1.6;
}
html[data-theme="dark"] .cx-root {
  --paper: #121220;          /* 官網深色模式底色 */
  --paper-deep: #1c2540;
  --paper-panel: #16213e;    /* --fanta-card-bg */
  --ink: #d9d5c9;
  --ink-soft: #bdb7a8;
  --ink-faint: #9aa0ad;
  --line: #2a3a5c;           /* --fanta-border */
  --seal: #e0857a;
  --seal-soft: rgba(224, 133, 122, 0.14);
  --jade: #7fc4a0;
  --river: #82b5ff;
  --gold: #e3cf8e;
  --title: #e3cf8e;          /* 官網深色標題亮金 */
  --fali: #b49ae0;
  --shadow: rgba(0, 0, 0, 0.5);
  --map-line: #3c4d72;
}
.cx-root button { font: inherit; color: inherit; }
/* iPhone 自動偵測出來的地址／電話連結：維持原本的字色，不要變藍 */
.cx-root a[x-apple-data-detectors], .cx-root a[href^="tel:"] { color: inherit !important; text-decoration: none !important; }
.cx-loading { padding: 40px; text-align: center; color: var(--ink-faint); }

/* ---- 圖鑑卡片的標頭：官網 .card-header（深褐漸層＋金字）裡放標題、搜尋、分頁 ---- */
.cx-shell { margin-bottom: 24px; }
.cx-shell > .card-header { padding: 12px 18px 0; }
.cx-head-row { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; }
.cx-title { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: .12em; color: var(--fanta-gold, #c8a84b); }
.cx-count { font-size: 12px; color: #e8d9b0; opacity: .8; }
.cx-search { flex: 1 1 220px; min-width: 0; max-width: 340px; margin-left: auto; padding: 5px 10px; border-radius: 3px;
  border: 1px solid rgba(200, 168, 75, .45); background: rgba(0, 0, 0, .28); color: #f4ecd6; font: inherit; font-size: 14px; }
.cx-search::placeholder { color: #b8a986; }
.cx-search:focus { outline: none; border-color: var(--fanta-gold, #c8a84b); }
.cx-root .cx-back { font-size: 13px; white-space: nowrap; padding: 4px 12px; border-radius: 3px; text-decoration: none;
  color: var(--fanta-gold, #c8a84b); border: 1px solid rgba(200, 168, 75, .55); }
.cx-root .cx-back:hover { background: rgba(200, 168, 75, .15); color: var(--fanta-gold, #c8a84b); }
.cx-tabs { display: flex; gap: 2px; margin: 8px -6px 0; overflow-x: auto; scrollbar-width: none; }
.cx-tabs::-webkit-scrollbar { display: none; }
.cx-tab { flex: none; padding: 7px 14px; border: 0; background: transparent; color: #e8d9b0; cursor: pointer;
  border-bottom: 3px solid transparent; font-size: 15px; letter-spacing: .03em; }
.cx-tab:hover { color: var(--fanta-gold, #c8a84b); }
.cx-tab.is-on { color: var(--fanta-gold, #c8a84b); border-bottom-color: var(--fanta-gold, #c8a84b); font-weight: 700; }
.cx-tab:focus { outline: none; }
.cx-main { padding: 18px; }

/* ---- 共用 ---- */
.cx-h2 { margin: 0 0 6px; font-size: 22px; color: var(--title); font-weight: 600; letter-spacing: .04em; }
.cx-sub { color: var(--ink-faint); font-size: 13px; margin-bottom: 10px; }
.cx-desc { white-space: pre-wrap; line-height: 1.85; margin: 0 0 10px; }
.cx-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; align-items: center; }
.cx-chips-label { font-size: 12px; color: var(--ink-faint); margin-right: 2px; }
.cx-chip { border: 1px solid var(--line); background: var(--paper-panel); border-radius: 14px; padding: 2px 11px; cursor: pointer; font-size: 13px; line-height: 1.6; }
.cx-chip:hover { border-color: var(--seal); }
/* 稀有度籤的字色是 inline style，選中時要壓過去，否則字跟朱紅底同色 */
.cx-chip.is-on { background: var(--seal); border-color: var(--seal); color: #fff !important; }
html[data-theme="dark"] .cx-chip.is-on { color: #121220 !important; }
.cx-chip small { color: inherit; opacity: .7; margin-left: 3px; }
.cx-select { font: inherit; font-size: 13px; padding: 3px 6px; border: 1px solid var(--line); background: var(--paper-panel); color: var(--ink); border-radius: 3px; }
/* 國度鈕：比區域鈕方正、粗一點，一眼分得出是兩層 */
.cx-nations { margin-bottom: 6px; padding-bottom: 8px; border-bottom: 1px dashed var(--line); }
.cx-chip.cx-nat { border-radius: 3px; font-weight: 600; padding: 3px 14px; }
.cx-panel { background: var(--paper-panel); border: 1px solid var(--line); border-radius: 3px; padding: 14px 16px; }
.cx-empty { color: var(--ink-faint); font-style: italic; padding: 10px 0; }
.cx-more { display: block; margin: 12px auto; padding: 6px 20px; border: 1px solid var(--line); background: var(--paper-panel); border-radius: 3px; cursor: pointer; }
.cx-tag { display: inline-block; font-size: 11px; padding: 0 6px; border-radius: 2px; border: 1px solid currentColor; margin-right: 4px; line-height: 1.6; vertical-align: 1px; }
.cx-tag.master { color: var(--gold); } .cx-tag.shopkeeper { color: var(--jade); } .cx-tag.hostile { color: var(--seal); }
.cx-tag.animal { color: var(--ink-soft); } .cx-tag.ferryman { color: var(--river); }
/* 物品標章（板 #52）：不會掉落／販售用／酒；「不會掉落」也是三個物品頁共用的切換鈕 */
.cx-itag { display: inline-block; font-size: 11px; padding: 0 6px; border-radius: 2px; border: 1px solid currentColor; line-height: 1.6; margin-right: 6px; vertical-align: 1px; }
.cx-itag.is-noloot { color: var(--seal); background: var(--seal-soft); }
.cx-itag.is-trade { color: var(--gold); }
.cx-itag.is-wine { color: var(--river); }
.cx-chip.cx-toggle { border-style: dashed; color: var(--seal); }
.cx-sells > span { line-height: 1.9; }
.cx-price { color: var(--ink-faint); margin-left: 3px; font-size: 11px; }
.cx-link { color: var(--river); cursor: pointer; border-bottom: 1px dotted currentColor; }
.cx-link:hover { color: var(--seal); }

/* ---- 地圖頁 ---- */
.cx-nation { font-size: 12px; color: var(--ink-faint); width: 100%; margin-top: 4px; }
.cx-mapwrap { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 14px; align-items: start; }
.cx-mapbox { overflow: auto; max-height: 72vh; background: var(--paper); border: 1px solid var(--line); border-radius: 3px; }
.cx-mapbox .fcm-svg { margin: 12px; }
.cx-room-banner { width: 100%; aspect-ratio: 1536 / 528; object-fit: cover; border-radius: 2px; display: block; margin-bottom: 10px; }
.cx-room h3 { margin: 0 0 6px; font-size: 20px; color: var(--title); }
.cx-exits { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0 10px; }
.cx-exit { font-size: 13px; padding: 1px 8px; border: 1px solid var(--seal); border-radius: 2px; color: var(--seal); background: var(--seal-soft); cursor: pointer; }
.cx-exit.is-out { border-color: var(--river); color: var(--river); background: transparent; cursor: default; }
.cx-npcrow { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---- 人物卡 ---- */
.cx-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.cx-card { background: var(--paper-panel); border: 1px solid var(--line); border-radius: 3px; overflow: hidden; cursor: pointer; display: flex; flex-direction: column; }
.cx-card:hover { border-color: var(--seal); box-shadow: 0 3px 10px var(--shadow); }
.cx-card-img { height: 150px; background: var(--paper-deep); display: flex; align-items: flex-end; justify-content: center; overflow: hidden; }
.cx-card-img img { width: 100%; height: 100%; object-fit: cover; object-position: center 12%; }
.cx-card-img img.is-full { object-fit: contain; object-position: center bottom; }
.cx-card-img .cx-noimg { font-size: 42px; color: var(--paper); align-self: center; }
.cx-card-body { padding: 6px 8px 8px; }
.cx-card-name { font-size: 15px; font-weight: 600; }
.cx-card-meta { font-size: 12px; color: var(--ink-faint); line-height: 1.45; }
.cx-mini { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 3px; border: 1px solid var(--line); border-radius: 18px;
  background: var(--paper-panel); cursor: pointer; font-size: 13px; }
.cx-mini:hover { border-color: var(--seal); }
.cx-mini i { width: 28px; height: 28px; border-radius: 50%; background: var(--paper-deep) center 14% / 220% auto no-repeat; flex: none; }

/* ---- 門派 ---- */
.cx-sects { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
.cx-sect h3 { margin: 0; font-size: 20px; color: var(--title); }
.cx-sect h3 small { font-size: 12px; color: var(--ink-faint); font-weight: 400; margin-left: 6px; }
.cx-motto { font-style: italic; color: var(--ink-soft); margin: 4px 0; }
.cx-sect .cx-desc { max-height: 9.5em; overflow: hidden; position: relative; }
.cx-sect .cx-desc.is-open { max-height: none; }
.cx-sect-more { font-size: 12px; }
.cx-artlist { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 13px; }

/* ---- 武學／物品列表 ---- */
.cx-list { display: flex; flex-direction: column; gap: 6px; }
.cx-row { background: var(--paper-panel); border: 1px solid var(--line); border-left-width: 4px; border-radius: 3px; padding: 7px 12px; }
.cx-row-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.cx-row-name { font-size: 16px; font-weight: 600; }
.cx-row-meta { font-size: 12px; color: var(--ink-faint); }
.cx-row-desc { font-size: 14px; color: var(--ink-soft); margin-top: 3px; white-space: pre-wrap; }
.cx-row-desc[data-clamp] { cursor: pointer; }
.cx-row-desc.is-clamp { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.cx-stats { font-size: 13px; margin-top: 3px; display: flex; flex-wrap: wrap; gap: 2px 12px; }
.cx-stats b { font-weight: 600; color: var(--jade); }

/* ---- 搜尋結果 ---- */
.cx-results h3 { font-size: 15px; color: var(--ink-soft); margin: 14px 0 6px; border-bottom: 1px solid var(--line); }

/* ---- 人物詳情（浮層） ---- */
.cx-modal { position: fixed; inset: 0; z-index: 1050; background: rgba(20, 16, 12, .55); display: none; align-items: center; justify-content: center; padding: 16px; }
.cx-modal.is-on { display: flex; }
.cx-modal-card { background: var(--paper); border: 1px solid var(--line); border-radius: 4px; max-width: 760px; width: 100%; max-height: 90vh; overflow: auto;
  display: grid; grid-template-columns: 260px minmax(0, 1fr); box-shadow: 0 10px 40px rgba(0,0,0,.4); }
.cx-modal-img { background: var(--paper-deep); display: flex; align-items: flex-end; justify-content: center; min-height: 300px; }
.cx-modal-img img { width: 100%; height: auto; display: block; }
.cx-modal-body { padding: 16px 18px; position: relative; }
.cx-close { position: absolute; top: 6px; right: 8px; border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--ink-faint); }
.cx-modal-body h3 { margin: 0 0 2px; font-size: 24px; color: var(--title); }
.cx-kv { font-size: 13px; color: var(--ink-soft); margin: 2px 0; }
.cx-kv b { color: var(--ink-faint); font-weight: 400; margin-right: 6px; }

@media (max-width: 860px) {
  .cx-mapwrap { grid-template-columns: 1fr; }
  .cx-mapbox { max-height: 55vh; }
  .cx-modal-card { grid-template-columns: 1fr; }
  .cx-modal-img { min-height: 0; max-height: 46vh; overflow: hidden; }
  .cx-modal-img img { object-fit: cover; object-position: center 10%; }
  .cx-sects { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .cx-shell > .card-header { padding: 10px 12px 0; }
  .cx-title { font-size: 19px; }
  .cx-count { display: none; }
  .cx-search { max-width: none; flex-basis: 100%; order: 5; font-size: 16px; }
  .cx-tab { padding: 7px 10px; font-size: 14px; }
  .cx-main { padding: 12px; }
  .cx-grid { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
  .cx-card-img { height: 128px; }
}
