/* Replacement site header — see inc/header-gradient.php */

.acm-header {
	position: sticky;
	top: 0;
	z-index: 999;
	width: 100%;
}

/* The gradient lives on its own layer so its opacity can fade in on
   scroll (set via --acm-header-scroll-opacity in JS) independently of
   the header's actual content, which should always stay fully visible. */
.acm-header::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: -1;
	background: linear-gradient(90deg, rgba(0, 0, 0, 0.4) 0%, var(--acm-header-color, #0000CE) 100%);
	opacity: var(--acm-header-scroll-opacity, 0);
}

.acm-header__inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 24px;
	max-width: 1400px;
	margin: 0 auto;
	padding: 5px 10px;
}

/* Sized by height, not width — the Mongolian (200x69) and English
   (228x69) logo files have different aspect ratios, so pinning width
   alone made them render at different heights. */
.acm-header__logo img {
	display: block;
	width: auto;
	height: 35px;
	margin: 5px 0;
}

.acm-header__menu {
	flex: 1 1 auto;
	/* Stretches to the full header row height instead of being centered
	   as a short island — otherwise the <li> below ends up shorter than
	   the header bar, and a dropdown positioned at top:100% (relative to
	   that short <li>) lands inside the header's own background instead
	   of flush against its real bottom edge. */
	align-self: stretch;
	display: flex;
}

.acm-nav-menu {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	align-items: stretch;
	gap: 18px;
	margin: 0;
	padding: 0;
	list-style: none;
	width: 100%;
}

.acm-nav-menu > li {
	position: relative;
	display: flex;
	align-items: center;
}


.acm-nav-menu a {
	display: inline-block;
	padding: 1px;
	color: #ffffff;
	font-family: 'Inter', sans-serif;
	font-size: 0.75em;
	font-weight: 600;
	line-height: 1.3em;
	letter-spacing: -0.3px;
	text-transform: uppercase;
	text-decoration: none;
}

/* Scoped to the top-level bar only — submenu links have their own
   dark-on-white / white-on-dark-hover scheme below. */
.acm-nav-menu > li > a:hover,
.acm-nav-menu > li.current-menu-item > a {
	color: rgba(255, 255, 255, 0.8);
}

/* Arrow markup (<span class="sub-arrow"><i class="fas fa-chevron-down">)
   is injected by JS onto items with children — see header-gradient.php —
   matching the original's actual markup instead of a CSS-only glyph. */
.acm-nav-menu > li.menu-item-has-children > a .sub-arrow {
	display: inline-block;
	margin-left: 5px;
	font-size: 0.85em;
}

.acm-nav-menu ul li.menu-item-has-children > a .sub-arrow {
	display: inline-block;
	margin-left: 5px;
	float: right;
}

.acm-nav-menu ul li.menu-item-has-children > a .sub-arrow i {
	/* points sideways, since nested submenus open to the right, not down */
	transform: rotate(-90deg);
	display: inline-block;
}

/* Submenus are hidden until their parent item is hovered/focused —
   :focus-within keeps them reachable via keyboard, not just a mouse.
   Flush against the parent item (no gap) — nothing extra needed to
   bridge :hover across a gap that no longer exists. */
.acm-nav-menu ul {
	display: none;
	list-style: none;
	margin: 0;
	padding: 0;
	position: absolute;
	top: 100%;
	left: 0;
	min-width: 220px;
	background: #ffffff;
	box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
	text-transform: uppercase;
	z-index: 10;
	border-radius: 0 6px 6px 6px;
}

.acm-nav-menu li:hover > ul,
.acm-nav-menu li:focus-within > ul {
	display: block;
}

/* A submenu nested inside another submenu opens to the side, not below —
   otherwise it would stack underneath the whole dropdown. */
.acm-nav-menu ul ul {
	top: 0;
	left: 100%;
}

/* Dropdown items are dark-on-white, inverting to light-on-dark on
   hover — overrides the light-on-color scheme used by the top-level bar. */
.acm-nav-menu ul a {
	display: block;
	width: 100%;
	box-sizing: border-box;
	padding: 5px 10px;
	white-space: nowrap;
	color: #222;
	font-family: 'Inter', sans-serif;
	font-size: 0.75em;
	font-weight: 600;
	letter-spacing: -0.3px;
}

.acm-nav-menu ul a:hover {
	background: #333;
	color: #fff;
	opacity: 1;
}

.acm-nav-menu ul li {
	position: relative;
	display: block;
	width: 100%;
}

.acm-header__search {
	position: relative;
	display: flex;
	align-items: center;
}

.acm-search-toggle {
	border: none;
	background: transparent;
	color: #fff;
	font-size: 1em;
	cursor: pointer;
	padding: 6px;
}

