/* =====================================================================
   Шапка v2 (16.09.2026): две строки — меню и контакты, рейтинги и
   мессенджеры. Подключается после main.css и перекрывает старые правила
   шапки (main.css не правился — откат: убрать подключение в functions.php).

   Десктоп (≥992px): <header class="site-header"> в потоке и липкий,
   вторая строка .header_down всегда открыта (решение 18.09.2026).
   Мобильная шапка (≤991px) остаётся как была: .header_up fixed, бургер.
   ===================================================================== */

@media (min-width: 992px) {

	/* ---------- каркас: шапка в потоке, липкая ---------- */
	body {
		padding-top: 0;
	}

	.site-header {
		position: sticky;
		top: 0;
		z-index: 2; /* как у прежней .header_up: попапы (z-index 3) остаются поверх */
		background: #fff;
	}

	body.admin-bar .site-header {
		top: 32px;
	}

	.header_up {
		position: static;
		transition: none;
	}

	/* поиск выпадает под шапку, как и раньше */
	.site-header .search_block {
		top: 100%;
	}

	/* отступ между шапкой и контентом (хлебные крошки) — 20px (решение 18.09.2026);
	   на главной первый экран прижат к шапке */
	.site-header + * {
		margin-top: 20px;
	}

	body.home .site-header + * {
		margin-top: 0;
	}

	/* ---------- строка 1 ---------- */
	.header_up > .container {
		padding-right: 6px; /* под выступающий счётчик корзины */
	}

	.header_up .container .row {
		align-items: center;
		justify-content: flex-start;
		gap: 28px;
	}

	.header_up .container .row > div {
		flex: none;
	}

	.header_up .container .row .logo {
		padding-right: 24px;
	}

	.header_up .container .row .logo a {
		padding-right: 0;
		display: block;
	}

	.header_up .container .row .logo img {
		width: 118px;
		height: auto;
	}

	/* каталог + меню */
	.header_up .header_menu {
		padding: 0;
		border-right: 0;
		gap: 24px;
		height: 100%;
	}

	.header_menu .catalog_btn {
		margin-right: 0;
		display: flex;
		align-items: center;
		position: relative;
	}

	/* ---------- мегаменю каталога: слева категории, справа подкатегории ---------- */
	/* под первой строкой, от левого края кнопки
	   (у flex-родителя статическая позиция absolute-потомка — верх, а не низ) */
	.header_menu .catalog_btn .catalog_menu {
		top: 100%;
		left: 0;
		width: 900px;
		max-height: none;
		border: 1px solid #e9e9e9;
		border-radius: 10px;
		box-shadow: 0 24px 60px -30px rgba(16, 32, 64, 0.5);
		overflow: hidden;
	}

	/* левая колонка */
	.catalog_menu > div {
		width: 300px;
		height: auto;
		padding: 8px 0;
		border-right: 1px solid #e9e9e9;
		overflow: visible;
	}

	.catalog_menu > div > div > a {
		width: auto;
		padding: 11px 20px;
		border: 0;
		font-weight: 600;
		font-size: 15px;
		color: #1c1c1f;
		transition: 0.16s;
	}

	/* иконки категорий те же (синие линейные), но на плитке, как в макете */
	.catalog_menu > div > div > a img {
		width: 34px;
		height: 34px;
		padding: 6px;
		border-radius: 8px;
		background: #eef3fb;
		object-fit: contain;
		margin-right: 12px;
		flex: none;
	}

	/* стрелок у категорий в макете нет */
	.catalog_menu > div > div > a::after,
	.catalog_menu > div > div.active > a::after {
		content: none;
	}

	.catalog_menu > div > div > a:hover,
	.catalog_menu > div > div.active > a {
		background: #f9f9f9;
		color: #2568fe;
		text-shadow: none;
	}

	/* правая часть: подкатегории активной категории текстом в две колонки */
	.catalog_menu_right {
		width: calc(100% - 300px);
		height: 100%;
		margin: 0;
		padding: 20px 24px;
		background: #f9f9f9;
		overflow: auto;
	}

	.catalog_menu_right .row-wrap {
		margin: 0;
	}

	.catalog_menu_right > .row-wrap {
		display: grid;
		grid-template-columns: 1fr 1fr;
		gap: 14px 28px;
		align-content: start;
	}

	.catalog_menu_right > .row-wrap > div {
		display: block;
		width: auto;
		min-width: 0;
		padding: 0;
	}

	/* фото подкатегорий в макете нет */
	.catalog_menu_right > .row-wrap > div > a {
		display: none;
	}

	.catalog_menu_right .row-wrap > div > div a.name {
		font-size: 15px;
		margin-bottom: 0;
		transition: 0.16s;
	}

	.catalog_menu_right .row-wrap > div > div a.name:hover {
		text-decoration: underline;
	}

	/* третьего уровня в макете нет (подкатегории подкатегорий видны на странице подкатегории) */
	.catalog_menu_right .row-wrap > div > div > div {
		display: none;
	}

	.header_menu .catalog_btn button {
		font-size: 14px;
		margin-right: 0;
		gap: 9px;
	}

	.header_menu .catalog_btn button::after {
		order: -1; /* сетка-иконка перед словом «Каталог» */
		margin-left: 0;
	}

	.header_menu > ul {
		margin: 0;
		gap: 24px;
	}

	.header_menu > ul > li {
		padding: 0;
		position: relative;
	}

	.header_menu > ul > li > a {
		font-weight: 600;
		font-size: 15px;
		color: #1c1c1f;
		gap: 6px;
		white-space: nowrap;
	}

	.header_menu > ul > li.menu-item-has-children > a::after {
		margin-left: 0;
	}

	/* выпадающие списки первого уровня */
	.header_menu > ul > li.menu-item-has-children > .sub-menu,
	.header_menu > ul > li.menu-item-has-children.no_border > .sub-menu {
		top: 100%;
		left: -20px;
		min-width: 300px;
		padding: 8px 0;
		border: 1px solid #e9e9e9;
		border-radius: 10px;
		box-shadow: 0 24px 60px -30px rgba(16, 32, 64, 0.5);
	}

	.header_menu > ul > li.menu-item-has-children > .sub-menu > li > a,
	.header_menu > ul > li.menu-item-has-children.no_border > .sub-menu > li > a {
		padding: 13px 22px;
		border-bottom: 0;
		font-weight: 500;
		font-size: 15px;
		color: #1c1c1f;
		white-space: nowrap;
	}

	.header_menu > ul > li.menu-item-has-children > .sub-menu > li.menu-item-has-children > a {
		padding-right: 52px;
	}

	.header_menu > ul > li.menu-item-has-children > .sub-menu > li.menu-item-has-children > a::after {
		right: 22px;
	}

	.header_menu > ul > li.menu-item-has-children > .sub-menu > li > a:hover,
	.header_menu > ul > li.menu-item-has-children > .sub-menu > li > a.active {
		background: #f9f9f9;
		color: #2568fe;
		text-shadow: none;
	}

	/* третий уровень — выезжает вправо */
	.header_menu > ul > li.menu-item-has-children > .sub-menu > li > .sub-menu {
		top: -9px;
		min-width: 400px;
		padding: 8px 0;
		border: 1px solid #e9e9e9;
		box-shadow: 0 24px 60px -30px rgba(16, 32, 64, 0.5);
	}

	.header_menu > ul > li.menu-item-has-children > .sub-menu > li > .sub-menu > li > a {
		display: block;
		margin: 0;
		padding: 13px 22px;
		font-size: 15px;
		color: #1c1c1f;
		transition: 0.16s;
	}

	.header_menu > ul > li.menu-item-has-children > .sub-menu > li > .sub-menu > li > a::after {
		content: none;
	}

	.header_menu > ul > li.menu-item-has-children > .sub-menu > li > .sub-menu > li > a:hover {
		background: #f9f9f9;
		color: #2568fe;
	}

	/* телефоны — столбиком, первый синий */
	.header_up .header_phone {
		margin-left: auto;
		padding: 0;
		border-right: 0;
	}

	.header_up .header_phone > div {
		display: flex;
		flex-direction: column;
		gap: 1px;
		padding: 0;
		line-height: 1.25;
	}

	.header_up .header_phone > div::before,
	.header_up .header_phone > div::after {
		content: none;
	}

	.header_up .header_phone > div a {
		font-weight: 800;
		font-size: 15px;
		color: #1c1c1f;
		white-space: nowrap;
		transition: 0.16s;
	}

	.header_up .header_phone > div a:first-child {
		color: #2568fe;
	}

	.header_up .header_phone > div a:hover {
		color: #2568fe;
	}

	/* мессенджеры первой строки переехали во вторую */
	.header_up .header_soc {
		display: none;
	}

	/* иконки: поиск и корзина */
	.header_up .header_icons {
		width: auto;
		margin-left: -8px;
		padding-left: 16px;
		border-left: 1px solid #e9e9e9;
		justify-content: flex-start;
		gap: 14px;
	}

	.header_up .header_icons button {
		width: 24px;
		height: 24px;
		margin: 0;
		background-size: 19px auto;
	}

	/* избранное и сравнение в шапке макета нет; вернуть — удалить эту строку */
	.header_up .header_icons button.btn_favorite,
	.header_up .header_icons button.btn_compare {
		display: none;
	}

	.header_up .header_icons button.btn_cart {
		position: relative;
		overflow: visible;
	}

	.header_cart_count {
		position: absolute;
		top: -5px;
		right: -6px;
		min-width: 16px;
		height: 16px;
		padding: 0 4px;
		border-radius: 20px;
		background: #2568fe;
		color: #fff;
		font-weight: 800;
		font-size: 10px;
		line-height: 16px;
		text-align: center;
		pointer-events: none;
	}

	.header_cart_count[hidden] {
		display: none;
	}

	/* ---------- строка 2 (всегда открыта — решение 18.09.2026) ---------- */
	.header_down {
		background: #fff;
		border-bottom: 1px solid #e9e9e9;
	}

	.header_down .container {
		display: flex;
		align-items: center;
		justify-content: flex-start;
		gap: 18px;
		height: 56px;
		white-space: nowrap;
	}

	.header_down .container > * {
		flex: none;
	}

	.header_down__right {
		margin-left: auto;
		display: flex;
		align-items: center;
		gap: 18px;
	}

	/* бейджи рейтингов */
	.rating_badge {
		display: inline-flex;
		align-items: center;
		gap: 8px;
		padding: 5px 12px 5px 7px;
		background: #f9f9f9;
		border: 1px solid #e9e9e9;
		border-radius: 100px;
		color: #1c1c1f;
		transition: 0.16s;
	}

	.rating_badge:hover {
		border-color: #f03434;
		background: #fff;
	}

	.rating_badge--gis:hover {
		border-color: #19aa1e;
	}

	.rating_badge__pin {
		flex: none;
		display: block;
	}

	.rating_badge__name {
		font-weight: 600;
		font-size: 13px;
		color: #4f4f4f;
	}

	.rating_badge__score {
		font-weight: 800;
		font-size: 14px;
		color: #1c1c1f;
	}

	.rating_badge__stars {
		color: #ffc107;
		font-size: 12px;
		line-height: 1;
		letter-spacing: 0.5px;
	}

	.rating_badge__count {
		font-weight: 500;
		font-size: 13px;
		color: #6b7280;
	}

	/* мессенджеры */
	.header_msg_label {
		font-weight: 600;
		font-size: 13px;
		color: #4f4f4f;
	}

	.header_messengers {
		display: flex;
		gap: 8px;
	}

	.header_messengers a {
		width: 34px;
		height: 34px;
		border-radius: 9px;
		display: flex;
		align-items: center;
		justify-content: center;
		background-color: #f9f9f9;
		border: 1px solid #e9e9e9;
		transition: 0.16s;
	}

	.header_messengers a:hover {
		border-color: #2568fe;
	}

	.header_messengers a svg {
		display: block;
	}

	/* MAX — тот же знак, что у плавающей кнопки и в мобильной шапке */
	.header_messengers__max {
		background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg width='24' height='24' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3e%3cdefs%3e%3clinearGradient id='bgGradient' x1='0' y1='0' x2='1' y2='1'%3e%3cstop offset='0%25' stop-color='%2300C6FF'/%3e%3cstop offset='100%25' stop-color='%237B2FFF'/%3e%3c/linearGradient%3e%3c/defs%3e%3crect x='0' y='0' width='24' height='24' rx='6' fill='url(%23bgGradient)'/%3e%3cpath fill-rule='evenodd' clip-rule='evenodd' d='M12.1971 21.0799C10.3969 21.0799 9.56034 20.8171 8.10619 19.7659C7.1864 20.9485 4.27373 21.8726 4.14671 20.2915C4.14671 19.1045 3.88391 18.1015 3.58607 17.0065C3.23129 15.6575 2.82834 14.1552 2.82834 11.9783C2.82834 6.7793 7.09442 2.868 12.1489 2.868C17.2078 2.868 21.1716 6.97202 21.1716 12.0265C21.1886 17.0028 17.1733 21.0533 12.1971 21.0799ZM12.2715 7.36184C9.81 7.23482 7.89157 8.93862 7.46672 11.6104C7.11632 13.8223 7.73828 16.516 8.26825 16.6561C8.52229 16.7174 9.16176 16.2006 9.56034 15.802C10.2194 16.2573 10.9869 16.5308 11.7854 16.5948C14.3359 16.7175 16.5153 14.7757 16.6865 12.228C16.7862 9.67482 14.8225 7.51232 12.2715 7.36622Z' fill='white'/%3e%3c/svg%3e");
		background-repeat: no-repeat;
		background-position: center;
		background-size: 20px 20px;
	}

	/* почта */
	.header_mail {
		font-weight: 700;
		font-size: 14px;
		color: #2568fe;
		padding-left: 18px;
		border-left: 1px solid #e9e9e9;
		transition: 0.16s;
	}

	.header_mail:hover {
		color: #1c1c1f;
	}

	/* «Получить КП» */
	.header_down .btn_blue.header_kp {
		padding: 9px 20px;
		font-size: 14px;
		transition: 0.18s;
	}

	.header_down .btn_blue.header_kp:hover {
		background: #1f58dc;
	}
}

