/* 表紙ページの装飾 */

/* トップの集合画像を中央寄せ・丸角・控えめに */
.md-typeset h1 + p img[alt*="リナ"],
.md-typeset h1 + p img[alt*="メイ"],
.md-typeset h1 + p img[alt*="快"] {
  display: block;
  margin: 1rem auto 1.5rem;
  max-width: 100%;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

/* 登場人物カードの横並び */
.character-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  margin: 1.5rem 0 2rem;
}

@media (max-width: 768px) {
  .character-cards {
    grid-template-columns: 1fr;
  }
}

.character-card {
  text-align: center;
  padding: 1rem;
  border-radius: 12px;
  background: var(--md-default-bg-color);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.character-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.14);
}

.character-card img {
  border-radius: 8px;
  max-width: 100%;
  height: auto;
  margin-bottom: 0.5rem;
}

/* ヘッダーのサイト名リンク */
.md-header__topic-link {
  text-decoration: none;
  color: inherit;
}

/* ヘッダーのサイト名を大きく */
.md-header__topic:first-child .md-ellipsis {
  font-size: 1.4rem;
  font-weight: bold;
}
.md-header__topic:first-child {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
}

.md-header__subtitle {
  display: block;
  width: 100%;
  font-size: 0.7rem;
  font-weight: normal;
  opacity: 0.85;
  line-height: 1.2;
  margin-top: 0.15rem;
  margin-bottom: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* サブタイトルとタブメニューの間隔 */
.md-header--lifted .md-header__inner {
  padding-bottom: 1.2rem;
}

@media (max-width: 768px) {
  .md-header__subtitle {
    font-size: 0.6rem;
  }
}

/* ヘッダー: デスクトップのみカスタム */
@media (min-width: 769px) {
  .md-header__inner.md-grid {
    overflow: visible;
    padding-top: 1rem;
    padding-bottom: 0.3rem;
    align-items: center;
  }

  .md-header__brand-logo {
    flex-shrink: 0;
    margin-right: 0.75rem;
    margin-top: -0.2rem;
    margin-bottom: -3.5rem;
    align-self: flex-start;
    z-index: 2;
  }

  .md-header__brand-logo img {
    height: 120px;
    width: auto;
    display: block;
  }

  .md-header .md-tabs {
    margin-top: -0.1rem;
  }

  .md-header .md-tabs .md-grid {
    padding-left: 7rem;
  }

  /* タイトルを強制表示（Material の lifted モードが隠すのを上書き） */
  .md-header .md-header__title {
    display: flex !important;
    align-items: center;
    height: auto;
    line-height: normal;
  }

  .md-header .md-header__ellipsis {
    position: static;
  }

  .md-header .md-header__topic {
    position: static !important;
    opacity: 1 !important;
    transform: none !important;
    pointer-events: auto !important;
  }

  .md-header .md-header__topic + .md-header__topic {
    display: none;
  }

}

/* ライトモード: 背景白、テキスト黒（全デバイス共通） */
[data-md-color-scheme="default"] .md-header {
  background-color: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

[data-md-color-scheme="default"] .md-header .md-header__title,
[data-md-color-scheme="default"] .md-header .md-header__topic .md-ellipsis,
[data-md-color-scheme="default"] .md-header .md-header__topic-link,
[data-md-color-scheme="default"] .md-header .md-header__subtitle,
[data-md-color-scheme="default"] .md-header .md-header__button,
[data-md-color-scheme="default"] .md-header .md-search__input,
[data-md-color-scheme="default"] .md-header .md-search__input::placeholder {
  color: #333 !important;
}

[data-md-color-scheme="default"] .md-header .md-tabs__link {
  color: #111 !important;
}

[data-md-color-scheme="default"] .md-header .md-tabs__item--active .md-tabs__link {
  font-weight: 700;
}

[data-md-color-scheme="default"] .md-header .md-header__button.md-icon svg,
[data-md-color-scheme="default"] .md-header .md-tabs__link svg {
  fill: #333;
}

[data-md-color-scheme="default"] .md-header .md-search__form {
  background-color: #fff !important;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

[data-md-color-scheme="default"] .md-header .md-search__icon svg {
  fill: #333;
}

[data-md-color-scheme="default"] .md-header .md-tabs {
  background-color: transparent;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

/* ダークモード（全デバイス共通） */
[data-md-color-scheme="slate"] .md-header {
  background-color: var(--md-default-bg-color);
  box-shadow: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.4);
}

[data-md-color-scheme="slate"] .md-header .md-header__title,
[data-md-color-scheme="slate"] .md-header .md-header__topic .md-ellipsis,
[data-md-color-scheme="slate"] .md-header .md-header__topic-link,
[data-md-color-scheme="slate"] .md-header .md-header__subtitle,
[data-md-color-scheme="slate"] .md-header .md-tabs__link,
[data-md-color-scheme="slate"] .md-header .md-header__button,
[data-md-color-scheme="slate"] .md-header .md-search__input,
[data-md-color-scheme="slate"] .md-header .md-search__input::placeholder {
  color: #fff !important;
}

[data-md-color-scheme="slate"] .md-header .md-header__button.md-icon svg,
[data-md-color-scheme="slate"] .md-header .md-tabs__link svg {
  fill: #fff;
}

[data-md-color-scheme="slate"] .md-header .md-search {
  background-color: rgba(255, 255, 255, 0.1);
}

[data-md-color-scheme="slate"] .md-header .md-tabs {
  background-color: transparent;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

/* スマホ: ロゴ非表示 + ドロワーの紫をモードに合わせる */
@media (max-width: 768px) {
  .md-header__brand-logo {
    display: none;
  }
}

[data-md-color-scheme="default"] .md-nav--primary .md-nav__title[for=__drawer] {
  background-color: #fff;
  color: #333;
}

[data-md-color-scheme="slate"] .md-nav--primary .md-nav__title[for=__drawer] {
  background-color: var(--md-default-bg-color);
  color: #fff;
}


/* 見出し内の数式を少し小さく（特に h2 で数式が大きく見える問題の緩和） */
.md-typeset h2 .MathJax,
.md-typeset h2 mjx-container {
  font-size: 0.85em;
}
.md-typeset h3 .MathJax,
.md-typeset h3 mjx-container {
  font-size: 0.9em;
}

/* Mermaid 図: 常に白背景・中央寄せ（ライト・ダーク共通） */
.mermaid {
  background: #ffffff;
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  justify-content: center;
}


/* 練習問題集約ページの目次 admonition（abstract）のフォントサイズを本文と揃える */
.md-typeset .admonition.abstract,
.md-typeset details.abstract {
  font-size: 0.8rem; /* 通常の admonition は 0.64rem 程度、本文と同じサイズに */
}

.md-typeset .admonition.abstract p,
.md-typeset .admonition.abstract ul,
.md-typeset .admonition.abstract li,
.md-typeset details.abstract p,
.md-typeset details.abstract ul,
.md-typeset details.abstract li {
  font-size: 0.8rem;
  line-height: 1.6;
}

.md-typeset .admonition.abstract .admonition-title,
.md-typeset details.abstract summary {
  font-size: 0.85rem;
}

/* 理解度チェックの答え・補足ブロックのフォントサイズを本文と揃える */
.md-typeset .admonition.success,
.md-typeset details.success,
.md-typeset .admonition.tip,
.md-typeset details.tip,
.md-typeset .admonition.note,
.md-typeset details.note,
.md-typeset .admonition.info,
.md-typeset details.info {
  font-size: 0.76rem;
}

.md-typeset .admonition.success p,
.md-typeset details.success p,
.md-typeset .admonition.tip p,
.md-typeset details.tip p,
.md-typeset .admonition.note p,
.md-typeset details.note p,
.md-typeset .admonition.info p,
.md-typeset details.info p {
  font-size: 0.76rem;
  line-height: 1.6;
}

.md-typeset .admonition.success .admonition-title,
.md-typeset details.success summary,
.md-typeset .admonition.tip .admonition-title,
.md-typeset details.tip summary,
.md-typeset .admonition.note .admonition-title,
.md-typeset details.note summary,
.md-typeset .admonition.info .admonition-title,
.md-typeset details.info summary {
  font-size: 0.8rem;
}

/* ============================================================
   章ナビゲーション: パンくず + 前後リンク
   ============================================================ */

/* パンくず */
.chapter-breadcrumb {
  font-size: 0.78rem;
  color: var(--md-default-fg-color--light);
  margin-bottom: 0.25rem;
}

.chapter-breadcrumb .breadcrumb-sep {
  margin: 0 0.4em;
  opacity: 0.6;
}

.chapter-breadcrumb .breadcrumb-part {
  opacity: 0.85;
}

/* 前後ナビ */
.chapter-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 1rem 0;
  padding: 0.6rem 0;
  border-top: 1px solid var(--md-default-fg-color--lightest);
  border-bottom: 1px solid var(--md-default-fg-color--lightest);
  font-size: 0.82rem;
}

.chapter-nav a {
  color: var(--md-typeset-a-color);
  text-decoration: none;
  transition: color 0.2s;
}

.chapter-nav a:hover {
  color: var(--md-accent-fg-color);
  text-decoration: underline;
}

.chapter-nav-prev {
  text-align: left;
  max-width: 48%;
}

.chapter-nav-next {
  text-align: right;
  max-width: 48%;
  margin-left: auto;
}

@media (max-width: 600px) {
  .chapter-nav {
    flex-direction: column;
    gap: 0.5rem;
    align-items: stretch;
  }
  .chapter-nav-prev {
    max-width: 100%;
    text-align: left;
  }
  .chapter-nav-next {
    max-width: 100%;
    text-align: right;
  }
}
