/* Шапка для планшетов */
.page-header--tablet {
	display: none;
	width: 100%;
	padding: 16px 20px;
	background-color: var(--white);
	border-bottom: 1px solid var(--gray-stroke);
	margin-bottom: 40px;
	height: 72px;
	z-index: 10;
	align-items: center;
	position: relative;
}

/* Обёртка содержимого шапки */
.page-header__wrapper {
	flex: 1;
	display: flex;
	align-items: center;
	gap: 16px;
	position: relative;
}

/* Кнопка "Содержание" */
.page-header__contents-btn {
	padding: 12.5px 16px;
	font-size: 14px;
	font-weight: bold;
	line-height: 110%;
	color: var(--accent-blue);
	border-radius: 10px;
	border: 1px solid var(--gray-stroke);
	cursor: pointer;
	transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out, background-color 0.3s ease-in-out;
	flex-shrink: 0;
	z-index: 15;
}

.page-header__wrapper:has(.page-header__input-container.expanded) .page-header__contents-btn {
	opacity: 0;
	transform: translateX(-20px);
}

.page-header__contents-btn:hover,
.page-header__contents-btn:active,
.page-header__contents-btn[aria-expanded="true"] {
	background-color: var(--gray-back);
}

/* Всплывающее меню */
.page-header__contents-menu {
	position: fixed;
	bottom: 0;
	left: 0;
	right: 0;
	width: 100%;
	max-width: 480px;
	margin: 0 auto;
	background-color: var(--white);
	border-radius: 20px 20px 0 0;
	z-index: 150;
	transform: translateY(100%);
	opacity: 0;
	visibility: hidden;
	transition: transform 0.3s ease-in-out, opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
}

.page-header__contents-menu.active {
	transform: translateY(0);
	opacity: 1;
	visibility: visible;
}

