/**
 * No.12 menu-link / No.13 toc。
 *
 * menu-link（header/sidebar）と toc__link。
 * device=SP の toc は横並び（max-width: 767px）。
 * hover は data-hover-*（hover.css）。toc の state は data-state。
 */

/* --- 共通 --- */

.menu-link,
.toc__link {
	display: inline-flex;
	align-items: center;
	gap: var(--wp--custom--atom--rg, 0.5rem);
	box-sizing: border-box;
	margin: 0;
	padding: 0;
	color: var(--wp--preset--color--base-black);
	font-family: var(--wp--preset--font-family--jp-sans);
	font-size: var(--wp--preset--font-size--text-sm);
	font-weight: var(--wp--custom--font-weight--regular, 400);
	line-height: var(--wp--custom--line-height--narrow, 1);
	text-decoration: none;
	vertical-align: middle;
	cursor: pointer;
}

.menu-link:focus {
	outline: none;
}

.menu-link:focus-visible {
	outline: 1px solid var(--wp--preset--color--logo-blue);
	outline-offset: 2px;
}

.menu-link .menu-link__label {
	display: inline-block;
}

/* --- header（親 Element とのマルチクラス想定。例: site-header__contact-link menu-link） --- */

.wp-block-navigation-item.is-style-nav-header .wp-block-navigation-item__content.menu-link {
	font-size: var(--wp--preset--font-size--text-md);
}

/* --- sidebar（親 Element とのマルチクラス想定） --- */

.sidebar .menu-link {
	padding-block: var(--wp--custom--atom--xs, 0.25rem);
	padding-inline: var(--wp--custom--atom--md, 0.75rem);
}

/* --- toc: リスト＋ counter マーカー --- */

.toc {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	margin: 0;
	padding: 0;
	list-style: none;
	counter-reset: toc;
}

.toc__link {
	--menu-link-marker-border: var(--wp--custom--border-width--thin, 1px);
	--menu-link-marker-color: var(--wp--preset--color--line-grey);
	position: relative;
	align-items: center;
	width: 100%;
	padding-block: 0;
	gap: var(--wp--custom--atom--rg, 0.5rem);
	text-decoration: none;
}

.toc__link:hover,
.toc__link:focus-visible,
.toc__link:hover *,
.toc__link:focus-visible * {
	text-decoration: none;
}

.toc__link .toc__label {
	padding-top: 0;
	font-size: var(--wp--preset--font-size--text-sm);
}

.toc__marker {
	--menu-link-marker-size: 1.9375rem; /* 31px @ 16 */
	--menu-link-marker-line: 0.625rem; /* 10px: PC 縦コネクタ */
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	flex-shrink: 0;
	inline-size: var(--menu-link-marker-size);
	color: inherit;
	text-decoration: none;
}

.toc__marker-num {
	display: flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	inline-size: var(--menu-link-marker-size);
	block-size: var(--menu-link-marker-size);
	border: var(--menu-link-marker-border) solid var(--menu-link-marker-color);
	border-radius: var(--wp--custom--radius--pill, 500px);
	background-color: var(--wp--preset--color--base-white);
	font-family: var(--wp--preset--font-family--en-sans, var(--wp--preset--font-family--jp-sans));
	font-size: var(--wp--preset--font-size--text-xs);
	font-weight: var(--wp--custom--font-weight--semibold, 600);
	line-height: 0.9;
	text-align: center;
	text-decoration: none;
}

.toc__marker-num::before {
	counter-increment: toc;
	content: counter(toc, decimal-leading-zero);
}

/* process の手順は番号をマークアップに直接書く（success・error の項目も数えるため counter は使わない） */
.toc__marker-num:not(:empty)::before {
	content: none;
}

/* process の手順はリンクではない（ホバー・クリックの見た目を付けない） */
.toc__link--step {
	cursor: default;
}

/* 状態の読み上げ用（ブロックテーマのフロントには汎用の .screen-reader-text が無い） */
.toc__status.screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

.toc__marker-icon {
	display: none;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	inline-size: var(--menu-link-marker-size);
	block-size: var(--menu-link-marker-size);
	border: var(--menu-link-marker-border) solid var(--menu-link-marker-color);
	border-radius: var(--wp--custom--radius--pill, 500px);
	background-color: var(--wp--preset--color--base-white);
	color: inherit;
}

.toc__marker-icon .icon {
	inline-size: 1.5rem;
	block-size: 1.5rem;
}

