/* =========================================================
   LLM 101｜PART 02 · UX 補強（ux.css）
   只放 UX Fixer 新增的樣式；不覆寫 main.css／unit-*.css／appendix.css。
   - UX-P1-03：章節結尾的上一節／下一節
   - UI-P2-02：手機單元 H2 的字級與行高
   ========================================================= */

/* ---------- Hero H1：只讓「自己的電腦」不斷行 ----------
   main.css 的 `.hero h1 span` 原本是副標的 block 樣式；
   這裡把 .nowrap 還原成行內，避免主標被拆成三段。 */
.hero h1 span.nowrap {
  display: inline;
  margin-top: 0;
  font-size: inherit;
  line-height: inherit;
  letter-spacing: inherit;
  color: inherit;
  font-weight: inherit;
}

/* 桌面：主標只小幅下調，讓「在自己的電腦上跑起來？」完整落在第二行，
   不出現「來？」孤字；390 走 main.css 的手機字級，不受此規則影響。 */
@media (min-width: 860px) {
  .hero h1 {
    font-size: clamp(2.2rem, 3.4vw, 3.2rem);
  }
}

/* 桌面寬螢幕：標題只縮約 5%，避免移除 UNIT 前綴後把「模型」等詞拆行。 */
@media (min-width: 1200px) {
  .unit-band h2 {
    font-size: 2.55rem;
    text-wrap: pretty;
  }
}

/* ---------- 章節結尾導覽 ---------- */
.p2-section-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 18px;
  margin-top: 34px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: .9rem;
  line-height: 1.6;
}

.p2-section-nav-link {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  min-width: 0;
  padding: 3px 2px;
  color: var(--primary);
  font-weight: 700;
  text-decoration: none;
  border-radius: 6px;
}

.p2-section-nav-link:hover {
  text-decoration: underline;
  text-underline-offset: .18em;
}

.p2-section-nav-link:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.p2-section-nav-dir {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 800;
}

.p2-section-nav-label {
  min-width: 0;
}

.p2-section-nav-prev {
  margin-right: 0;
}

/* 手機：單欄、每個連結至少 44px 高；接在 section 結尾，不覆蓋 footer。 */
@media (max-width: 859px) {
  .p2-section-nav {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-top: 28px;
    padding-top: 14px;
    font-size: .9rem;
  }

  .p2-section-nav-link {
    align-items: center;
    min-height: 44px;
    padding: 9px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
  }

  .p2-section-nav-link:hover {
    border-color: var(--primary);
    text-decoration: none;
  }

  .p2-section-nav-prev {
    margin-right: 0;
    margin-left: 0;
  }

  /* UI-P2-02：390 的單元 H2 不再用 29.6px 擠成三行；
     英文專有名詞與中文詞比較不會被拆開。 */
  .unit-band h2 {
    font-size: clamp(1.35rem, 5.7vw, 1.85rem);
    line-height: 1.38;
    text-wrap: pretty;
  }
}

/* ---------- Header 品牌兩行（模仿 Part 03 的節奏） ----------
   三條槓 icon、header 高度、gradient 都不動；只把 .brand-text
   從橫排改成兩行，並沿用既有 token，不新增顏色。 */
.brand-text {
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  line-height: 1.15;
}

.brand-text strong {
  line-height: 1.1;
}

.header-sub {
  line-height: 1.2;
  white-space: nowrap;
}

/* main.css 在 859 以下會把 .header-sub 收起來；這裡保留第二行，
   並用略小字級讓 390 的 header 仍放得下目錄／主題按鈕。 */
@media (max-width: 859px) {
  .header-sub {
    display: block;
    font-size: .68rem;
  }
}

@media print {
  .p2-section-nav {
    display: none !important;
  }
}