/* Список содержимого меню */
.page-header__contents-list {
	list-style: none;
	margin: 0;
	padding: 20px;
	max-height: 80vh;
	/* Увеличено для предотвращения обрезки */
	overflow-y: auto;
	scrollbar-width: none;
	-ms-overflow-style: none;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.page-header__contents-list::-webkit-scrollbar {
	display: none;
}

/* Элементы меню (неиспользуемые, сохранены для совместимости) */
.contents-menu__item {
	display: block;
	padding: 12px 16px;
	color: var(--gray-dark);
	text-decoration: none;
	font-size: 16px;
	font-weight: 500;
	border-radius: 8px;
}

.contents-menu__item:hover {
	background-color: var(--gray-back);
}

/* Заголовок категории (согласован с sidebar__category-title) */
.page-header__category-title {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	padding: 12px 20px;
	border-radius: 10px;
	background-color: transparent;
	border: none;
	cursor: pointer;
	font-size: 20px;
	font-weight: 700;
	color: var(--black);
	line-height: 140%;
	transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out;
}

.page-header__category-title:hover {
	background-color: var(--blue-back);
	color: var(--accent-blue);
}

.page-header__category-content {
	display: flex;
	align-items: center;
	gap: 8px;
}

.page-header__category-count {
	font-size: 16px;
	font-weight: 700;
	color: var(--accent-blue);
	background-color: rgba(0, 128, 255, 0.08);
	padding: 2px 4px;
	border-radius: 4px;
}

.page-header__category-arrow {
	width: 16px;
	height: 8px;
	transition: transform 0.3s ease-in-out;
}

.page-header__category-title.is-active .page-header__category-arrow {
	transform: rotate(180deg);
}

/* Список постов (согласован с sidebar__post-list) */
.page-header__post-list {
	display: none;
	flex-direction: column;
	gap: 4px;
	opacity: 0;
	max-height: 0;
	overflow: hidden;
	transform: translateY(-10px);
	transition: opacity 0.3s ease-in-out, max-height 0.3s ease-in-out, transform 0.3s ease-in-out;
}

.page-header__post-list.active {
	display: flex;
	opacity: 1;
	max-height: 1000px;
	transform: translateY(0);
	overflow: visible;
}

.page-header__post-list[style*="display: flex"] {
	display: flex;
	opacity: 1;
	max-height: 1000px;
	/* Достаточно для всех постов */
	transform: translateY(0);
	overflow: visible;
	/* Предотвращает обрезку после анимации */
}

.page-header__post-item {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 12px 20px;
	border-radius: 10px;
	font-size: 16px;
	font-weight: 600;
	color: var(--gray-dark);
	text-decoration: none;
	transition: background-color 0.2s ease-in-out;
	min-height: 44px;
	/* Гарантирует минимальную высоту */
}

.page-header__post-item:hover {
	background-color: var(--gray-back);
}

.page-header__post-item.active {
	background-color: var(--gray-back);
}

.page-header__post-icon {
	width: 8px;
	height: 16px;
	opacity: 0;
	flex-shrink: 0;
	transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;
}

.page-header__post-item:hover .page-header__post-icon {
	opacity: 1;
	transform: translateX(2px);
}

/* Контейнер для поля поиска */
.page-header__input-container {
	border-radius: 10px;
	border: 1px solid var(--gray-stroke);
	display: flex;
	gap: 8px;
	align-items: center;
	padding: 0 8px;
	position: absolute;
	top: 0;
	left: 140px;
	width: calc(100% - 140px);
	background-color: var(--white);
	z-index: 19;
	transition: width 0.3s ease-in-out, left 0.3s ease-in-out, border-color 0.3s ease-in-out, border-radius 0.3s ease-in-out;
}

.page-header__input-container.expanded {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	border: 2px solid var(--accent-blue);
	z-index: 30;
}

.page-header__input-container:has(+ .page-header__search-results.active) {
	border-bottom-left-radius: 0;
	border-bottom-right-radius: 0;
}

/* Поле ввода поиска */
.page-header__input {
	width: 100%;
	padding: 9px 0;
	padding-left: 0;
	font-size: 16px;
	font-weight: 500;
	border-radius: 10px;
	line-height: 110%;
	color: var(--gray-dark);
	border: none;
	outline: none;
}

.page-header__input::placeholder {
	color: #A6ABB5;
	transition: color 0.2s ease-in-out;
}

.page-header__input:hover::placeholder {
	color: var(--gray-dark);
}

.page-header__input-container svg {
	flex-shrink: 0;
}

.page-header--tablet:has(.page-header__input:focus) {
	z-index: 30;
}

/* Результаты поиска */
.page-header__search-results {
	display: none;
	position: absolute;
	top: calc(100% + 16px);
	left: 0;
	width: 100vw;
	margin-left: calc(-22px);
	max-height: 300px;
	overflow-y: auto;
	background-color: var(--white);
	border: 1px solid var(--gray-stroke);
	border-radius: 0 0 20px 20px;
	z-index: 20;
	padding: 10px;
	flex-direction: column;
	gap: 4px;
	opacity: 0;
	transform: translateY(10px);
	transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
}

.page-header__search-results.active {
	display: flex;
	opacity: 1;
	transform: translateY(0);
	border-top: none;
}

.page-header-search-result-item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 20px;
	color: var(--gray-dark);
	font-size: 16px;
	font-weight: 600;
	line-height: 140%;
	text-decoration: none;
	border-radius: 10px;
	transition: background-color 0.2s ease-in-out, transform 0.3s ease-in-out, opacity 0.3s ease-in-out;
	opacity: 0;
	transform: translateY(10px);
}

.page-header__search-results.active .page-header-search-result-item {
	opacity: 1;
	transform: translateY(0);
}

.page-header-search-result-item:hover {
	background-color: var(--gray-back);
}

