/**
 * WorkBuddy TOC - front-end styles.
 *
 * The layout values are injected as CSS custom properties on :root by
 * WBTOC_Frontend::print_variables(). The fallbacks below keep the component
 * usable when the inline variables are stripped by an optimiser.
 */

:root {
	--wbtoc-accent: #2563eb;
	--wbtoc-accent-soft: rgba(37, 99, 235, 0.1);
	--wbtoc-accent-line: rgba(37, 99, 235, 0.28);
	--wbtoc-width: 260px;
	--wbtoc-offset: 90px;
	--wbtoc-max-height: 70vh;
}

/* -------------------------------------------------------------------------
 * Wrapper
 * ---------------------------------------------------------------------- */

.wbtoc-root {
	position: static;
}

/* -------------------------------------------------------------------------
 * Fixed sidebar
 * ---------------------------------------------------------------------- */

.wbtoc-sidebar {
	position: fixed;
	top: var(--wbtoc-offset);
	width: var(--wbtoc-width);
	max-height: var(--wbtoc-max-height);
	display: flex;
	flex-direction: column;
	box-sizing: border-box;
	overflow: hidden;
	background: #fff;
	color: #334155;
	border: 1px solid rgba(15, 23, 42, 0.08);
	box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
	font-size: 14px;
	line-height: 1.55;
	text-align: left;
	z-index: 9990;
	-webkit-font-smoothing: antialiased;
}

.wbtoc-left .wbtoc-sidebar {
	left: 0;
	border-left: 0;
	border-radius: 0 14px 14px 0;
}

.wbtoc-right .wbtoc-sidebar {
	right: 0;
	border-right: 0;
	border-radius: 14px 0 0 14px;
}

.wbtoc-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	flex: 0 0 auto;
	padding: 12px 14px;
	border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}

.wbtoc-title {
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: #0f172a;
}

.wbtoc-toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	padding: 0;
	flex: 0 0 auto;
	border: 1px solid rgba(15, 23, 42, 0.1);
	border-radius: 7px;
	background: #fff;
	color: #64748b;
	cursor: pointer;
	line-height: 1;
	transition: color 0.15s ease, border-color 0.15s ease;
}

.wbtoc-toggle:hover,
.wbtoc-toggle:focus-visible {
	color: var(--wbtoc-accent);
	border-color: var(--wbtoc-accent-line);
}

.wbtoc-toggle svg {
	width: 14px;
	height: 14px;
	display: block;
	transition: transform 0.2s ease;
}

.wbtoc-sidebar.is-collapsed .wbtoc-toggle svg {
	transform: rotate(-90deg);
}

/* -------------------------------------------------------------------------
 * Scrollable list area
 * ---------------------------------------------------------------------- */

.wbtoc-body {
	position: relative;
	flex: 1 1 auto;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 8px 8px 12px;
	scrollbar-width: thin;
}

.wbtoc-body::-webkit-scrollbar {
	width: 6px;
}

.wbtoc-body::-webkit-scrollbar-thumb {
	background: rgba(15, 23, 42, 0.15);
	border-radius: 3px;
}

.wbtoc-sidebar.is-collapsed .wbtoc-body {
	display: none;
}

.wbtoc-sidebar.is-collapsed {
	max-height: none;
}

/* -------------------------------------------------------------------------
 * List
 * ---------------------------------------------------------------------- */

.wbtoc-list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.wbtoc-item {
	margin: 0;
	padding: 0;
}

