/* 使用手冊頁樣式（/handbook，註冊二期，任務#98新增）。
   共用 app.css 的變數 / nav / footer 等既有類別；左側目錄＋右側內文排版
   直接沿用技術分析教室（kline_guide.css）驗證過的 `.ta-layout` 手感，但
   獨立成 `.hb-` 前綴，避免耦合到那個頁面專屬的檔案。手機 <900px 收成
   單欄（目錄變成頂部橫向可捲動列），比照全站既有斷點慣例。 */

.hb-intro {
  margin-bottom: 20px;
  padding: 14px 18px;
  background: rgba(var(--brand-cyan-rgb), 0.08);
  border: 1px solid rgba(var(--brand-cyan-rgb), 0.25);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.7;
}

.hb-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 18px;
  align-items: start;
}

/* [#177] 2026-08-16：同 guide.css .gd-toc，寫死的 76px / calc(100vh - 96px)
   改吃 nav.js 發布的 `--sv-nav-h`（nav 被事後注入的徽章/主題鈕撐高換行時，
   寫死值會讓目錄滑進 nav 底下被蓋住）。fallback 62px＝改動前行為。 */
.hb-toc {
  position: sticky;
  top: calc(var(--sv-nav-h, 62px) + 14px);
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 10px;
  max-height: calc(100vh - var(--sv-nav-h, 62px) - 34px);
  overflow-y: auto;
}

.hb-toc-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.5;
  font: inherit;
  text-decoration: none;
}

.hb-toc-item:hover {
  background: rgba(var(--surface-tint-rgb), 0.05);
  border-color: var(--border);
  color: var(--text);
}

.hb-toc-item.active {
  background: rgba(var(--brand-cyan-rgb), 0.12);
  border-color: rgba(var(--brand-cyan-rgb), 0.4);
  color: var(--brand-cyan-text);
  font-weight: 700;
}

.hb-main {
  min-width: 0;
  max-width: 820px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 22px 26px 26px;
}

.hb-content h1 {
  margin: 0 0 14px;
  font-size: clamp(20px, 1.2vw + 16px, 26px);
  font-weight: 800;
  color: var(--text);
}

.hb-content h2 {
  margin: 30px 0 12px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  font-size: 17px;
  font-weight: 800;
  color: var(--text);
}

.hb-content .hb-section:first-of-type h2 {
  margin-top: 22px;
}

.hb-content p {
  margin: 0 0 10px;
  font-size: 13.5px;
  line-height: 1.8;
  color: var(--text-muted);
}

.hb-content blockquote {
  margin: 0 0 18px;
  padding: 10px 14px;
  background: rgba(var(--watch-rgb), 0.1);
  border: 1px solid rgba(var(--watch-rgb), 0.3);
  border-left: 3px solid rgba(var(--watch-rgb), 0.6);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--text);
}

.hb-list {
  margin: 0 0 10px;
  padding-left: 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hb-list li {
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--text-muted);
}

.hb-content strong {
  color: var(--text);
  font-weight: 700;
}

.hb-content hr {
  margin: 20px 0;
  border: none;
  border-top: 1px solid var(--border);
}

.hb-content .hb-italic {
  font-size: 12px;
  color: var(--text-faint);
  font-style: italic;
}

.hb-table-wrap {
  overflow-x: auto;
  margin: 0 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.hb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.hb-table th,
.hb-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.hb-table th {
  background: rgba(var(--surface-tint-rgb), 0.04);
  color: var(--text);
  font-weight: 700;
}

.hb-table td {
  color: var(--text-muted);
}

.hb-table tr:last-child td {
  border-bottom: none;
}

.hb-footer-meta {
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-faint);
}

/* modal 內嵌手冊（登入頁註冊表單「閱讀使用手冊」，M2）沿用同一份 .hb-content
   渲染邏輯，但外層容器改用 modal 自己的捲動偵測，見 login.html/login 頁
   inline script。*/
.hb-modal-body .hb-content h2:first-child,
.hb-modal-body .hb-content .hb-section:first-of-type h2 {
  margin-top: 0;
}

@media (max-width: 900px) {
  .hb-layout {
    grid-template-columns: 1fr;
  }

  .hb-toc {
    position: static;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    max-height: none;
    gap: 6px;
  }

  .hb-toc-item {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .hb-main {
    padding: 18px 16px 20px;
  }
}
