/* ==========================================================================
   CL Header Menu — верхнее меню калькуляторов
   Брейкпоинт бургера: 960px (как у конкурента calcstroy.ru, UIkit @m).
   < 960px  — бургер + выезжающая панель-аккордеон.
   >= 960px — чёрная пилюля «Калькуляторы» + выпадающие списки по наведению.
   ========================================================================== */

.cl-header-menu {
	position: relative;
	display: flex;
	justify-content: flex-end;
	font-size: 15px;
}

.cl-header-menu ul,
.cl-header-menu li {
	list-style: none;
	margin: 0;
	padding: 0;
}

.cl-header-menu a {
	text-decoration: none;
	color: inherit;
}

/* --------------------------------------------------------------------------
   Кнопка-бургер (по умолчанию видна — мобильный-first)
   -------------------------------------------------------------------------- */
.cl-burger {
	display: inline-flex;
	align-items: center;
	gap: .6rem;
	background: #111;
	color: #fff;
	border: 0;
	border-radius: 4px;
	padding: .65rem 1.15rem;
	font: inherit;
	font-weight: 600;
	line-height: 1;
	cursor: pointer;
}
.cl-burger:hover { background: #333; }

.cl-burger__box {
	position: relative;
	width: 20px;
	height: 14px;
	display: inline-block;
	flex: 0 0 auto;
}
.cl-burger__inner,
.cl-burger__inner::before,
.cl-burger__inner::after {
	position: absolute;
	left: 0;
	width: 20px;
	height: 2px;
	background: currentColor;
	border-radius: 2px;
	transition: transform .2s ease, opacity .2s ease, top .2s ease;
}
.cl-burger__inner { top: 6px; }
.cl-burger__inner::before { content: ""; top: -6px; }
.cl-burger__inner::after  { content: ""; top: 6px; }

/* Крестик в открытом состоянии */
.cl-header-menu.is-open .cl-burger__inner { background: transparent; }
.cl-header-menu.is-open .cl-burger__inner::before { top: 0; transform: rotate(45deg); }
.cl-header-menu.is-open .cl-burger__inner::after  { top: 0; transform: rotate(-45deg); }

/* --------------------------------------------------------------------------
   Панель (мобильная — выпадает под бургером)
   -------------------------------------------------------------------------- */
.cl-menu-panel {
	display: none;
	position: absolute;
	top: calc(100% + 8px);
	right: 0;
	z-index: 1000;
	width: min(92vw, 360px);
	max-height: 80vh;
	overflow-y: auto;
	background: #fff;
	border: 1px solid #e5e5e5;
	border-radius: 8px;
	box-shadow: 0 12px 30px rgba(0, 0, 0, .18);
	-webkit-overflow-scrolling: touch;
}
.cl-header-menu.is-open .cl-menu-panel { display: block; }

.cl-menu-backdrop {
	position: fixed;
	inset: 0;
	z-index: 999;
	background: rgba(0, 0, 0, .35);
	border: 0;
}
.cl-menu-backdrop[hidden] { display: none; }

/* Верхний пункт «Калькуляторы» на мобильном не нужен — показываем категории напрямую */
.cl-menu-panel .cl-menu > li > a { display: none; }
.cl-menu-panel .cl-menu > li > .sub-menu { display: block; }

/* Категории и страницы — вертикальный список */
.cl-menu-panel .sub-menu li { border-top: 1px solid #f0f0f0; }
.cl-menu-panel .sub-menu > li:first-child { border-top: 0; }

.cl-menu-panel .sub-menu a {
	display: block;
	padding: .7rem 1rem;
	line-height: 1.3;
	color: #1a1a1a;
}

/* Категория 1-го уровня (жирнее) с кареткой-аккордеоном */
.cl-menu-panel .cl-menu > li > .sub-menu > li.menu-item-has-children > a {
	position: relative;
	font-weight: 600;
	background: #fafafa;
	padding-right: 2.4rem;
}
.cl-menu-panel .cl-menu > li > .sub-menu > li.menu-item-has-children > a::after {
	content: "";
	position: absolute;
	right: 1rem;
	top: 50%;
	width: 8px;
	height: 8px;
	border-right: 2px solid #777;
	border-bottom: 2px solid #777;
	transform: translateY(-70%) rotate(45deg);
	transition: transform .2s ease;
}
.cl-menu-panel .menu-item.is-open > a::after { transform: translateY(-30%) rotate(-135deg) !important; }

/* Вложенные списки (страницы) — свёрнуты, раскрываются по клику */
.cl-menu-panel .sub-menu .sub-menu { display: none; }
.cl-menu-panel .sub-menu .menu-item.is-open > .sub-menu { display: block; }
.cl-menu-panel .sub-menu .sub-menu a { padding-left: 1.8rem; color: #333; }

.cl-menu-panel .sub-menu a:hover { background: #f2f2f2; }

/* Текущая страница */
.cl-menu-panel .current-menu-item > a { color: #0a58ca; font-weight: 600; }

/* ==========================================================================
   ДЕСКТОП: >= 960px — прячем бургер, показываем меню с выпадашками
   ========================================================================== */
@media (min-width: 960px) {
	.cl-burger,
	.cl-menu-backdrop { display: none !important; }

	/* Панель — обычный поток, без оверлея */
	.cl-menu-panel {
		display: block;
		position: static;
		width: auto;
		max-height: none;
		overflow: visible;
		background: none;
		border: 0;
		border-radius: 0;
		box-shadow: none;
	}

	.cl-menu { display: flex; justify-content: flex-end; }

	/* Восстанавливаем верхний пункт «Калькуляторы» как чёрную пилюлю */
	.cl-menu-panel .cl-menu > li > a { display: flex; }

	.cl-menu > li {
		position: relative;
		background: #111;
		border-radius: 4px;
	}
	.cl-menu > li:hover { background: #333; }
	.cl-menu > li > a {
		align-items: center;
		gap: .4rem;
		color: #fff;
		padding: .7rem 1.4rem;
		font-weight: 600;
	}
	/* Каретка у пилюли */
	.cl-menu > li.menu-item-has-children > a::after {
		content: "";
		width: 7px;
		height: 7px;
		border-right: 2px solid currentColor;
		border-bottom: 2px solid currentColor;
		transform: translateY(-2px) rotate(45deg);
	}

	/* Все выпадающие списки */
	.cl-menu .sub-menu {
		position: absolute;
		min-width: 280px;
		background: #fff;
		border: 1px solid #e5e5e5;
		border-radius: 6px;
		box-shadow: 0 10px 28px rgba(0, 0, 0, .16);
		padding: .35rem 0;
		visibility: hidden;
		opacity: 0;
		transform: translateY(4px);
		transition: opacity .15s ease, transform .15s ease, visibility .15s;
		z-index: 1000;
	}
	/* Список категорий — под пилюлей, прижат вправо */
	.cl-menu > li > .sub-menu { top: 100%; right: 0; }
	/* Список страниц — вылетает влево от категории */
	.cl-menu .sub-menu .sub-menu { top: -.35rem; right: 100%; margin-right: 1px; }

	.cl-menu li:hover > .sub-menu,
	.cl-menu li:focus-within > .sub-menu {
		visibility: visible;
		opacity: 1;
		transform: translateY(0);
	}

	/* Пункты выпадашек */
	.cl-menu .sub-menu a {
		display: block;
		padding: .28rem 1rem;
		line-height: 1.3;
		color: #1a1a1a;
		white-space: normal;
	}
	.cl-menu .sub-menu li:hover > a { background: #f2f2f2; }
	.cl-menu .sub-menu .menu-item-has-children > a { font-weight: 600; padding-right: 1.6rem; position: relative; }
	.cl-menu .sub-menu .menu-item-has-children > a::after {
		content: "";
		position: absolute;
		right: .8rem;
		top: 50%;
		width: 6px; height: 6px;
		border-left: 2px solid #999;
		border-bottom: 2px solid #999;
		transform: translateY(-50%) rotate(45deg);
	}

	/* Длинные списки страниц не должны уходить за экран */
	.cl-menu .sub-menu .sub-menu {
		max-height: 74vh;
		overflow-y: auto;
	}

	.cl-menu .current-menu-item > a { color: #0a58ca; }
}
