/**
 * Component: site header. Restyles the BuddyBoss header (desktop + mobile) to the prototype.
 * #masthead in the selectors outranks BuddyBoss's header rules.
 *
 * Height, sticky behaviour, shadow and BuddyPanel are BuddyBoss Theme Options.
 */

#masthead.site-header {
	border-top: 4px solid var(--cac-color-brand);
	border-bottom: 1px solid var(--cac-color-border);
	box-shadow: none;
}

/* Full width with the page gutter, like the footer. */
#masthead .site-header-container {
	max-width: none;
	padding-inline: var(--cac-gutter);
	gap: var(--cac-space-8);
}

/* Compact while scrolled (BuddyBoss adds .has-scrolled to the sticky header). */
#masthead {
	--cac-header-height: var(--bb-header-height, 76px);
	--cac-header-logo-height: var(--bb-header-height, 76px);
}

#masthead.has-scrolled {
	--cac-header-height: 3.5rem;
	--cac-header-logo-height: 2.5rem;
}

#masthead :is(.site-header-container, .header-search-wrap, .header-search-wrap input.search-field, .header-search-wrap form.search-form, #site-navigation, #primary-navbar, #primary-menu, #primary-menu > li, #primary-menu > li > a, #site-logo, #header-aside, .header-aside-inner) {
	height: var(--cac-header-height);
	transition: height 0.2s ease, line-height 0.2s ease;
}

#masthead #primary-menu > li {
	line-height: var(--cac-header-height);
}

#masthead #site-logo img {
	max-height: var(--cac-header-logo-height);
	transition: max-height 0.2s ease;
}

@media (prefers-reduced-motion: reduce) {
	#masthead :is(.site-header-container, .header-search-wrap, .header-search-wrap input.search-field, .header-search-wrap form.search-form, #site-navigation, #primary-navbar, #primary-menu, #primary-menu > li, #primary-menu > li > a, #site-logo, #header-aside, .header-aside-inner),
	#masthead #site-logo img {
		transition: none;
	}
}

/*
 * Logo slot. Without a logo image (Theme Options › Logo) BuddyBoss prints the site name:
 * keep the link as an empty reserved space; the name stays available to screen readers.
 */
#masthead .site-title a:not(:has(img)),
#masthead .bb-mobile-panel-header .logo-wrap a:not(:has(img)) {
	display: block;
	width: 10rem;
	height: 2.5rem;
	overflow: hidden;
	font-size: 0;
	color: transparent;
}

/* ---------- Main navigation ---------- */

#masthead #primary-menu > li {
	margin: 0 1.75rem 0 0;
}

#masthead #primary-menu > li:last-child {
	margin-right: 0;
}

#masthead #primary-menu > li > a {
	padding-inline: 0;
	font-size: var(--cac-font-size-base);
	color: var(--cac-color-text);
	border-bottom: 0; /* BuddyBoss marks the current item with a 2px border; we use the box-shadow below. */
}

/* Remove BuddyBoss rounded hover background */
#masthead #primary-menu > li > a::before {
	content: none;
}


#masthead #primary-menu > li:not(.current-menu-item, .current-menu-ancestor, .current-page-ancestor) > a:is(:hover, :focus-visible) {
	color: var(--cac-color-brand);
	box-shadow: inset 0 -2px 0 var(--cac-color-brand);
}

#masthead #primary-menu > :is(.current-menu-item, .current-menu-ancestor, .current-page-ancestor) > a {
	font-weight: var(--cac-font-weight-bold);
	color: var(--cac-color-text-strong);
	box-shadow: inset 0 -3px 0 var(--cac-color-brand);
}

/* Mobile panel hover: underline, no background (except the "Registra't" button). */
#masthead .side-panel-menu > li:not(.cac-menu-signup) > a:is(:hover, :focus-visible) {
	color: var(--cac-color-brand);
	text-decoration: underline;
	text-decoration-thickness: 2px;
	text-underline-offset: 0.3em;
	background: none;
}

/* ---------- Visitor buttons: "Accedir" link + "Registra't" button ---------- */

#masthead .bb-header-buttons {
	display: flex;
	align-items: center;
	gap: var(--cac-space-3);
}

#masthead .bb-header-buttons .button {
	display: inline-flex;
	align-items: center;
	min-height: var(--cac-target-min);
	margin: 0;
	font-size: var(--cac-font-size-base);
	font-weight: var(--cac-font-weight-bold);
	line-height: 1;
	border-radius: var(--cac-radius-sm);
	box-shadow: none;
}

#masthead .bb-header-buttons .signin-button {
	padding: 0 var(--cac-space-2);
	color: var(--cac-color-text-strong);
	background: none;
	border: 0;
}

#masthead .bb-header-buttons .signin-button:hover {
	color: var(--cac-color-brand);
}

#masthead .bb-header-buttons .signup {
	padding: 0 var(--cac-space-5);
	color: var(--cac-color-on-brand);
	background-color: var(--cac-color-brand);
	border: 0;
}

#masthead .bb-header-buttons .signup:hover {
	background-color: var(--cac-color-brand-hover);
}

/* Mobile panel: BuddyBoss's menu walker adds a default icon to each item; the prototype has none. */
#masthead .bb-mobile-panel-wrapper .side-panel-menu > li > a > i {
	display: none;
}

/* Mobile panel current item: bold instead of BuddyBoss's coloured background. */
#masthead .bb-mobile-panel-wrapper .side-panel-menu > .current-menu-item > a {
	font-weight: var(--cac-font-weight-bold);
	color: var(--cac-color-text-strong);
	background: none;
}

/*
 * Mobile panel (visitors): the "Mòbil (visitants)" menu ends with "Accedir" and "Registra't",
 * marked with the menu item classes cac-menu-signin / cac-menu-signup.
 */
#masthead .bb-mobile-panel-wrapper .cac-menu-signin {
	margin-top: var(--cac-space-4);
	border-top: 1px solid var(--cac-color-border);
}

#masthead .bb-mobile-panel-wrapper .cac-menu-signin > a {
	font-weight: var(--cac-font-weight-bold);
	color: var(--cac-color-text-strong);
}

#masthead .bb-mobile-panel-wrapper .cac-menu-signup > a {
	display: inline-flex;
	align-items: center;
	min-height: 3rem;
	margin-top: var(--cac-space-2);
	padding: 0 var(--cac-space-5);
	font-weight: var(--cac-font-weight-bold);
	color: var(--cac-color-on-brand);
	background-color: var(--cac-color-brand);
	border-radius: var(--cac-radius-sm);
}

#masthead .bb-mobile-panel-wrapper .cac-menu-signup > a:hover {
	background-color: var(--cac-color-brand-hover);
}
