/**
 * Table of Contents Styles
 *
 * Styles for the reusable table of contents component.
 * Supports both inline and sticky sidebar modes.
 *
 * @package AgenticWP
 */

/* ==========================================================================
   Smooth Scrolling
   ========================================================================== */

html {
	scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
	html {
		scroll-behavior: auto;
	}
}

/* ==========================================================================
   Base TOC Styles
   ========================================================================== */

.toc {
	font-size: 14px;
	line-height: 1.5;
}

.toc-inner {
	background: var(--bg);
	border: 1px solid var(--line);
	border-radius: 12px;
	padding: 24px;
}

.toc-title {
	font-size: 13px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--muted);
	margin: 0 0 16px;
}

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

.toc-item {
	margin-bottom: 4px;
}

.toc-item:last-child {
	margin-bottom: 0;
}

.toc-link {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	padding: 8px 12px;
	border-radius: 8px;
	text-decoration: none;
	color: var(--muted);
	transition: all 0.2s ease;
}

.toc-link:hover {
	background: #f3f4f6;
	color: var(--ink);
}

.toc-link:focus {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

.toc-link.is-active {
	background: var(--accent-weak);
	color: var(--accent);
}

.toc-link.is-active .toc-number {
	background: var(--accent);
	color: var(--bg);
}

.toc-number {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	width: 24px;
	height: 24px;
	background: #f3f4f6;
	color: var(--muted);
	font-size: 12px;
	font-weight: 600;
	border-radius: 6px;
	transition: all 0.2s ease;
}

.toc-text {
	flex: 1;
	font-weight: 500;
	padding-top: 2px;
}

/* ==========================================================================
   Progress Bar
   ========================================================================== */

.toc-progress {
	margin-top: 20px;
	padding-top: 16px;
	border-top: 1px solid var(--line);
}

.toc-progress-bar {
	height: 4px;
	background: #f3f4f6;
	border-radius: 2px;
	overflow: hidden;
	position: relative;
}

.toc-progress-bar::after {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	height: 100%;
	width: var(--toc-progress, 0%);
	background: var(--accent);
	border-radius: 2px;
	transition: width 0.3s ease;
}

/* ==========================================================================
   Sticky Sidebar Mode
   ========================================================================== */

.toc--sticky {
	position: sticky;
	top: 100px;
	align-self: flex-start;
	flex-shrink: 0;
	width: 260px;
}

/* ==========================================================================
   Inline Mode
   ========================================================================== */

.toc--inline {
	margin: 32px 0;
}

.toc--inline .toc-inner {
	max-width: 400px;
}

.toc--inline .toc-progress {
	display: none;
}

/* ==========================================================================
   Post Layout (for sticky TOC)
   ========================================================================== */

.post-layout {
	padding: 0 0 48px;
}

.post-layout-inner {
	display: flex;
	gap: 48px;
	align-items: flex-start;
}

.post-article {
	flex: 1;
	min-width: 0;
	max-width: 720px;
}

/* ==========================================================================
   Responsive: Hide sticky TOC on smaller screens
   ========================================================================== */

@media (max-width: 1100px) {
	.toc--sticky {
		display: none;
	}

	.post-layout-inner {
		display: block;
	}

	.post-article {
		max-width: none;
	}
}

/* ==========================================================================
   Accessibility: Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
	.toc-link,
	.toc-number,
	.toc-progress-bar::after {
		transition: none;
	}
}
