/* =============================================================================
 * §15. MOBILE HEADER — the reference's drawer                  (2026-08-18)
 * -----------------------------------------------------------------------------
 * Ported from solutech templates/header/mobile.php + css/single.css. The
 * reference does NOT slide a panel over the page: it ROTATES THE PAGE ITSELF
 * out of the way and reveals the menu sitting behind it. Measured on the
 * reference at 414x896:
 *
 *     .menu-mobile__header   fixed  y0  h50   rgba(0,0,0,.42) + blur(5px)
 *     .menu-mobile__list     fixed  top 55%  right 5%  w200  (hidden until open)
 *     .pix-mobile-overlay    fixed  full viewport, fades in
 *     page content           rotate(30deg), radius 16px, big shadow
 *
 * THE CHECKBOX STAYS THE SOURCE OF TRUTH. The existing markup is a real
 * checkbox + label disclosure, so the menu opens with CSS alone and keeps
 * working if the script never runs. The script only adds what CSS cannot
 * express — the scroll lock and the page rotation, which is applied to
 * `.wp-site-blocks` and therefore needs a class on <body>, not a sibling
 * selector. Without JS you get a plain open menu; with it, the reference's
 * effect. Neither state is broken.
 *
 * Everything is inside the mobile breakpoint. Above it the desktop masthead in
 * §10/§13 is untouched.
 * ========================================================================== */

