/**
 * JMAA Brand Kit - site header and footer.
 *
 * Paired with class-jmaa-brand-chrome.php. Two jobs:
 *
 *   1. Hide the markup WordPress falls back to when Elementor's header and
 *      footer page template runs on a block theme. Those ids are fixed in
 *      wp-includes/theme-compat/header.php and footer.php, so targeting them
 *      is safe: #header, #headerimg, #footer, and the rule between the
 *      content and the footer.
 *   2. Draw the association's own header and footer in their place.
 *
 * Colours come from the tokens the Brand Kit prints on :root, with literal
 * fallbacks so the bar is never invisible if those fail to load.
 */

/* ---------- Hide the fallback chrome ------------------------------------- */

.jmaa-has-chrome #header,
.jmaa-has-chrome #headerimg,
.jmaa-has-chrome #footer,
.jmaa-has-chrome #page > hr {
	display: none !important;
}

/* Block themes that do render their own header and footer under the Elementor
   canvas template would otherwise double up with ours. */
.jmaa-has-chrome .wp-site-blocks > header.wp-block-template-part,
.jmaa-has-chrome .wp-site-blocks > footer.wp-block-template-part {
	display: none !important;
}

/* ---------- Header ------------------------------------------------------- */

.jmaa-header {
	position: sticky;
	top: 0;
	z-index: 900;
	background: var(--jmaa-black, #000);
	border-bottom: 3px solid var(--jmaa-gold, #FFC20E);
	font-family: var(--jmaa-font, system-ui, sans-serif);
}

.jmaa-header__inner {
	display: flex;
	align-items: center;
	gap: clamp(12px, 2vw, 28px);
	max-width: var(--jmaa-maxw, 1180px);
	margin-inline: auto;
	padding: 10px max(16px, 3vw);
	min-height: 72px;
}

.jmaa-header__brand {
	display: inline-flex;
	align-items: center;
	gap: 12px;
	text-decoration: none;
	flex: 0 0 auto;
}

.jmaa-header__crest {
	display: block;
	width: 52px;
	height: 52px;
	object-fit: contain;
	background: #fff;
	border-radius: 50%;
	padding: 3px;
}

.jmaa-header__wordmark {
	color: #fff;
	font-size: clamp(.82rem, 1.1vw, .96rem);
	font-weight: 700;
	letter-spacing: .06em;
	line-height: 1.15;
	text-transform: uppercase;
	max-width: 15ch;
}

/* ---------- Menu --------------------------------------------------------- */

.jmaa-header__nav {
	flex: 1 1 auto;
	min-width: 0;
}

.jmaa-menu {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 2px 4px;
	list-style: none;
	margin: 0;
	padding: 0;
}

.jmaa-menu li {
	position: relative;
	margin: 0;
	list-style: none;
}

.jmaa-menu a {
	display: block;
	padding: 10px 12px;
	color: #fff;
	font-size: .78rem;
	font-weight: 700;
	letter-spacing: .07em;
	text-transform: uppercase;
	text-decoration: none;
	white-space: nowrap;
	border-bottom: 3px solid transparent;
	transition: color .18s ease, border-color .18s ease;
}

.jmaa-menu a:hover,
.jmaa-menu a:focus-visible,
.jmaa-menu .current-menu-item > a,
.jmaa-menu .current-menu-ancestor > a,
.jmaa-menu .current_page_item > a {
	color: var(--jmaa-gold, #FFC20E);
	border-bottom-color: var(--jmaa-gold, #FFC20E);
}

/* Dropdowns. The association menu has three folders, so these carry weight. */
.jmaa-menu .sub-menu,
.jmaa-menu .children {
	position: absolute;
	left: 0;
	top: 100%;
	z-index: 10;
	display: block;
	min-width: 236px;
	margin: 0;
	padding: 6px 0;
	list-style: none;
	background: var(--jmaa-black, #000);
	border: 1px solid rgba(255, 255, 255, .14);
	border-top: 3px solid var(--jmaa-gold, #FFC20E);
	border-radius: 0 0 8px 8px;
	box-shadow: 0 14px 34px rgba(0, 0, 0, .38);
	opacity: 0;
	visibility: hidden;
	transform: translateY(-6px);
	transition: opacity .16s ease, transform .16s ease, visibility .16s;
}

.jmaa-menu li:hover > .sub-menu,
.jmaa-menu li:focus-within > .sub-menu,
.jmaa-menu li:hover > .children,
.jmaa-menu li:focus-within > .children {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}

.jmaa-menu .sub-menu a,
.jmaa-menu .children a {
	padding: 10px 18px;
	font-size: .76rem;
	white-space: normal;
	border-bottom: 0;
	border-left: 3px solid transparent;
}

.jmaa-menu .sub-menu a:hover,
.jmaa-menu .children a:hover {
	background: rgba(255, 255, 255, .07);
	border-left-color: var(--jmaa-gold, #FFC20E);
}

/* ---------- Donate button ------------------------------------------------ */

.jmaa-header__cta {
	flex: 0 0 auto;
	padding: 12px 22px;
	background: var(--jmaa-gold, #FFC20E);
	color: #111;
	font-size: .78rem;
	font-weight: 800;
	letter-spacing: .09em;
	text-transform: uppercase;
	text-decoration: none;
	border-radius: 3px;
	transition: background .18s ease, transform .18s ease;
}

.jmaa-header__cta:hover,
.jmaa-header__cta:focus-visible {
	background: var(--jmaa-gold-light, #FFD75E);
	transform: translateY(-1px);
	color: #111;
}

/* ---------- Mobile ------------------------------------------------------- */

.jmaa-header__toggle {
	display: none;
	flex: 0 0 auto;
	width: 46px;
	height: 42px;
	margin-left: auto;
	padding: 0;
	background: transparent;
	border: 1px solid rgba(255, 255, 255, .28);
	border-radius: 4px;
	cursor: pointer;
}

.jmaa-header__toggle-bars,
.jmaa-header__toggle-bars::before,
.jmaa-header__toggle-bars::after {
	display: block;
	width: 20px;
	height: 2px;
	margin-inline: auto;
	background: var(--jmaa-gold, #FFC20E);
	content: '';
	transition: transform .2s ease, opacity .2s ease;
}

.jmaa-header__toggle-bars::before { transform: translateY(-6px); }
.jmaa-header__toggle-bars::after  { transform: translateY(4px); }

@media (max-width: 1080px) {
	/* One row: crest on the left, Donate and the menu button on the right.
	   The menu itself takes a full row underneath, opened by the button. */
	.jmaa-header__inner { flex-wrap: wrap; row-gap: 0; padding-block: 8px; min-height: 64px; }
	.jmaa-header__brand { order: 1; margin-right: auto; }
	.jmaa-header__cta { order: 2; margin: 0; padding: 10px 16px; font-size: .72rem; }
	.jmaa-header__toggle { order: 3; display: block; margin-left: 10px; }

	.jmaa-header__nav {
		order: 10;
		flex: 1 0 100%;
		max-height: 0;
		overflow: hidden;
		transition: max-height .26s ease;
	}
	.jmaa-header__nav.is-open {
		max-height: 80vh;
		overflow-y: auto;
		padding-bottom: 12px;
	}

	.jmaa-menu { flex-direction: column; align-items: stretch; }
	.jmaa-menu a {
		padding: 13px 4px;
		border-bottom: 1px solid rgba(255, 255, 255, .1);
	}
	.jmaa-menu .sub-menu,
	.jmaa-menu .children {
		position: static;
		opacity: 1;
		visibility: visible;
		transform: none;
		min-width: 0;
		padding-left: 16px;
		background: transparent;
		border: 0;
		box-shadow: none;
	}
}

@media (max-width: 520px) {
	.jmaa-header__wordmark { display: none; }
	.jmaa-header__crest { width: 46px; height: 46px; }
	.jmaa-header__cta { padding: 9px 13px; letter-spacing: .06em; }
}

/* ---------- Footer ------------------------------------------------------- */

.jmaa-footer {
	background: var(--jmaa-black, #000);
	border-top: 3px solid var(--jmaa-gold, #FFC20E);
	color: rgba(255, 255, 255, .74);
	font-family: var(--jmaa-font, system-ui, sans-serif);
	margin-top: 0;
}

.jmaa-footer__inner {
	max-width: var(--jmaa-maxw, 1180px);
	margin-inline: auto;
	padding: clamp(36px, 5vw, 64px) max(16px, 3vw);
	text-align: center;
}

.jmaa-footer h2.jmaa-footer__title {
	margin: 0 0 22px;
	padding: 0;
	/* Block themes colour every h2 from their palette; this one sits on black. */
	color: #fff !important;
	font-size: clamp(1rem, 1.6vw, 1.24rem);
	font-weight: 800;
	letter-spacing: .16em;
	text-transform: uppercase;
}

.jmaa-footer__menu {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 6px 28px;
	list-style: none;
	margin: 0 0 18px;
	padding: 0;
}

.jmaa-footer__menu a,
.jmaa-footer__email a {
	color: var(--jmaa-gold, #FFC20E);
	font-size: .78rem;
	font-weight: 700;
	letter-spacing: .1em;
	text-transform: uppercase;
	text-decoration: none;
}

.jmaa-footer__menu a:hover,
.jmaa-footer__email a:hover {
	text-decoration: underline;
}

.jmaa-footer__email { margin: 0 0 20px; }

.jmaa-footer__legal {
	margin: 0;
	font-size: .72rem;
	letter-spacing: .06em;
	color: rgba(255, 255, 255, .46);
}

@media (prefers-reduced-motion: reduce) {
	.jmaa-header__cta,
	.jmaa-menu a,
	.jmaa-header__nav,
	.jmaa-menu .sub-menu { transition: none; }
}
