/*
 * Stand-in: layout controls for the phone header bar (Nova Blocks Header). See nova-mobile-header-layout.php for the
 * issues and the class tokens. Below 1024 px only (Nova's fold); nothing here applies from 1024 px.
 * Each section is keyed on its own token on the header element (`.nb-header--main`), reached from the menu button and
 * the bar, its preceding siblings, with `:has(~ …)`. Where two controls meet (the menu button's side decides where the
 * start-aligned brand must stop) the rule names both tokens. Tokens only: no colour, size or face of a site's own.
 */
@media not screen and (min-width: 1024px) {

	/* ---------------------------------------------------------------------------------------------------------------
	 * 1 · Menu side · `has-mobile-menu-right` · issue "Header: choose the side of the mobile menu button"
	 * The button sits at the bar's end edge (logical properties: RTL mirrors). Its height stays Nova's (the bar's);
	 * the open drawer's close control is the same button, so it is in the same place.
	 * A cart or a phone/e-mail action, which Nova places at the end edge, moves to the button's start side.
	 * UNTESTED (no such item on the reference site).
	 */
	.c-menu-toggle:has(~ .nb-header--main.has-mobile-menu-right) {
		inset-inline-start: auto;
		inset-inline-end: 0;
	}

	.nb-header--mobile:has(~ .nb-header--main.has-mobile-menu-right) :is(.nb-header__mobile-actions, .menu-item--cart) {
		inset-inline-end: var(--pxg-mobile-menu-width, 48px);
	}

	/* ---------------------------------------------------------------------------------------------------------------
	 * 2 · Visible word · `has-mobile-menu-label` (the word only) or `has-mobile-menu-icon-label` (icon, then the word)
	 * issue "Header: show the mobile menu button's label"
	 * Nova prints its own translated label ("Menu") with `screen-reader-text` (Anima: `position: absolute !important`).
	 * Here it is shown, in the navigation type role like the bar's other text; its colour is the button's, which Nova
	 * switches for the open state. The side of the button that faces the bar's content gets the smaller spacing step
	 * instead of the page gutter; the word's outer edge stays on the gutter (Nova's padding).
	 */
	.c-menu-toggle:has(~ .nb-header--main:is(.has-mobile-menu-label, .has-mobile-menu-icon-label)) .c-menu-toggle__label {
		position: relative !important;
		inline-size: auto;
		block-size: auto;
		margin: 0;
		overflow: visible;
		clip: auto;
		clip-path: none;
		white-space: nowrap;
		--font-size: var(--theme-navigation-font-size);
		--current-font-family: var(--theme-navigation-font-family);
		--current-font-weight: var(--theme-navigation-font-weight);
		--current-font-style: var(--theme-navigation-font-style);
		--current-line-height: var(--theme-navigation-line-height);
		--current-letter-spacing: var(--theme-navigation-letter-spacing);
		--current-text-transform: var(--theme-navigation-text-transform);
	}

	.c-menu-toggle:has(~ .nb-header--main.has-mobile-menu-right:is(.has-mobile-menu-label, .has-mobile-menu-icon-label)) .c-menu-toggle__wrap {
		padding-inline-start: var(--theme-spacing-smaller);
	}

	.c-menu-toggle:has(~ .nb-header--main:not(.has-mobile-menu-right):is(.has-mobile-menu-label, .has-mobile-menu-icon-label)) .c-menu-toggle__wrap {
		padding-inline-end: var(--theme-spacing-smaller);
	}

	/* Icon and word: Nova's own 0.5em between them. */
	.c-menu-toggle:has(~ .nb-header--main.has-mobile-menu-icon-label) .c-menu-toggle__label {
		margin-inline-start: 0.5em;
	}

	/* The word only: no three-bar icon while the menu is closed. Open, Nova's × takes the word's place: both share one
	   grid cell and the word turns transparent, so it stays the button's accessible name (with `aria-expanded`) and
	   keeps the button's width (the bar does not jump). */
	.c-menu-toggle:has(~ .nb-header--main.has-mobile-menu-label) .c-menu-toggle__wrap {
		display: grid;
		place-items: center;
	}

	.c-menu-toggle:has(~ .nb-header--main.has-mobile-menu-label) :is(.c-menu-toggle__icon, .c-menu-toggle__label) {
		grid-area: 1 / 1;
	}

	.c-menu-toggle__checkbox:not(:checked) ~ .c-menu-toggle:has(~ .nb-header--main.has-mobile-menu-label) .c-menu-toggle__icon {
		visibility: hidden;
	}

	.c-menu-toggle__checkbox:checked ~ .c-menu-toggle:has(~ .nb-header--main.has-mobile-menu-label) .c-menu-toggle__label {
		color: transparent;
	}

	/* ---------------------------------------------------------------------------------------------------------------
	 * 3 · Brand at the start · `has-mobile-brand-start` · issue "Header: align the mobile brand to the start"
	 * The brand's start edge is the bar's own side padding (the page gutter). It stops before the menu button: the
	 * bar keeps room for the button (its width, written by the script as --pxg-mobile-menu-width; Nova's 48 px minimum
	 * until then), any bar actions (Nova's --nb-header-mobile-actions-width; UNTESTED) and the smallest spacing step.
	 * The mark never shrinks; the name and the tagline stay on one line each and, if the room still runs out, end in an
	 * ellipsis instead of wrapping under the mark or running under the button. (Below 360 px the tagline leaves the
	 * bar: nova-logo-site-text-type.css.)
	 */
	.nb-header--mobile:has(~ .nb-header--main.has-mobile-brand-start) {
		justify-content: flex-start;
	}

	.nb-header--mobile:has(~ .nb-header--main.has-mobile-brand-start.has-mobile-menu-right) {
		padding-inline-end: calc(var(--pxg-mobile-menu-width, 48px) + var(--nb-header-mobile-actions-width, 0px) + var(--theme-spacing-smallest));
	}

	/* Menu on the start side (Nova's): the brand starts after the button. UNTESTED. */
	.nb-header--mobile:has(~ .nb-header--main.has-mobile-brand-start:not(.has-mobile-menu-right)) {
		padding-inline-start: calc(var(--pxg-mobile-menu-width, 48px) + var(--theme-spacing-smallest));
	}

	.nb-header--mobile:has(~ .nb-header--main.has-mobile-brand-start) .nb-header__mobile-brand {
		min-width: 0;
		max-width: 100%;
	}

	.nb-header--mobile:has(~ .nb-header--main.has-mobile-brand-start) .nb-header__mobile-brand > .site-logo {
		flex-shrink: 0;
	}

	.nb-header--mobile:has(~ .nb-header--main.has-mobile-brand-start) .nb-header__mobile-brand :is(.site-info, .site-title, .site-description) {
		min-width: 0;
	}

	.nb-header--mobile:has(~ .nb-header--main.has-mobile-brand-start) .nb-header__mobile-brand :is(.site-title, .site-description) {
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
	}

	/* ---------------------------------------------------------------------------------------------------------------
	 * 4 · Bar height · `has-mobile-bar-height-<n>` · issue "Header: mobile bar height"
	 * The PHP filter writes --pxg-mobile-bar-height on the header element; Nova copies the header's inline style to the
	 * bar. The bar is that tall (plus Nova's safe-area term on top) with no block padding; its content is centred by
	 * the bar's own `align-items: center`, and content taller than the value grows the bar (never clipped). Nova then
	 * measures the bar and gives the menu button, the page's top padding and --nb-header-height the same height. The
	 * button's content is centred on the same box (Nova's 1em block padding off; the safe-area term kept).
	 * Nova's padding-top rule carries an id in :is() for its weight; this one matches it the same way.
	 */
	:is(.nb-header--mobile, #pxg-lt-bridge.specificity):has(~ .nb-header--main[class*="has-mobile-bar-height-"]) {
		min-height: calc(var(--pxg-mobile-bar-height, 60px) + var(--nb-mobile-header-safe-area-inset-top, 0px));
		padding-top: var(--nb-mobile-header-safe-area-inset-top, 0px);
		padding-bottom: 0;
	}

	.c-menu-toggle:has(~ .nb-header--main[class*="has-mobile-bar-height-"]) .c-menu-toggle__wrap {
		padding-top: var(--nb-mobile-header-safe-area-inset-top, 0px);
		padding-bottom: 0;
	}
}
