/* 読む・書く・伝える：研究の実践ガイド 用スタイル調整 */

/* 明朝とゴシックの混在を防ぎ、全体でゴシック体に統一 */
:root {
  --bs-body-font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", "Yu Gothic", "Meiryo", sans-serif !important;
  --bs-headings-font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", "Yu Gothic", "Meiryo", sans-serif !important;
}

html, body,
#quarto-content, #quarto-document-content,
.quarto-title, .chapter-title,
.sidebar, .sidebar-title, .sidebar-item-container, .sidebar-item-text,
#TOC, #TOC .nav-link,
.quarto-secondary-nav, .breadcrumb,
h1, h2, h3, h4, h5, h6,
p, li, td, th, span, div {
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", "Yu Gothic", "Meiryo", sans-serif !important;
}

/* コード・等幅は別フォントを維持 */
pre, code, kbd {
  font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, monospace !important;
}

/* アイコンフォント（Bootstrap Icons）はそのまま */
.bi, [class^="bi-"] {
  font-family: "bootstrap-icons" !important;
}

/* 数式(KaTeX)は専用フォントを使う。
   上の「span/div を !important でゴシックに統一」が KaTeX の数式フォントまで
   上書きしてしまい、積分記号が拡大されない・大カッコが伸びない・変数がゴシックに
   なる問題が起きる。ここで KaTeX 本来のフォント割り当てを復元する。
   .katex * (詳細度 0,1,0) で span (0,0,1) を打ち消し、各 .katex .xxx (0,2,0) で
   記号ごとに正しいフォントへ上書きする。 */
.katex, .katex * {
  font-family: KaTeX_Main, "Times New Roman", serif !important;
}
.katex .mathnormal { font-family: KaTeX_Math !important; }
.katex .mathit { font-family: KaTeX_Main !important; font-style: italic !important; }
.katex .mathrm, .katex .textrm { font-family: KaTeX_Main !important; }
.katex .mathbf, .katex .textbf { font-family: KaTeX_Main !important; font-weight: bold !important; }
.katex .boldsymbol { font-family: KaTeX_Math !important; font-weight: bold !important; }
.katex .amsrm, .katex .mathbb, .katex .textbb { font-family: KaTeX_AMS !important; }
.katex .mathcal { font-family: KaTeX_Caligraphic !important; }
.katex .mathfrak, .katex .textfrak { font-family: KaTeX_Fraktur !important; }
.katex .mathscr { font-family: KaTeX_Script !important; }
.katex .mathsf, .katex .textsf { font-family: KaTeX_SansSerif !important; }
.katex .mathtt, .katex .texttt { font-family: KaTeX_Typewriter !important; }
.katex .delimsizing.size1 { font-family: KaTeX_Size1 !important; }
.katex .delimsizing.size2 { font-family: KaTeX_Size2 !important; }
.katex .delimsizing.size3 { font-family: KaTeX_Size3 !important; }
.katex .delimsizing.size4 { font-family: KaTeX_Size4 !important; }
.katex .delim-size1 > span { font-family: KaTeX_Size1 !important; }
.katex .delim-size4 > span { font-family: KaTeX_Size4 !important; }
.katex .op-symbol.small-op { font-family: KaTeX_Size1 !important; }
.katex .op-symbol.large-op { font-family: KaTeX_Size2 !important; }
.katex .mathnormal,
.katex .mspace { font-style: normal; }

/* 図（Graphviz の SVG・埋め込み画像）が本文幅を超えない・重ならないための保険 */
.quarto-figure svg, .quarto-figure img,
.cell-output-display svg, .cell-output-display img,
figure svg, figure img {
  max-width: 100% !important;
  height: auto !important;
}
.quarto-figure { text-align: center; }

