/*
 * TutsVela Theme: V4 header details that Kadence settings cannot express.
 *
 * Everything else in the header (layout, logo, heights, colours, typography, menus, dropdown widths, icons and
 * descriptions, button, search modal, colour switch, sticky state, drawer) is set in Appearance > Customize and
 * Appearance > Menus (Ultimate Menu). Each section below names the V4 source rule (design-reference/v4/project/tv.css)
 * and why it is CSS. Colours use Kadence palette variables, so the dark palette (Color Switch) follows.
 * Native options checked for each item: docs/v4/kadence-mapping.md, section "Header".
 */

/* 1. Glass bar (tv.css .hdr v3 layer: --glass + backdrop blur).
 * Why CSS: the header background control takes one solid or rgba colour that does not change with the dark palette,
 * and Kadence has no backdrop-filter control for the classic header. */
.site-main-header-wrap .site-header-row-container-inner {
	background: color-mix(in srgb, var(--global-palette9) 72%, transparent);
	-webkit-backdrop-filter: saturate(1.6) blur(16px);
	backdrop-filter: saturate(1.6) blur(16px);
	transition: border-color .25s, box-shadow .25s;
}

/* 2. Navigation centred between the logo and the actions (tv.css .pnav flex:1, justify-content:center).
 * Why CSS: the Header Builder centre column is centred on the page; the left-centre column only renders when the
 * centre column has content, so there is no native "centre in remaining space" placement. */
@media (min-width: 981px) {
	.site-main-header-inner-wrap.site-header-row-center-column {
		grid-template-columns: auto minmax(0, 1fr) auto;
		column-gap: 16px;
	}
	.site-main-header-inner-wrap .site-header-main-section-center {
		justify-content: center;
	}
	/* Kadence gives every header item a 10px right margin and removes it only from the last item. The empty
	 * left-centre wrapper follows the logo, so the logo kept 10px and pushed the navigation 5px right of V4.
	 * V4 action spacing: .hdr-act gap 6px, plus 6px extra before the button (.nav-cta). No item-spacing control exists. */
	#main-header .site-header-main-section-left > .site-header-item {
		margin-right: 0;
	}
	#main-header .site-header-main-section-right > .site-header-item {
		margin-right: 6px;
	}
	#main-header .site-header-main-section-right > .site-header-item:last-child {
		margin-right: 0;
	}
	#main-header .site-header-main-section-right > .site-header-item[data-section="kadence_customizer_header_button"] {
		margin-left: 6px;
	}
}

/* 3. Navigation pills (tv.css .nav-a v3 layer: 10px radius, 4px gap, current item dot).
 * Why CSS: Kadence sets the item background colours but has no item radius, item gap or current-item marker. */
.header-navigation .primary-menu-container > ul > li.menu-item {
	margin: 0 2px;
}
.header-navigation .primary-menu-container > ul > li.menu-item > a {
	/* One centred row: Kadence prints top-level links as display:block, and dropdown parents hold their text and
	 * chevron in a flex wrapper. Without this the current-item dot below dropped to a second line and stretched the
	 * active pill to 67px (Phase 3 fix). */
	display: flex;
	align-items: center;
	border-radius: 10px;
	transition: background-color .15s;
}
.header-navigation .primary-menu-container > ul > li.current-menu-item > a::after,
.header-navigation .primary-menu-container > ul > li.current-menu-ancestor > a::after {
	content: "";
	flex: none;
	width: 5px;
	height: 5px;
	margin-left: 8px;
	border-radius: 50%;
	background: var(--global-palette1);
}
.header-navigation .primary-menu-container > ul > li.menu-item-has-children:hover > a .dropdown-nav-toggle svg,
.header-navigation .primary-menu-container > ul > li.menu-item-has-children:focus-within > a .dropdown-nav-toggle svg {
	transform: rotate(180deg);
}
.header-navigation .dropdown-nav-toggle svg {
	transition: transform .18s;
}

