/*!
 * Blocksy 悬浮目录 Floating TOC - 样式
 * 桌面端与移动端统一使用「垂直居中的点块导航」，无差异化分支。
 * 变量由插件内联输出：accent / rail_alpha / row，--bftoc-offset 由脚本按吸顶头部实测。
 */

.bftoc {
	--bftoc-accent: #2271b1;
	--bftoc-text: #2b2f36;
	--bftoc-border: rgba(0, 0, 0, 0.08);
	--bftoc-shadow: 0 8px 22px rgba(15, 23, 42, 0.12);

	position: fixed;
	top: 0;
	bottom: 0;
	right: 0;
	left: auto;
	z-index: 9999;
	width: 68px;
	display: flex;
	align-items: center;
	justify-content: flex-end;
	pointer-events: none;
	/* 让垂直居中发生在「吸顶头部下方」的可视区，避免顶部导航条压住轨道 */
	padding-top: var(--bftoc-offset, 96px);
	padding-bottom: 24px;
	box-sizing: border-box;
	font-size: 13px;
	line-height: 1.4;
	color: var(--bftoc-text);
	font-family: inherit;
	-webkit-font-smoothing: antialiased;
}

.bftoc[hidden] {
	display: none !important;
}

.bftoc--left {
	left: 0;
	right: auto;
	justify-content: flex-start;
}

/* 标题锚点：让原生 #hash 跳转也停在吸顶头部下方 */
.bftoc-target {
	scroll-margin-top: var(--bftoc-offset, 96px);
}

/* ---------- 点块轨道 ---------- */
.bftoc__rail {
	pointer-events: auto;
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 4px;
	max-height: calc(100vh - var(--bftoc-offset, 96px) - 48px);
	padding: 14px 6px;
	margin-right: 3px;
	border-radius: 999px;
	background: rgba(255, 255, 255, var(--bftoc-rail-alpha, 0.26));
	-webkit-backdrop-filter: blur(10px) saturate(120%);
	backdrop-filter: blur(10px) saturate(120%);
	border: 1px solid var(--bftoc-border);
	box-shadow: var(--bftoc-shadow);
	touch-action: none;
	-webkit-user-select: none;
	user-select: none;
	-webkit-tap-highlight-color: transparent;
	transition: background-color 0.18s ease, box-shadow 0.18s ease;
}

.bftoc.is-peek .bftoc__rail {
	background: rgba(255, 255, 255, var(--bftoc-rail-alpha-peek, 0.62));
	box-shadow: 0 10px 28px rgba(15, 23, 42, 0.16);
}

.bftoc__dot-item {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: flex-end;
	width: 30px;
	height: var(--bftoc-row, 30px);
	padding: 0;
	margin: 0;
	border: 0;
	background: none;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
	font: inherit;
}

.bftoc__dot {
	display: block;
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: rgba(15, 23, 42, 0.32);
	transition: transform 0.16s ease, background-color 0.16s ease, box-shadow 0.16s ease;
}

/* 圆点按标题层级分大小 */
.bftoc__dot-item--h1 .bftoc__dot,
.bftoc__dot-item--h2 .bftoc__dot {
	width: 9px;
	height: 9px;
}

.bftoc__dot-item--h3 .bftoc__dot {
	width: 7px;
	height: 7px;
}

.bftoc__dot-item--h4 .bftoc__dot {
	width: 5px;
	height: 5px;
}

.bftoc__dot-item--h5 .bftoc__dot,
.bftoc__dot-item--h6 .bftoc__dot {
	width: 4px;
	height: 4px;
}

/* 当前章节 */
.bftoc__dot-item.is-active .bftoc__dot {
	background: var(--bftoc-accent);
	transform: scale(1.4);
	box-shadow: 0 0 0 4px rgba(34, 113, 177, 0.14);
}