.page-header-search-result-item span {
	flex: 1;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.page-header-search-result-item .page-header__post-icon {
	width: 8px;
	height: 16px;
	flex-shrink: 0;
	opacity: 0;
	transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;
}

.page-header-search-result-item:hover .page-header__post-icon {
	opacity: 1;
	transform: translateX(2px);
}

.page-header__no-posts {
	font-size: 16px;
	font-weight: 600;
	line-height: 140%;
	color: var(--gray-dark);
	padding: 8px 20px;
	line-height: 140%;
	text-align: center;
}

/* Кнопка очистки поиска */
.page-header__input-clear {
	display: none;
	background: none;
	border: none;
	cursor: pointer;
	padding: 8px;
}

.page-header__input-clear svg {
	width: 24px;
	height: 24px;
	flex-shrink: 0;
	color: var(--gray-dark);
	transition: color 0.2s ease-in-out;
	cursor: pointer;
}

.page-header__input-clear:hover svg {
	color: var(--black);
}

/* Контейнер кнопки закрытия меню */
.contents-menu__btn-container {
	padding: 20px;
	border-top: 1px solid var(--gray-stroke);
}

.contents-menu__btn {
	padding: 12.5px 16px;
	width: 100%;
	line-height: 110%;
	font-size: 14px;
	font-weight: bold;
	border-radius: 10px;
	outline: 1px solid var(--gray-stroke);
	cursor: pointer;
	transition: background-color 0.2s ease-in-out;
	color: var(--accent-blue);
}

.contents-menu__btn:hover {
	background-color: var(--gray-back);
}

.page-header__post-wrapper {
	display: flex;
	flex-direction: column;
}

.page-header__child-list {
	flex-direction: column;
	gap: 4px;
	opacity: 0;
	max-height: 0;
	overflow: hidden;
	transform: translateY(-10px);
	transition: opacity 0.3s ease-in-out, max-height 0.3s ease-in-out, transform 0.3s ease-in-out;
	padding-left: 10px;
	margin-top: 5px;
}

.page-header__child-list.active {
	opacity: 1;
	max-height: 1000px;
	display: flex;
	transform: translateY(0);
}

.page-header__child-item {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 8px 20px;
	border-radius: 10px;
	font-size: 14px;
	font-weight: 600;
	color: var(--gray-dark);
	text-decoration: none;
	transition: background-color 0.2s ease-in-out;
}

.page-header__child-item:hover {
	background-color: var(--gray-back);
}

.page-header__child-item.active {
	background-color: var(--gray-back);
}

.page-header__child-icon {
	width: 8px;
	height: 16px;
	opacity: 0;
	flex-shrink: 0;
	transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;
}

.page-header__child-item:hover .page-header__child-icon {
	opacity: 1;
	transform: translateX(2px);
}

.page-header__post-item span {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	flex: 1;
	min-width: 0;
	display: flex;
	align-items: center;
	width: 100%;
	gap: 5px;
}

.page-header__post-arrow {
	width: 16px;
	height: 8px;
	transition: transform 0.3s ease-in-out;
}

.page-header__post-item.is-active .page-header__post-arrow {
	transform: rotate(180deg);
}

/* Медиа-запросы */
@media (max-width: 900px) {
	.page-header--tablet {
		display: flex;
	}
}

/* single.css */
@media (max-width: 400px) {

	.page-header__wrapper {
		justify-content: space-between;
	}

	.page-header__contents-btn {
		width: calc(100% - 52px);
	}

	.page-header__input-container {
		display: flex;
		align-items: center;
		cursor: pointer;
		width: 40px;
		height: 42px;
		right: 0;
		left: auto;
		transition: background-color 0.2s ease-in-out;
	}

	.page-header__input-container:active {
		background-color: var(--gray-back);
	}

	.page-header__input {
		opacity: 0;
		width: 0;
		pointer-events: none;
		transition: opacity 0.3s ease-in-out, width 0.3s ease-in-out;
	}

	.page-header__input-container:focus-within .page-header__input {
		opacity: 1;
		width: 100%;
		pointer-events: auto;
	}

	.page-header__input-container svg {
		pointer-events: none;
	}
}