/*
 * Chrome: header, phone menu, page transitions, touch response.
 * Loaded on every page after motion.css. Only transform, opacity and
 * clip-path move; colours change on hover and focus only.
 */

/* ------------------------- Sticky header ------------------------------- */
:root {
	--header-h: 78px;
}
@media (min-width: 900px) {
	:root {
		--header-h: 100px;
	}
}
html {
	/* Anchors (#form, #firms, #swipein) land below the sticky header. */
	scroll-padding-top: calc(var(--header-h) + 16px);
}
.site-header {
	position: sticky;
	top: 0;
	view-transition-name: site-header;
}
/* Page background and hairline appear once the visitor has scrolled. */
.site-header::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: -1;
	background: var(--bg);
	border-bottom: 1px solid var(--line);
	opacity: 0;
	pointer-events: none;
}
.site-header.is-scrolled::before,
html:not(.js) .site-header::before {
	/* Without JavaScript the bar cannot tell it has scrolled, so it always
	   carries its background and never sits over the page text. */
	opacity: 1;
}

@media (prefers-reduced-motion: no-preference) {
	.site-header {
		transition: transform 0.3s var(--ease-out);
	}
	.site-header::before {
		transition: opacity var(--dur-fast) linear;
	}
	/* Tighter bar: slide up a little (transform, so nothing below shifts). */
	.site-header.is-scrolled {
		transform: translate3d(0, -6px, 0);
	}
	html .site-header.is-hidden {
		transform: translate3d(0, calc(-100% - 8px), 0);
	}
	html.menu-open .site-header,
	.site-header:focus-within {
		transform: none;
	}
}
@media (min-width: 900px) and (prefers-reduced-motion: no-preference) {
	.site-header.is-scrolled {
		transform: translate3d(0, -8px, 0);
	}
}

/* ----------------------------- Phone menu ------------------------------ */
html.menu-open {
	overflow: hidden;
}
.site-menu__panel {
	overscroll-behavior: contain;
	min-height: calc(100vh - var(--header-h));
	/* A phone on its side is shorter than the menu: let the panel scroll. */
	max-height: calc(100vh - var(--header-h));
	overflow-y: auto;
}
@supports (height: 100dvh) {
	.site-menu__panel {
		min-height: calc(100dvh - var(--header-h));
		max-height: calc(100dvh - var(--header-h));
	}
}
.site-menu__list li:nth-child(1) { --n: 0; }
.site-menu__list li:nth-child(2) { --n: 1; }
.site-menu__list li:nth-child(3) { --n: 2; }
.site-menu__list li:nth-child(4) { --n: 3; }
.site-menu__list li:nth-child(5) { --n: 4; }
.site-menu__list li:nth-child(6) { --n: 5; }
.site-menu__panel > .btn { --n: 6; }
.site-menu__email { --n: 7; }

@keyframes htech-menu-in {
	from { opacity: 0; transform: translate3d(0, -12px, 0); }
	to { opacity: 1; transform: none; }
}
@keyframes htech-menu-out {
	from { opacity: 1; transform: none; }
	to { opacity: 0; transform: translate3d(0, -8px, 0); }
}
@keyframes htech-menu-rise {
	from { opacity: 0; transform: translate3d(0, 14px, 0); }
	to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: no-preference) {
	.js .site-menu[open] .site-menu__panel {
		animation: htech-menu-in 0.3s var(--ease-out) both;
	}
	.js .site-menu[open] .site-menu__list li,
	.js .site-menu[open] .site-menu__panel > .btn,
	.js .site-menu[open] .site-menu__email {
		animation: htech-menu-rise var(--dur) var(--ease-out) both;
		animation-delay: calc(60ms + var(--n, 0) * 55ms);
	}
	.js .site-menu.is-closing .site-menu__panel {
		animation: htech-menu-out 0.16s ease-in both;
	}
	.js .site-menu.is-closing .site-menu__list li,
	.js .site-menu.is-closing .site-menu__panel > .btn,
	.js .site-menu.is-closing .site-menu__email {
		animation: none;
	}
}

/* --------------------------- Page transitions -------------------------- */
@view-transition {
	navigation: auto;
}
::view-transition-group(root) {
	animation-duration: 0.25s;
}
/* The header is the same on both pages: keep it steady, no cross-fade. */
::view-transition-old(site-header) {
	display: none;
}
::view-transition-new(site-header) {
	animation: none;
}
@media (prefers-reduced-motion: reduce) {
	@view-transition {
		navigation: none;
	}
}

/* ---------------------------- Touch response --------------------------- */
.btn {
	transition:
		background-color 0.15s ease,
		border-color 0.15s ease,
		color 0.15s ease,
		transform 0.15s var(--ease-out);
}
.btn:active {
	transform: scale(0.98);
}

.link > span {
	transition: box-shadow var(--dur-fast) ease;
}
/* Same thicker line as before, drawn inside the box so nothing shifts. */
.link:hover > span,
.link:focus-visible > span,
a.card--link:hover .link > span {
	border-bottom-width: 2px;
	padding-bottom: 4px;
	box-shadow: inset 0 -2px 0 var(--accent);
}
.link > span {
	box-shadow: inset 0 -2px 0 transparent;
}

@media (min-width: 900px) {
	.site-nav__list a {
		position: relative;
	}
	.site-nav__list a:hover,
	.site-nav__list .current-menu-item a {
		box-shadow: none;
	}
	.site-nav__list a::after {
		content: "";
		position: absolute;
		left: 0;
		right: 0;
		bottom: -2px;
		height: 2px;
		background: var(--accent);
		transform: scaleX(0);
		transform-origin: left center;
		transition: transform 0.3s var(--ease-out);
	}
	.site-nav__list a:hover::after,
	.site-nav__list a:focus-visible::after,
	.site-nav__list .current-menu-item a::after {
		transform: scaleX(1);
	}
}

.card--link,
.tile {
	/* The lift uses `translate`, so it never fights a reveal's `transform`. */
	transition:
		translate var(--dur-fast) var(--ease-out),
		border-color var(--dur-fast) ease;
}
.card--link:focus-within,
.tile:focus-within {
	border-color: var(--field);
}
@media (hover: hover) {
	.card--link:hover,
	.tile:hover {
		translate: 0 -3px;
		border-color: var(--field);
	}
}
.card--link:focus-visible,
.tile:focus-visible {
	translate: 0 -3px;
}

.topics a span {
	transition: transform var(--dur-fast) var(--ease-out);
}
.topics a:focus-visible span {
	transform: translateX(4px);
}
