/*
 * Front-end styles for bsm-topnav (header chrome).
 *
 * Markup: ../template-parts/topnav.php
 * Source: ../files/10_Projects/bsm_company/05_Brand/design/04-library.html (.topnav)
 *
 * BEM-нейминг: .bsm-topnav + __brand, __nav, __menu, __spacer,
 *   __contacts, __search, __burger, __contacts-list, __contact.
 *
 * Sticky bar сверху, белый фон, hairline снизу. На мобильных — навигация
 * прячется, появляется бургер, который открывает выезжающую панель.
 */

.bsm-topnav {
	position: sticky;
	top: 0;
	z-index: 50;
	background: var(--surface);
	border-bottom: var(--hairline);
	height: var(--topnav-h);
	display: flex;
	align-items: center;
	padding: 0 32px;
	gap: 28px;
	font-family: inherit;
}

.bsm-topnav__brand {
	display: flex;
	align-items: baseline;
	gap: 10px;
	flex-shrink: 0;
	text-decoration: none;
	color: inherit;
}

.bsm-topnav__brand:hover {
	text-decoration: none;
}

.bsm-topnav__logo {
	font-weight: 700;
	font-size: 18px;
	letter-spacing: 0.06em;
	font-family: inherit;
}

.bsm-topnav__logo .b { color: var(--accent); }
.bsm-topnav__logo .m { color: var(--navy); }

.bsm-topnav__nav {
	display: flex;
	align-items: center;
}

.bsm-topnav__menu {
	display: table;
	border-collapse: collapse;
	list-style: none;
	margin: 0;
	padding: 0;
}

.bsm-topnav__menu > li {
	display: table-cell;
	vertical-align: middle;
	position: relative;
}

.bsm-topnav__menu > li > a {
	display: inline-block;
	height: var(--topnav-h);
	line-height: var(--topnav-h);
	padding: 0 14px;
	color: var(--text);
	font-size: 14px;
	font-weight: 400;
	text-decoration: none;
	white-space: nowrap;
	box-sizing: border-box;
	transition: color 0.15s, font-weight 0.15s, transform 0.15s;
	transform-origin: center center;
}

.bsm-topnav__menu > li > a:hover {
	color: var(--accent-strong);
	text-decoration: none;
	font-weight: 600;
	transform: scale(1.05);
}

.bsm-topnav__menu > li.current-menu-item > a,
.bsm-topnav__menu > li.current-menu-ancestor > a {
	color: var(--accent-strong);
}

/* На главной (home) WP помечает все menu-item с URL "/" как current, т.к.
 * static front page = /. Это визуальный артефакт — все пункты выглядят
 * подсвеченными. Скрываем current-styling для menu-item-home на home,
 * чтобы topnav выглядел чисто. Постоянное решение — изменить URL-ы
 * пунктов меню в Appearance → Menus на конкретные slug-и страниц.
 * Hover всё равно работает — он перебит более специфичным :hover ниже. */
.home .bsm-topnav__menu > li.menu-item-home.current-menu-item > a,
.home .bsm-topnav__menu > li.menu-item-home.current-menu-ancestor > a {
	color: var(--text);
	font-weight: 400;
}

.home .bsm-topnav__menu > li.menu-item-home.current-menu-item > a:hover,
.home .bsm-topnav__menu > li.menu-item-home.current-menu-ancestor > a:hover {
	color: var(--accent-strong);
}

/* Dropdown submenu inside nav */
.bsm-topnav__menu .sub-menu {
	position: absolute;
	top: 100%;
	left: 0;
	min-width: 240px;
	background: var(--surface);
	border: var(--hairline);
	padding: 6px 0;
	margin: 0;
	list-style: none;
	display: none;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
	z-index: 10;
}

.bsm-topnav__menu li:hover > .sub-menu,
.bsm-topnav__menu li:focus-within > .sub-menu {
	display: block;
}

.bsm-topnav__menu .sub-menu a {
	display: block;
	padding: 10px 18px;
	border-bottom: none;
	font-size: 13.5px;
	font-weight: 400;
	color: var(--text);
}

/* Submenu current item — never inherit bold from parent current-menu-item. */
.bsm-topnav__menu .sub-menu li.current-menu-item > a,
.bsm-topnav__menu .sub-menu li.current_page_item > a,
.bsm-topnav__menu li.current-menu-item .sub-menu a {
	font-weight: 400;
}

.bsm-topnav__menu .sub-menu a:hover {
	background: var(--bg-soft);
	color: var(--accent-strong);
	text-decoration: none;
}

.bsm-topnav__empty {
	color: var(--gray);
	font-size: 13px;
	font-style: italic;
}

.bsm-topnav__spacer {
	flex: 1;
}

/* ----- Contacts dropdown ----- */

.bsm-topnav__contacts {
	position: relative;
}

