/**
 * CFUL 2026 — Header
 *
 * Sticky site header: top bar (logo + top_menu subsite links) and the
 * angled primary-nav strip below it. Colors/spacing/type come exclusively
 * from assets/css/tokens.css custom properties.
 */

/* -------------------------------------------------------------------- */
/* Shared accessibility utility (also used by footer + search markup)   */
/* -------------------------------------------------------------------- */

.screen-reader-text {
	border: 0;
	clip: rect(1px, 1px, 1px, 1px);
	clip-path: inset(50%);
	height: 1px;
	margin: -1px;
	overflow: hidden;
	padding: 0;
	position: absolute;
	width: 1px;
	word-wrap: normal;
}

.screen-reader-text:focus {
	background-color: var(--cful-white);
	border-radius: var(--radius-card);
	box-shadow: 0 0 2px 2px rgba(0, 0, 0, 0.4);
	clip: auto !important;
	clip-path: none;
	color: var(--cful-black);
	display: block;
	font-size: var(--text-sm);
	height: auto;
	left: var(--space-2);
	line-height: var(--leading-normal);
	padding: var(--space-2) var(--space-3);
	text-decoration: none;
	top: var(--space-2);
	width: auto;
	z-index: 1000000;
}

.cful-skip-link {
	left: -9999px;
	position: absolute;
	top: 0;
	z-index: 1000000;
}

.cful-skip-link:focus {
	left: var(--space-2);
}

/* -------------------------------------------------------------------- */
/* Site header shell                                                    */
/* -------------------------------------------------------------------- */

.cful-site-header {
	background: var(--cful-white);
	position: sticky;
	top: 0;
	z-index: 100;
}

/* -------------------------------------------------------------------- */
/* Top bar: logo (left) + top_menu subsite links (right)                */
/* -------------------------------------------------------------------- */

.cful-top-bar {
	background: var(--cful-white);
	border-bottom: var(--border-hairline);
	width: 100%;
}

.cful-top-bar__inner {
	align-items: center;
	display: flex;
	height: var(--header-bar-h);
	justify-content: space-between;
	margin: 0 auto;
	max-width: var(--container-max);
	padding: 0 var(--container-pad);
}

.cful-top-bar__logo {
	display: flex;
	flex: 0 0 auto;
}

.cful-logo-link {
	display: inline-flex;
}

.cful-logo {
	display: block;
	height: auto;
	max-width: 100%;
	width: clamp(220px, 33vw, 473px);
}

.cful-logo-text {
	color: var(--cful-black);
	font-family: var(--font-sans);
	font-size: var(--text-lg);
	font-weight: var(--fw-bold);
	letter-spacing: 0.02em;
}

.cful-top-menu {
	flex: 0 0 auto;
}

.cful-top-menu__list {
	align-items: center;
	display: flex;
	gap: var(--space-6);
	list-style: none;
	margin: 0;
	padding: 0;
}

.cful-top-menu__list .menu-item a {
	color: var(--cful-black);
	font-family: var(--font-sans);
	font-size: var(--text-md);
	font-weight: var(--fw-semibold);
	text-decoration: none;
}

.cful-top-menu__list .menu-item a:hover,
.cful-top-menu__list .menu-item a:focus {
	text-decoration: underline;
}

/* On the comp, "Home" is represented by the logo itself; hide the
   duplicate "Home" text link from the rendered top_menu so only the
   subsite names (HPhil / LanCog / Praxis) show at the right. */
.cful-top-menu__list .menu-item:first-child {
	display: none;
}

/* -------------------------------------------------------------------- */
/* Angled strip: primary_menu                                           */
/* -------------------------------------------------------------------- */

.cful-primary-strip {
	background: var(--cful-white);
	border-bottom: var(--border-hairline);
	min-height: var(--header-strip-h);
	width: 100%;
}

.cful-primary-strip__inner {
	align-items: center;
	display: flex;
	margin: 0 auto;
	max-width: var(--container-max);
	min-height: var(--header-strip-h);
	padding: 0 var(--container-pad);
}

.cful-primary-nav {
	flex: 1 1 auto;
}

.cful-primary-nav__list {
	align-items: center;
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-5) var(--space-6);
	list-style: none;
	margin: 0;
	padding: 0;
}

.cful-primary-nav__list .menu-item a {
	color: var(--cful-black);
	font-family: var(--font-sans);
	font-size: var(--text-sm);
	font-weight: var(--fw-regular);
	text-decoration: none;
}

.cful-primary-nav__list .menu-item a:hover,
.cful-primary-nav__list .menu-item a:focus {
	text-decoration: underline;
}

/* -------------------------------------------------------------------- */
/* Mobile nav toggle (hamburger) — wired up in assets/js/navigation.js  */
/* -------------------------------------------------------------------- */