@media (max-width: 899.98px) {

	/* ---- the bar itself ------------------------------------------------- */

	.vnm-header {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		height: 50px;
		min-height: 50px;
		padding: 0 15px;
		background: transparent;
		border: none;
		box-shadow: none;
		z-index: 9999;
	}

	/*
	 * THE BLUR IS ON A PSEUDO-ELEMENT, NOT ON THE BAR, AND THAT IS LOAD-BEARING.
	 * `backdrop-filter` makes an element the CONTAINING BLOCK for any
	 * `position: fixed` descendant. With it on `.vnm-header`, the drawer below —
	 * which is a descendant, not a sibling as in the reference — resolved
	 * `top: 55%` against the 50px BAR instead of the viewport and landed at
	 * 27.5px, tucked inside the header. Moving the blur to `::before` keeps the
	 * same frosted bar while leaving the drawer anchored to the viewport.
	 * (`position: fixed` on the bar itself does NOT create a containing block —
	 * only transform / filter / backdrop-filter / will-change / contain do.)
	 */
	.vnm-header::before {
		content: "";
		position: absolute;
		inset: 0;
		background: rgba(0, 0, 0, 0.42);
		-webkit-backdrop-filter: blur(5px);
		backdrop-filter: blur(5px);
		z-index: 0;
	}

	.vnm-header__inner {
		position: relative;
		z-index: 1;          /* above the frosted layer */
		height: 50px;
		min-height: 0;
		max-width: none;
		padding-inline: 0;
		/* §3 of vnm-chrome.css sets padding-block:10px for the old 72px bar.
		   Left in place it leaves a 30px content box inside a 50px bar, which
		   is what pushed the contents out of it. */
		padding-block: 0;
		/* The nav still needs to wrap onto its own line (flex-basis:100%), so
		   wrapping stays on — but nothing in the top row may wrap now that it
		   all fits. */
		flex-wrap: wrap;
	}

	/* ---- the top row has to FIT the 50px bar ---------------------------- *
	 * The bar was shrunk from 72px to 50px here (§15) but the controls kept the
	 * sizes §3 of vnm-chrome.css gave them for the taller bar: a 56px logo and
	 * 10px block padding inside a 50px box. The logo alone was 6px taller than
	 * the bar, so the brand, burger and actions all rendered past its bottom
	 * edge. Sized against the bar instead, from a single variable so the bar
	 * height and its contents cannot drift apart.
	 * -------------------------------------------------------------------- */

	.vnm-header {
		--vnm-mobile-bar-h: 50px;
	}

	.vnm-header__brand {
		flex: 0 0 auto;
		align-self: center;
	}

	.vnm-header__logo {
		width: 34px;
		height: 34px;
	}

	/* Kept at 44px: that is the minimum comfortable touch target, and it fits
	   the bar now that the block padding is gone. */
	.vnm-header__burger {
		width: 44px;
		height: 44px;
		align-self: center;
		/* §3 of vnm-chrome.css gives the burger `margin-inline-start: auto` at
		   ALL widths, and gives .vnm-header__actions one too on mobile. Two auto
		   margins SPLIT the free space between them, which left search/login
		   stranded in the middle of the bar with 84px of air on either side.
		   Dropping this one makes the actions' auto margin the only one, so all
		   the slack collects before it and the two sit together at the right
		   edge, separated by the row's own 12px gap. */
		margin-inline-start: 0;
	}

	.vnm-header__actions {
		align-self: center;
	}

	/* ---- the drawer ------------------------------------------------------ *
	 * Behind the page (z-index -1) until it opens, which is what lets the
	 * rotating page reveal it rather than cover it.
	 * --------------------------------------------------------------------- */

	.vnm-header__nav {
		position: fixed;
		top: 55%;
		right: 5%;
		bottom: auto;
		left: auto;
		width: 200px;
		max-width: 85vw;
		margin: 0;
		padding: 0;
		background: transparent;
		box-shadow: none;
		opacity: 0;
		visibility: hidden;
		pointer-events: none;
		z-index: -1;
		transition: opacity 0.4s ease, visibility 0.4s ease;
	}

	/*
	 * TWO SELECTORS, TWO WORLDS.
	 *
	 * With the script running, the drawer is MOVED OUT of `.wp-site-blocks` for
	 * the duration of the open state, so it is no longer a sibling of the
	 * checkbox and the body class is what opens it. That move is not tidiness:
	 * `.wp-site-blocks` takes `transform: rotate(30deg)` while open, and a
	 * transformed element becomes the CONTAINING BLOCK for `position: fixed`
	 * descendants — so a drawer left inside it resolves `top: 55%` against the
	 * whole rotated page (measured: 1325px) and rotates along with it, which is
	 * the one thing this effect must not do. The reference has the same split:
	 * its `.menu-mobile__list` is a sibling of `.pix-slide-content`, not a child.
	 *
	 * Without the script nothing moves, nothing rotates, and the original
	 * checkbox sibling selector still opens the menu in place.
	 */
	#vnm-nav-toggle:checked ~ .vnm-header__nav,
	body.vnm-menu-open .vnm-header__nav {
		opacity: 1;
		visibility: visible;
		pointer-events: auto;
		z-index: 1;
	}

	/* The close animation runs from a body class because the checkbox is already
	   back to unchecked by the time it plays. */
	body.vnm-menu-closing .vnm-header__nav {
		opacity: 0;
		visibility: hidden;
		pointer-events: none;
		z-index: -1;
	}

	.vnm-header__nav ul {
		display: block;
		width: 100%;
		margin: 0;
		padding: 10px 0 40px;
		list-style: none;
	}

	.vnm-header__nav li {
		display: block;
		margin: 0;
		border: none;
		list-style: none;
	}

	.vnm-header__nav a {
		display: block;
		padding: 10px 0;
		color: rgba(255, 255, 255, 0.9);
		font-size: 22px;
		font-weight: 600;
		letter-spacing: 0.5px;
		text-decoration: none;
		text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
		transition: color 0.2s ease, padding-right 0.2s ease;
	}

	/* ---- search: out of the bar, into the drawer ------------------------ *
	 * solutech puts NO search control in the mobile bar. Its bar is logo,
	 * hamburger, cart and the account/login cluster — `templates/header/mobile.php`
	 * lines 15-72 — and the search form lives inside the drawer instead, as the
	 * FIRST child of `.menu-mobile__list`, immediately above the menu container:
	 *
	 *     <div class="menu-mobile__list">
	 *       <div class="pix-mobile-search"> <?php get_search_form(); ?> </div>
	 *       <div class="pix-mobile-menu-container"> ...the items... </div>
	 *     </div>
	 *
	 * Read from the theme source rather than measured: exam.vania-novikau.me is
	 * the surviving solutech install, but its DNS records were never added, so
	 * Caddy has no certificate for it and a browser cannot reach it. The page
	 * does serve over plain HTTP inside node-1, which is how the markup above
	 * was confirmed; the numbers below come from `css/single.css` 418-460.
	 *
	 * DONE IN CSS, NOT IN THE MARKUP. `.vnm-header__searchbox` is already a
	 * SIBLING of `.vnm-header__nav` inside `.vnm-header__inner`, and the script
	 * moves the whole header to <body> as one node, so the box travels with the
	 * drawer for free and the `#vnm-nav-toggle:checked ~` selector still reaches
	 * it. Wrapping the two in a drawer element would have read better, but the
	 * desktop panel opens through `#vnm-search-toggle:checked ~ .vnm-header__searchbox`,
	 * and a wrapper — even `display: contents` — ends that sibling relationship
	 * and silently breaks the desktop search. Two fixed boxes stacked by `top`
	 * costs one variable and touches nothing above 900px.
	 * --------------------------------------------------------------------- */

	.vnm-header {
		/* The reference's field is 46px tall; the nav below is offset by exactly
		   this so the two read as one column. Declared once so they cannot drift. */
		--vnm-drawer-search-h: 46px;

		/* solutech opens the drawer with 30px of air above the field —
		   `.pix-mobile-search { padding: 30px 0 0 }`, css/single.css:418. I
		   quoted that rule when this shipped and then did not apply it, so the
		   field sat flush against the drawer's top edge. MEASURED against the
		   live reference (exam.vania-novikau.me, 390x900, drawer open): field
		   top 525 = drawer top 495 + 30, menu container 571 = 495 + 76. Ours
		   had field 464 = drawer top + 0 and menu +46. */
		--vnm-drawer-search-gap: 30px;
	}

	/* The bar's magnifier and the panel's close button are the two halves of the
	   desktop disclosure. Neither exists in the reference's bar, and with the
	   field permanently in the drawer there is nothing left for them to open or
	   close. */
	.vnm-header__search,
	.vnm-header__search-close {
		display: none;
	}

	/* Same geometry as `.vnm-header__nav` above — the drawer is 200px at
	   `right: 5%`, and the reference's field + button (150 + 46) was sized to
	   sit in it. */
	.vnm-header__searchbox {
		position: fixed;
		top: calc(55% + var(--vnm-drawer-search-gap));
		right: 5%;
		bottom: auto;
		left: auto;
		display: flex;
		width: 200px;
		max-width: 85vw;
		margin: 0;
		padding: 0;
		opacity: 0;
		visibility: hidden;
		pointer-events: none;
		z-index: -1;
		transition: opacity 0.4s ease, visibility 0.4s ease;
	}

	/* The menu starts below the field instead of at the drawer's top edge, which
	   is what the reference does by listing the search first in the flow. */
	.vnm-header__nav {
		top: calc(55% + var(--vnm-drawer-search-gap) + var(--vnm-drawer-search-h));
	}

	/* Opened by the BURGER, not by the search toggle — same two selectors the
	   nav uses, and for the same reason: the checkbox works when the script has
	   not run, the body class works after the header has been re-parented. */
	#vnm-nav-toggle:checked ~ .vnm-header__searchbox,
	body.vnm-menu-open .vnm-header__searchbox {
		opacity: 1;
		visibility: visible;
		pointer-events: auto;
		z-index: 1;
	}

	body.vnm-menu-closing .vnm-header__searchbox {
		opacity: 0;
		visibility: hidden;
		pointer-events: none;
		z-index: -1;
	}

	/* A viewport resized from desktop with the search panel open would arrive
	   here with `#vnm-search-toggle` still checked, and the desktop rule
	   `#vnm-search-toggle:checked ~ .vnm-header__nav { display: none }` would
	   take the whole menu away. Same specificity, later in the cascade. */
	#vnm-search-toggle:checked ~ .vnm-header__nav {
		display: block;
	}

	.vnm-header__searchbox form {
		display: flex;
		align-items: center;
		width: 100%;
		margin: 0;
	}

	/* Core wraps the field in a <label> that also carries a screen-reader span,
	   so the label is kept as the flex item and the field fills it. `min-width: 0`
	   because a flex item's default `min-width: auto` refuses to shrink below the
	   input's intrinsic width and would push the button out of the drawer. */
	.vnm-header__searchbox form label {
		flex: 1 1 auto;
		min-width: 0;
		display: block;
		margin: 0;
	}

	.vnm-header__searchbox input[type="search"],
	.vnm-header__searchbox .search-field {
		width: 100%;
		height: var(--vnm-drawer-search-h);
		padding: 8px 12px;
		color: #1a1a1a;
		font-size: 15px;
		background: #fff;
		border: 0;
		border-radius: 4px 0 0 4px;
	}

	.vnm-header__searchbox input[type="search"]::placeholder,
	.vnm-header__searchbox .search-field::placeholder {
		color: rgba(0, 0, 0, 0.45);
	}

	/* The desktop panel hides the submit and takes Enter instead; the reference's
	   drawer shows it as a square accent button carrying a white magnifier, so it
	   comes back here. The glyph is a background image and the value text is
	   pushed out of the box, exactly as `single.css` does it — the input's value
	   is what an assistive reader announces, so it must not be removed. */
	.vnm-header__searchbox input[type="submit"],
	.vnm-header__searchbox .search-submit {
		display: block;
		flex: 0 0 var(--vnm-drawer-search-h);
		width: var(--vnm-drawer-search-h);
		height: var(--vnm-drawer-search-h);
		padding: 0;
		background-color: var(--pix-main-color, #8888ea);
		background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='6.5' fill='none' stroke='%23ffffff' stroke-width='2'/%3E%3Cline x1='16' y1='16' x2='21' y2='21' stroke='%23ffffff' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
		background-repeat: no-repeat;
		background-position: center;
		background-size: 26px 26px;
		border: 0;
		border-radius: 0 4px 4px 0;
		color: transparent;
		font-size: 0;
		text-indent: -9999px;
		overflow: hidden;
		cursor: pointer;
	}

	/* ---- account menu: opened by tap, hung off the bar's edge ------------ *
	 * TWO THINGS, and the first is why the second was never visible.
	 *
	 * The cluster is a hover disclosure — `.vnm-header__account:hover` reveals
	 * the panel and the icon is a real link to /my-account/ beneath it. A touch
	 * screen has no hover, so a tap could only ever follow the link: the panel
	 * was unreachable on mobile and its seven endpoints with it. The tap is
	 * turned into a disclosure in vnm-mobile-header.js, which sets `.is-open`
	 * here; the link still works above the breakpoint and without JavaScript.
	 *
	 * MEASURED before the change, 390px, logged in: `.vnm-header__account` is a
	 * 20x20 box centred in the 50px bar, ending at y=35. The panel is
	 * `position: absolute; top: 100%` against it, so it would have opened at 35
	 * — 15px ABOVE the bar's bottom edge, overlapping the frosted strip it is
	 * supposed to hang from. Stretching the cluster to the full bar height makes
	 * `top: 100%` mean the bar's bottom edge, which is what it means on desktop,
	 * and it stays correct if the bar height or the admin-bar offset changes.
	 * The icon does not move: `.vnm-header__actions` centres its own children.
	 * --------------------------------------------------------------------- */

	.vnm-header__actions,
	.vnm-header__account {
		align-self: stretch;
	}

	.vnm-header__account.is-open .vnm-header__submenu {
		display: block;
	}

	/* The 10px strip that keeps a travelling POINTER inside the disclosure. With
	   no hover to preserve it is just an invisible tap target hanging below the
	   bar, and stretching the cluster has moved it onto the panel's own edge. */
	.vnm-header__account::after {
		display: none;
	}

	/* ---- tap-to-close backdrop ------------------------------------------ */

	.vnm-mobile-overlay {
		position: fixed;
		inset: 0;
		z-index: 0;
		opacity: 0;
		pointer-events: none;
		cursor: pointer;
		transition: opacity 0.4s ease;
	}

	body.vnm-menu-open .vnm-mobile-overlay {
		opacity: 1;
		pointer-events: auto;
	}

	/* ---- the page, which is what actually moves -------------------------- *
	 * `transform-origin: right var(--vnm-menu-origin-y)` is why the page pivots
	 * about the point the reader is actually looking at instead of about the top
	 * of a document that may be thousands of pixels tall. The script measures it.
	 * --------------------------------------------------------------------- */

	/*
	 * OPAQUE BACKING FOR THE ROTATED CARD, IN THE SITE'S OWN COLOUR.
	 *
	 * The card has to be opaque or the drawer shows through it while it pivots,
	 * but the colour has to be the PAGE's, not a constant. This was `#000`, and
	 * black is only correct on the front page: everywhere the page's own boxes
	 * do not paint, the site wrapper showed through as black under body text
	 * that theme.json sets to `contrast` (#000). Measured on `/my-account/` at
	 * 390px: YITH prints `.username` and `.user-email` in #000 on this #000, so
	 * the account name and address were rendered and INVISIBLE — the element
	 * boxes were the right size the whole time, which is why nothing looked
	 * missing in the DOM. `base` is #ffffff here and is what `body` already
	 * carries, so this makes the wrapper agree with the document instead of
	 * fighting it. The front page's black is restored below, where it belongs.
	 */
	.wp-site-blocks {
		position: relative;
		z-index: 2;
		background: var(--wp--preset--color--base, #fff);
		transform-origin: right var(--vnm-menu-origin-y, 0px);
		transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
			border-radius 0.4s ease,
			box-shadow 0.4s ease;
		backface-visibility: hidden;
	}

	/* The front page is the one document that WANTS a black canvas: its main
	   runs edge to edge over dark art and ends against the near-black footer,
	   so the strip between the carousel and the footer reads as part of the
	   design rather than as a hole. It is `templates/front-page.html` that adds
	   `.vnm-home-canvas`, so the colour now travels with that template instead
	   of with every page on the site. */
	.vnm-home-canvas {
		background: #000;
	}

	body.vnm-menu-open .wp-site-blocks {
		transform: translate3d(0, 0, 0) rotate(30deg);
		border-radius: 16px;
		box-shadow: 10px 12px 44px rgba(0, 0, 0, 0.62);
		pointer-events: none;
		z-index: 9995;
	}

	/* The soft edge the reference casts alongside the rotated page. */
	body.vnm-menu-open .wp-site-blocks::after {
		content: "";
		position: absolute;
		top: -10%;
		left: 99%;
		width: 50px;
		height: 135%;
		background: linear-gradient(90deg, rgba(0, 0, 0, 0.52) 0%, rgba(0, 0, 0, 0.22) 45%, rgba(0, 0, 0, 0) 100%);
		filter: blur(8px);
		transform: translateX(8px) skewY(-11deg);
		pointer-events: none;
	}

	body.vnm-menu-closing .wp-site-blocks {
		transform: translate3d(0, 0, 0) rotate(0deg);
		border-radius: 0;
		box-shadow: none;
		pointer-events: none;
		z-index: 9995;
	}

	/* ---- scroll lock ----------------------------------------------------- *
	 * `position: fixed` on the body is what stops the page scrolling behind the
	 * drawer. It also throws the scroll position away, so the offset is pinned
	 * back with a custom property and restored by the script on close.
	 * --------------------------------------------------------------------- */

	body.vnm-menu-open,
	body.vnm-menu-closing {
		position: fixed;
		top: calc(-1 * var(--vnm-menu-scroll-y, 0px));
		left: 0;
		right: 0;
		width: 100%;
		overflow: hidden;
		overscroll-behavior: none;
		background: #0a0a0a;
	}
}
