/* toc-block v1.0.0 — frontend styles */

/* ── Wrapper — sticky, sits under the navbar ────────────────────── */
.toc-block-wrapper {
	position: sticky;
	top: var(--toc-sticky-top, 0px);
	z-index: 400;
	background: #fff;
	border-bottom: 1px solid #e2e2e2;
	padding: 10px 20px;
	box-sizing: border-box;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	font-size: 14px;
	/* Hidden until JS has populated it, to avoid a flash of "Loading…" */
	visibility: hidden;
	opacity: 0;
}
.toc-block-wrapper.is-ready {
	visibility: visible;
	opacity: 1;
	transition: opacity 0.2s ease;
}

.toc-block-placeholder {
	color: #888;
	font-size: 13px;
	list-style: none;
}

/* ── Header row (title + mobile toggle) ─────────────────────────── */
.toc-block-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
}

.toc-block-title {
	font-weight: 600;
	color: #1e1e1e;
	white-space: nowrap;
}

.toc-block-toggle {
	display: none;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	padding: 0;
	border: none;
	background: transparent;
	cursor: pointer;
	flex-shrink: 0;
}
.toc-block-toggle-icon {
	position: relative;
	width: 14px;
	height: 10px;
}
.toc-block-toggle-icon,
.toc-block-toggle-icon::before,
.toc-block-toggle-icon::after {
	display: block;
}
.toc-block-toggle-icon::before,
.toc-block-toggle-icon::after {
	content: "";
	position: absolute;
	left: 0;
	width: 100%;
	height: 2px;
	background: #1e1e1e;
	transition: transform 0.2s ease;
}
.toc-block-toggle-icon::before { top: 0; }
.toc-block-toggle-icon::after  { bottom: 0; }
.toc-block-toggle-icon { border-top: 2px solid #1e1e1e; }
.toc-block-wrapper.is-collapsed .toc-block-toggle-icon::after {
	transform: translateY(-4px) rotate(0deg);
}
.toc-block-wrapper:not(.is-collapsed) .toc-block-toggle .toc-block-toggle-icon::after {
	transform: translateY(4px);
}

/* ── List ────────────────────────────────────────────────────────── */
.toc-block-list {
	list-style: none;
	margin: 8px 0 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	gap: 6px 24px;
	max-height: 1000px;
	overflow: hidden;
	transition: max-height 0.25s ease, opacity 0.2s ease, margin 0.2s ease;
}

.toc-block-item {
	list-style: none;
}

.toc-block-link {
	color: #1e1e1e;
	text-decoration: none;
	border-bottom: 2px solid transparent;
	padding-bottom: 2px;
	transition: color 0.15s ease, border-color 0.15s ease;
}
.toc-block-link:hover,
.toc-block-link:focus {
	color: #0967d2;
}
.toc-block-link.is-active {
	color: #0967d2;
	border-color: #0967d2;
	font-weight: 600;
}

/* Bulleted variant */
.toc-block-style-bullet .toc-block-list {
	flex-direction: column;
	gap: 4px;
}
.toc-block-style-bullet .toc-block-item {
	list-style: disc;
	margin-left: 20px;
}

/* Numbered variant */
.toc-block-style-number .toc-block-list {
	flex-direction: column;
	gap: 4px;
	counter-reset: toc-block-counter;
}
.toc-block-style-number .toc-block-item {
	counter-increment: toc-block-counter;
}
.toc-block-style-number .toc-block-item::before {
	content: counter(toc-block-counter) ". ";
	font-weight: 600;
	margin-right: 2px;
}

/* ── Collapsed state (mobile) ───────────────────────────────────── */
.toc-block-wrapper.is-collapsed .toc-block-list {
	max-height: 0;
	opacity: 0;
	margin-top: 0;
}

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 781px) {
	.toc-block-wrapper.is-collapsible .toc-block-toggle {
		display: flex;
	}
	.toc-block-wrapper.is-collapsible .toc-block-list {
		flex-direction: column;
	}
}

.screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(1px, 1px, 1px, 1px);
	white-space: nowrap;
}
