/**
 * 目次（lastshot/toc）。
 *
 * 目次を出すページだけで読み込む。色はテーマのカラーパレットを使うため、
 * カラーバリエーションを切り替えると目次の色も変わる。
 */

.lastshot-toc {
	background-color: var( --wp--preset--color--base-2, #f6f7f8 );
	border: 1px solid var( --wp--preset--color--border, #e3e5e8 );
	border-radius: 6px;
	margin: 2em 0;
	padding: 0.9em 1.1em;
}

.lastshot-toc summary {
	cursor: pointer;
	font-weight: 700;
	letter-spacing: 0.04em;
	list-style-position: inside;
}

.lastshot-toc summary:focus-visible {
	outline: 2px solid var( --wp--preset--color--primary, #1e3a5f );
	outline-offset: 2px;
}

/* 目次の中は番号を付けない。 */
.lastshot-toc ol {
	list-style: none;
	margin: 0.8em 0 0;
	padding: 0;
}

.lastshot-toc ol ol {
	margin: 0.2em 0 0.4em 1.1em;
}

.lastshot-toc li {
	margin: 0;
	padding: 0.2em 0;
}

.lastshot-toc li::marker {
	content: "";
}

.lastshot-toc a {
	color: inherit;
	text-decoration: none;
	border-bottom: 1px solid transparent;
	line-height: 1.6;
}

.lastshot-toc a:hover,
.lastshot-toc a:focus {
	border-bottom-color: currentColor;
}

/* 入れ子（h3）は小さめにして、親との差を付ける。 */
.lastshot-toc ol ol a {
	font-size: 0.92em;
	color: var( --wp--preset--color--contrast-2, #5b6270 );
}

.lastshot-toc ol ol li {
	padding-left: 0.8em;
	position: relative;
}

.lastshot-toc ol ol li::before {
	content: "";
	position: absolute;
	left: 0;
	top: 1em;
	width: 0.4em;
	height: 1px;
	background-color: var( --wp--preset--color--border, #e3e5e8 );
}

/* 見出しへ飛んだとき、見出しが画面の上にくっつかないようにする。 */
h2[id],
h3[id],
h4[id] {
	scroll-margin-top: 1.5rem;
}

/* 動きを減らす設定のときは、なめらかに動かさない。 */
@media ( prefers-reduced-motion: no-preference ) {

	html {
		scroll-behavior: smooth;
	}
}
