/*!
 * Linux Header Menu — меню рубрик в шапке.
 * Верхний уровень: Linux / Windows / Другие ОС / Общее.
 * Подменю: архитектуры ОС (Ubuntu, Windows 10, …) или уровни (Основы, Сервер, …).
 */

.linux-menu {
	width: 100%;
	margin-top: 0.25rem;
	border-top: 1px solid var(--linux-border);
}

.linux-menu__list {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 0.15rem 0.35rem;
	margin: 0;
	padding: 0.35rem 0;
	list-style: none;
}

.linux-menu__item {
	position: relative;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
}

.linux-menu__link {
	display: inline-block;
	padding: 0.45rem 0.8rem;
	border-radius: 8px;
	color: var(--linux-fg);
	font-weight: 600;
	font-size: 0.95rem;
	line-height: 1.2;
	text-decoration: none;
	white-space: nowrap;
	transition: background-color 0.18s ease, color 0.18s ease;
}

.linux-menu__link:hover,
.linux-menu__link:focus-visible {
	background: color-mix(in srgb, var(--linux-fg) 9%, transparent);
	color: #38bdf8;
	outline: none;
}

.linux-menu__caret {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 1.6rem;
	height: 1.6rem;
	margin-left: -0.35rem;
	padding: 0;
	border: 0;
	border-radius: 6px;
	background: transparent;
	color: var(--linux-muted);
	cursor: pointer;
}

.linux-menu__caret:hover,
.linux-menu__caret:focus-visible {
	color: var(--linux-fg);
	outline: none;
}

.linux-menu__caret svg {
	transition: transform 0.18s ease;
}

.linux-menu__item--open > .linux-menu__caret svg {
	transform: rotate(180deg);
}

.linux-menu__sub {
	display: none;
	margin: 0;
	padding: 0.35rem;
	list-style: none;
}

.linux-menu__sub a {
	display: block;
	padding: 0.4rem 0.7rem;
	border-radius: 7px;
	color: var(--linux-fg);
	font-size: 0.9rem;
	text-decoration: none;
	white-space: nowrap;
	transition: background-color 0.15s ease, color 0.15s ease;
}

.linux-menu__sub a:hover,
.linux-menu__sub a:focus-visible {
	background: color-mix(in srgb, var(--linux-fg) 9%, transparent);
	color: #38bdf8;
	outline: none;
}

/* Мобильная версия: подменю — аккордеон под пунктом. */
.linux-menu__item--open > .linux-menu__sub {
	display: block;
	position: static;
	flex: 1 1 100%;
	width: 100%;
	min-width: 0;
	background: transparent;
	border: 0;
	box-shadow: none;
	padding: 0.15rem 0 0.35rem 0.9rem;
}

/* Десктоп: подменю — выпадающая панель. */
@media (min-width: 861px) {
	.linux-menu__caret {
		display: none;
	}

	.linux-menu__item--has-children:hover > .linux-menu__sub,
	.linux-menu__item--has-children:focus-within > .linux-menu__sub {
		display: block;
	}

	.linux-menu__sub {
		position: absolute;
		top: 100%;
		left: 0;
		z-index: 500;
		min-width: 210px;
		padding: 0.4rem;
		background: var(--linux-surface);
		border: 1px solid var(--linux-border);
		border-radius: 12px;
		box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
	}

	.linux-menu__item:last-child .linux-menu__sub {
		left: auto;
		right: 0;
	}
}

@media (max-width: 860px) {
	.linux-menu__list {
		display: grid;
		grid-template-columns: 1fr 1fr;
		gap: 0.1rem 0.35rem;
		justify-content: stretch;
	}

	.linux-menu__item {
		width: 100%;
	}

	.linux-menu__link {
		flex: 1 1 auto;
		min-width: 0;
		overflow: hidden;
		text-overflow: ellipsis;
	}

	.linux-menu__sub a {
		white-space: normal;
	}
}

@media (max-width: 400px) {
	.linux-menu__list {
		grid-template-columns: 1fr;
	}
}

@media (max-width: 480px) {
	.linux-menu__link {
		padding: 0.45rem 0.55rem;
	}

	.linux-menu {
		margin-top: 0.15rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.linux-menu__link,
	.linux-menu__sub a,
	.linux-menu__caret svg {
		transition: none;
	}
}
