/*
 * PSE motion and polish — loaded last on every page by functions.php
 * (pse_motion_inject). Additions only: no colour, font or layout grid changes.
 *
 *  1. Header: the nine-item menu stays on one line at every desktop width
 *  2. Homepage hero: the first photograph is painted before the slider loads
 *  3. Sections arrive as they are scrolled to (pse-motion.js)
 *  4. Page-to-page cross-fade
 *  5. Keyboard focus, and less motion for visitors who ask for it
 */

:root {
	--pse-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
	--pse-fast: 0.2s;
	--pse-slow: 0.6s;
}

/* ---------------------------------------------------------------- 1. Header */

/*
 * The menu gained a ninth item (Events) after its spacing was tuned for
 * eight. From 960px to about 1500px wide — most laptops — the items no longer
 * fitted beside the logo, the menu dropped to a second row, and the fixed
 * header doubled from 111px to 221px, a quarter of a 900px screen.
 *
 * Instead of another set of fixed steps, the gap either side of each item is
 * worked out from the room there actually is:
 *
 *   (header width − logo − the nine labels) ÷ 18 gaps, never more than 20px
 *
 * The header is 90% of the window; 15.3px (90% of a 17px scrollbar) and 8px
 * of slack keep it true on Windows, where the scrollbar takes layout width.
 * --pse-nav-logo and --pse-nav-text are the measured widths of the logo and
 * of the labels at each text size below.
 */
@media (min-width: 960px) {
	:root {
		--pse-nav-logo: 193px;
		--pse-nav-text: 793px; /* 16px, 0.6px tracking */
	}

	#site-navigation-wrap .dropdown-menu > li > a {
		padding-left: clamp(5px, calc((90vw - 23.3px - var(--pse-nav-logo) - var(--pse-nav-text)) / 18), 20px) !important;
		padding-right: clamp(5px, calc((90vw - 23.3px - var(--pse-nav-logo) - var(--pse-nav-text)) / 18), 20px) !important;
	}
}

@media (min-width: 960px) and (max-width: 1499px) {
	:root { --pse-nav-text: 747px; } /* 15px, 0.6px tracking */
}

@media (min-width: 960px) and (max-width: 1279px) {
	:root {
		--pse-nav-logo: 160px;
		--pse-nav-text: 676px; /* 14px, 0.3px tracking */
	}

	#site-navigation-wrap .dropdown-menu > li > a { letter-spacing: 0.3px !important; }
}

@media (min-width: 960px) and (max-width: 1099px) {
	:root { --pse-nav-text: 645px; } /* 13.5px, 0.2px tracking */

	#site-navigation-wrap .dropdown-menu > li > a { letter-spacing: 0.2px !important; }
}

@media (min-width: 960px) and (max-width: 1023px) {
	:root {
		--pse-nav-logo: 140px;
		--pse-nav-text: 606px; /* 13px, no tracking */
	}

	#site-navigation-wrap .dropdown-menu > li > a { letter-spacing: 0 !important; }
}

/* ------------------------------------------------------------------ 2. Hero */

/*
 * Smart Slider keeps the whole hero hidden until the page's load event — every
 * script, stylesheet and image — so the first screen stayed blank for as long
 * as the page took to finish loading. This paints the first slide's own
 * photograph, under the same blue shade, the moment the stylesheet arrives.
 *
 * It is drawn where the hero ends up (the top of the page, the full height of
 * the screen), not where the hero sits before pse-enhancements.js pulls it up
 * under the header — so nothing moves when the scripts run. functions.php
 * (pse_hero_first_paint) puts the header in its over-the-hero state from the
 * first paint for the same reason. The slider then appears over the stand-in
 * exactly as before, and pse-motion.js removes it so it cannot show through a
 * cross-fade between slides.
 *
 * Same address, query string included, as the slide's <img>, so the browser
 * fetches the photograph once. z-index −1 keeps it behind everything on the
 * page; only the hero, which has no background of its own, lets it through.
 */
body.home::before {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100vh;
	height: 100svh;
	min-height: 480px;
	z-index: -1;
	pointer-events: none;
	background:
		linear-gradient(180deg, rgba(var(--pse-logo-deep, 4, 38, 92), 0.6) 0%, rgba(var(--pse-logo-deep, 4, 38, 92), 0) 24%),
		linear-gradient(90deg, rgba(var(--pse-logo-deep, 4, 38, 92), 0.88) 0%, rgba(var(--pse-logo-deep, 4, 38, 92), 0.6) 32%, rgba(16, 132, 255, 0.18) 60%, rgba(16, 132, 255, 0) 80%),
		linear-gradient(0deg, rgba(var(--pse-logo-deep, 4, 38, 92), 0.45) 0%, rgba(var(--pse-logo-deep, 4, 38, 92), 0) 30%),
		url('wp-content/uploads/2026/11/hero/hero-1-instrumentation-desktop.webp?v=2') 10% 35% / cover no-repeat; /* the slide's own focus point */
}

@media (max-width: 767px), (orientation: portrait) and (max-width: 1199px) {
	body.home::before {
		background:
			linear-gradient(180deg, rgba(var(--pse-logo-deep, 4, 38, 92), 0.9) 0%, rgba(var(--pse-logo-deep, 4, 38, 92), 0.6) 40%, rgba(16, 132, 255, 0.12) 62%, rgba(16, 132, 255, 0) 100%),
			url('wp-content/uploads/2026/11/hero/hero-1-instrumentation-mobile.webp?v=2') center / cover no-repeat;
	}
}

html.pse-hero-ready body.home::before {
	display: none;
}

/* ------------------------------------------------------ 3. Reveal on scroll */

/*
 * .pse-reveal is only ever added by pse-motion.js, never written into the
 * markup, so with that script blocked, on an old browser, or under
 * prefers-reduced-motion nothing is hidden in the first place.
 */
.pse-reveal {
	opacity: 0;
	transform: translateY(22px);
	transition: opacity var(--pse-slow) var(--pse-ease), transform var(--pse-slow) var(--pse-ease);
	transition-delay: calc(var(--pse-i, 0) * 80ms);
}

.pse-reveal.pse-inview {
	opacity: 1;
	transform: none;
}

@media print {
	.pse-reveal {
		opacity: 1 !important;
		transform: none !important;
	}
}

/* ---------------------------------------------------- 4. Page cross-fade */

@media (prefers-reduced-motion: no-preference) {
	@view-transition {
		navigation: auto;
	}

	::view-transition-old(root),
	::view-transition-new(root) {
		animation-duration: 0.22s;
		animation-timing-function: var(--pse-ease);
	}
}

/* ------------------------------------------------- 5. Focus and less motion */

:where(a, button, summary, [tabindex]):focus-visible {
	outline: 2px solid var(--pse-logo-blue, #1084ff);
	outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
		scroll-behavior: auto !important;
	}
}
