@charset "UTF-8";

/*
 * 目次の追加スタイルを定義する。
 */
/* 記事内の目次を本文幅の80%で中央に配置する。 */
.article .toc {
  display: block;
  box-sizing: border-box;
  width: 80%;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
  background-color: #f8fafc;
  border: 1px solid #c7d2dc;
  border-radius: 16px;
  box-shadow: 0 4px 12px rgba(62, 88, 111, 0.08);
}

/* 狭い画面では項目が折り返しすぎないよう本文幅に合わせる。 */
@media (max-width: 600px) {
  .article .toc {
    width: 100%;
  }
}

.article .toc .toc-title {
  font-size: 1.25em;
  font-weight: 700;
  color: #3e586f;
  border-bottom: 2px solid #b7c6d6;
  padding-bottom: 10px;
  margin-bottom: 12px;
}

.article .toc :is(ol, ul) {
  padding-left: 1.5em;
  margin-left: 0;
}

.article .toc li {
  margin-top: 0.4em;
  margin-bottom: 0.4em;
}

.article .toc a {
  color: #364856;
  line-height: 1.7;
  text-decoration: none;
}

.article .toc a:hover {
  color: #3e586f;
  text-decoration: underline;
}

/* 記事内とサイドバーの目次項目の文字サイズをそろえる。 */
:is(.article .toc, .sidebar .widget_toc) li,
:is(.article .toc, .sidebar .widget_toc) li > a {
  font-size: 14px;
}

/* 目次の最上位は番号、下位の階層は線でつなぐ。 */
:is(.article .toc, .sidebar .widget_toc) :is(ol, ul) > li {
  padding-left: 3px;
}

:is(.article .toc, .sidebar .widget_toc) :is(ol, ul) > li > a {
  font-weight: 700;
}

:is(.article .toc, .sidebar .widget_toc) :is(ol, ul) > li::marker {
  font-weight: 700;
}

:is(.article .toc, .sidebar .widget_toc) :is(ol, ul) :is(ol, ul) > li > a {
  font-weight: 400;
}

:is(.article .toc, .sidebar .widget_toc) :is(ol, ul) {
  list-style-type: decimal;
}

:is(.article .toc, .sidebar .widget_toc) :is(ol, ul) :is(ol, ul) {
  list-style: none;
  padding-left: 1.25em;
  margin-left: 0.4em;
}

:is(.article .toc, .sidebar .widget_toc) :is(ol, ul) :is(ol, ul) > li {
  list-style: none;
  padding-left: 0;
  position: relative;
  line-height: 1.7;
}

/* 縦線から各項目の先頭行へ横線を伸ばす。 */
:is(.article .toc, .sidebar .widget_toc) :is(ol, ul) :is(ol, ul) > li::before {
  content: "";
  position: absolute;
  left: calc(-1.25em - 1px);
  top: 0.85em;
  transform: translateY(-50%);
  width: 0.8em;
  height: 1px;
  background-color: #b7c6d6;
}

/* 項目間をつなぎ、最後の項目の横線の位置で止める。 */
:is(.article .toc, .sidebar .widget_toc) :is(ol, ul) :is(ol, ul) > li::after {
  content: "";
  position: absolute;
  left: calc(-1.25em - 1px);
  top: -0.4em;
  bottom: -0.4em;
  width: 1px;
  background-color: #b7c6d6;
}

:is(.article .toc, .sidebar .widget_toc) :is(ol, ul) :is(ol, ul) > li:first-child::after {
  top: 0;
}

:is(.article .toc, .sidebar .widget_toc) :is(ol, ul) :is(ol, ul) > li:last-child::after {
  bottom: calc(100% - 0.85em);
}

/* 強調用の余白は通常時から確保し、横幅はマイナス余白で相殺する。 */
:is(.article .toc, .widget_toc) li > a {
  padding: 2px 6px;
  margin-left: -6px;
  margin-right: -6px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

/* 現在読んでいる見出しを、両方の目次でマーカー表示する。 */
:is(.article .toc, .widget_toc) a.is-current {
  color: #3e586f;
  background-color: #e2ebf3;
  border-radius: 8px;
}

/* 下位階層もアクティブな項目は太字にする。 */
:is(.article .toc, .sidebar .widget_toc) :is(ol, ul) li > a.is-current {
  font-weight: 700;
}

/* 目次ウィジェット内の目次タイトルを非表示にする。 */
.widget_toc .toc-title {
  display: none;
}