/* 各図を控えめのサイズで中央寄せ（はみ出し・重なり対策＋小さく） */
#fig-fork svg, #fig-collider svg { max-width: 300px !important; }
#fig-overview svg            { max-width: 520px !important; }
#fig-patterns svg            { max-width: 620px !important; }
#fig-dist-map svg            { max-width: 700px !important; }
#fig-bias-variance img       { max-width: 540px !important; }

/* 本文: 日本語の可読性向上 - 両端揃えをやめ左揃えでリバーを防ぐ */
#quarto-document-content {
  text-align: left !important;
}

/* 段落の余白と行間 */
#quarto-document-content p {
  line-height: 1.65;
  margin-bottom: 1em;
  text-align: left;
}

/* 見出しの余白とタイポグラフィ */
#quarto-document-content h1 {
  margin-top: 0;
  margin-bottom: 1em;
  font-weight: 600;
}

#quarto-document-content h2,
#quarto-document-content h3 {
  margin-top: 1.75em;
  margin-bottom: 0.6em;
  font-weight: 600;
}

/* サイドバー: アクティブ項目のハイライトを落ち着いた色に */
.sidebar-item-container .active {
  background-color: #eef2f7 !important;
  color: #1a365d !important;
  border-radius: 6px;
  font-weight: 500;
}

/* 章内目次 TOC: アクティブ項目 */
#TOC .nav-link.active {
  background-color: #eef2f7 !important;
  color: #1a365d !important;
  border-radius: 6px;
}

/* サイドバー全体の余白 */
.sidebar-item-container {
  font-size: 0.9rem;
  line-height: 1.5;
}

#TOC .nav-link {
  font-size: 0.875rem;
}

/* 表の見やすさ */
#quarto-document-content table {
  font-size: 0.9375rem;
  margin: 1.5em 0;
  border-collapse: collapse;
  width: 100%;
}

#quarto-document-content table th,
#quarto-document-content table td {
  vertical-align: top;
  padding: 0.55em 0.7em;
  border: 1px solid #e2e8f0;
}

#quarto-document-content table thead th,
#quarto-document-content table tr:first-child th {
  background-color: #f6f8fb;
  font-weight: 600;
}

#quarto-document-content table tbody tr:nth-child(even) {
  background-color: #fbfcfe;
}

/* リンクの色を控えめに */
#quarto-document-content a {
  color: #2b6cb0;
}

#quarto-document-content a:hover {
  color: #1a365d;
}

/* 本文エリアの最大幅（広めに設定） */
.column-body {
  max-width: 65em;
}

/* 折りたたみセクション（参考文献・ツール一覧に使用） */
details {
  margin: 1em 0;
  padding: 0.5em 1em;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background-color: #fafbfc;
}

details summary {
  cursor: pointer;
  font-weight: 600;
  color: #2b6cb0;
  padding: 0.3em 0;
}

details summary:hover {
  color: #1a365d;
}

details[open] summary {
  margin-bottom: 0.5em;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 0.5em;
}

/* コールアウトの日本語調整 */
.callout {
  margin: 1.5em 0;
}

.callout .callout-body {
  font-size: 0.95rem;
}

/* マージンノート */
.column-margin {
  font-size: 0.85rem;
  color: #4a5568;
  line-height: 1.5;
}

/* タブセットの見やすさ */
.panel-tabset .nav-tabs .nav-link {
  font-size: 0.9rem;
}

/* パート区切り（部の見出し） */
.part-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1a365d;
  border-bottom: 3px solid #2b6cb0;
  padding-bottom: 0.5em;
  margin-bottom: 1em;
}

/* 参考文献: ぶら下がり（hanging indent）、文献間の区切り、リンク有効化 */
section.references ul {
  list-style: none;
  padding-left: 0;
}

section.references ul li {
  margin-bottom: 0.85em;
  padding-left: 2em;
  text-indent: -2em;
  line-height: 1.65;
}

section.references a {
  color: #2b6cb0;
}

section.references a:hover {
  color: #1a365d;
  text-decoration: underline;
}

section.references p,
section.references li {
  line-height: 1.65;
}