/* 3b. Dropdown toggle target size (WCAG 2.2 target size, 24 x 24 CSS px; ui-ux-pro-max `web-target-size`). Kadence's
 * keyboard/pointer toggle over each chevron is an empty absolutely positioned button 0.9em (14px) wide, and Kadence has
 * no setting for it (selector matches Kadence's own specificity). It keeps its left edge on the chevron and grows to the right into the item's own padding, so it
 * never covers the label. */
.wp-site-blocks .header-navigation .primary-menu-container > ul > li.menu-item .dropdown-nav-special-toggle {
	width: 24px;
	right: 3px;
}

/* 4. Dropdown panels (tv.css .ddm and .dd-list v3 layer: 20px radius, hairline border, 10px padding, 12px offset).
 * Why CSS: Ultimate Menu sets width, background, shadow and item colours; panel radius, border, inner padding and
 * the gap above the panel are not options. */
.header-navigation .header-menu-container ul ul.sub-menu {
	border-radius: 20px;
	border: 1px solid var(--global-palette7);
	padding: 10px;
	margin-top: 12px;
}
.header-navigation .header-menu-container ul ul.sub-menu::before {
	/* keeps hover-to-open working across the 12px gap */
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	top: -14px;
	height: 14px;
}
.header-navigation .header-menu-container ul ul li.menu-item > a {
	display: grid;
	grid-template-columns: 40px minmax(0, 1fr);
	gap: 12px;
	align-items: center;
	width: 100%;
	padding: 10px 12px;
	border-radius: 12px;
	line-height: 1.3;
}
.header-navigation .menu-label-content {
	display: block;
}
.header-navigation .menu-label-description {
	display: block;
	margin-top: 2px;
	font-size: 13.5px;
	font-weight: 400;
	color: var(--global-palette5);
}
/* Item icon tile (tv.css .mi-ic). Why CSS: Ultimate Menu icons have size and colour, not a framed tile. */
.header-navigation .menu-label-icon-wrap {
	display: grid;
	place-items: center;
	width: 40px;
	height: 40px;
	margin: 0;
	border-radius: 12px;
	border: 1px solid var(--global-palette7);
	background: var(--global-palette8);
	color: var(--global-palette3);
	transition: background-color .15s, color .15s, border-color .15s;
}
.header-navigation .menu-label-icon svg {
	width: 20px;
	height: 20px;
}
.header-navigation ul ul li.menu-item > a:hover .menu-label-icon-wrap,
.header-navigation ul ul li.menu-item > a:focus-visible .menu-label-icon-wrap {
	background: color-mix(in srgb, var(--global-palette1) 12%, transparent);
	border-color: color-mix(in srgb, var(--global-palette1) 30%, transparent);
	color: var(--global-palette10);
}
/* Dropdown footer row (tv.css .mega-foot), built as a Kadence Element placed with "Replace item with an Element".
 * Why CSS: the row's top rule and muted text belong to the menu panel context, not to the Element itself. */
.header-navigation ul ul li.menu-item .tv-mega-foot {
	margin-top: 4px;
	padding: 12px 12px 4px;
	border-top: 1px solid var(--global-palette7);
	font-size: 14px;
	color: var(--global-palette5);
}
.tv-mega-foot p {
	margin: 0;
}
.tv-mega-foot a {
	text-decoration: none;
	color: var(--global-palette3);
}
.tv-mega-foot .tv-mega-foot-link a {
	font-weight: 600;
	text-decoration: underline;
	text-decoration-color: var(--global-palette1);
	text-decoration-thickness: 2px;
	text-underline-offset: 6px;
}
.tv-mega-foot .tv-mega-foot-strong a {
	font-weight: 600;
}

