/* ==========================================================================
   /manual — 操作手冊（文件型版面）
   內容標記沿用改版前的 class 名稱，這裡整批重寫成新的設計 token。
   ========================================================================== */

/* --------------------------------------------------------------------------
   閱讀進度條
   -------------------------------------------------------------------------- */
.read-progress {
  position: fixed;
  top: var(--nav-h);
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: 0 50%;
  z-index: calc(var(--z-nav) - 1);
  will-change: transform;
}

/* --------------------------------------------------------------------------
   文件版面：側欄 + 內容
   -------------------------------------------------------------------------- */
.docs {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  gap: var(--sp-12);
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--sp-12) var(--sp-8) var(--sp-24);
}

/* --------------------------------------------------------------------------
   側欄目錄
   -------------------------------------------------------------------------- */
.sidebar {
  position: sticky;
  top: calc(var(--nav-h) + var(--sp-6));
  align-self: start;
  max-height: calc(100vh - var(--nav-h) - var(--sp-12));
  overflow-y: auto;
  padding-right: var(--sp-2);
}

.sidebar-group + .sidebar-group { margin-top: var(--sp-6); }

.sidebar-group-label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--text-lo);
  margin-bottom: var(--sp-3);
  padding-left: var(--sp-3);
}

.sidebar-link {
  /* 必須是 flex：base.css 的 reset 把 svg 設成 display:block，
     若這裡用 display:block，圖示會自己佔一行、文字被擠到下一行。 */
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  color: var(--text-mid);
  border-left: 2px solid transparent;
  transition:
    color var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out);
}

.sidebar-link:hover {
  color: var(--text-hi);
  background: var(--bg-raised);
}

/* 捲動高亮由 motion.js 的 scroll spy 加上 .is-active */
.sidebar-link.is-active {
  color: var(--accent-hi);
  border-left-color: var(--accent);
  background: var(--accent-dim);
}

/* --------------------------------------------------------------------------
   內文
   -------------------------------------------------------------------------- */
.doc-section {
  padding-top: var(--sp-10);
  scroll-margin-top: calc(var(--nav-h) + var(--sp-6));
}

.doc-section:first-child { padding-top: 0; }

.doc-section + .doc-section {
  margin-top: var(--sp-10);
  border-top: 1px solid var(--line-subtle);
}

.doc-h2 {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  font-size: var(--fs-2xl);
  margin-bottom: var(--sp-4);
}

/* 標題前的圖示方塊 */
.hicon {
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: var(--r);
  display: grid;
  place-items: center;
  background: var(--accent-dim);
  border: 1px solid var(--accent-line);
  color: var(--accent);
}

.hicon .icon { width: 17px; height: 17px; }

.doc-lead {
  color: var(--text-mid);
  font-size: var(--fs-base);
  line-height: var(--lh-relax);
  margin-bottom: var(--sp-8);
}

.doc-h3 {
  font-size: var(--fs-lg);
  margin: var(--sp-10) 0 var(--sp-4);
}

.doc-h4 {
  font-size: var(--fs-base);
  color: var(--text-hi);
  margin: var(--sp-6) 0 var(--sp-3);
}

.doc-p {
  color: var(--text-mid);
  line-height: var(--lh-relax);
  margin-bottom: var(--sp-4);
}

/* --------------------------------------------------------------------------
   設定表
   -------------------------------------------------------------------------- */
.settings-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--bg-raised);
  margin-bottom: var(--sp-6);
}

.settings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
  min-width: 480px;
}

.settings-table th {
  text-align: left;
  background: var(--bg-sunken);
  color: var(--text-hi);
  font-weight: var(--fw-semi);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.settings-table td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line-subtle);
  color: var(--text-mid);
  vertical-align: top;
  line-height: var(--lh-normal);
}

.settings-table tr:last-child td { border-bottom: none; }

.settings-table tbody tr {
  transition: background-color var(--dur-fast) var(--ease-out);
}

