/* ============================================
   目次プラグイン（toc.js）スタイル
   ─────────────────────────────────────────
   カスタマイズは :root のカスタムプロパティで行えます。
============================================ */

:root {
  --toc-btn-width: 56px;
  --toc-btn-height: 56px;
  --toc-color: #506e93;
  --toc-color-hover: #506e93;
  --toc-color-active: #506e93;
  --toc-z: 99999;
  --toc-font: "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", sans-serif;
}

/* ── 固定ボタン（四角・右下ピッタリ） ──────── */
#toc-fab {
  position: fixed;
  right: 0;
  bottom: 0;
  width: var(--toc-btn-width);
  height: var(--toc-btn-height);
  border-radius: 6px 0 0 0;
  background: var(--toc-color);
  border: none;
  cursor: pointer;
  z-index: var(--toc-z);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  box-shadow: -2px -2px 10px rgba(0, 0, 0, 0.12);
  transition: background 0.2s, box-shadow 0.2s;
  -webkit-tap-highlight-color: transparent;
}

#toc-fab:hover {
  background: var(--toc-color-hover);
  box-shadow: -3px -3px 16px rgba(0, 0, 0, 0.18);
}

#toc-fab:active {
  background: var(--toc-color-active);
}

/* ハンバーガー三本線 */
#toc-fab .toc-bar {
  display: block;
  width: 20px;
  height: 2px;
  background: #fff;
  border-radius: 1px;
}

/* 「目次」ラベル */
#toc-fab .toc-label {
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.08em;
  margin-top: 2px;
  line-height: 1;
  font-family: var(--toc-font);
}

/* ── オーバーレイ ──────────────────────────── */
#toc-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: calc(var(--toc-z) + 1);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s, visibility 0.25s;
}

#toc-overlay.is-visible {
  opacity: 1;
  visibility: visible;
}

/* ── モーダル ──────────────────────────────── */
#toc-modal {
  position: fixed;
  z-index: calc(var(--toc-z) + 2);
  right: 0;
  bottom: calc(var(--toc-btn-height) + 8px);
  width: min(360px, calc(100vw - 24px));
  max-height: min(520px, calc(100vh - 140px));
  background: #fff;
  border-radius: 16px 0 0 16px;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15),
              0 -4px 24px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateX(20px);
  opacity: 0;
  visibility: hidden;
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1),
              opacity 0.25s,
              visibility 0.25s;
}

#toc-modal.is-visible {
  transform: translateX(0);
  opacity: 1;
  visibility: visible;
}

/* ── モーダルヘッダー ─────────────────────── */
#toc-modal .toc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
}

#toc-modal .toc-header-title {
  font-size: 16px;
  font-weight: 700;
  color: #333;
  font-family: var(--toc-font);
}

#toc-modal .toc-close {
  width: 32px;
  height: 32px;
  border: none;
  background: #f3f3f3;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  color: #888;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

#toc-modal .toc-close:hover {
  background: #e5e5e5;
}

/* ── 目次リスト ───────────────────────────── */
#toc-modal .toc-body {
  overflow-y: auto;
  padding: 12px 0;
  -webkit-overflow-scrolling: touch;
}

#toc-modal .toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

#toc-modal .toc-list li a {
  display: block;
  padding: 10px 20px;
  color: #444;
  text-decoration: none;
  font-size: 14px;
  line-height: 1.6;
  transition: background 0.15s, color 0.15s;
  font-family: var(--toc-font);
}

#toc-modal .toc-list li a:hover {
  background: #fdf2ec;
  color: var(--toc-color);
}

/* h3 はインデント */
#toc-modal .toc-list li.toc-h3 a {
  padding-left: 36px;
  font-size: 13px;
  color: #777;
}

#toc-modal .toc-list li.toc-h3 a::before {
  content: "—";
  margin-right: 6px;
  color: #ccc;
}
