/*
 * Site header. Component-specific sizes from the approved design; the global
 * type presets are not used or changed here.
 *
 * Markup: parts/header.html
 *   .bl-header            outer Group (constrained to the 660px column)
 *   .bl-header__row       flex row: wordmark left, navigation right
 *   .bl-header__title     site title (wordmark)
 *   .bl-header__tagline   subtitle under the wordmark
 *   .bl-header__nav       core Navigation block
 *
 * Below 820px the Navigation block shows its "Menu" button and opens core's
 * overlay. Core switches at 600px; the rules in the 600-820px query move that
 * switch to the design's 820px. The overlay is restyled as a white panel
 * that drops below the header row, as in the design, with "Close" drawn over
 * the "Menu" button. Core's dialog behaviour (focus trap, Escape, scroll lock)
 * is unchanged.
 */

.bl-header {
	position: relative;
	padding-top: 44px;
}

.bl-header__row {
	align-items: baseline;
	gap: 12px 40px;
}

/* Wordmark: Newsreader 21px */
.bl-header__brand {
	gap: 0;
}

.bl-header .bl-header__title {
	margin: 0;
	font-family: var(--wp--preset--font-family--serif);
	font-size: 21px;
	font-weight: 400;
	letter-spacing: 0.005em;
	line-height: 1.1;
}

.bl-header .bl-header__title a,
.bl-header .bl-header__title a:hover {
	color: var(--wp--preset--color--contrast);
	text-decoration: none;
}

/* Subtitle: Source Sans 3, 12px, tracked caps */
.bl-header .bl-header__tagline {
	margin: 4px 0 0;
	font-family: var(--wp--preset--font-family--sans);
	font-size: 12px;
	font-weight: 400;
	letter-spacing: 0.16em;
	line-height: normal;
	text-transform: uppercase;
	color: var(--wp--preset--color--muted);
}

/* Navigation: Source Sans 3, 15px, 28px gaps */
.bl-header .bl-header__nav {
	font-family: var(--wp--preset--font-family--sans);
	font-size: 15px;
	font-weight: 400;
	letter-spacing: 0.02em;
	line-height: normal;
}

.bl-header .bl-header__nav .wp-block-navigation__container {
	gap: 4px 28px;
}

.bl-header .bl-header__nav a.wp-block-navigation-item__content {
	display: inline-block;
	padding: 10px 0;
	color: var(--wp--preset--color--contrast);
	text-decoration: none;
}

.bl-header .bl-header__nav a.wp-block-navigation-item__content:hover {
	color: var(--wp--preset--color--accent-text);
}

/* Current page (and Writing on a single article): 1px rust underline, 7px below the text */
.bl-header .bl-header__nav a.wp-block-navigation-item__content[aria-current="page"],
.bl-header .bl-header__nav .current-menu-ancestor > a.wp-block-navigation-item__content {
	text-decoration: underline;
	text-decoration-color: var(--wp--custom--color--accent);
	text-decoration-thickness: 1px;
	text-underline-offset: 7px;
}

/* Toggle buttons: text label plus a drawn icon */
.bl-header .bl-header__nav :is(.wp-block-navigation__responsive-container-open, .wp-block-navigation__responsive-container-close) {
	align-items: center;
	gap: 10px;
	min-height: 44px;
	padding: 0 0 0 12px;
	font-size: 15px;
	letter-spacing: 0.02em;
	color: var(--wp--preset--color--contrast);
}

.bl-header .bl-header__nav :is(.wp-block-navigation__responsive-container-open, .wp-block-navigation__responsive-container-close)::after {
	content: "";
	display: block;
	background: currentColor;
	-webkit-mask: var(--bl-icon) center / contain no-repeat;
	mask: var(--bl-icon) center / contain no-repeat;
}

.bl-header .bl-header__nav .wp-block-navigation__responsive-container-open::after {
	width: 20px;
	height: 12px;
	--bl-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 12'%3E%3Cpath d='M0 1h20M0 11h20' stroke='%23000' stroke-width='1.4'/%3E%3C/svg%3E");
}

.bl-header .bl-header__nav .wp-block-navigation__responsive-container-close {
	display: inline-flex;
}

.bl-header .bl-header__nav .wp-block-navigation__responsive-container-close::after {
	width: 14px;
	height: 14px;
	--bl-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath d='M1 1l12 12M13 1L1 13' stroke='%23000' stroke-width='1.4'/%3E%3C/svg%3E");
}

/*
 * Overlay as a panel under the header row, out to the page gutters. The row
 * (position: relative for the spine marker) is its containing block.
 */
.bl-header .bl-header__nav {
	position: static;
}

.bl-header .bl-header__nav .wp-block-navigation__responsive-container.is-menu-open {
	position: absolute;
	top: 100%;
	bottom: auto;
	left: calc(-1 * var(--wp--style--root--padding-left));
	right: calc(-1 * var(--wp--style--root--padding-right));
	padding: 8px var(--wp--style--root--padding-right) 20px var(--wp--style--root--padding-left);
	overflow: visible;
	border-bottom: 1px solid var(--wp--preset--color--hairline);
}

.bl-header .bl-header__nav .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-close {
	max-width: none;
}

/* Core pushes the dialog below the admin bar; the panel is already below the header */
.bl-header .bl-header__nav .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-dialog {
	margin-top: 0;
}

/* "Close" sits exactly over "Menu": the row is 44px tall on mobile, plus the panel's 8px top padding */
.bl-header .bl-header__nav .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-close {
	top: -52px;
	right: 0;
	background: var(--wp--preset--color--base);
}

/* Not visibility: hidden, which would stop core returning focus to it on close */
.bl-header .bl-header__nav:has(.is-menu-open) .wp-block-navigation__responsive-container-open {
	opacity: 0;
}

.bl-header .bl-header__nav .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__responsive-container-content {
	padding-top: 0;
	align-items: stretch;
}

.bl-header .bl-header__nav .wp-block-navigation__responsive-container.is-menu-open :is(.wp-block-navigation__container, .wp-block-navigation-item) {
	align-items: stretch;
	gap: 0;
}

/*
 * Each link's tap target spans the whole panel, gutters included: negative
 * margins pull it out to the panel edges and matching padding puts the text
 * back on the page gutter, so the text stays left-aligned with the header.
 */
.bl-header .bl-header__nav .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item__content.wp-block-navigation-item__content {
	display: block;
	margin-inline: calc(-1 * var(--wp--style--root--padding-left)) calc(-1 * var(--wp--style--root--padding-right));
	padding: 12px var(--wp--style--root--padding-right) 12px var(--wp--style--root--padding-left);
	font-size: 17px;
	line-height: 1.4;
}

@media (max-width: 820px) {
	.bl-header {
		padding-top: 28px;
	}

	.bl-header__row {
		flex-wrap: nowrap;
		align-items: center;
	}
}

/* Move core's 600px overlay breakpoint to 820px */
@media (min-width: 600px) and (max-width: 820px) {
	.bl-header .bl-header__nav .wp-block-navigation__responsive-container-open:not(.always-shown) {
		display: flex;
	}

	.bl-header .bl-header__nav .wp-block-navigation__responsive-container:not(.hidden-by-default):not(.is-menu-open) {
		display: none;
	}
}
