/* #site-header is fixed at top: 0, so the bar is fixed above it and pushes the header and page down by its own height.
   --site-header-height stays untouched, so every offset that uses it still lines up under the header. */
:root:has(#top-bar) {
	--top-bar-height: 3rem;
}

body:has(#top-bar) {
	padding-top: var(--top-bar-height);
}

body:has(#top-bar) #site-header {
	top: var(--top-bar-height);
}

#top-bar {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	z-index: 99;
	height: var(--top-bar-height);
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding-inline: var(--site-padding);
	background: var(--site-header-bg);
	color: var(--site-header-color);
	font-size: 0.9375rem; /* 15px like bjurfors.se, between --font-size-small and --font-size-default */
	font-weight: 300;
	letter-spacing: 0.1em;
	text-transform: uppercase;
}

/* Fade with the header on scroll, same as #site-header */
html.has-scrolled-down #top-bar {
	opacity: 0;
	transition: opacity 0.2s;
}

html.has-scrolled-down.scrolling-up #top-bar {
	opacity: 1;
}

#top-bar ul {
	margin: 0;
	padding: 0;
	list-style: none;
}

#top-bar > a,
#top-bar > ul > li > button {
	display: flex;
	align-items: center;
	gap: 1em;
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	letter-spacing: inherit;
	text-transform: inherit;
	line-height: 24px;
	text-decoration: none;
	cursor: pointer;
}

#top-bar > a:hover,
#top-bar > ul > li > button:hover {
	text-decoration: underline;
}

#top-bar svg {
	fill: currentColor;
}

/* Dropdown */
#top-bar [popover] {
	inset: calc(var(--top-bar-height) + 4px) var(--site-padding) auto auto; /* fallback without anchor positioning */
	margin: 0;
	min-width: 12rem;
	padding: 15px 0;
	border: 0;
	border-radius: 5px;
	box-shadow: 0 0 10px 10px #00000026;
	background: #fff;
	color: #333;
}

@supports (position-area: bottom) {
	#top-bar > ul > li > button {
		anchor-name: --top-bar-lang;
	}

	#top-bar [popover] {
		position-anchor: --top-bar-lang;
		position-area: bottom span-left;
		inset: auto;
		margin-top: 4px;
	}
}

#top-bar [popover] button {
	position: absolute;
	top: 22px;
	right: 33px; /* bjurfors.se: 18px icon in a 32px box, 19px from the edge */
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	cursor: pointer;
}

#top-bar [popover] a {
	display: block;
	padding: 7px 47px 7px 19px;
	color: inherit;
	font-weight: 400;
	letter-spacing: normal;
	text-transform: none;
	text-decoration: none;
	line-height: 1.5;
}

#top-bar [popover] a:hover {
	background: #efedea;
}
