/* =====================================================================
   tool-pages.css — 工具類內容頁共用排版層（2026-11-09）
   適用：mortgage / stamp-duty / utilities / asset-allocation（四語言各版）
   原則：只改「排版／互動／可讀性」，頁面所有文字、數字、連結一律不動。
   載入位置：各頁 <head> 內 brand.css 之後（<link rel="stylesheet" href="/assets/css/tool-pages.css">）
   所有選擇器都掛喺 body.tp 下，唔影響其他頁面。
   ===================================================================== */

/* ---------- 0. 版面闊度：文章欄放闊，貼近頂部導航 ---------- */
body.tp { --maxw: 920px; }
body.tp .topbar-inner { max-width: var(--maxnav-tp, 1040px); }
@media (min-width: 1100px) { body.tp { --maxw: 980px; } }

/* ---------- 1. 手機頂欄：品牌名同牌照唔換行 ---------- */
body.tp .brand-name { white-space: nowrap; min-width: 0; }
body.tp .brand-name .lic { white-space: nowrap; }
@media (max-width: 560px) {
  body.tp .topbar-inner { padding: 10px 14px; gap: 8px; }
  body.tp .brand-name { font-size: 14px; gap: 6px; }
  body.tp .brand-name .lic { font-size: 11px; margin-left: 2px; }
  body.tp .back-link { padding: 6px 10px; font-size: 13px; }
}
@media (max-width: 400px) {
  body.tp .brand-name .lic { display: none; }
}

/* ---------- 2. Hero：版頭更有層次 ---------- */
body.tp .hero { padding: 44px 0 30px; position: relative; }
body.tp .hero::after {
  content: ""; position: absolute; left: 0; bottom: -1px; width: 88px; height: 2px;
  background: linear-gradient(90deg, var(--gold), transparent);
}
body.tp .hero .lede { max-width: 62ch; line-height: 1.85; }
@media (max-width: 560px) {
  body.tp .hero { padding: 30px 0 24px; }
  body.tp .hero .lede { font-size: 16.5px; }
}

/* ---------- 3. 頁內目錄（JS 按 h2 自動生成）---------- */
body.tp .tp-toc {
  position: sticky; top: var(--tp-sticky, 58px); z-index: 30;
  display: flex; gap: 8px; align-items: center;
  margin: 18px -20px 0; padding: 6px 20px;
  background: rgba(15,24,41,.9); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
body.tp .tp-toc::-webkit-scrollbar { display: none; }
body.tp .tp-toc a {
  flex: 0 0 auto; text-decoration: none; white-space: nowrap;
  display: inline-flex; align-items: center; min-height: 44px;
  padding: 6px 15px; border-radius: 999px;
  font-size: 13.5px; font-weight: 700; color: var(--ink-dim);
  border: 1px solid var(--line-soft); background: rgba(255,255,255,.02);
  transition: color .15s, border-color .15s, background .15s;
}
body.tp .tp-toc a:hover { color: var(--gold-light); border-color: var(--gold); }
body.tp .tp-toc a.on {
  color: #1A1206; border-color: transparent;
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
}
body.tp h2.sec { scroll-margin-top: calc(var(--tp-sticky, 58px) + 76px); }
/* --tp-sticky 由 tool-pages.js 量度「常駐頂欄」實際高度（topbar；sitenav 若 sticky 亦計入），
   唔再寫死 px，咁頂欄由其他人改高度都唔會撞 */
@media (max-width: 768px) {
  body.tp .tp-toc { margin-left: -20px; margin-right: -20px; }
}

/* ---------- 4. 章節標題：金線＋序號，增加掃讀節奏 ---------- */
body.tp h2.sec {
  font-size: 23px; margin: 56px 0 18px; padding-left: 15px;
  border-left-width: 4px; border-radius: 1px;
}
@media (max-width: 560px) { body.tp h2.sec { font-size: 20px; margin-top: 44px; } }

/* ---------- 5. 表格：粘頭、斑馬紋、較大行高、手機橫向捲動提示 ---------- */
body.tp .tablewrap {
  position: relative; max-height: none; border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.18);
}
body.tp table.schools { min-width: 0; width: 100%; }
body.tp table.schools thead th { position: sticky; top: 0; z-index: 1; }
body.tp table.schools tbody tr:nth-child(even) { background: rgba(255,255,255,.022); }
body.tp table.schools tbody tr:hover { background: var(--panel-2); }
body.tp table.schools tbody td { padding: 14px 16px; line-height: 1.6; }
body.tp table.schools thead th { padding: 13px 16px; }
body.tp table.schools .net { font-variant-numeric: tabular-nums; }
body.tp table.schools td, body.tp table.schools th { overflow-wrap: anywhere; }
@media (max-width: 640px) {
  body.tp table.schools { font-size: 14.5px; }
  body.tp table.schools tbody td { padding: 12px 12px; }
  body.tp table.schools thead th { padding: 11px 12px; font-size: 13px; white-space: normal; }
}
/* 稅率表（3 欄、有長稅額文字）：手機轉做逐行卡片，欄名由 data-label 帶出 */
@media (max-width: 640px) {
  body.tp table.schools.tp-stack { display: block; }
  body.tp table.schools.tp-stack thead { display: none; }
  body.tp table.schools.tp-stack tbody { display: block; }
  body.tp table.schools.tp-stack tbody tr {
    display: block; padding: 12px 14px; border-top: 1px solid var(--line-soft);
  }
  body.tp table.schools.tp-stack tbody td {
    display: flex; justify-content: space-between; align-items: baseline; gap: 14px;
    padding: 4px 0; border: 0; text-align: right; overflow-wrap: anywhere;
  }
  body.tp table.schools.tp-stack tbody td::before {
    content: attr(data-label); flex: 0 0 auto; max-width: 42%;
    text-align: left; color: var(--ink-faint); font-size: 13px; font-weight: 700;
  }
  body.tp table.schools.tp-stack tbody td.net { color: var(--gold-light); }
  body.tp table.schools.tp-stack .tablewrap { overflow: visible; }
}