/* Collapsed by default — only the toggle icon shows until clicked. */
.acm-search-form {
	display: none;
	align-items: center;
	position: absolute;
	top: calc(100% + 18px);
	right: -15px;
	border-radius: 0 6px 6px 6px;
	box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
	overflow: hidden;
}

.acm-header__search.is-open .acm-search-form {
	display: flex;
}

.acm-search-form__input {
	border: none;
	background: #ffffff;
	color: #333;
	padding: 6px 10px;
	font-size: 0.85em;
}

.acm-search-form__input:focus {
	outline: none;
	border: none;
}

.acm-search-form__input::placeholder {
	color: #333;
}

.acm-search-form__submit {
	border: none;
	background: #ffffff;
	color: #333;
	padding: 4px 10px;
	cursor: pointer;
}

.acm-search-form__submit:focus {
	outline: none;
	border: none;
}

.acm-header__lang {
	margin-top: -5px;
}

.acm-lang-switcher ul {
	display: flex;
	gap: 10px;
	margin: 0;
	padding: 0;
	list-style: none;
}

/* Hamburger toggle — hidden on desktop, shown once the menu collapses. */
.acm-mobile-toggle {
	display: none;
	border: 1px solid #fff;
	border-radius: 4px;
	outline: none;
	background: transparent;
	color: #fff;
	font-size: 1.3em;
	line-height: 1;
	cursor: pointer;
	padding: 6px 10px;
}

/* Tablets (iPad-ish widths) get the same hamburger treatment as phones —
   the full horizontal nav has no room to wrap cleanly here without the
   header splitting into two mismatched rows (logo pushed onto a bare
   white line above the gradient bar, no toggle visible to open the
   menu). Collapsing to hamburger at 1024px avoids that split entirely. */
@media (max-width: 1024px) {
	.acm-header__menu,
	.acm-header__search {
		display: none;
	}

	/* Logo / hamburger / language switcher as three real grid columns —
	   with space-between the toggle only looked centered by coincidence,
	   since it actually sat wherever the leftover space (logo width vs.
	   lang-switcher width) happened to land it. Hidden items (nav,
	   search) don't occupy a grid cell, so this still resolves to
	   exactly the 3 visible items in DOM order: logo, toggle, lang. */
	.acm-header__inner {
		display: grid;
		grid-template-columns: 1fr auto 1fr;
		align-items: center;
		justify-items: center;
	}

	.acm-header__logo {
		justify-self: start;
	}

	.acm-header__lang {
		justify-self: end;
	}

	.acm-mobile-toggle {
		display: block;
	}

	/* Open state: a white panel dropping down below the colored bar. */
	.acm-header__menu.is-open {
		display: block;
		position: absolute;
		top: 100%;
		left: 0;
		width: 100%;
		max-height: 80vh;
		overflow-y: auto;
		background: #fff;
		box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
		border-radius: 0 0 8px 8px;
	}

	.acm-header__menu.is-open .acm-nav-menu {
		display: flex;
		flex-direction: column;
		flex-wrap: nowrap;
		gap: 0;
		padding: 8px 0;
	}

	.acm-header__menu.is-open .acm-nav-menu li {
		display: block;
		width: 100%;
	}

	.acm-header__menu.is-open .acm-nav-menu > li > a {
		color: #222;
	}

	.acm-header__menu.is-open .acm-nav-menu a {
		display: block;
		width: 100%;
		box-sizing: border-box;
		padding: 12px 20px;
	}

	/* Submenus behave as an accordion here (toggled via JS adding
	   .acm-submenu-open), not hover — touch has no hover state. Slides
	   open/closed via max-height rather than display:none/block, since
	   display can't be transitioned/animated. */
	.acm-header__menu.is-open .acm-nav-menu ul {
		display: block;
		position: static;
		width: 100%;
		box-shadow: none;
		border-radius: 0;
		background: #f5f5f5;
		max-height: 0;
		overflow: hidden;
		transition: max-height 0.3s ease;
	}

	.acm-header__menu.is-open .acm-nav-menu li.acm-submenu-open > ul {
		max-height: 1000px;
	}

	/* The expanded parent item gets the same dark/white treatment as a
	   dropdown item's :hover state elsewhere, so it's visually marked as
	   "currently open" the same way the rest of the menu marks active
	   items. */
	.acm-header__menu.is-open .acm-nav-menu li.acm-submenu-open > a {
		background: #333;
		color: #fff;
	}

	.acm-header__menu.is-open .acm-nav-menu > li.menu-item-has-children > a .sub-arrow,
	.acm-header__menu.is-open .acm-nav-menu ul li.menu-item-has-children > a .sub-arrow {
		float: right;
	}

	.acm-header__menu.is-open .acm-nav-menu ul li.menu-item-has-children > a .sub-arrow i {
		transform: none; /* accordion on mobile: arrow points down like the top-level ones, not sideways */
	}
}