.cful-nav-toggle {
	background: transparent;
	border: 0;
	cursor: pointer;
	display: none;
	height: var(--space-7);
	padding: var(--space-2);
	width: var(--space-7);
}

.cful-nav-toggle__bars,
.cful-nav-toggle__bars::before,
.cful-nav-toggle__bars::after {
	background: var(--cful-black);
	content: "";
	display: block;
	height: 2px;
	width: 100%;
}

.cful-nav-toggle__bars {
	position: relative;
}

.cful-nav-toggle__bars::before {
	position: absolute;
	top: -7px;
}

.cful-nav-toggle__bars::after {
	position: absolute;
	top: 7px;
}

/* -------------------------------------------------------------------- */
/* Search affordance (id="cful-search"), revealed via :target or .is-open */
/* (assets/js/navigation.js) — see the rule below for both paths.       */
/* -------------------------------------------------------------------- */

.cful-search-overlay {
	align-items: flex-start;
	background: rgba(12, 12, 12, 0.92);
	display: none;
	inset: 0;
	justify-content: center;
	padding-top: var(--space-9);
	position: fixed;
	z-index: 200;
}

/*
 * Two parallel reveal paths so the overlay works with and without JS:
 * - :target — no-JS fallback (browser's hash navigation to #cful-search).
 * - .is-open — JS path (assets/js/navigation.js intercepts the trigger
 *   clicks, prevents the hash jump, and toggles this class instead so
 *   the URL/history stays clean when script is available).
 */
.cful-search-overlay:target,
.cful-search-overlay.is-open {
	display: flex;
}

.cful-search-overlay__panel {
	background: var(--cful-white);
	max-width: 90vw;
	padding: var(--space-6);
	position: relative;
	width: 560px;
}

.cful-search-overlay__close {
	position: absolute;
	top: 0;
	right: 0;
	height: var(--space-6);
	width: var(--space-6);
	align-items: center;
	color: var(--cful-black);
	display: inline-flex;
	font-size: var(--text-xl);
	justify-content: center;
	line-height: 1;
	text-decoration: none;
}

.cful-search-form {
	display: flex;
	gap: var(--space-3);
}

.cful-search-form__field {
	border: var(--border-hairline);
	flex: 1 1 auto;
	font-family: var(--font-sans);
	font-size: var(--text-sm);
	min-height: 40px;
	padding: var(--space-3) var(--space-4);
}

.cful-search-form__submit {
	background: var(--color-primary);
	border: 0;
	color: var(--color-primary-contrast);
	cursor: pointer;
	font-family: var(--font-sans);
	font-size: var(--text-sm);
	font-weight: var(--fw-semibold);
	min-height: 40px;
	padding: var(--space-3) var(--space-5);
}

/* -------------------------------------------------------------------- */
/* Responsive collapse (~900px and below)                               */
/* -------------------------------------------------------------------- */

@media (max-width: 899px) {
	.cful-top-bar__inner {
		height: auto;
		min-height: var(--header-bar-h);
	}

	.cful-top-menu__list {
		gap: var(--space-4);
	}

	.cful-logo {
		width: clamp(160px, 50vw, 320px);
	}

	.cful-primary-strip {
		clip-path: none;
	}

	.cful-nav-toggle {
		display: block;
		order: -1;
	}

	.cful-primary-strip__inner {
		flex-wrap: wrap;
	}

	.cful-primary-nav {
		flex-basis: 100%;
		max-height: 0;
		overflow: hidden;
		transition: max-height 0.25s ease;
	}

	/* JS (a later task) toggles aria-expanded on the button; when true,
	   reveal the menu as a vertical list. Works without JS too: the
	   browser still allows keyboard/focus navigation into the hidden
	   list's links since only max-height/overflow are used, not
	   display:none or visibility:hidden. */
	.cful-nav-toggle[aria-expanded="true"] + .cful-primary-nav,
	.cful-primary-strip__inner:has(.cful-nav-toggle[aria-expanded="true"])
		.cful-primary-nav,
	.cful-primary-nav.is-open {
		max-height: 70vh;
		overflow-y: auto;
	}

	.cful-primary-nav__list {
		flex-direction: column;
		align-items: flex-start;
		gap: var(--space-4);
		padding: var(--space-4) 0;
	}

	.cful-primary-nav__list .menu-item a {
		display: inline-flex;
		min-height: 40px;
		align-items: center;
	}

	.cful-search-overlay {
		padding-top: var(--space-7);
	}

	.cful-search-overlay__panel {
		padding: var(--space-5);
		width: 100%;
	}

	.cful-search-form {
		flex-direction: column;
	}
}