/* 桌面：滑鼠移過稅率／成數行時，整行金邊高亮 */
@media (hover: hover) {
  body.tp table.schools tbody tr { transition: background .14s, box-shadow .14s; }
  body.tp table.schools tbody tr:hover { box-shadow: inset 3px 0 0 var(--gold); }
}

body.tp .tablewrap + ul, body.tp .tablewrap + p, body.tp .tablewrap + .note { margin-top: 18px; }
body.tp .tablewrap { margin-bottom: 4px; }

/* ---------- 6. 提示框 / 註腳 ---------- */
body.tp .note { border-radius: 14px; padding: 16px 18px; line-height: 1.8; }
body.tp .note b { color: var(--gold-light); }

/* ---------- 7. 列表 ---------- */
body.tp ul li, body.tp ol li { line-height: 1.8; }

/* ---------- 8. CTA：兩個大掣，手機底部同 Tab Bar 唔打架 ---------- */
body.tp .cta-row { margin: 44px 0 10px; }
body.tp .btn { min-height: 52px; display: inline-flex; align-items: center; justify-content: center; }
body.tp .btn-gold { box-shadow: 0 12px 34px rgba(201,164,92,.26); }
@media (max-width: 768px) { body.tp .wrap { padding-bottom: 110px; } }

/* ---------- 9. 返回頂部按鈕 ---------- */
body.tp .tp-top {
  position: fixed; right: 16px; bottom: 86px; z-index: 90;
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line);
  background: rgba(22,33,58,.92); color: var(--gold-light);
  display: grid; place-items: center; cursor: pointer; backdrop-filter: blur(8px);
  opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: opacity .2s, transform .2s, border-color .2s;
}
body.tp .tp-top.show { opacity: 1; transform: none; pointer-events: auto; }
body.tp .tp-top:hover { border-color: var(--gold); }
body.tp .tp-top svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
@media (min-width: 769px) { body.tp .tp-top { bottom: 28px; right: 24px; } }