/* 5. Icon buttons: search, colour switch, menu (tv.css .icon-btn: 44 x 44px, 12px radius, hover background).
 * Why CSS: search and menu toggles have padding and hover background but no radius; the Color Switch "button"
 * style paints its own two colours (one of them becomes the background in each mode), so a transparent button
 * with an ink icon in both palettes is not possible with its two colour pickers. */
.search-toggle-open,
.menu-toggle-open,
.kadence-color-palette-header-switcher .kadence-color-palette-toggle,
.kadence-color-palette-mobile-switcher .kadence-color-palette-toggle {
	border-radius: 12px;
}
.site-header .kadence-color-palette-switcher button.kadence-color-palette-toggle,
.color-switch-light .site-header .kadence-color-palette-switcher button.kadence-color-palette-toggle,
.color-switch-dark .site-header .kadence-color-palette-switcher button.kadence-color-palette-toggle {
	display: grid;
	place-items: center;
	width: 44px;
	height: 44px;
	padding: 0;
	background: transparent;
	color: var(--global-palette4);
	filter: none;
	transition: background-color .15s, color .15s;
}
.color-switch-light .site-header .kadence-color-palette-switcher button.kadence-color-palette-toggle:hover,
.color-switch-dark .site-header .kadence-color-palette-switcher button.kadence-color-palette-toggle:hover {
	background: var(--global-palette8);
	color: var(--global-palette3);
	filter: none;
}
.site-header .kadence-color-palette-switcher .kadence-color-palette-icon svg {
	width: 21px;
	height: 21px;
}

/* 6. Search modal as a centred panel (tv.css .modal, .scrim, .search-bar v3 layer).
 * Why CSS: Kadence's search modal is a full-screen overlay with a large input; it has a background colour but no
 * panel width, radius, position or blurred backdrop options. The form and its behaviour stay native. */
#search-drawer .drawer-overlay {
	background: rgba(10, 10, 10, .45);
	-webkit-backdrop-filter: blur(4px);
	backdrop-filter: blur(4px);
}
#search-drawer .drawer-inner {
	position: fixed;
	left: 50%;
	top: max(10vh, 24px);
	bottom: auto;
	transform: translateX(-50%);
	width: min(760px, calc(100% - 24px));
	height: auto;
	min-height: 0;
	max-height: 88vh;
	background: var(--global-palette9);
	color: var(--global-palette3);
	border: 1px solid var(--global-palette7);
	border-radius: 22px;
	box-shadow: 0 2px 4px rgba(20, 20, 20, .04), 0 24px 60px -16px rgba(20, 20, 20, .22);
	overflow: hidden;
}
#search-drawer .drawer-inner .drawer-header {
	position: absolute;
	top: 14px;
	right: 14px;
	padding: 0;
	z-index: 2;
}
#search-drawer .drawer-header .search-toggle-close {
	width: 44px;
	height: 44px;
	padding: 0;
	display: grid;
	place-items: center;
	border-radius: 12px;
	color: var(--global-palette4);
}
#search-drawer .drawer-header .search-toggle-close:hover {
	background: var(--global-palette8);
	color: var(--global-palette3);
}
#search-drawer .drawer-inner .drawer-content {
	position: static;
	display: block;
	height: auto;
	padding: 0;
}
/* V4 .search-bar: 10px 16px padding, 52px field, hairline under the bar; the panel below spans the full modal. */
#search-drawer .drawer-inner .drawer-content form.search-form {
	padding: 10px 70px 10px 16px;
	border-bottom: 1px solid var(--global-palette7);
}
#search-drawer .drawer-content form.search-form {
	max-width: none;
	margin: 0;
	position: relative;
}
#search-drawer .drawer-inner .drawer-content form.search-form label input.search-field {
	min-height: 52px;
	padding: 0 0 0 36px;
	font-size: 20px;
	border: 0;
	background: transparent;
	color: var(--global-palette3);
	box-shadow: none;
}
#search-drawer .drawer-inner .drawer-content form.search-form input.search-field:focus {
	outline: none;
	color: var(--global-palette3);
	box-shadow: none;
}
#search-drawer .drawer-inner .drawer-content input.search-field::-webkit-search-cancel-button {
	-webkit-appearance: none;
	appearance: none;
}
#search-drawer .drawer-inner .drawer-content .kadence-search-icon-wrap {
	left: 16px;
	right: auto;
	width: 24px;
	color: var(--global-palette5);
}
#search-drawer .drawer-inner .drawer-content .kadence-search-icon-wrap svg {
	width: 24px;
	height: 24px;
}
@media (prefers-reduced-motion: no-preference) {
	.showing-popup-drawer-from-full #search-drawer.active .drawer-inner {
		animation: tv-search-in .2s cubic-bezier(.2, .7, .2, 1);
	}
}
@keyframes tv-search-in {
	from { opacity: 0; transform: translate(-50%, 10px) scale(.98); }
	to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

/* 7. Mobile drawer (tv.css .drawer, .scrim, .mnav).
 * Why CSS: the side panel has width and background options; its rounded inner edge, shadow, blurred overlay and the
 * 56px row height with hairline dividers between top-level rows only are not options. */
#mobile-drawer .drawer-overlay {
	background: rgba(10, 10, 10, .45);
	-webkit-backdrop-filter: blur(4px);
	backdrop-filter: blur(4px);
}
#mobile-drawer.popup-drawer-side-right .drawer-inner {
	width: min(420px, 100%);
	max-width: none;
	border-radius: 24px 0 0 24px;
	box-shadow: 0 2px 4px rgba(20, 20, 20, .04), 0 24px 60px -16px rgba(20, 20, 20, .22);
}
#mobile-drawer .drawer-header {
	min-height: 72px;
	border-bottom: 1px solid var(--global-palette7);
	padding: 12px 16px;
}
#mobile-drawer .drawer-content {
	padding: 16px 20px;
}
/* Drawer head logo (V4 .drawer-head: logo 26px tall, left, beside the close button). The theme prints Kadence's
 * mobile branding at the top of the drawer content (functions.php); this lifts it into the 72px head row
 * (the drawer panel is already positioned by Kadence, so it is the containing block). */
