/**
 * Sticky Bar: a page's own bar in place of the site header (divb-hq#357,
 * docs/SPEC-sticky-bar.md §7–§8).
 *
 * The bar is printed as the first thing in <body> (`Mf_Sb_Page`), inside a holder of no height
 * of its own: the bar is absolute inside it, so shrinking or hiding it never moves the page.
 * The three behaviours that keep the page below the bar give the holder the bar's full height
 * as padding; that height never changes with the states.
 *
 * The accent is free, so its four colours come from the server as custom properties on the bar
 * (`--mf-sb-acc`, `-ink`, `-on-dark`, `-on-light`), each one readable on the surface it is
 * used on. The states (`is-clear`, `is-small`, `is-hidden`) are set by the script; without it
 * every bar is simply there.
 *
 * Host theme (docs/shared/host-theme.md): the phone menu's button follows the five-class
 * button rule, and every colour rule on a link has its `:root:root:root:root` twin.
 */

/* `flow-root`: the holder is the first box in <body>. Without a height (under `over` and
   `after`) the next box's top margin fell through it and moved the whole body down (19px on
   Twenty Twenty-Four, measured), so a hidden bar still showed its bottom edge. */
.mf-sbw {
	display: flow-root;
	position: sticky;
	top: var(--wp-admin--admin-bar--height, 0);
	z-index: 9990;
	height: 0;
	--mf-sb-full: 64px;
	--mf-sb-away: translateY(calc(-100% - 24px));
}

.mf-sbw--push {
	box-sizing: content-box;
	padding-block-end: var(--mf-sb-full);
}

.mf-sbw:has(> .mf-sb--pill) {
	--mf-sb-full: 74px;
}

/* ---------- the bar ---------- */

