/**
 * 見出しバッジ（本文・目次リンク内）。
 */

.affifocus-heading-has-badge {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	column-gap: 0.4em;
	row-gap: 0.25em;
}

.affifocus-heading-badge {
	display: inline-flex;
	box-sizing: border-box;
	align-items: center;
	justify-content: center;
	text-align: center;
	max-width: 100%;
	font-size: 0.72em;
	line-height: 1;
	font-weight: 600;
	padding: 0.28em 0.55em;
	min-height: 1.85em;
	border-radius: 3px;
	vertical-align: middle;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.affifocus-toc a.affifocus-toc-link:has(.affifocus-heading-badge) {
	gap: 0.35em;
}

.affifocus-toc-link .affifocus-heading-badge--toc {
	flex-shrink: 0;
}

/* エディター: wrapperProps の data + 疑似要素でバッジ（ブロック枠・見出しと同じ塊に収める） */
.block-editor-block-list__block[data-type="core/heading"].affifocus-heading-editor-has-badge {
	display: flex;
	flex-direction: row;
	flex-wrap: nowrap;
	align-items: baseline;
	column-gap: 0.45em;
	box-sizing: border-box;
	/* 列の stretch で無理に狭くならないよう、短い見出しは内容幅・長文は列幅まで */
	align-self: flex-start;
	width: min(100%, max-content);
}

.block-editor-block-list__block[data-type="core/heading"].affifocus-heading-editor-has-badge
	> .block-editor-block-list__block-edit {
	/* 親が min(100%,max-content) のとき長文用に伸びる。親が内容幅のときは中身に合わせる */
	flex: 1 1 auto;
	min-width: 0;
}

.block-editor-block-list__block[data-type="core/heading"].affifocus-heading-editor-has-badge--before::before,
.block-editor-block-list__block[data-type="core/heading"].affifocus-heading-editor-has-badge--after::after {
	box-sizing: border-box;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	text-align: center;
	content: attr(data-affifocus-badge-text);
	font-size: max(11px, 0.72em);
	line-height: 1;
	font-weight: 600;
	padding: 0.28em 0.55em;
	min-height: 1.85em;
	max-width: min(42%, 12rem);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	border-radius: 3px;
	flex-shrink: 0;
	background-color: var(--affifocus-badge-bg, #64748b);
	color: var(--affifocus-badge-color, #fff);
}

.block-editor-block-list__block[data-type="core/heading"].affifocus-heading-editor-has-badge--before::after {
	content: none !important;
	display: none !important;
}

.block-editor-block-list__block[data-type="core/heading"].affifocus-heading-editor-has-badge--after::before {
	content: none !important;
	display: none !important;
}