/* 縦の接続線（マーカー上下）— PC 既定。色・太さは --menu-link-marker-* を継承 */
.toc__link .toc__marker::before,
.toc__link .toc__marker::after {
	content: "";
	flex: 1 0 auto;
	inline-size: 0;
	min-block-size: var(--menu-link-marker-line);
	border-inline-start: var(--menu-link-marker-border) solid var(--menu-link-marker-color);
	border-block-start: 0;
}

.toc > .toc__item {
	display: contents;
}

.toc > .toc__item:first-child .toc__link .toc__marker::before,
.toc > .toc__link:first-child .toc__marker::before {
	visibility: hidden;
}

.toc > .toc__item:last-child .toc__link .toc__marker::after,
.toc > .toc__link:last-child .toc__marker::after {
	visibility: hidden;
}

/* toc hover: マーカー枠も logo-blue（text change と連動）。番号に underline は付けない。process の手順（span）は対象外 */
.toc__link:where(a):hover,
.toc__link:where(a):focus-visible {
	--menu-link-marker-color: var(--wp--preset--color--logo-blue);
	color: var(--wp--preset--color--logo-blue);
	text-decoration: none;
}

.toc__link:where(a):hover .toc__marker-num,
.toc__link:where(a):focus-visible .toc__marker-num {
	color: var(--wp--preset--color--logo-blue);
	text-decoration: none;
}

/* toc data-state=active（自リンク相当: クリック不可） */
.toc__link[data-state="active"] {
	--menu-link-marker-border: var(--wp--custom--border-width--light, 2px);
	--menu-link-marker-color: var(--wp--preset--color--logo-blue);
	color: var(--wp--preset--color--logo-blue);
	font-weight: var(--wp--custom--font-weight--medium, 500);
	pointer-events: none;
	cursor: default;
}

.toc__link[data-state="active"] .toc__marker-num {
	color: var(--wp--preset--color--logo-blue);
	font-weight: var(--wp--custom--font-weight--bold, 700);
}

/* toc data-state=success */
.toc__link[data-state="success"] {
	--menu-link-marker-border: var(--wp--custom--border-width--light, 2px);
	--menu-link-marker-color: var(--wp--preset--color--state-success);
	color: var(--wp--preset--color--state-success);
	font-weight: var(--wp--custom--font-weight--medium, 500);
}

.toc__link[data-state="success"] .toc__marker-num {
	display: none;
}

.toc__link[data-state="success"] .toc__marker-icon--success {
	display: flex;
	color: var(--wp--preset--color--state-success);
}

/* toc data-state=error（バリデーション NG） */
.toc__link[data-state="error"] {
	--menu-link-marker-border: var(--wp--custom--border-width--light, 2px);
	--menu-link-marker-color: var(--wp--preset--color--state-alert);
	color: var(--wp--preset--color--state-alert);
	font-weight: var(--wp--custom--font-weight--medium, 500);
}

.toc__link[data-state="error"] .toc__marker-num {
	display: none;
}

.toc__link[data-state="error"] .toc__marker-icon--error {
	display: flex;
	color: var(--wp--preset--color--state-alert);
}

/* active のみ text-move を抑止（pointer-events:none の保険） */
.toc__link[data-state="active"]:hover .toc__label-text,
.toc__link[data-state="active"]:focus-visible .toc__label-text {
	animation: none;
}

/**
 * device=SP: 横並び＋左右コネクタ（ラベル非表示）。
 */
@media (max-width: 767px) {
	.toc {
		flex-direction: row;
		align-items: center;
		width: max-content;
	}

	.toc .toc__link {
		width: auto;
	}

	.toc .toc__link .toc__label {
		display: none;
	}

	.toc .toc__marker {
		--menu-link-marker-size: 1.5625rem; /* 25px */
		--menu-link-marker-line: 0.5625rem; /* (43 - 25) / 2 */
		flex-direction: row;
		inline-size: auto;
		min-inline-size: 2.6875rem; /* 43px */
	}

	.toc .toc__link .toc__marker::before,
	.toc .toc__link .toc__marker::after {
		inline-size: var(--menu-link-marker-line);
		min-inline-size: var(--menu-link-marker-line);
		block-size: 0;
		min-block-size: 0;
		border-inline-start: 0;
		border-block-start: var(--menu-link-marker-border) solid var(--menu-link-marker-color);
	}

	.toc .toc__marker-icon .icon {
		inline-size: 1.25rem;
		block-size: 1.25rem;
	}
}

