/**
 * Ohmwork — the site header.
 *
 * One header for every page of ohmwork.net: the WordPress pages and the
 * static browser taster at /try/. This file is the single source; the
 * theme enqueues it and tools/build-web-taster.sh copies it into
 * website/try/css/ so the taster loads the identical rules. Edit it
 * here only, then run the build.
 *
 * The header runs the full width of the sheet on every page, whatever
 * width the content below it takes: the mark and name at the left
 * edge, the section links in the instrument voice, the Run-green
 * button at the right edge. It is sticky and translucent, takes a
 * shadow once the page has scrolled, and on a narrow screen folds the
 * links into a menu behind a button. Every colour and face has a
 * fallback, so the file stands alone wherever it is loaded.
 *
 * Mobile first: the base rules are the phone layout; the one media
 * query opens the row out once there is room for it.
 *
 * Author: Steve Austen, The PCGP.
 */

/* The header's height as a token, so anchored sections can land clear
   of it (the rule on [id] below) and pages can offset their own sticky
   parts from it. */
:root {
	--site-header-h: 3.75rem;
}

/* A jump to #section lands below the sticky header, not under it. */
[id] {
	scroll-margin-top: calc(var(--site-header-h) + 1rem);
}

/* ---- Skip link: off-screen until it takes focus ------------------ */
.skip-link {
	position: absolute;
	left: -999px;
	top: 0;
	z-index: 100;
	padding: 0.6rem 1rem;
	background: var(--wire, #2e5e2e);
	color: #ffffff;
	font-weight: 700;
	text-decoration: none;
	border-radius: 0 0 8px 0;
}

.skip-link:focus {
	left: 0;
	top: 0;
}

/* ---- The bar ------------------------------------------------------ */
.site-header {
	position: sticky;
	top: 0;
	z-index: 50;
	background: rgba(250, 250, 247, 0.86);
	backdrop-filter: blur(12px);
	-webkit-backdrop-filter: blur(12px);
	border-bottom: 1px solid var(--rule, #dddad2);
	transition: box-shadow 0.2s ease;
}

/* Once the page has scrolled the bar lifts off the sheet. */
.site-header.is-stuck {
	box-shadow: 0 8px 24px -18px rgba(32, 32, 32, 0.45);
}

.site-header-bar {
	min-height: var(--site-header-h);
	padding: 0 1rem;
	display: flex;
	align-items: center;
	gap: 0.6rem;
}

/* Every control in the bar shows the same focus ring. */
.site-header a:focus-visible,
.site-header button:focus-visible {
	outline: 2px solid var(--wire, #2e5e2e);
	outline-offset: 3px;
	border-radius: 4px;
}

/* ---- Brand -------------------------------------------------------- */
.site-brand {
	display: inline-flex;
	align-items: center;
	gap: 0.55rem;
	margin-right: auto;
	color: var(--ink, #202020);
	text-decoration: none;
}

.site-brand:hover {
	color: var(--ink, #202020);
}

.site-brand-mark {
	width: 30px;
	height: 30px;
	flex: none;
}

.site-brand-name {
	font-family: var(--serif, "Fraunces", Georgia, "Times New Roman", serif);
	font-size: 1.35rem;
	font-weight: 500;
	letter-spacing: 0.005em;
	line-height: 1;
}

/* ---- The button --------------------------------------------------- */
.site-cta {
	display: inline-flex;
	align-items: center;
	gap: 0.45rem;
	padding: 0.55rem 0.9rem;
	background: var(--wire, #2e5e2e);
	color: #ffffff;
	border: 1.5px solid var(--wire, #2e5e2e);
	border-radius: 8px;
	font-family: var(--sans, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
	font-size: 0.88rem;
	font-weight: 700;
	line-height: 1.2;
	white-space: nowrap;
	text-decoration: none;
	box-shadow: 0 2px 0 rgba(32, 32, 32, 0.25);
	transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.site-cta:hover,
.site-cta:focus-visible {
	background: var(--wire-deep, #234a23);
	color: #ffffff;
	transform: translateY(-1px);
	box-shadow: 0 3px 0 rgba(32, 32, 32, 0.25);
}

.site-cta:active {
	transform: translateY(1px);
	box-shadow: none;
}

.site-cta-glyph {
	font-size: 0.8em;
}

/* A page may give the button a short label for phones beside the full
   one (the taster's "Choose a lesson" is "Lessons" there); the full
   label alone is fine and shows everywhere. */
.site-cta:has(.site-cta-short) .site-cta-long {
	display: none;
}

/* ---- The menu button (phones only) ------------------------------- */
.site-menu-toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	min-width: 2.75rem;
	min-height: 2.75rem;
	padding: 0.4rem 0.7rem;
	background: transparent;
	color: var(--ink, #202020);
	border: 1.5px solid var(--rule, #dddad2);
	border-radius: 8px;
	font-family: var(--mono, "IBM Plex Mono", Menlo, Consolas, monospace);
	font-size: 0.74rem;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	cursor: pointer;
}

.site-menu-toggle:hover {
	border-color: var(--wire, #2e5e2e);
	color: var(--wire, #2e5e2e);
}

/* Three bars that fold into a cross when the menu is open. */
.site-menu-icon {
	position: relative;
	width: 18px;
	height: 12px;
	flex: none;
}

.site-menu-icon::before,
.site-menu-icon::after,
.site-menu-icon > i {
	content: "";
	position: absolute;
	left: 0;
	width: 18px;
	height: 2px;
	background: currentColor;
	border-radius: 1px;
	transition: transform 0.2s ease, opacity 0.2s ease;
}

.site-menu-icon::before { top: 0; }
.site-menu-icon > i { top: 5px; }
.site-menu-icon::after { top: 10px; }

.site-menu-toggle[aria-expanded="true"] .site-menu-icon::before { transform: translateY(5px) rotate(45deg); }
.site-menu-toggle[aria-expanded="true"] .site-menu-icon > i { opacity: 0; }
.site-menu-toggle[aria-expanded="true"] .site-menu-icon::after { transform: translateY(-5px) rotate(-45deg); }

/* On the narrowest screens the button is its icon alone; the word is
   still read out. */
.site-menu-label {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/* Without the script there is nothing to press: the links simply show. */
html:not(.has-js) .site-menu-toggle {
	display: none;
}

/* ---- The links ---------------------------------------------------- */
.site-nav-list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.site-nav a {
	font-family: var(--mono, "IBM Plex Mono", Menlo, Consolas, monospace);
	font-size: 0.78rem;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--ink-soft, #52524e);
	text-decoration: none;
	white-space: nowrap;
}

.site-nav a:hover,
.site-nav a:focus-visible {
	color: var(--wire, #2e5e2e);
}

/* The page, or the section in view, is marked in ink. */
.site-nav a[aria-current] {
	color: var(--ink, #202020);
}

/* Phone: the links are a panel that drops from the bar. */
.has-js .site-nav {
	display: none;
	position: absolute;
	top: 100%;
	left: 0;
	right: 0;
	background: var(--paper, #fafaf7);
	border-bottom: 1px solid var(--rule, #dddad2);
	box-shadow: 0 16px 32px -20px rgba(32, 32, 32, 0.45);
}

.has-js .site-nav.is-open {
	display: block;
}

.has-js .site-nav-list {
	padding: 0.4rem 1rem 0.9rem;
}

.has-js .site-nav a {
	display: block;
	padding: 0.85rem 0.25rem;
	border-bottom: 1px solid var(--rule, #dddad2);
}

.has-js .site-nav li:last-child a {
	border-bottom: 0;
}

/* The current item wears a wire down its left edge. */
.has-js .site-nav a[aria-current] {
	padding-left: 0.85rem;
	box-shadow: inset 3px 0 0 var(--wire, #2e5e2e);
}

/* Without the script the links run in a row under the bar, scrolling
   sideways on a phone; the fade at the right says so. */
html:not(.has-js) .site-header-bar {
	flex-wrap: wrap;
}

html:not(.has-js) .site-nav {
	flex: 1 0 100%;
	order: 3;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	padding-bottom: 0.6rem;
	mask-image: linear-gradient(to right, #000 calc(100% - 2rem), transparent);
	-webkit-mask-image: linear-gradient(to right, #000 calc(100% - 2rem), transparent);
}

html:not(.has-js) .site-nav-list {
	display: flex;
	gap: 1.1rem;
}

/* ---- A little room: the button's word and the full label ------------ */
@media (min-width: 40rem) {
	.site-menu-label {
		position: static;
		width: auto;
		height: auto;
		margin: 0;
		overflow: visible;
		clip: auto;
		clip-path: none;
		white-space: nowrap;
	}

	.site-cta:has(.site-cta-short) .site-cta-long {
		display: inline;
	}

	.site-cta-short {
		display: none;
	}
}

/* ---- Room for the row: one line, links centred --------------------- */
@media (min-width: 52rem) {
	.site-header-bar {
		padding: 0 1.25rem;
		gap: 1.25rem;
		flex-wrap: nowrap;
	}

	.site-menu-toggle {
		display: none;
	}

	/* The links sit between brand and button, whatever the script. */
	.site-nav,
	.has-js .site-nav,
	html:not(.has-js) .site-nav {
		display: block;
		position: static;
		flex: 1 1 auto;
		order: 0;
		overflow: visible;
		padding: 0;
		background: transparent;
		border: 0;
		box-shadow: none;
		mask-image: none;
		-webkit-mask-image: none;
	}

	.site-nav-list,
	.has-js .site-nav-list,
	html:not(.has-js) .site-nav-list {
		display: flex;
		justify-content: center;
		gap: 1.7rem;
		padding: 0;
	}

	.site-nav a,
	.has-js .site-nav a {
		position: relative;
		display: inline-block;
		padding: 0.4rem 0;
		border: 0;
		box-shadow: none;
	}

	.has-js .site-nav a[aria-current] {
		padding-left: 0;
		box-shadow: none;
	}

	/* An underline of wire that draws in from the left. */
	.site-nav a::after {
		content: "";
		position: absolute;
		left: 0;
		right: 0;
		bottom: 0;
		height: 2px;
		background: var(--wire, #2e5e2e);
		transform: scaleX(0);
		transform-origin: left center;
		transition: transform 0.2s ease;
	}

	.site-nav a:hover::after,
	.site-nav a:focus-visible::after,
	.site-nav a[aria-current]::after {
		transform: scaleX(1);
	}
}

@media (min-width: 64rem) {
	.site-header-bar {
		padding: 0 1.75rem;
	}

	.site-nav-list,
	.has-js .site-nav-list,
	html:not(.has-js) .site-nav-list {
		gap: 2.1rem;
	}
}

/* ---- Nothing moves for those who asked for that ------------------- */
@media (prefers-reduced-motion: reduce) {
	.site-header,
	.site-cta,
	.site-menu-icon::before,
	.site-menu-icon::after,
	.site-menu-icon > i,
	.site-nav a::after {
		transition: none;
	}

	.site-cta:hover,
	.site-cta:focus-visible,
	.site-cta:active {
		transform: none;
	}
}