/* ---------- до 1340px у .container есть боковые отступы 15px ---------- */
@media (min-width: 992px) and (max-width: 1340px) {
	.header_up > .container {
		padding-right: 21px; /* 15px отступ контейнера + 6px под счётчик корзины */
	}

	/* подпись «Мессенджеры:» не влезает вместе с длинной почтой коллтрекинга */
	.header_msg_label {
		display: none;
	}
}

/* ---------- компактный десктоп: контейнер 990px ---------- */
@media (min-width: 992px) and (max-width: 1199px) {
	.header_up .container .row {
		gap: 16px;
	}

	.header_up .container .row .logo {
		padding-right: 14px;
	}

	.header_up .container .row .logo img {
		width: 96px;
	}

	.header_up .header_menu {
		gap: 14px;
	}

	.header_menu > ul {
		gap: 14px;
	}

	.header_menu > ul > li > a,
	.header_menu .catalog_btn button {
		font-size: 13px;
	}

	.header_up .header_phone > div a {
		font-size: 13px;
	}

	.header_up .header_icons {
		margin-left: -6px;
		padding-left: 10px;
		gap: 10px;
	}

	.header_down .container,
	.header_down__right {
		gap: 12px;
	}

	.rating_badge__stars {
		display: none;
	}

	.header_mail {
		padding-left: 12px;
	}

	/* мегаменю не должно уходить за правый край экрана */
	.header_menu .catalog_btn .catalog_menu {
		width: min(900px, calc(100vw - 170px));
	}
}

/* ---------- мобильная шапка: вторая строка не нужна ---------- */
@media (max-width: 991px) {
	.header_down {
		display: none;
	}

	/* Mobile uses the same Telegram and MAX artwork as the desktop header. */
	.header_up .header_soc .header_mobile_messenger {
		display: flex;
		align-items: center;
		justify-content: center;
		width: 24px !important;
		height: 24px !important;
		background: none;
	}

	.header_up .header_soc .header_mobile_messenger--tg {
		margin-right: 8px;
	}

	.header_up .header_soc .header_mobile_messenger svg,
	.header_up .header_soc .header_mobile_messenger img {
		display: block;
		width: 24px;
		height: 24px;
	}

	/* main.css даёт header margin-bottom 20px на ≤575px (отступ до хлебных крошек);
	   на главной первый экран должен прижиматься к шапке */
	body.home .site-header {
		margin-bottom: 0;
	}
}