.bsm-topnav__contacts-btn {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	height: 40px;
	padding: 0 14px;
	background: transparent;
	border: var(--hairline);
	color: var(--navy);
	font-family: inherit;
	font-size: 13.5px;
	font-weight: 600;
	cursor: pointer;
	transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.bsm-topnav__contacts-btn:hover,
.bsm-topnav__contacts-btn[aria-expanded="true"] {
	border-color: var(--accent);
	color: var(--accent-strong);
	background: var(--accent-soft);
}

.bsm-topnav__contacts-btn svg {
	width: 16px;
	height: 16px;
}

.bsm-topnav__contacts-list {
	position: absolute;
	top: calc(100% + 4px);
	right: 0;
	min-width: 280px;
	background: var(--surface);
	border: var(--hairline);
	border-top: var(--accent-rule);
	padding: 6px 0;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
	z-index: 11;
}

.bsm-topnav__contacts-list[hidden] {
	display: none;
}

.bsm-topnav__contact {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 16px;
	color: var(--text);
	text-decoration: none;
	transition: background 0.15s;
}

.bsm-topnav__contact:hover {
	background: var(--bg-soft);
	color: var(--accent-strong);
	text-decoration: none;
}

.bsm-topnav__contact-icon {
	flex-shrink: 0;
	width: 32px;
	height: 32px;
	display: flex;
	align-items: center;
	justify-content: center;
	border: var(--hairline);
	color: var(--navy);
}

.bsm-topnav__contact-icon svg {
	width: 16px;
	height: 16px;
}

.bsm-topnav__contact-text {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.bsm-topnav__contact-label {
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--gray);
	font-weight: 600;
}

.bsm-topnav__contact-value {
	font-size: 14px;
	color: var(--text);
	font-weight: 500;
}

.bsm-topnav__contact:hover .bsm-topnav__contact-icon {
	border-color: var(--accent);
	color: var(--accent-strong);
}

/* Phone — на десктопе не-ссылка (tel: бесполезен), на мобильном работает. */
@media (min-width: 901px) {
	.bsm-topnav__contact--phone {
		pointer-events: none;
		cursor: default;
	}
	.bsm-topnav__contact--phone:hover {
		background: transparent;
		color: inherit;
	}
	.bsm-topnav__contact--phone:hover .bsm-topnav__contact-icon {
		border-color: var(--line);
		color: var(--navy);
	}
}

/* ----- Search button ----- */

.bsm-topnav__search {
	width: 40px;
	height: 40px;
	flex-shrink: 0;
	border: var(--hairline);
	background: var(--surface);
	color: var(--navy);
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.bsm-topnav__search:hover {
	border-color: var(--accent);
	background: var(--accent-soft);
	color: var(--accent-strong);
}

.bsm-topnav__search svg {
	width: 18px;
	height: 18px;
}

/* ----- Burger (hidden on desktop) ----- */

.bsm-topnav__burger {
	display: none;
	background: transparent;
	border: var(--hairline);
	cursor: pointer;
	width: 40px;
	height: 40px;
	padding: 0;
	align-items: center;
	justify-content: center;
	position: relative;
}

.bsm-topnav__burger span {
	display: block;
	width: 18px;
	height: 2px;
	background: var(--navy);
	position: relative;
	transition: transform 0.2s ease, top 0.2s ease, background-color 0.2s ease;
}

.bsm-topnav__burger span::before,
.bsm-topnav__burger span::after {
	content: "";
	position: absolute;
	left: 0;
	width: 18px;
	height: 2px;
	background: var(--navy);
	transition: transform 0.2s ease, top 0.2s ease, background-color 0.2s ease;
}

.bsm-topnav__burger span::before { top: -6px; }
.bsm-topnav__burger span::after  { top:  6px; }

.bsm-topnav__burger[aria-expanded="true"] span { background: transparent; }
.bsm-topnav__burger[aria-expanded="true"] span::before { top: 0; transform: rotate(45deg); }
.bsm-topnav__burger[aria-expanded="true"] span::after  { top: 0; transform: rotate(-45deg); }

/* ----- Responsive ----- */

@media (max-width: 900px) {
	.bsm-topnav {
		padding: 0 16px;
		gap: 12px;
	}

	.bsm-topnav__nav {
		display: none;
	}

	.bsm-topnav__contacts-label {
		display: none;
	}

	.bsm-topnav__burger {
		display: flex;
	}

	/* Mobile menu opened — full-width panel under topnav. */
	.bsm-topnav__nav.is-open {
		display: flex;
		position: absolute;
		top: var(--topnav-h);
		left: 0;
		right: 0;
		flex-direction: column;
		background: var(--surface);
		border-bottom: var(--hairline);
		padding: 12px 0;
		gap: 0;
		align-items: stretch;
		box-shadow: 0 8px 16px rgba(0, 0, 0, 0.06);
		max-height: calc(100vh - var(--topnav-h));
		overflow-y: auto;
	}

	.bsm-topnav__nav.is-open .bsm-topnav__menu {
		flex-direction: column;
		align-items: stretch;
		gap: 0;
	}

	.bsm-topnav__nav.is-open .bsm-topnav__menu > li > a {
		padding: 14px 20px;
		border-bottom: 1px solid var(--line);
		justify-content: space-between;
	}

	.bsm-topnav__nav.is-open .bsm-topnav__menu > li:last-child > a {
		border-bottom: none;
	}

	.bsm-topnav__nav.is-open .bsm-topnav__menu > li.current-menu-item > a {
		background: var(--bg-soft);
	}

	.bsm-topnav__nav.is-open .sub-menu {
		position: static;
		display: block;
		box-shadow: none;
		padding: 0;
		margin: 0;
		border: none;
		background: var(--bg-soft);
		min-width: 0;
		border-top: 1px solid var(--line);
	}

	.bsm-topnav__nav.is-open .sub-menu a {
		padding: 10px 20px 10px 36px;
		font-size: 13px;
		border-bottom: 1px solid var(--line);
	}
}
