/*
 * am-header — the site header treatment (the bar, the AM/SbH lockup, the nav row).
 *
 * Structure lives in an Elementor Pro Theme Builder Header (exported later to
 * elementor-templates/); this file owns the *look*. Assign `am-header` to the
 * header wrapper and the element classes below to the widgets inside it.
 *
 * Structure:
 *   am-header [--sticky]
 *     am-header__inner              container: brand left, nav + action right
 *       am-header__brand            the AM wordmark (a link to home)
 *         am-header__brand-name     "Activemind"
 *         am-header__brand-ethos    the Security by Heart ethos line (NOT a logo)
 *       am-nav
 *         am-nav__list / am-nav__item / am-nav__link
 *       am-header__actions          the primary CTA (am-cta)
 *
 * Nav note: if the Elementor Pro Nav Menu widget is used instead of a plain menu,
 * theme its links with a scoped rule rather than the widget's colour pickers
 * (widget style pickers are banned) — its markup differs from am-nav__link.
 */

/* No own background — the bar is transparent by default (shows the page bg), so an
   am-bg-* / am-section--* class on the header controls the colour (like the footer).
   Add e.g. am-bg-inverse for a dark header; the border + nav adapt via the tokens. */
.am-header {
	border-block-end: 1px solid var(--am-color-border);
}

.am-header--sticky {
	position: sticky;
	inset-block-start: 0;
	z-index: 100;
}

.am-header__inner {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: var(--am-space-500);
	max-width: var(--am-container-max);
	margin-inline: auto;
	padding-block: var(--am-space-400);
	padding-inline: var(--am-container-pad);
}

/* Brand lockup — the AM name with the ethos line beneath it. */
.am-header__brand {
	display: inline-flex;
	flex-direction: column;
	gap: var(--am-space-100);
	text-decoration: none;
	line-height: var(--am-leading-tight);
}

.am-header__brand-name {
	color: var(--am-color-heading);
	font-size: var(--am-font-size-500);
	font-weight: var(--am-weight-bold);
	letter-spacing: var(--am-tracking-tight);
}

.am-header__brand-ethos {
	color: var(--am-color-accent);
	font-size: var(--am-font-size-100);
	font-weight: var(--am-weight-semibold);
	letter-spacing: var(--am-tracking-wide);
	text-transform: uppercase;
}

/* Nav — works with a wp_nav_menu (plain <li><a>) or explicit am-nav__link. -------- */
.am-nav__list {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--am-space-500);
	margin: 0;
	padding: 0;
	list-style: none;
}

.am-nav__list li,
.am-nav__list li + li {
	margin: 0; /* reset base.css list rhythm in a horizontal nav */
}

/* Plain nav links. `:not(.am-cta)` so a menu item styled as a button (CSS class
   "cta" on the item — see functions.php) keeps its am-cta styling, not the link colour. */
.am-nav__list a:not(.am-cta),
.am-nav__link {
	color: var(--am-color-text);
	font-weight: var(--am-weight-medium);
	text-decoration: none;
	transition: color var(--am-transition);
}

.am-nav__list a:not(.am-cta):hover,
.am-nav__list .current-menu-item > a:not(.am-cta),
.am-nav__list a[aria-current]:not(.am-cta),
.am-nav__link:hover,
.am-nav__link[aria-current] {
	color: var(--am-color-accent);
}

.am-header__actions {
	display: flex;
	align-items: center;
	gap: var(--am-space-400);
}

/* -- Mobile nav: hamburger toggle + collapsible panel ----------------------- */
/* Progressive enhancement: the `.js` class (set in header.php) turns the panel
   into a toggle-controlled menu. Without JS the panel stays visible and usable. */

.am-nav-toggle {
	display: none; /* shown only on small screens with JS on */
	align-items: center;
	justify-content: center;
	width: var(--am-space-700);
	height: var(--am-space-700);
	padding: 0;
	background-color: transparent;
	border: 1px solid var(--am-color-border);
	border-radius: var(--am-radius-md);
	color: var(--am-color-heading);
	cursor: pointer;
}

.am-nav-toggle__icon,
.am-nav-toggle__icon::before,
.am-nav-toggle__icon::after {
	display: block;
	width: 1.25em;
	height: 2px;
	background-color: currentColor;
	transition: transform var(--am-transition), opacity var(--am-transition);
}

.am-nav-toggle__icon {
	position: relative;
}

.am-nav-toggle__icon::before,
.am-nav-toggle__icon::after {
	content: "";
	position: absolute;
	left: 0;
}

.am-nav-toggle__icon::before { top: -0.375em; }
.am-nav-toggle__icon::after  { top: 0.375em; }

/* Open → morph the bars into an X. */
.am-nav-toggle[aria-expanded="true"] .am-nav-toggle__icon {
	background-color: transparent;
}

.am-nav-toggle[aria-expanded="true"] .am-nav-toggle__icon::before {
	transform: translateY(0.375em) rotate(45deg);
}

.am-nav-toggle[aria-expanded="true"] .am-nav-toggle__icon::after {
	transform: translateY(-0.375em) rotate(-45deg);
}

/* Collapsible region holds the nav + the header CTA. Mobile: full-width, stacked,
   and visible by default so the menu works without JS. */
.am-header__collapse {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: var(--am-space-400);
	flex-basis: 100%;
	width: 100%;
	padding-block: var(--am-space-300);
}

.am-header__collapse .am-nav__list {
	flex-direction: column;
	align-items: flex-start;
	gap: var(--am-space-300);
	width: 100%;
}

/* With JS on small screens, collapse the panel behind the toggle. */
.js .am-nav-toggle {
	display: inline-flex;
}

.js .am-header__collapse {
	display: none;
}

.js .am-header__collapse.is-open {
	display: flex;
}

/* Desktop: inline row, no toggle, regardless of JS. */
@media (min-width: 768px) {
	.am-nav-toggle,
	.js .am-nav-toggle {
		display: none;
	}

	.am-header__collapse,
	.js .am-header__collapse {
		display: flex;
		flex-direction: row;
		align-items: center;
		gap: var(--am-space-500);
		flex-basis: auto;
		width: auto;
		padding-block: 0;
	}

	.am-header__collapse .am-nav__list {
		flex-direction: row;
		align-items: center;
		gap: var(--am-space-500);
		width: auto;
	}
}

@media (prefers-reduced-motion: reduce) {
	.am-nav-toggle__icon,
	.am-nav-toggle__icon::before,
	.am-nav-toggle__icon::after {
		transition: none;
	}
}