/* ---------- 弹出的胶囊标签 ---------- */
.bftoc__chip {
	position: absolute;
	right: calc(100% + 10px);
	top: 50%;
	transform: translateY(-50%) translateX(10px);
	opacity: 0;
	max-width: min(48vw, 320px);
	padding: 5px 12px;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.94);
	-webkit-backdrop-filter: blur(10px);
	backdrop-filter: blur(10px);
	box-shadow: 0 4px 14px rgba(15, 23, 42, 0.16);
	font-size: 12px;
	color: var(--bftoc-text);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	pointer-events: none;
	transition: opacity 0.16s ease, transform 0.16s ease, background-color 0.16s ease, color 0.16s ease;
}

.bftoc.is-peek .bftoc__chip {
	opacity: 1;
	transform: translateY(-50%) translateX(0);
}

/* 手指/鼠标选中的那一项 */
.bftoc__dot-item.is-peek-active .bftoc__chip {
	background: var(--bftoc-accent);
	color: #fff;
	font-weight: 600;
}

.bftoc__dot-item.is-peek-active .bftoc__dot {
	background: var(--bftoc-accent);
	transform: scale(1.45);
}

/* 左侧模式：标签向右弹出 */
.bftoc--left .bftoc__rail {
	align-items: flex-start;
	margin-right: 0;
	margin-left: 3px;
}

.bftoc--left .bftoc__dot-item {
	justify-content: flex-start;
}

.bftoc--left .bftoc__chip {
	right: auto;
	left: calc(100% + 10px);
	transform: translateY(-50%) translateX(-10px);
}

.bftoc--left.is-peek .bftoc__chip {
	transform: translateY(-50%) translateX(0);
}

/* ---------- 密集模式：章节过多时压缩，且只展开选中项 ---------- */
.bftoc__rail--dense {
	gap: 2px;
	padding: 12px 5px;
}

.bftoc__rail--dense .bftoc__dot-item {
	height: calc(var(--bftoc-row, 30px) - 6px);
}

.bftoc.is-peek .bftoc__rail--dense .bftoc__chip {
	opacity: 0;
}

.bftoc.is-peek .bftoc__rail--dense .bftoc__dot-item.is-peek-active .bftoc__chip {
	opacity: 1;
}

/* ---------- 键盘可达 ---------- */
.bftoc__dot-item:focus-visible {
	outline: none;
}

.bftoc__dot-item:focus-visible .bftoc__dot {
	box-shadow: 0 0 0 3px var(--bftoc-accent);
}

.bftoc__dot-item:focus-visible .bftoc__chip {
	opacity: 1;
	transform: translateY(-50%) translateX(0);
}

.bftoc--left .bftoc__dot-item:focus-visible .bftoc__chip {
	transform: translateY(-50%) translateX(0);
}

/* ---------- 深色 ---------- */
.bftoc--dark .bftoc__rail {
	background: rgba(27, 31, 39, var(--bftoc-rail-alpha, 0.3));
}

.bftoc--dark.is-peek .bftoc__rail {
	background: rgba(27, 31, 39, var(--bftoc-rail-alpha-peek, 0.66));
}

.bftoc--dark .bftoc__dot {
	background: rgba(255, 255, 255, 0.42);
}

.bftoc--dark .bftoc__chip {
	background: rgba(27, 31, 39, 0.94);
	color: #e5e7eb;
}

@media (prefers-color-scheme: dark) {
	.bftoc--auto .bftoc__rail {
		background: rgba(27, 31, 39, var(--bftoc-rail-alpha, 0.3));
	}

	.bftoc--auto.is-peek .bftoc__rail {
		background: rgba(27, 31, 39, var(--bftoc-rail-alpha-peek, 0.66));
	}

	.bftoc--auto .bftoc__dot {
		background: rgba(255, 255, 255, 0.42);
	}

	.bftoc--auto .bftoc__chip {
		background: rgba(27, 31, 39, 0.94);
		color: #e5e7eb;
	}
}

/* ---------- 打印时隐藏 ---------- */
@media print {
	.bftoc {
		display: none !important;
	}
}

/* 尊重系统「减少动态效果」（平滑滚动由脚本同步关闭） */
@media (prefers-reduced-motion: reduce) {
	.bftoc,
	.bftoc * {
		transition: none !important;
		animation: none !important;
	}
}