.mf-sb {
	position: absolute;
	inset: 0 0 auto 0;
	box-sizing: border-box;
	display: flex;
	align-items: center;
	gap: 20px;
	height: var(--mf-sb-h, 64px);
	margin: 0;
	padding: 0 24px;
	font-size: 16px;
	line-height: 1.2;
	color: var(--mf-sb-ink);
	background: var(--mf-sb-bg);
	border-bottom: 1px solid var(--mf-sb-line);
	-webkit-backdrop-filter: var(--mf-sb-blur, none);
	backdrop-filter: var(--mf-sb-blur, none);
	transition:
		transform 0.4s cubic-bezier(0.16, 1, 0.3, 1),
		background-color 0.3s,
		border-color 0.3s,
		height 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.mf-sb a {
	text-decoration: none;
	background-color: transparent;
}

.mf-sb :focus-visible {
	outline: 2px solid var(--mf-sb-ink);
	outline-offset: 2px;
	border-radius: 4px;
}

.mf-sb .mf-sb__cta:focus-visible {
	outline-offset: 3px;
	border-radius: 999px;
}

.mf-sb .mf-sb__br {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 44px;
	font-size: 17px;
	letter-spacing: -0.02em;
	white-space: nowrap;
	color: var(--mf-sb-ink);
}

:root:root:root:root .mf-sb .mf-sb__br {
	color: var(--mf-sb-ink);
}

.mf-sb .mf-sb__br b {
	font-weight: 700;
}

.mf-sb .mf-sb__br em {
	font-style: normal;
	font-weight: 400;
	color: var(--mf-sb-name);
}

.mf-sb .mf-sb__ttl {
	min-width: 0;
	overflow: hidden;
	font-size: 15px;
	font-weight: 600;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.mf-sb .mf-sb__nav {
	display: flex;
	gap: 4px;
	margin-left: auto;
}

.mf-sb .mf-sb__nav a {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	padding: 0 10px;
	border-radius: 4px;
	font-size: 14px;
	font-weight: 500;
	color: var(--mf-sb-ink);
	opacity: 0.78;
}

:root:root:root:root .mf-sb .mf-sb__nav a {
	color: var(--mf-sb-ink);
}

.mf-sb .mf-sb__nav a:hover,
.mf-sb .mf-sb__nav a[aria-current],
.mf-sb.mf-sb--accent .mf-sb__nav a {
	opacity: 1;
}

.mf-sb .mf-sb__nav a[aria-current] {
	background:
		linear-gradient(var(--mf-sb-mark), var(--mf-sb-mark))
		50% calc(100% - 9px) / calc(100% - 14px) 2px no-repeat;
}

.mf-sb .mf-sb__meta {
	display: flex;
	gap: 16px;
	margin-left: auto;
	font-size: 14px;
	white-space: nowrap;
	opacity: 0.85;
}

.mf-sb .mf-sb__alt {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	margin-left: auto;
	padding: 0 8px;
	font-size: 14px;
	font-weight: 500;
	color: var(--mf-sb-ink);
}

:root:root:root:root .mf-sb .mf-sb__alt {
	color: var(--mf-sb-ink);
}

.mf-sb .mf-sb__cta {
	display: inline-flex;
	align-items: center;
	min-height: 40px;
	margin-left: auto;
	padding: 0 20px;
	border-radius: 999px;
	font-size: 14px;
	font-weight: 600;
	white-space: nowrap;
	color: var(--mf-sb-cta-ink);
	background: var(--mf-sb-cta);
}

:root:root:root:root .mf-sb .mf-sb__cta {
	color: var(--mf-sb-cta-ink);
}

.mf-sb :is(.mf-sb__nav, .mf-sb__meta, .mf-sb__alt) + .mf-sb__cta {
	margin-left: 8px;
}

.mf-sb .mf-sb__prog {
	position: absolute;
	left: 0;
	bottom: -1px;
	width: 100%;
	height: 3px;
	background: var(--mf-sb-mark);
	transform: scaleX(var(--mf-sb-p, 0));
	transform-origin: 0 50%;
}

/* The phone menu's button: hidden on the desktop, the host's button rule at the end. */
.mf-sb .mf-sb__more {
	display: none;
	align-items: center;
	gap: 6px;
	min-height: 44px;
	margin: 0 0 0 auto;
	padding: 0 8px;
	border: 0;
	border-radius: 4px;
	font: inherit;
	font-size: 14px;
	font-weight: 500;
	cursor: pointer;
	--mf-btn-ink: var(--mf-sb-ink);
	--mf-btn-fill: transparent;
}

.mf-sb .mf-sb__more::after {
	content: "";
	width: 7px;
	height: 7px;
	border-right: 1.5px solid currentcolor;
	border-bottom: 1.5px solid currentcolor;
	transform: rotate(45deg) translateY(-2px);
}

.mf-sb .mf-sb__more[aria-expanded="true"]::after {
	transform: rotate(-135deg) translateY(-2px);
}

/* ---------- the four looks (block styles) ---------- */

/* .94, not the live .8: over light sections .8 turns grey and the name drops to 4.2:1. */
.mf-sb.mf-sb--glass,
.mf-sb.mf-sb--pill {
	--mf-sb-solid: #141416;
	--mf-sb-bg: rgba(12, 12, 14, 0.94);
	--mf-sb-blur: blur(40px);
	--mf-sb-line: rgba(255, 255, 255, 0.08);
	--mf-sb-ink: #fff;
	--mf-sb-name: var(--mf-sb-acc-on-dark);
	--mf-sb-mark: var(--mf-sb-acc-on-dark);
	--mf-sb-cta: var(--mf-sb-acc);
	--mf-sb-cta-ink: var(--mf-sb-acc-ink);
}

.mf-sb.mf-sb--light {
	--mf-sb-solid: #f9f9f9;
	--mf-sb-bg: rgba(249, 249, 249, 0.86);
	--mf-sb-blur: blur(24px);
	--mf-sb-line: #e5e5e5;
	--mf-sb-ink: #111;
	--mf-sb-name: var(--mf-sb-acc-on-light);
	--mf-sb-mark: var(--mf-sb-acc-on-light);
	--mf-sb-cta: var(--mf-sb-acc);
	--mf-sb-cta-ink: var(--mf-sb-acc-ink);
}

.mf-sb.mf-sb--accent {
	--mf-sb-solid: var(--mf-sb-acc);
	--mf-sb-bg: var(--mf-sb-acc);
	--mf-sb-line: transparent;
	--mf-sb-ink: var(--mf-sb-acc-ink);
	--mf-sb-name: var(--mf-sb-acc-ink);
	--mf-sb-mark: var(--mf-sb-acc-ink);
	--mf-sb-cta: var(--mf-sb-acc-ink);
	--mf-sb-cta-ink: var(--mf-sb-acc);
}

.mf-sb.mf-sb--pill {
	inset: 10px 16px auto 16px;
	padding: 0 8px 0 20px;
	border: 1px solid rgba(255, 255, 255, 0.1);
	border-radius: 999px;
	box-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.45);
}

/* ---------- the states, set by the script ---------- */

/* See-through over the hero: the hero's own ink, and the accent partner that reads on it. */
.mf-sb.mf-sb.is-clear {
	--mf-sb-bg: transparent;
	--mf-sb-line: transparent;
	--mf-sb-blur: none;
	--mf-sb-ink: var(--mf-sb-hero-ink, #fff);
	--mf-sb-name: var(--mf-sb-hero-acc, var(--mf-sb-acc-on-dark));
	--mf-sb-mark: var(--mf-sb-hero-acc, var(--mf-sb-acc-on-dark));
	box-shadow: none;
}

.mf-sb.is-small {
	--mf-sb-h: 48px;
}

.mf-sb.is-hidden {
	transform: var(--mf-sb-away);
	box-shadow: none;
}

/* "Only after the hero" is hidden from the first paint, not from when the deferred script
   runs; without JavaScript it stays, as every behaviour does. The script adds `is-ready`. */
@media (scripting: enabled) {

	.mf-sbw[data-mf-sb-behaviour="after"] .mf-sb:not(.is-ready) {
		transform: var(--mf-sb-away);
		box-shadow: none;
		transition: none;
	}
}

/* ---------- jump targets land below the bar ---------- */

.mf-sb-on :where(.wp-block-post-content, .entry-content) [id] {
	scroll-margin-top: calc(var(--mf-site-header-height, 0px) + 16px);
}

/* ---------- between phone and desktop, and the phone (D7) ---------- */

@media (max-width: 900px) {

	.mf-sb {
		gap: 12px;
		padding: 0 16px;
	}

	.mf-sb .mf-sb__br b {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip-path: inset(50%);
		white-space: nowrap;
	}

	.mf-sb .mf-sb__nav a {
		padding: 0 7px;
	}
}

@media (max-width: 760px) {

	.mf-sb {
		gap: 10px;
		padding: 0 12px;
	}

	.mf-sb.mf-sb--pill {
		inset: 8px 8px auto 8px;
		padding: 0 6px 0 14px;
	}

	.mf-sb .mf-sb__br {
		font-size: 15px;
	}

	.mf-sb .mf-sb__cta {
		padding: 0 14px;
		font-size: 13px;
	}

	.mf-sb .mf-sb__meta span:not(:first-child),
	.mf-sb .mf-sb__alt,
	.mf-sb .mf-sb__nav {
		display: none;
	}

	.mf-sb :is(.mf-sb__nav, .mf-sb__alt) + .mf-sb__cta {
		margin-left: auto;
	}

	/* S16: the sections as a second row to swipe. */
	.mf-sb.mf-sb--ph-scroll:has(.mf-sb__nav) {
		flex-wrap: wrap;
		row-gap: 0;
		height: auto;
		padding-top: 10px;
	}

	.mf-sbw:has(.mf-sb--ph-scroll .mf-sb__nav) {
		--mf-sb-full: 100px;
	}

	.mf-sb.mf-sb--ph-scroll .mf-sb__nav {
		display: flex;
		flex: 1 0 100%;
		order: 3;
		margin: 0 -12px;
		padding: 0 6px;
		overflow-x: auto;
		scrollbar-width: none;
		-webkit-mask: linear-gradient(90deg, #000 85%, transparent);
		mask: linear-gradient(90deg, #000 85%, transparent);
	}

	.mf-sb.mf-sb--ph-scroll .mf-sb__nav a {
		flex: none;
	}

	/* S17: the sections under a disclosure; opaque, as a blur inside the bar's blur does not. */
	.mf-sb.mf-sb--ph-menu .mf-sb__more {
		display: inline-flex;
	}

	.mf-sb.mf-sb--ph-menu .mf-sb__nav + .mf-sb__cta {
		margin-left: 4px;
	}

	.mf-sb.mf-sb--ph-menu .mf-sb__nav.is-open {
		display: flex;
		flex-direction: column;
		position: absolute;
		top: 100%;
		left: 0;
		right: 0;
		margin: 0;
		padding: 6px 12px 12px;
		background: var(--mf-sb-solid);
		border-bottom: 1px solid var(--mf-sb-line);
	}

	.mf-sb.mf-sb--ph-menu.mf-sb--pill .mf-sb__nav.is-open {
		top: calc(100% + 6px);
		border: 1px solid var(--mf-sb-line);
		border-radius: 14px;
	}
}

@media (max-width: 360px) {

	/* The menu's button keeps its name for screen readers and shows only the chevron. */
	.mf-sb.mf-sb--ph-menu .mf-sb__more {
		gap: 0;
		padding: 0 12px;
		font-size: 0;
	}
}

@media (prefers-reduced-motion: reduce) {

	.mf-sb {
		transition: none;
	}
}

/* The host's button rule (docs/shared/host-theme.md), once, at five classes. */
.mf-sb__more.mf-sb__more.mf-sb__more.mf-sb__more.mf-sb__more {
	color: var(--mf-btn-ink, currentcolor);
	background: var(--mf-btn-fill, transparent);
}
