/**
 * 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-site-header.legendary-site-header--menu-open {
	z-index: 100;
}

.legendary-header-inner {
	position: relative;
	z-index: 70;
	display: flex !important;
	flex-direction: row;
	flex-wrap: nowrap !important;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	max-width: var(--legendary-max);
	margin-left: auto;
	margin-right: auto;
	column-gap: 0.75rem;
	/* 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 (max-width: 767px) {
	.legendary-header-inner {
		justify-content: space-between;
		align-items: center;
	}
}

@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;
}

@media (max-width: 767px) {
	.legendary-header-brand {
		flex: 1 1 auto;
		max-width: calc(100% - 3.5rem);
	}
}

/* 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;
}

/* --- Hamburger (mobile only) --- */
.legendary-header-menu-toggle {
	display: none;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: 2.75rem;
	height: 2.75rem;
	margin: 0;
	padding: 0;
	border: 1px solid var(--legendary-white-15);
	border-radius: var(--legendary-r2);
	background: transparent;
	color: var(--legendary-text);
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
	transition: background 0.2s ease, border-color 0.2s ease;
}

.legendary-header-menu-toggle:hover {
	background: var(--legendary-white-5);
}

.legendary-header-menu-toggle:focus-visible {
	outline: 2px solid var(--legendary-text);
	outline-offset: 2px;
}

.legendary-header-menu-toggle__bars {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 5px;
	width: 1.25rem;
}

.legendary-header-menu-toggle__bar {
	display: block;
	width: 100%;
	height: 2px;
	background: currentColor;
	border-radius: 1px;
	transition: transform 0.28s ease, opacity 0.28s ease;
}

.legendary-header-menu-toggle.is-open .legendary-header-menu-toggle__bar:nth-child(1) {
	transform: translateY(7px) rotate(45deg);
}

.legendary-header-menu-toggle.is-open .legendary-header-menu-toggle__bar:nth-child(2) {
	opacity: 0;
}

.legendary-header-menu-toggle.is-open .legendary-header-menu-toggle__bar:nth-child(3) {
	transform: translateY(-7px) rotate(-45deg);
}

@media (prefers-reduced-motion: reduce) {
	.legendary-header-menu-toggle__bar,
	.legendary-header-menu-toggle.is-open .legendary-header-menu-toggle__bar:nth-child(1),
	.legendary-header-menu-toggle.is-open .legendary-header-menu-toggle__bar:nth-child(3) {
		transition: none;
	}
}

@media (max-width: 767px) {
	.legendary-header-menu-toggle {
		display: inline-flex !important;
	}
}

@media (min-width: 768px) {
	.legendary-header-menu-toggle {
		display: none !important;
	}
}

/* Drawer chrome (mobile only — hidden on desktop) */
.legendary-header-nav__top {
	display: none;
}

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

@media (max-width: 767px) {
	.legendary-header-nav__top {
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		flex-shrink: 0;
		gap: 0.75rem;
		margin: 0 0 1rem;
		padding-bottom: 1rem;
		border-bottom: 1px solid var(--legendary-white-10);
	}

	.legendary-header-nav__title {
		font-size: 0.8125rem;
		font-weight: 600;
		letter-spacing: 0.12em;
		text-transform: uppercase;
		color: var(--legendary-text);
	}

	.legendary-header-menu-close {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		flex-shrink: 0;
		width: 2.5rem;
		height: 2.5rem;
		margin: 0;
		padding: 0;
		border: 1px solid var(--legendary-white-15);
		border-radius: var(--legendary-r2);
		background: transparent;
		color: var(--legendary-text);
		cursor: pointer;
		-webkit-tap-highlight-color: transparent;
		position: relative;
		transition: background 0.2s ease;
	}

	.legendary-header-menu-close:hover {
		background: var(--legendary-white-5);
	}

	.legendary-header-menu-close:focus-visible {
		outline: 2px solid var(--legendary-text);
		outline-offset: 2px;
	}

	.legendary-header-menu-close__icon {
		position: relative;
		display: block;
		width: 1rem;
		height: 1rem;
	}

	.legendary-header-menu-close__icon::before,
	.legendary-header-menu-close__icon::after {
		content: '';
		position: absolute;
		top: 50%;
		left: 50%;
		width: 1rem;
		height: 2px;
		margin-left: -0.5rem;
		margin-top: -1px;
		background: currentColor;
		border-radius: 1px;
	}

	.legendary-header-menu-close__icon::before {
		transform: rotate(45deg);
	}

	.legendary-header-menu-close__icon::after {
		transform: rotate(-45deg);
	}

	nav.legendary-header-nav {
		position: fixed;
		top: 0;
		right: 0;
		width: min(20rem, 100vw);
		max-width: 100vw;
		height: 100%;
		min-height: 100vh;
		min-height: 100dvh;
		box-sizing: border-box;
		padding: max(1rem, env(safe-area-inset-top, 0px)) 1.25rem 1.5rem;
		background: rgba(10, 10, 10, 0.98);
		border-left: 1px solid var(--legendary-white-10);
		box-shadow: -12px 0 40px rgba(0, 0, 0, 0.45);
		transform: translateX(100%);
		visibility: hidden;
		pointer-events: none;
		transition: transform 0.28s ease, visibility 0.28s ease;
		z-index: 56;
		overflow-x: hidden;
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
		justify-content: flex-start;
	}

	body.legendary-mobile-nav-open nav.legendary-header-nav {
		transform: translateX(0);
		visibility: visible;
		pointer-events: auto;
	}

	body.admin-bar nav.legendary-header-nav {
		top: 46px;
		min-height: calc(100vh - 46px);
		min-height: calc(100dvh - 46px);
		height: calc(100% - 46px);
	}
}

