/**
 * Global chrome — Legendary header (PHP-injected) + Kadence masthead hiding.
 * Loaded on all front-end views that use the shared header; pairs with legendary-tokens.css.
 *
 * @package Legendary_Kadence_Child
 */

/* --- Header (JSX: flex-nowrap max-w-7xl justify-between px-6 py-4 lg:px-8) --- */
.legendary-site-header.wp-block-group {
	margin: 0;
	padding: 0;
}

.legendary-site-header .wp-block-group {
	margin-top: 0;
	margin-bottom: 0;
}

.legendary-site-header {
	position: sticky;
	top: 0;
	z-index: 50;
	border-bottom: 1px solid var(--legendary-white-10);
	background: rgba(10, 10, 10, 0.8);
	backdrop-filter: blur(8px);
	-webkit-backdrop-filter: blur(8px);
	min-height: 0;
}

.legendary-header-inner {
	display: flex !important;
	flex-wrap: nowrap !important;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	max-width: var(--legendary-max);
	margin-left: auto;
	margin-right: auto;
	/* Tight vertical padding — logo height sets bar height; extra py was making the bar look oversized */
	padding: 0.375rem 1.5rem;
	box-sizing: border-box;
	min-width: 0;
	min-height: 0;
}

@media (min-width: 1024px) {
	.legendary-header-inner {
		padding-left: 2rem;
		padding-right: 2rem;
	}
}

.legendary-header-inner.is-layout-flex {
	gap: 0.75rem;
}

@media (min-width: 768px) {
	.legendary-header-inner.is-layout-flex {
		gap: 1.5rem;
	}
}

.legendary-header-brand {
	flex-shrink: 0;
	min-width: 0;
	max-height: 100px;
	margin: 0;
	padding: 0;
	line-height: 0;
	display: flex;
	align-items: center;
}

/* Customizer → Site Identity → Logo — fixed 100×100 display box (object-fit keeps aspect ratio) */
.legendary-header-logo {
	margin: 0;
	padding: 0;
	line-height: 0;
}

.legendary-header-logo .custom-logo-link {
	display: inline-block;
	line-height: 0;
	vertical-align: top;
}

.legendary-header-brand .legendary-header-logo img.custom-logo,
.legendary-header-brand img.custom-logo {
	display: block;
	width: 100px !important;
	height: 100px !important;
	max-width: 100px !important;
	max-height: 100px !important;
	box-sizing: border-box;
	object-fit: contain;
	object-position: left center;
}

/* Narrow phones: shrink slightly so CTAs stay usable */
@media (max-width: 480px) {
	.legendary-header-brand .legendary-header-logo img.custom-logo,
	.legendary-header-brand img.custom-logo {
		width: min(100px, 36vw) !important;
		height: min(100px, 36vw) !important;
		max-width: min(100px, 36vw) !important;
		max-height: min(100px, 36vw) !important;
	}
}

/* Custom HTML block wrapper must not break the JSX flex row */
.legendary-header-inner > .wp-block-html {
	display: contents;
}

/* Primary nav: flat fallback <a> or WordPress menu (ul.legendary-header-nav__list) */
nav.legendary-header-nav {
	display: none;
	align-items: center;
	gap: 2rem;
	flex-shrink: 1;
	min-width: 0;
	margin: 0;
	padding: 0;
	list-style: none;
}

@media (min-width: 768px) {
	nav.legendary-header-nav {
		display: flex;
		flex-wrap: nowrap !important;
		min-width: 0;
	}
}

nav.legendary-header-nav ul.legendary-header-nav__list {
	display: flex;
	align-items: center;
	flex-wrap: nowrap !important;
	gap: 2rem;
	list-style: none;
	margin: 0;
	padding: 0;
}

nav.legendary-header-nav ul.legendary-header-nav__list > li {
	position: relative;
	margin: 0;
	padding: 0;
}

nav.legendary-header-nav .sub-menu {
	display: none;
	position: absolute;
	top: 100%;
	left: 0;
	min-width: 12rem;
	margin: 0.35rem 0 0;
	padding: 0.35rem 0;
	list-style: none;
	background: rgba(10, 10, 10, 0.96);
	border: 1px solid var(--legendary-white-10);
	border-radius: var(--legendary-r2);
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
	z-index: 100;
}