.wbtoc-link {
	display: block;
	padding: 6px 10px;
	border-left: 2px solid transparent;
	border-radius: 6px;
	color: #475569;
	text-decoration: none;
	box-shadow: none;
	word-break: break-word;
	transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.wbtoc-link:hover,
.wbtoc-link:focus {
	color: var(--wbtoc-accent);
	background: var(--wbtoc-accent-soft);
	text-decoration: none;
}

.wbtoc-link:focus-visible {
	outline: 2px solid var(--wbtoc-accent-line);
	outline-offset: 1px;
}

.wbtoc-link.is-active {
	color: var(--wbtoc-accent);
	background: var(--wbtoc-accent-soft);
	border-left-color: var(--wbtoc-accent);
	font-weight: 600;
}

.wbtoc-level-3 > .wbtoc-link {
	padding-left: 24px;
	font-size: 13.5px;
}

.wbtoc-level-4 > .wbtoc-link {
	padding-left: 38px;
	font-size: 13px;
}

.wbtoc-level-5 > .wbtoc-link {
	padding-left: 52px;
	font-size: 13px;
}

.wbtoc-level-6 > .wbtoc-link {
	padding-left: 66px;
	font-size: 13px;
}

/* Hierarchical numbering (1, 1.1, 1.1.1 ...). */
.wbtoc-numbered .wbtoc-list {
	counter-reset: wbtoc-counter;
}

.wbtoc-numbered .wbtoc-item {
	counter-increment: wbtoc-counter;
}

.wbtoc-numbered .wbtoc-link::before {
	content: counters(wbtoc-counter, ".") "  ";
	color: #94a3b8;
	font-variant-numeric: tabular-nums;
}

/* -------------------------------------------------------------------------
 * Reserve the sidebar width so the entry is never covered
 * ---------------------------------------------------------------------- */

@media (min-width: 1100px) {
	body.wbtoc-push-left,
	body.wbtoc-push-right {
		box-sizing: border-box;
	}

	body.wbtoc-push-left {
		padding-left: var(--wbtoc-width);
	}

	body.wbtoc-push-right {
		padding-right: var(--wbtoc-width);
	}
}

/* -------------------------------------------------------------------------
 * Small screens: hide the rail, optionally offer a drawer
 * ---------------------------------------------------------------------- */

.wbtoc-fab {
	position: fixed;
	left: 16px;
	bottom: 16px;
	z-index: 9992;
	display: none;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 48px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--wbtoc-accent);
	color: #fff;
	box-shadow: 0 10px 24px rgba(15, 23, 42, 0.25);
	cursor: pointer;
}

.wbtoc-fab svg {
	width: 20px;
	height: 20px;
	display: block;
}

.wbtoc-right .wbtoc-fab {
	left: auto;
	right: 16px;
}

@media (max-width: 1099px) {
	.wbtoc-sidebar {
		display: none;
	}

	body.wbtoc-mobile-enabled .wbtoc-fab {
		display: inline-flex;
	}

	body.wbtoc-mobile-enabled .wbtoc-sidebar.wbtoc-mobile-open {
		display: flex;
		top: auto;
		bottom: 76px;
		left: 16px;
		right: 16px;
		width: auto;
		max-height: 60vh;
		border: 1px solid rgba(15, 23, 42, 0.08);
		border-radius: 14px;
	}
}

/* -------------------------------------------------------------------------
 * Inline shortcode output
 * ---------------------------------------------------------------------- */

.wbtoc-inline-nav {
	margin: 1.75em 0;
	padding: 16px 20px;
	border: 1px solid rgba(15, 23, 42, 0.1);
	border-left: 3px solid var(--wbtoc-accent);
	border-radius: 10px;
	background: rgba(248, 250, 252, 0.85);
}

.wbtoc-inline-title {
	margin: 0 0 8px;
	font-weight: 700;
	color: #0f172a;
}

.wbtoc-inline-nav .wbtoc-link {
	padding-left: 0;
	border-left: 0;
}

.wbtoc-inline-nav .wbtoc-level-3 > .wbtoc-link {
	padding-left: 16px;
}

.wbtoc-inline-nav .wbtoc-level-4 > .wbtoc-link {
	padding-left: 32px;
}

.wbtoc-inline-nav .wbtoc-level-5 > .wbtoc-link {
	padding-left: 48px;
}

.wbtoc-inline-nav .wbtoc-level-6 > .wbtoc-link {
	padding-left: 64px;
}

/* -------------------------------------------------------------------------
 * Print and motion preferences
 * ---------------------------------------------------------------------- */

@media print {
	.wbtoc-root,
	.wbtoc-inline-nav {
		display: none !important;
	}
}

@media (prefers-reduced-motion: reduce) {
	.wbtoc-link,
	.wbtoc-toggle,
	.wbtoc-toggle svg {
		transition: none;
	}
}