.settings-table tbody tr:hover { background: var(--bg-overlay); }

/* 第一欄是設定項名稱、第二欄是預設值，都用等寬字比較好對齊 */
.settings-table td:first-child {
  font-family: var(--font-mono);
  font-size: .78rem;
  color: var(--accent-hi);
  white-space: nowrap;
}

.settings-table td:nth-child(2) {
  font-family: var(--font-mono);
  font-size: .78rem;
  color: var(--text-lo);
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   提示框
   -------------------------------------------------------------------------- */
.callout {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--bg-raised);
  font-size: var(--fs-sm);
  line-height: var(--lh-relax);
  color: var(--text-mid);
  margin-bottom: var(--sp-5);
}

.callout .icon { width: 17px; height: 17px; flex: none; margin-top: 3px; }

.callout.tip  { border-color: var(--accent-line); background: var(--accent-dim); }
.callout.tip  .icon { color: var(--accent); }
.callout.warn { border-color: rgba(251,191,36,.28); background: var(--warn-dim); }
.callout.warn .icon { color: var(--warn); }
.callout.info { border-color: rgba(52,211,153,.28); background: var(--ok-dim); }
.callout.info .icon { color: var(--ok); }

.callout strong { color: var(--text-hi); }

.info-card {
  padding: var(--sp-5);
  border-radius: var(--r-lg);
  background: var(--bg-raised);
  border: 1px solid var(--line);
  margin-bottom: var(--sp-5);
}

/* --------------------------------------------------------------------------
   步驟清單
   -------------------------------------------------------------------------- */
.step-list {
  counter-reset: s;
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}

.step-list li {
  position: relative;
  padding-left: var(--sp-10);
  font-size: var(--fs-sm);
  color: var(--text-mid);
  line-height: var(--lh-relax);
}

.step-list li::before {
  counter-increment: s;
  content: counter(s);
  position: absolute;
  left: 0;
  top: -1px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--bg-overlay);
  border: 1px solid var(--line-strong);
  color: var(--text-hi);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
}

.step-list strong { color: var(--text-hi); }

/* --------------------------------------------------------------------------
   按鍵標籤
   -------------------------------------------------------------------------- */
.key-chip {
  display: inline-block;
  padding: 2px var(--sp-2);
  border-radius: var(--r-sm);
  background: var(--bg-overlay);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-mid);
  line-height: 1.5;
  white-space: nowrap;
}

.key-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-bottom: var(--sp-5);
}

/* --------------------------------------------------------------------------
   驗證閘門（沿用 download 的 .gate，這裡只調整外距）
   -------------------------------------------------------------------------- */
.manual-gate {
  padding-block: var(--sp-20) var(--sp-24);
}

/* --------------------------------------------------------------------------
   響應式
   -------------------------------------------------------------------------- */
@media (max-width: 1024px) {
  .docs {
    grid-template-columns: 1fr;
    gap: var(--sp-8);
    padding-inline: var(--sp-5);
  }

  /* 側欄改成頂部橫向捲動的頁籤列 */
  .sidebar {
    position: static;
    max-height: none;
    overflow-x: auto;
    overflow-y: visible;
    padding-bottom: var(--sp-3);
    border-bottom: 1px solid var(--line-subtle);
    display: flex;
    gap: var(--sp-6);
  }

  .sidebar-group + .sidebar-group { margin-top: 0; }

  .sidebar-group {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    white-space: nowrap;
  }

  .sidebar-group-label { margin-bottom: 0; padding-left: 0; }

  .sidebar-link {
    border-left: none;
    border-bottom: 2px solid transparent;
    border-radius: var(--r-sm) var(--r-sm) 0 0;
  }

  .sidebar-link.is-active {
    border-left-color: transparent;
    border-bottom-color: var(--accent);
  }
}

@media (max-width: 768px) {
  .doc-h2 { font-size: var(--fs-xl); }
  .hicon { width: 30px; height: 30px; }
  .hicon .icon { width: 15px; height: 15px; }
}
