/* ── Header shell ─────────────────────────────────────── */

.header {
	position: absolute;
	top: 20px;
	left: 20px;
	right: 20px;
	background: var(--color-white);
	border-radius: 16px;
	padding: 20px;
}

/* Reserve space for the absolutely positioned header.
   --ct-header-height is set by header.js (falls back to a sane default). */
.page-content__top {
	position: relative;
	padding-top: calc(20px + var(--ct-header-height, 130px));
}

/* Блокируем скролл страницы, пока открыто мобильное меню (классы — из header.js). */
html.ct-mobile-menu-open {
	overflow: hidden;
}

body.ct-mobile-menu-open {
	overflow: hidden;
	position: relative;
}

/* ── Rows shared ──────────────────────────────────────── */

.header__top,
.header__bottom {
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.header__top {
	border-bottom: 0.8px solid var(--color-neutral-100);
	padding-bottom: 10px;
}

.header__bottom {
	padding-top: 16px;
}

.header__menu .menu-item > a:hover {
	color: var(--color-purple-deep);
	text-decoration: underline;
}

/* ── Top left ─────────────────────────────────────────── */

.header__top-left {
	display: flex;
	align-items: center;
}

.header__contacts {
	display: flex;
	align-items: center;
	gap: 10px;
}

/* ── Logo ─────────────────────────────────────────────── */

.header__logo a {
	display: block;
}

.header__logo img {
	width: 148px;
	height: 29px;
	object-fit: contain;
	margin-right: 24px;
}

/* ── Phone ────────────────────────────────────────────── */

.header__phone {
	font-weight: 600;
	font-size: 14px;
	line-height: 120%;
	text-decoration: underline;
	color: var(--color-purple-deep);
	transition: text-decoration 0.2s ease;
}

.header__phone:hover {
	text-decoration: none;
}

/* ── Working hours ────────────────────────────────────── */

.header__working-hours {
	font-weight: 400;
	font-size: 14px;
	line-height: 120%;
	color: var(--color-neutral-500);
}

/* ── Top menu ─────────────────────────────────────────── */

.header__menu--top {
	display: flex;
	align-items: center;
	gap: 16px;
	list-style: none;
	margin: 0;
	padding: 0;
}

.header__menu--top a {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	font-weight: 500;
	font-size: 14px;
	line-height: 120%;
	color: var(--color-neutral-600);
	text-decoration: none;
}

/* ── Bottom left ──────────────────────────────────────── */

.header__bottom-left {
	flex: 1;
	min-width: 0;
	position: relative;
}

/* ── Bottom menu ──────────────────────────────────────── */

.header__menu--bottom {
	display: flex;
	align-items: center;
	gap: 18px;
	list-style: none;
	margin: 0;
	padding: 0;
	transition: opacity 0.2s ease;
}

.header__menu--bottom > .menu-item {
	position: relative;
	transition: z-index 0s linear 0.2s;
}

.header__menu--bottom > .menu-item-has-children:hover {
	z-index: 100;
	transition: z-index 0s linear 0s;
}

.header__menu--bottom a {
	font-weight: 600;
	font-size: 14px;
	line-height: 120%;
	text-transform: uppercase;
	color: var(--color-bg-deepest);
	text-decoration: none;
}

/* ── Bottom submenu (level 2) ─────────────────────────── */

.header__menu--bottom > .menu-item-has-children > a {
	position: relative;
	z-index: 2;
}

.header__menu--bottom .sub-menu {
	position: absolute;
	top: -16px;
	left: -20px;
	min-width: calc(100% + 40px);
	list-style: none;
	margin: 0;
	padding: 48px 20px 20px;
	background: var(--color-white);
	border-radius: 12px;
	box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
	z-index: 1;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity 0.2s ease, visibility 0.2s ease;
}

.header__menu--bottom > .menu-item-has-children:hover > .sub-menu {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
}

.header__menu--bottom .sub-menu li {
	display: block;
}

.header__menu--bottom .sub-menu li + li {
	margin-top: 12px;
}

.header__menu--bottom .sub-menu a {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-weight: 500;
	font-size: 14px;
	line-height: 120%;
	text-transform: none;
	color: var(--color-bg-deepest);
	text-decoration: none;
	white-space: nowrap;
}

.header__menu--bottom .sub-menu a::before {
	content: '';
	width: 5px;
	height: 5px;
	border-right: 1.2px solid currentColor;
	border-top: 1.2px solid currentColor;
	transform: rotate(45deg);
	flex-shrink: 0;
}

.header__menu--bottom .sub-menu a:hover {
	color: var(--color-purple-deep);
}

/* ── Page overlay when submenu open ───────────────────── */

body::after {
	content: '';
	position: fixed;
	inset: 0;
	background: #24232E5C;
	z-index: 50;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity 0.2s ease, visibility 0.2s ease;
}

body:has(.header__menu--bottom > .menu-item-has-children:hover)::after {
	opacity: 1;
	visibility: visible;
}

/* ── Bottom right ─────────────────────────────────────── */

.header__bottom-right {
	display: flex;
	align-items: center;
	gap: 12px;
	flex-shrink: 0;
	margin-left: 16px;
}

/* ── Header button overrides ──────────────────────────── */

.header .btn {
	width: auto;
	height: 38px;
	padding: 0 24px;
	font-size: 14px;
}

/* ── Search form ──────────────────────────────────────── */

.header__search-form {
	position: absolute;
	top: 50%;
	right: 0;
	transform: translateY(-50%);
	display: flex;
	align-items: center;
	width: 38px;
	height: 38px;
	background: var(--color-light-100);
	border-radius: 10px;
	overflow: hidden;
	transition: width 0.4s ease;
	padding: 4px;
}

.header__bottom.is-search-open .header__search-form {
	width: 100%;
}

.header__search-toggle {
	flex-shrink: 0;
	width: 30px;
	height: 30px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: transparent;
	border: none;
	border-radius: 10px;
	padding: 0;
	cursor: pointer;
	color: var(--color-purple-muted);
	transition: background-color 0.2s ease, color 0.2s ease;
}

.header__search-form:focus-within .header__search-toggle {
	background: var(--color-purple-deep);
	color: var(--color-white);
}

.header__search-input {
	flex: 1;
	min-width: 0;
	height: 100%;
	border: none;
	background: transparent;
	padding: 0 16px 0 4px;
	font-size: 14px;
	line-height: 120%;
	color: var(--color-bg-deepest);
	outline: none;
}

/* ── Open state ───────────────────────────────────────── */

.header__bottom.is-search-open .header__menu--bottom {
	opacity: 0;
	pointer-events: none;
}

/* ── Mobile-only elements (hidden by default) ─────────── */

.header__mobile-controls,
.header__mobile-menu,
.header__top > .header__search-form {
	display: none;
}

/* ── Mobile (≤ 1200px) ────────────────────────────────── */

@media (max-width: 1200px) {

	/* Header shell */
	.header {
		top: 12px;
		left: 12px;
		right: 12px;
		padding: 12px;
		border-radius: 8px;
	}

	.page-content__top {
		padding-top: calc(12px + var(--ct-header-height, 64px));
	}

	/* Top row */
	.header__top {
		position: relative;
		border-bottom: none;
		padding-bottom: 0;
		gap: 8px;
	}

	/* Hide desktop-only elements */
	.header__top-nav,
	.header__bottom {
		display: none;
	}

	/* Top-left: logo on top, contacts under */
	.header__top-left {
		flex-direction: column;
		align-items: flex-start;
	}

	.header__logo {
		margin-bottom: 2px;
	}

	.header__logo img {
		width: 124px;
		height: 24px;
		margin-right: 0;
	}

	.header__contacts {
		gap: 6px;
	}

	.header__phone,
	.header__working-hours {
		font-weight: 600;
		font-size: 12px;
		line-height: 120%;
	}

	.header__phone {
		color: var(--color-purple-deep);
	}

	.header__working-hours {
		color: var(--color-neutral-500);
	}

	/* Mobile controls (search + burger) */
	.header__mobile-controls {
		display: flex;
		align-items: center;
		gap: 8px;
		flex-shrink: 0;
		margin-left: auto;
	}

	/* Burger button */
	.header__burger {
		width: 40px;
		height: 40px;
		border-radius: 10px;
		background: var(--color-light-100);
		border: none;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		gap: 4px;
		padding: 0;
		cursor: pointer;
		flex-shrink: 0;
		transition: background-color 0.2s ease;
	}

	.header__burger-line {
		display: block;
		width: 16px;
		height: 1px;
		background: var(--color-neutral-600);
		transition: transform 0.3s ease, opacity 0.2s ease;
	}

	.header.is-mobile-menu-open .header__burger-line:nth-child(1) {
		transform: translateY(5px) rotate(45deg);
	}

	.header.is-mobile-menu-open .header__burger-line:nth-child(2) {
		opacity: 0;
	}

	.header.is-mobile-menu-open .header__burger-line:nth-child(3) {
		transform: translateY(-5px) rotate(-45deg);
	}

	/* Mobile search form (positioned absolute over top row) */
	.header__top > .header__search-form {
		display: flex;
		position: absolute;
		top: 50%;
		right: 48px; /* burger 40 + gap 8 */
		left: auto;
		transform: translateY(-50%);
		width: 40px;
		height: 40px;
		padding: 4px;
		border-radius: 10px;
		z-index: 2;
	}

	.header__top.is-search-open > .header__search-form {
		width: calc(100% - 48px);
	}

	.header__top > .header__search-form .header__search-toggle {
		width: 32px;
		height: 32px;
	}

	/* Hide top-left when search is expanded */
	.header__top.is-search-open .header__top-left {
		opacity: 0;
		pointer-events: none;
		transition: opacity 0.2s ease;
	}

	/* ── Mobile menu panel ─────────────────────────── */

	/* Фон на весь экран — через fixed-слой, рамку хедера не сдвигаем (top/left/right как у закрытого). */
	.header.is-mobile-menu-open {
		position: fixed;
		display: flex;
		flex-direction: column;
		top: 12px;
		left: 12px;
		right: 12px;
		min-height: calc(100svh - 12px);
		max-height: calc(100svh - 12px);
		overflow: hidden;
		border-radius: 8px;
		z-index: 200;
		isolation: isolate;
		background-image: url('../../img/vector-bg-1.png');
		background-repeat: no-repeat;
		background-position: bottom right;
		background-size: contain;
	}

	.header.is-mobile-menu-open::before {
		content: '';
		position: fixed;
		inset: 0;
		z-index: -1;
		background: var(--color-white);
		pointer-events: none;
	}

	.header.is-mobile-menu-open .header__top {
		flex-shrink: 0;
	}

	.header.is-mobile-menu-open .header__mobile-menu {
		display: flex;
		flex-direction: column;
		flex: 1 1 auto;
		min-height: 0;
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
	}

	.header__mobile-menu {
		padding-top: 32px;
	}

	/* Shared mobile menu link styles */
	.header__menu--top-mobile a,
	.header__menu--bottom-mobile a {
		font-weight: 500;
		font-size: 14px;
		line-height: 120%;
		text-decoration: none;
	}

	/* Top mobile menu: 2 columns */
	.header__menu--top-mobile {
		column-count: 2;
		column-gap: 16px;
		list-style: none;
		margin: 0;
		padding: 0;
	}

	.header__menu--top-mobile > .menu-item {
		break-inside: avoid;
	}

	.header__menu--top-mobile > .menu-item:not(:last-child) {
		padding-bottom: 16px;
	}

	.header__menu--top-mobile a {
		color: var(--color-neutral-600);
	}

	/* Divider (≥1px — субпиксельная высота часто не рисуется) */
	.header__mobile-divider {
		height: 1px;
		min-height: 1px;
		flex-shrink: 0;
		background: var(--color-neutral-100);
		margin: 32px 0;
	}

	/* Bottom row: bottom menu + socials */
	.header__mobile-bottom-row {
		display: flex;
		align-items: stretch;
		justify-content: space-between;
		gap: 16px;
	}

	.header__mobile-bottom-nav {
		flex: 1 1 auto;
		max-width: 268px;
		min-width: 0;
	}

	/* Bottom mobile menu: column */
	.header__menu--bottom-mobile {
		display: flex;
		flex-direction: column;
		gap: 18px;
		list-style: none;
		margin: 0;
		padding: 0;
	}

	.header__menu--bottom-mobile a {
		font-weight: 600;
		color: var(--color-bg-deepest);
		text-transform: uppercase;
	}

	/* Socials — pinned to bottom of the row */
	.header__mobile-socials {
		display: flex;
		flex-direction: column;
		justify-content: flex-end;
		gap: 6px;
		flex-shrink: 0;
	}

	.header__social-icon {
		display: flex;
		align-items: center;
		justify-content: center;
		width: 40px;
		height: 40px;
		padding: 8px;
		background: var(--color-light-50);
		border: 1px solid var(--color-light-200);
		border-radius: 8px;
		box-sizing: border-box;
	}

	.header__social-icon svg {
		width: 100%;
		height: 100%;
		display: block;
	}

	/* Bottom contacts (email + working hours) pinned to bottom */
	.header__mobile-contacts {
		margin-top: auto;
		display: flex;
		flex-direction: column;
		gap: 12px;
		padding-top: 24px;
	}

	.header__mobile-contact {
		display: flex;
		flex-direction: column;
	}

	.header__mobile-contact-label {
		font-weight: 600;
		font-size: 12px;
		line-height: 120%;
		color: var(--color-bg-deepest-a40);
		margin-bottom: 2px;
	}

	.header__mobile-contact-value {
		font-weight: 700;
		font-size: 20px;
		line-height: 120%;
		text-transform: uppercase;
		color: var(--color-bg-deepest);
		text-decoration: none;
	}

	/* Disable desktop overlay on mobile */
	body:has(.header__menu--bottom > .menu-item-has-children:hover)::after {
		opacity: 0;
		visibility: hidden;
	}
}