#mobile-drawer .tv-drawer-logo {
	position: absolute;
	top: 0;
	left: 16px;
	height: 72px;
	display: flex;
	align-items: center;
}
#mobile-drawer .tv-drawer-logo .site-branding {
	padding: 0;
}
#mobile-drawer .tv-drawer-logo img.custom-logo {
	width: auto;
	max-width: none;
	height: 26px;
}
#mobile-drawer .mobile-navigation ul li.menu-item-has-children .drawer-nav-drop-wrap,
#mobile-drawer .mobile-navigation ul li:not(.menu-item-has-children) a {
	min-height: 56px;
	align-items: center;
}
/* Current item in the drawer (V4 .mnav .nav-a[aria-current]: bg-alt pill with the orange dot). The background is the
 * native Kadence mobile navigation "active" colour; Kadence has no radius or marker for it. */
#mobile-drawer .mobile-navigation > div > ul > li.current-menu-item > a,
#mobile-drawer .mobile-navigation > div > ul > li.current-menu-item > .drawer-nav-drop-wrap,
#mobile-drawer .mobile-navigation > div > ul > li.current-menu-ancestor > .drawer-nav-drop-wrap {
	border-radius: 10px;
}
#mobile-drawer .mobile-navigation > div > ul > li.current-menu-item > a::after,
#mobile-drawer .mobile-navigation > div > ul > li.current-menu-ancestor > .drawer-nav-drop-wrap > a::after {
	content: "";
	display: inline-block;
	vertical-align: middle;
	width: 5px;
	height: 5px;
	margin-left: 8px;
	border-radius: 50%;
	background: var(--global-palette1);
}
#mobile-drawer .mobile-navigation ul.sub-menu li a {
	min-height: 0;
	padding: 10px 12px;
	border-left: 2px solid var(--global-palette7);
	font-size: 16px;
	font-weight: 400;
	color: var(--global-palette4);
}
#mobile-drawer .mobile-navigation ul.sub-menu li a:hover {
	border-left-color: var(--global-palette1);
	color: var(--global-palette3);
}