nav.legendary-header-nav li:hover > .sub-menu,
nav.legendary-header-nav li:focus-within > .sub-menu {
	display: block;
}

nav.legendary-header-nav .sub-menu .sub-menu {
	top: 0;
	left: 100%;
	margin-top: 0;
	margin-left: 0.25rem;
}

nav.legendary-header-nav .sub-menu a {
	white-space: nowrap;
	padding: 0.45rem 1rem;
	display: block;
}

nav.legendary-header-nav a {
	color: var(--legendary-n300);
	font-size: 0.875rem;
	line-height: 1.25rem;
	font-weight: 400;
	text-decoration: none;
	transition: color 0.15s ease;
	white-space: nowrap;
}

nav.legendary-header-nav a:hover,
nav.legendary-header-nav li.current-menu-item > a,
nav.legendary-header-nav li.current-menu-ancestor > a {
	color: var(--legendary-text);
}

/* Brand: text-xl font-semibold tracking-[0.2em] / text-xs uppercase tracking-[0.35em] text-neutral-400 */
.legendary-brand-title {
	font-size: 1.25rem;
	line-height: 1.75rem;
	font-weight: 600;
	letter-spacing: 0.2em;
	color: var(--legendary-text);
	margin: 0;
}

.legendary-brand-sub {
	font-size: 0.75rem;
	line-height: 1rem;
	text-transform: uppercase;
	letter-spacing: 0.35em;
	color: var(--legendary-n400);
	margin: 0.25rem 0 0;
}

.legendary-header-actions {
	display: flex !important;
	flex-wrap: nowrap !important;
	align-items: center;
	gap: 0.75rem;
	flex-shrink: 0;
	min-width: 0;
}

.legendary-header-actions.wp-block-buttons {
	flex-wrap: nowrap !important;
}

.legendary-header-actions .wp-block-button {
	flex-shrink: 0;
}

/* Header buttons: rounded-2xl px-4 py-2 text-sm; primary font-medium text-neutral-950 */
.legendary-header-actions .wp-block-button__link {
	border-radius: var(--legendary-r2);
	padding: 0.5rem 1rem;
	font-size: 0.875rem;
	line-height: 1.25rem;
	border: 1px solid transparent;
	box-sizing: border-box;
}

.legendary-header-actions .wp-block-button:not(.is-style-fill) .wp-block-button__link {
	border-color: var(--legendary-white-15);
	background: transparent;
	color: rgba(255, 255, 255, 0.9);
	font-weight: 400;
}

.legendary-header-actions .wp-block-button:not(.is-style-fill) .wp-block-button__link:hover {
	background: var(--legendary-white-5);
}

.legendary-header-actions .wp-block-button.is-style-fill .wp-block-button__link {
	background: #fff;
	color: var(--legendary-n950);
	border-color: #fff;
	font-weight: 500;
}

.legendary-header-actions .wp-block-button.is-style-fill .wp-block-button__link:hover {
	opacity: 0.9;
}

/*
 * Site-wide: Legendary header is printed in PHP (wp_body_open). Hide Kadence’s masthead everywhere
 * and hide an old duplicate header block inside page content (pattern without --global).
 */
body.legendary-global-header #masthead,
body.legendary-global-header header#masthead,
body.legendary-global-header .site-header-wrap,
body.legendary-global-header .site-header-row,
body.legendary-global-header #main-header,
body.legendary-global-header .kadence-header {
	display: none !important;
}

body.legendary-global-header #wrapper > .site-header,
body.legendary-global-header #inner-wrap > .site-header,
body.legendary-global-header .site-header:not(.legendary-site-header) {
	display: none !important;
}

body.legendary-global-header .legendary-page header.legendary-site-header:not(.legendary-site-header--global),
body.legendary-global-header .entry-content header.legendary-site-header:not(.legendary-site-header--global) {
	display: none !important;
}

/* Sticky bar sits below the WP admin bar when logged in */
body.admin-bar .legendary-site-header.legendary-site-header--global {
	top: 32px;
}

@media screen and (max-width: 782px) {
	body.admin-bar .legendary-site-header.legendary-site-header--global {
		top: 46px;
	}
}