@media (prefers-reduced-motion: reduce) and (max-width: 767px) {
	nav.legendary-header-nav {
		transition: none;
	}
}

@media (min-width: 768px) {
	.legendary-header-nav__top {
		display: none !important;
	}

	nav.legendary-header-nav {
		position: relative;
		flex-direction: row;
		flex-wrap: nowrap !important;
		align-items: center;
		justify-content: center;
		flex: 1 1 auto;
		min-width: 0;
		gap: 2rem;
		width: auto;
		height: auto;
		min-height: 0;
		padding: 0;
		background: transparent;
		border: none;
		box-shadow: none;
		transform: none;
		visibility: visible;
		pointer-events: auto;
		transition: none;
		overflow: visible;
		z-index: auto;
	}
}

.legendary-header-nav__inner {
	display: flex;
	align-items: center;
	flex-wrap: nowrap !important;
	gap: 2rem;
	min-width: 0;
	flex: 1;
}

@media (min-width: 768px) {
	.legendary-header-nav__inner {
		justify-content: center;
	}
}

@media (max-width: 767px) {
	.legendary-header-nav__inner {
		flex-direction: column;
		align-items: stretch;
		flex-wrap: nowrap !important;
		gap: 0;
		flex: 0 0 auto;
		width: 100%;
	}
}

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;
}

@media (max-width: 767px) {
	nav.legendary-header-nav ul.legendary-header-nav__list {
		flex-direction: column;
		align-items: stretch;
		flex-wrap: nowrap !important;
		gap: 0;
	}
}

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

@media (min-width: 768px) {
	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;
	}
}

@media (max-width: 767px) {
	nav.legendary-header-nav .sub-menu {
		position: static;
		display: block;
		margin: 0 0 0 0.75rem;
		padding: 0 0 0.5rem;
		list-style: none;
		background: transparent;
		border: none;
		box-shadow: none;
		border-radius: 0;
	}

	nav.legendary-header-nav .sub-menu a {
		white-space: normal;
		padding: 0.5rem 0;
		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;
}

@media (max-width: 767px) {
	nav.legendary-header-nav a {
		white-space: normal;
	}

	nav.legendary-header-nav .legendary-header-nav__inner > a {
		padding: 0.75rem 0;
		border-bottom: 1px solid var(--legendary-white-10);
	}

	nav.legendary-header-nav ul.legendary-header-nav__list > li > a {
		padding: 0.75rem 0;
		border-bottom: 1px solid var(--legendary-white-10);
		display: block;
	}
}

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);
}

/* Mobile drawer: CTAs directly under links — not flex-pinned to bottom */
.legendary-header-actions--mobile-drawer {
	display: none !important;
}

@media (max-width: 767px) {
	.legendary-header-inner > .legendary-header-actions--bar,
	.legendary-header-inner .legendary-header-actions.legendary-header-actions--bar,
	.legendary-header-actions.legendary-header-actions--bar {
		display: none !important;
		visibility: hidden !important;
		position: absolute !important;
		width: 1px !important;
		height: 1px !important;
		padding: 0 !important;
		margin: -1px !important;
		overflow: hidden !important;
		clip: rect(0, 0, 0, 0) !important;
		clip-path: inset(50%) !important;
		border: 0 !important;
		pointer-events: none !important;
	}

	.legendary-header-actions--mobile-drawer {
		display: flex !important;
		flex-direction: column;
		align-items: center;
		justify-content: flex-start;
		flex-shrink: 0;
		flex-grow: 0;
		width: 100%;
		max-width: 100%;
		box-sizing: border-box;
		margin-top: 1.5rem;
		padding-top: 1.25rem;
		border-top: 1px solid var(--legendary-white-10);
		gap: 0.75rem;
	}

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

	.legendary-header-actions--mobile-drawer .wp-block-button {
		width: 100%;
		max-width: 18rem;
		margin-left: auto;
		margin-right: auto;
		flex-shrink: 0;
	}

	.legendary-header-actions--mobile-drawer .wp-block-button__link {
		display: flex !important;
		width: 100% !important;
		max-width: 100%;
		box-sizing: border-box;
		justify-content: center;
		align-items: center;
		text-align: center;
	}
}

.legendary-mobile-backdrop {
	display: none;
	position: fixed;
	inset: 0;
	z-index: 55;
	background: rgba(0, 0, 0, 0.45);
	opacity: 0;
	transition: opacity 0.28s ease;
	pointer-events: none;
}

body.legendary-mobile-nav-open .legendary-mobile-backdrop {
	display: block;
	opacity: 1;
	pointer-events: auto;
}

@media (prefers-reduced-motion: reduce) {
	.legendary-mobile-backdrop {
		transition: none;
	}
}

@media (min-width: 768px) {
	.legendary-mobile-backdrop {
		display: none !important;
	}
}

/* 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;
	}
}