/* Drawer search field, button and colour switch at full width (V4 drawer: full-width search button,
 * full-width Start a Project and theme buttons). Why CSS: these items have no width option in the drawer. */
#mobile-drawer .header-mobile-search-bar,
#mobile-drawer .header-mobile-search-bar form.search-form {
	width: 100%;
	max-width: none;
}
#mobile-drawer .header-mobile-search-bar input.search-field {
	width: 100%;
	min-height: 52px;
	border-radius: 12px;
	border: 1px solid var(--global-palette6);
	background: var(--global-palette9);
	color: var(--global-palette3);
	font-size: 16px;
}
#mobile-drawer .mobile-header-button-wrap,
#mobile-drawer .mobile-header-button-wrap .mobile-header-button-inner-wrap,
#mobile-drawer .mobile-header-button-wrap a.mobile-header-button {
	width: 100%;
	justify-content: center;
	text-align: center;
}
#mobile-drawer .drawer-sub-toggle {
	border-left: 0;
}
.popup-drawer .kadence-color-palette-switcher button.kadence-color-palette-toggle,
.color-switch-light .popup-drawer .kadence-color-palette-switcher button.kadence-color-palette-toggle,
.color-switch-dark .popup-drawer .kadence-color-palette-switcher button.kadence-color-palette-toggle {
	width: 44px;
	height: 44px;
	padding: 0;
	display: grid;
	place-items: center;
	border-radius: 12px;
	background: transparent;
	color: var(--global-palette4);
	filter: none;
}

/* 6b. Search panel key hints (tv.css .cmd-foot .kbd). The hint row is a Kadence Element; key names use the editor's
 * inline code format because the block editor has no keyboard-key format. Only the key chip look is set here. */
/* "Jump to" (V4 .g-auto: auto-fit grid, minmax(min(160px,100%),1fr), left-aligned labels). Kadence Buttons wraps
 * buttons by their text width and has no equal-width grid option. */
#search-drawer .tv-search-jump {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr));
}
#search-drawer .tv-search-jump .kb-button {
	width: 100%;
	justify-content: flex-start;
}
#search-drawer .tv-search-foot code {
	font-size: 12px;
	font-family: "JetBrains Mono", SFMono-Regular, Menlo, Consolas, monospace;
	color: var(--global-palette5);
	background: var(--global-palette8);
	border: 1px solid var(--global-palette7);
	border-bottom-width: 2px;
	border-radius: 6px;
	padding: 1px 7px;
}

/* 8. Focus ring (tv.css :focus-visible: 3px, ink in light, link orange in dark).
 * Why CSS: Kadence has no focus-ring control. */
.site-header a:focus-visible,
.site-header button:focus-visible,
.popup-drawer a:focus-visible,
.popup-drawer button:focus-visible,
.popup-drawer input:focus-visible {
	outline: 3px solid var(--global-palette3);
	outline-offset: 2px;
}
.color-switch-dark .site-header a:focus-visible,
.color-switch-dark .site-header button:focus-visible,
.color-switch-dark .popup-drawer a:focus-visible,
.color-switch-dark .popup-drawer button:focus-visible,
.color-switch-dark .popup-drawer input:focus-visible {
	outline-color: var(--global-palette10);
}

@media (prefers-reduced-motion: reduce) {
	.site-main-header-wrap .site-header-row-container-inner,
	.header-navigation .primary-menu-container > ul > li.menu-item > a,
	.header-navigation .dropdown-nav-toggle svg,
	.header-navigation .menu-label-icon-wrap {
		transition: none;
	}
}