/* ---------- 10. 可複製電話／電郵（utilities）---------- */
body.tp .tp-copy {
  display: inline-grid; place-items: center; width: 44px; height: 44px; margin: -10px -6px -10px 4px;
  vertical-align: middle; border-radius: 8px; border: 1px solid var(--line-soft);
  background: rgba(255,255,255,.03); color: var(--ink-dim); cursor: pointer; padding: 0;
  transition: color .15s, border-color .15s;
}
body.tp .tp-copy:hover { color: var(--gold-light); border-color: var(--gold); }
body.tp .tp-copy svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
body.tp .tp-copy.ok { color: #6EE7B7; border-color: #6EE7B7; }
body.tp .tp-toast {
  position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 10px); z-index: 200;
  padding: 9px 16px; border-radius: 999px; font-size: 13.5px; font-weight: 700;
  background: rgba(22,33,58,.96); color: var(--gold-light); border: 1px solid var(--line);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
body.tp .tp-toast.show { opacity: 1; transform: translate(-50%, 0); }
body.tp a.inline-link { text-underline-offset: 3px; text-decoration-thickness: 1px; }

/* ---------- 11. 電話／電郵表格（utilities）：手機版 label 在上、內容在下 ---------- */
@media (max-width: 640px) {
  body.tp table.schools.tp-kv tbody tr { display: block; padding: 11px 14px; border-top: 1px solid var(--line-soft); }
  body.tp table.schools.tp-kv { display: block; }
  body.tp table.schools.tp-kv thead { display: none; }
  body.tp table.schools.tp-kv tbody { display: block; }
  body.tp table.schools.tp-kv tbody td { display: block; padding: 2px 0; border: 0; }
  body.tp table.schools.tp-kv tbody td.sname { color: var(--ink-faint); font-size: 13px; font-weight: 700; }
  body.tp table.schools.tp-kv tbody td.net { font-size: 15.5px; }
}

/* ---------- 12. 按揭計算機：補返缺失嘅 Tailwind class，並做成「結果粘住」互動 ----------
   原頁用咗 lg:grid-cols-2 / w-screen / max-w-6xl / w-[220px] 等未編譯入 tailwind.css 嘅 class，
   令桌面版變單欄巨型圖、手機版右邊被裁。以下只補返「缺失」嘅 class，且全部限定喺計算機容器內，
   HTML 唔變、其他元素唔受影響。 */
body.tp .reveal.w-screen { width: 100%; margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0; }
body.tp .reveal.w-screen > .max-w-6xl { max-width: none; }
body.tp .reveal.w-screen .lg\:grid-cols-2 { display: grid; grid-template-columns: minmax(0, 1fr); }
body.tp .reveal.w-screen .md\:grid-cols-2,
body.tp .reveal.w-screen .sm\:grid-cols-2,
body.tp .reveal.w-screen .sm\:grid-cols-3 { display: grid; grid-template-columns: minmax(0, 1fr); }
body.tp .reveal.w-screen .gap-5 { gap: 20px; }
body.tp .reveal.w-screen svg.w-\[220px\] { width: min(260px, 70vw); height: auto; aspect-ratio: 1; }
/* Tailwind 小字（10/11/12px）：提升到可讀尺寸，淺灰字對比提升到 AA */
body.tp .reveal.w-screen .text-\[10px\] { font-size: 12px; }
body.tp .reveal.w-screen .text-\[11px\] { font-size: 12.5px; }
body.tp .reveal.w-screen .text-\[12px\] { font-size: 13px; }
body.tp .reveal.w-screen .soft-inset { box-shadow: inset 0 1px 0 rgba(255,255,255,.06); }
body.tp .reveal.w-screen .gold-gradient { background: linear-gradient(135deg, #FDE08D 0%, #C5A059 50%, #A1824A 100%); }
@media (min-width: 640px) {
  body.tp .reveal.w-screen .sm\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body.tp .reveal.w-screen .sm\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 768px) {
  body.tp .reveal.w-screen .md\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
  body.tp .reveal.w-screen .lg\:grid-cols-2 { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: start; }
  body.tp .reveal.w-screen .lg\:border-r { border-right: 1px solid rgba(30, 41, 59, 1); }
  body.tp .reveal.w-screen .lg\:border-b-0 { border-bottom: 0; }
  /* 結果面板：向下捲動輸入欄時，結果維持喺視窗內（粘住） */
  body.tp .reveal.w-screen .lg\:grid-cols-2 { align-items: start; padding: 16px; gap: 16px; }
  body.tp .reveal.w-screen .lg\:grid-cols-2 > :first-child {
    position: sticky; top: calc(var(--tp-sticky, 58px) + 66px); align-self: start; padding: 22px;
    border: 1px solid rgba(30, 41, 59, 1); border-radius: 16px; background: rgba(2, 6, 23, .42);
  }
}
/* 計算機左欄：圖表喺上、數字面板喺下（左欄較窄，唔再左右夾） */
@media (min-width: 1024px) {
  body.tp .reveal.w-screen .lg\:grid-cols-2 > :first-child .md\:grid-cols-2 { grid-template-columns: minmax(0, 1fr); gap: 18px; }
}
@media (min-width: 768px) and (max-width: 1023px) {
  body.tp .reveal.w-screen .lg\:grid-cols-2 > :first-child .md\:grid-cols-2 { grid-template-columns: 220px minmax(0, 1fr); }
}
body.tp #mort-payment { font-size: 22px; letter-spacing: .01em; }
body.tp #mort-payment-center { font-variant-numeric: tabular-nums; }

/* 手機：月供結果條粘喺頂欄下面，輸入時即時見到變化 */
body.tp .tp-mort-sticky {
  position: sticky; top: calc(var(--tp-sticky, 58px) + 58px); z-index: 35; display: none;
  align-items: center; justify-content: space-between; gap: 12px;
  margin: 10px 0 0; padding: 10px 14px; border-radius: 12px;
  background: rgba(15, 24, 41, .94); backdrop-filter: blur(10px);
  border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
}
body.tp .tp-mort-sticky .k { font-size: 13px; color: var(--ink-dim); font-weight: 700; }
body.tp .tp-mort-sticky .v { font-size: 19px; font-weight: 900; color: #FCD34D; font-variant-numeric: tabular-nums; }
@media (max-width: 1023px) { body.tp .tp-mort-sticky.show { display: flex; } }

/* 計算機輸入欄：觸控友善、聚焦金邊 */
body.tp input[type="number"] { min-height: 46px; font-variant-numeric: tabular-nums; }
body.tp input[type="number"]:focus, body.tp select:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
body.tp input[type="range"] { min-height: 44px; cursor: pointer; }

/* ---------- 13. 步驟（按揭流程）---------- */
body.tp .steps { margin-top: 14px; }

/* ---------- 14. 資產配置頁：卡片 hover、桌面多欄 ---------- */
@media (min-width: 900px) {
  body.tp .asset-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  body.tp .concept-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  body.tp .extension-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body.tp .thinking-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  /* 互動圖：圖喺左、拉桿喺右，唔使上下夾 */
  body.tp .allocation-map--interactive { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 8px 28px; align-items: center; padding: 28px 28px 22px; }
  body.tp .allocation-map--interactive > svg { grid-column: 1; grid-row: 1; margin: 0; }
  body.tp .allocation-map--interactive > .allocation-controls { grid-column: 2; grid-row: 1; margin: 0; max-width: none; grid-template-columns: minmax(0,1fr); }
  body.tp .allocation-map--interactive > .map-caption { grid-column: 1 / -1; }
}
@media (hover: hover) {
  body.tp .asset-card, body.tp .concept-card, body.tp .thinking-card, body.tp .extension-card {
    transition: transform .16s ease, border-color .16s ease, background .16s ease;
  }
  body.tp .asset-card:hover, body.tp .concept-card:hover, body.tp .thinking-card:hover {
    transform: translateY(-2px); border-color: var(--gold);
  }
}
/* 圓環：原 SVG 畫布 760x500 四邊留白太多，用 CSS 裁到圓環範圍（SVG 內容不動）
   圓環外半徑 = 122+42 = 164，圓心 (380,250) → 可視範圍約 x:206..554 y:76..424 */
body.tp .allocation-map--interactive > svg {
  width: min(100%, 360px); max-width: 360px; height: auto; aspect-ratio: 1 / 1; margin: 0 auto;
  overflow: hidden;
}
@media (max-width: 899px) {
  body.tp .allocation-map--interactive > svg { width: min(72%, 280px); margin: 0 auto 16px; }
  body.tp .allocation-map--interactive > .allocation-controls { margin-top: 0; }
}
/* 圓環區塊：拉動時對應拉桿旁數字高亮 */
body.tp .allocation-control output { font-variant-numeric: tabular-nums; }
body.tp .allocation-control.tp-active label, body.tp .allocation-control.tp-active output { color: var(--gold-light); }
body.tp .allocation-control input[type="range"] { height: 44px; }
@media (max-width: 899px) { body.tp .asset-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) {
  body.tp .asset-grid, body.tp .thinking-grid, body.tp .extension-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- 15. 減少動態偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
  body.tp *, body.tp *::before, body.tp *::after { transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- 16. 列印 ---------- */
@media print {
  body.tp .tp-toc, body.tp .tp-top, body.tp .tp-toast, body.tp .tp-mort-sticky { display: none !important; }
}

/* =====================================================================
   17. 2026-11-20 polish 層（觸控目標 / 字號 / 對比 / 標題層級 / 對焦環）
   ===================================================================== */

/* 17.1 弱化文字顏色：#7C8798 在 #16213A 面板上只有 4.4:1，提升到 ≥6:1（金色 #C9A45C 在深底 6–7.5:1，已達 AA，不用改） */
body.tp, body.sch { --ink-faint: #98A3B5; }
body.tp .reveal.w-screen .text-slate-500,
body.tp .reveal.w-screen .text-slate-600 { color: #94A3B8; }

/* 17.2 頁尾 sitemap 欄標題由 h4 改 h3（標題層級 h2→h3），外觀與 brand.css 原 h4 一致 */
body.tp .foot-sitemap-col h3, body.sch .foot-sitemap-col h3 {
  margin: 0 0 10px; font-size: 13px; font-weight: 800; letter-spacing: .04em;
  color: var(--gold-light); text-transform: uppercase; line-height: 1.5;
}
body.sch .netcard h3 { margin: 0 0 10px; font-size: 14px; color: var(--gold-light); font-weight: 700; }

/* 17.3 對焦環：Tailwind 的 outline-none + 30% 透明 ring 太淡，改成實色環（只影響內容區同目錄／回頂掣） */
body.tp .wrap :is(a, button, summary, input, select, textarea, [tabindex]):focus-visible,
body.tp .tp-toc a:focus-visible, body.tp .tp-top:focus-visible, body.tp .tp-copy:focus-visible,
body.sch .wrap :is(a, button, summary, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--gold-light); outline-offset: 2px;
}
body.tp .wrap :is(input, select, textarea):focus-visible { box-shadow: 0 0 0 4px rgba(227,200,142,.25); }

/* 17.4 分享掣、按鈕、計算機按鈕：≥44px */
body.tp .share-btn, body.sch .share-btn { min-height: 44px; padding: 8px 16px; font-size: 13.5px; }
body.tp #mort-calc, body.tp #mort-reset, body.tp #mort-reset-price,
body.tp #mort-rate-mode-prime, body.tp #mort-rate-mode-fixed { min-height: 44px; }
body.tp #mort-reset-price { padding-left: 16px; padding-right: 16px; }
body.tp #mort-calc, body.tp #mort-reset { min-height: 48px; }
body.tp .allocation-reset, body.tp .allocation-actions button { min-height: 44px; }
body.tp details summary { min-height: 44px; }

/* 17.5 文內連結：用上下 padding 擴大觸控範圍（行內元素 padding 唔推高行距，只擴大點擊區） */
body.tp .wrap :is(p, li, td, .note, .legal-box, .lede, .body, dd) a:not(.btn):not(.foot a) {
  padding-block: 12px;
}
body.tp .wrap td a.inline-link { display: inline-block; padding-block: 10px; }
@media (min-width: 769px) {
  body.tp .wrap :is(p, li, td, .note, .legal-box, .lede, .body, dd) a:not(.btn):not(.foot a) { padding-block: 11px; }
}

/* 17.6 其他細字提升 */
body.tp .pet-video-card .pv-title { font-size: 12.5px; }
body.tp .wrap .dim, body.tp .wrap .note { font-size: max(1em, 13px); }

/* 17.7 表格橫向捲動（只在表格真係溢出時由 JS 加 .tp-scroll / tabindex）：提示陰影＋聚焦環 */
body.tp .tablewrap.tp-scroll {
  background:
    linear-gradient(90deg, var(--navy) 30%, transparent) left center / 28px 100% no-repeat local,
    linear-gradient(270deg, var(--navy) 30%, transparent) right center / 28px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgba(201,164,92,.35), transparent) left center / 12px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgba(201,164,92,.35), transparent) right center / 12px 100% no-repeat scroll;
  overflow-x: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain;
}
body.tp .tablewrap.tp-scroll:focus-visible { outline: 2px solid var(--gold-light); outline-offset: 2px; }
body.tp .tablewrap.tp-scroll table { min-width: 560px; }
body.tp .tablewrap.tp-scroll + .tp-scroll-hint { display: block; }
body.tp .tp-scroll-hint { display: none; margin: 6px 2px 0; font-size: 12.5px; color: var(--ink-faint); }

/* =====================================================================
   18. 校網頁（body.sch）：只做觸控目標、字號、聚焦環，不改版面
   ===================================================================== */
body.sch .tab { min-height: 48px; }
body.sch .pager-btn { min-height: 44px; min-width: 44px; font-size: 14px; }
body.sch .filters select, body.sch .pagesize select { min-height: 44px; font-size: 14px; }
body.sch .rn-trigger, body.sch .rn-tab, body.sch .rn-clear, body.sch .chk-clear { min-height: 44px; }
body.sch .rn-right label { min-height: 44px; }
body.sch .searchbar input { min-height: 48px; }
body.sch .tag { font-size: 12px; }
body.sch .pagesize { font-size: 13.5px; }
body.sch .share-inline { margin-top: 12px; }
@media (max-width: 640px) { body.sch .tab { padding-left: 14px; padding-right: 14px; } }
