/* ───── Навигация по странице «Искусство войны» ───── */

/* Кнопка-триггер — всегда видна слева */
.aow-toc-trigger {
	position: fixed;
	top: 50%;
	left: 0;
	z-index: 1031;
	transform: translateY(-50%);

	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 48px;
	padding: 0;
	margin: 0;
	border: none;
	border-radius: 0 8px 8px 0;
	background: var(--bs-primary, #0d6efd);
	color: #fff;
	cursor: pointer;
	box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.15);
	transition:
		left 0.25s ease,
		box-shadow 0.25s ease;

	/* Минимальная площадь касания */
	min-width: 44px;
	min-height: 44px;
}

.aow-toc-trigger:hover {
	box-shadow: 2px 2px 12px rgba(0, 0, 0, 0.25);
}

.aow-toc-trigger:focus-visible {
	outline: 2px solid var(--bs-primary, #0d6efd);
	outline-offset: 2px;
}

/* Сама панель — скрыта по умолчанию, выезжает слева */
.aow-toc {
	position: fixed;
	top: 0;
	left: 0;
	z-index: 1031;
	width: 320px;
	max-width: calc(100vw - 16px);
	max-height: 100vh;

	background: var(--bs-body-bg, #fff);
	border: 1px solid var(--bs-border-color, #dee2e6);
	border-left: none;
	box-shadow: 4px 4px 16px rgba(0, 0, 0, 0.1);

	display: flex;
	flex-direction: column;

	/* Начальное состояние — скрыта */
	transform: translateX(-100%);
	visibility: hidden;
	transition:
		transform 0.3s ease,
		visibility 0.3s ease;
}

.aow-toc--open {
	transform: translateX(0);
	visibility: visible;
	padding-bottom: 20px;
}

/* Заголовок панели */
.aow-toc__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0.625rem 1rem;
	background: var(--bs-light, #f8f9fa);
	border-bottom: 1px solid var(--bs-border-color, #dee2e6);
	border-radius: 0 0 0 0;
	cursor: pointer;
	user-select: none;
	min-height: 44px;
}

.aow-toc__title {
	font-size: 0.875rem;
	font-weight: 600;
	color: var(--bs-body-color, #212529);
	display: flex;
	align-items: center;
	gap: 0.375rem;
	flex: 1;
}

.aow-toc__toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	padding: 0;
	border: none;
	background: transparent;
	color: var(--bs-secondary, #6c757d);
	cursor: pointer;
	border-radius: 4px;
	transition:
		background 0.2s,
		color 0.2s;
	min-width: 44px;
	min-height: 44px;
}

.aow-toc__toggle:hover {
	background: rgba(0, 0, 0, 0.05);
	color: var(--bs-body-color, #212529);
}

.aow-toc__toggle-icon {
	font-size: 1.25rem;
	transition: transform 0.2s;
}

/* ─── Тело панели (списки) ─── */
.aow-toc__body {
	overflow-y: auto;
	flex: 1;
	max-height: calc(100vh - 60px);
}

/* ─── Группа ─── */
.aow-toc__group {
	border-bottom: 1px solid var(--bs-border-color, #e9ecef);
}

.aow-toc__group:last-child {
	border-bottom: none;
}

/* Кнопка заголовка группы */
.aow-toc__group-toggle {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	padding: 0.5rem 1rem;
	border: none;
	background: transparent;
	color: var(--bs-body-color, #212529);
	font-size: 0.8rem;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.2s;
	min-height: 44px;
}

.aow-toc__group-toggle:hover {
	background: rgba(0, 0, 0, 0.03);
}

.aow-toc__group-label {
	display: flex;
	align-items: center;
	gap: 0.375rem;
}

.aow-toc__group-arrow {
	font-size: 1.125rem;
	transition: transform 0.2s;
	color: var(--bs-secondary, #6c757d);
}

/* Список пунктов группы */
.aow-toc__list {
	list-style: none;
	margin: 0;
	padding: 0;
	max-height: 0;
	overflow: hidden;
	transition: max-height 0.3s ease;
}

.aow-toc__list--open {
	max-height: 1000px;
}

/* Ссылка пункта */
.aow-toc__link {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.375rem 1rem 0.375rem 1.5rem;
	color: var(--bs-body-color, #212529);
	text-decoration: none;
	font-size: 0.8125rem;
	transition:
		background 0.15s,
		color 0.15s;
	min-height: 36px;
}

.aow-toc__link:hover {
	background: rgba(0, 0, 0, 0.03);
	color: var(--bs-primary, #0d6efd);
}

.aow-toc__link--active {
	background: rgba(13, 110, 253, 0.06);
	color: var(--bs-primary, #0d6efd);
	font-weight: 500;
}

.aow-toc__link-icon {
	font-size: 1rem;
	color: var(--bs-secondary, #6c757d);
	flex-shrink: 0;
}

.aow-toc__link--active .aow-toc__link-icon {
	color: var(--bs-primary, #0d6efd);
}

.aow-toc__link-text {
	line-height: 1.3;
}

/* ─── Адаптивность ─── */

/* Планшеты */
@media (max-width: 1199.98px) {
	.aow-toc {
		width: 280px;
	}
}

/* Мобильные: вся панель снизу на весь экран */
@media (max-width: 991.98px) {
	.aow-toc-trigger {
		top: auto;
		bottom: 16px;
		left: 16px;
		transform: none;
		border-radius: 50%;
		width: 52px;
		height: 52px;
		box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
	}

	.aow-toc {
		top: auto;
		bottom: 0;
		left: 0;
		right: 0;
		width: 100%;
		max-width: 100%;
		max-height: 70vh;
		border-radius: 0.75rem 0.75rem 0 0;
		border: 1px solid var(--bs-border-color, #dee2e6);
		border-bottom: none;
		box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.15);
		transform: translateY(100%);
	}

	.aow-toc--open {
		transform: translateY(0);
	}

	.aow-toc__body {
		max-height: calc(70vh - 52px);
	}

	.aow-toc__link {
		padding: 0.5rem 1rem 0.5rem 1.5rem;
		min-height: 44px;
	}
}

/* ─── Темная тема ─── */
[data-bs-theme='dark'] .aow-toc {
	background: var(--bs-body-bg, #212529);
	border-color: var(--bs-border-color, #495057);
	box-shadow: 4px 4px 16px rgba(0, 0, 0, 0.4);
}

[data-bs-theme='dark'] .aow-toc__header {
	background: var(--bs-light, #2b3035);
}

[data-bs-theme='dark'] .aow-toc-trigger {
	background: var(--bs-primary, #0d6efd);
}

[data-bs-theme='dark'] .aow-toc__group-toggle:hover,
[data-bs-theme='dark'] .aow-toc__link:hover {
	background: rgba(255, 255, 255, 0.05);
}

[data-bs-theme='dark'] .aow-toc__link--active {
	background: rgba(13, 110, 253, 0.15);
}
