/* Unified navbar (layouts/partials/header.html) and site toolbar (site-toolbar.html), CSS only.
   The navbar is fixed and 50px tall; the toolbar sits under it and scrolls with the page.
   The Inter font is loaded by custom.css. */

.sc-nav {
	--sc-nav-h: 50px;
	--sc-nav-font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--sc-nav-ink: #0b1e2a;
	--sc-nav-text: #4a5b66;
	--sc-nav-muted: #8a99a3;
	--sc-nav-line: rgba(11, 30, 42, 0.08);
	--sc-nav-soft: rgba(0, 116, 199, 0.07);
	--sc-nav-accent: #0074C7; /* same blue as the logo wordmark */
	--sc-nav-accent-dark: var(--secondary, #155A86);
	--sc-nav-bg: #fff;
	--sc-nav-panel: #fff;
	--sc-nav-divider: rgba(11, 30, 42, 0.22);
	--sc-nav-shadow: rgba(11, 30, 42, 0.25);
	--sc-nav-overlay: rgba(11, 30, 42, 0.2);

	position: fixed !important;
	top: 0;
	left: 0;
	right: 0;
	z-index: 1031 !important; /* beats #header { z-index: 1030 } in Porto's theme.css */
	background: var(--sc-nav-bg);
	border-bottom: 1px solid var(--sc-nav-line);
	font-family: var(--sc-nav-font);
	font-size: 0.875rem;
	font-feature-settings: "cv11", "ss01";
	letter-spacing: -0.011em;
	line-height: 1.2;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

.sc-nav-inner {
	position: relative;
	/* logo left, links centered, actions right */
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	align-items: center;
	gap: 2rem;
	height: var(--sc-nav-h);
	max-width: 1240px;
	margin: 0 auto;
	padding: 0 1.5rem;
}

.sc-nav-brand,
.sc-nav-actions {
	position: relative;
	z-index: 2;
}

/* Porto's theme.css underlines every a:not(.btn):hover */
.sc-nav a:not(.btn):hover,
.sc-nav a:not(.btn):focus {
	text-decoration: none;
}

.sc-nav-toggle {
	display: none;
}

/* Brand */

.sc-nav-brand {
	display: flex;
	align-items: center;
	justify-self: start;
	gap: 7px;
	flex-shrink: 0;
	color: var(--sc-nav-ink);
	font-size: 0.95rem;
	font-weight: 600;
	letter-spacing: -0.025em;
	white-space: nowrap;
	text-decoration: none;
}

.sc-nav-brand:hover {
	color: var(--sc-nav-ink);
	text-decoration: none;
}

.sc-nav-wheel {
	width: 26px;
	height: 26px;
	transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.sc-nav-brand:hover .sc-nav-wheel {
	transform: rotate(-120deg);
}

/* proportions of the logo in the old ecosystem bar, slightly smaller:
   wheel 26px, 7px gap, wordmark 12px tall */
.sc-nav-wordmark {
	width: auto;
	height: 12px;
}

/* Dark theme: add .sc-nav--dark to the header, only the tokens change.
   Neutral greys matched to GitLab's dark mode (gitlab.sci-compiler.com). */

.sc-nav--dark {
	--sc-nav-ink: #ececef;
	--sc-nav-text: #bfbfc3;
	--sc-nav-muted: #89888d;
	--sc-nav-line: #333238;
	--sc-nav-soft: rgba(255, 255, 255, 0.06);
	--sc-nav-accent: #38BDF8; /* bright sky blue: the logo blue #0074C7 is too dark on this bar */
	--sc-nav-bg: #18171d;
	--sc-nav-panel: #28272d;
	--sc-nav-divider: #4c4b51;
	--sc-nav-shadow: rgba(0, 0, 0, 0.6);
	--sc-nav-overlay: rgba(0, 0, 0, 0.5);
}

/* the blue logo has too little contrast on the dark bar: wheel in the accent, wordmark white.
   The wheel is recoloured with a mask (its own PNG as the shape, the accent as the fill);
   the url is relative to this stylesheet (/css/navbar.css -> /images/logos/). */
.sc-nav--dark .sc-nav-wheel {
	object-position: -9999px 0;
	background: var(--sc-nav-accent);
	-webkit-mask: url("../images/logos/sci-compiler-wheel.png") center / contain no-repeat;
	mask: url("../images/logos/sci-compiler-wheel.png") center / contain no-repeat;
}

.sc-nav--dark .sc-nav-wordmark {
	filter: brightness(0) invert(1);
}

/* Links */

.sc-nav-menu {
	display: flex;
	align-items: center;
	height: 100%;
}

.sc-nav-links {
	display: flex;
	align-items: center;
	height: 100%;
	margin: 0;
	padding: 0;
	list-style: none;
}

.sc-nav-links > li {
	position: relative;
	height: 100%;
	display: flex;
	align-items: center;
}

.sc-nav-link {
	display: flex;
	align-items: center;
	gap: 0.3rem;
	height: 100%;
	padding: 0 0.7rem;
	border: 0;
	background: none;
	color: var(--sc-nav-text);
	font: inherit;
	font-weight: 450;
	white-space: nowrap;
	text-decoration: none;
	cursor: pointer;
	transition: color 0.15s ease;
}

.sc-nav-link:hover,
.sc-nav-link:focus-visible,
.sc-nav-dropdown:hover > .sc-nav-link,
.sc-nav-dropdown:focus-within > .sc-nav-link {
	color: var(--sc-nav-accent);
	text-decoration: none;
	outline: 0;
}

.sc-nav-link.active {
	color: var(--sc-nav-accent);
	font-weight: 500;
}

.sc-nav-link .fa-chevron-down {
	font-size: 0.5rem;
	color: var(--sc-nav-muted);
}

.sc-nav-divider {
	width: 1px;
	height: 20px;
	margin: 0 0.75rem;
	background: var(--sc-nav-divider);
}

/* Dropdowns: open on hover or keyboard focus */

.sc-nav-submenu {
	position: absolute;
	top: calc(100% - 2px);
	left: 0.2rem;
	min-width: 210px;
	margin: 0;
	padding: 6px;
	list-style: none;
	background: var(--sc-nav-panel);
	border-radius: 12px;
	box-shadow: 0 0 0 1px var(--sc-nav-line), 0 16px 40px -12px var(--sc-nav-shadow);
	opacity: 0;
	visibility: hidden;
	/* closes at once (no fade out), so two submenus never overlap; the bridge below
	   lets the pointer reach the submenu */
	transition: none;
}

/* invisible bridge over the gap between link and submenu */
.sc-nav-submenu::before {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	top: -10px;
	height: 10px;
}

.sc-nav-dropdown:hover > .sc-nav-submenu,
.sc-nav-dropdown:focus-within > .sc-nav-submenu {
	opacity: 1;
	visibility: visible;
	transition: opacity 0.12s ease, visibility 0s;
}

/* a dropdown kept open by keyboard focus closes as soon as the pointer is on another entry */
@media (min-width: 1024px) {
	.sc-nav-menu:hover .sc-nav-dropdown:not(:hover) > .sc-nav-submenu {
		opacity: 0;
		visibility: hidden;
		transition: none;
	}
}

.sc-nav-submenu a {
	display: block;
	padding: 0.55rem 0.75rem;
	border-radius: 8px;
	color: var(--sc-nav-text);
	font-weight: 450;
	white-space: nowrap;
	text-decoration: none;
	transition: color 0.12s ease;
}

.sc-nav-submenu a:hover,
.sc-nav-submenu a:focus-visible,
.sc-nav-submenu a.active {
	color: var(--sc-nav-accent);
	text-decoration: none;
	outline: 0;
}

/* Actions */

.sc-nav-actions {
	display: flex;
	align-items: center;
	justify-self: end;
	gap: 0.35rem;
}

.sc-nav-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 30px;
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	color: var(--sc-nav-text);
	font-size: 0.9rem;
	cursor: pointer;
	user-select: none;
	transition: color 0.15s ease;
}

.sc-nav-icon:hover {
	color: var(--sc-nav-ink);
}

/* Hamburger */

.sc-nav-burger {
	display: none;
	flex-direction: column;
	gap: 4px;
}

.sc-nav-burger span {
	display: block;
	width: 16px;
	height: 1.5px;
	border-radius: 2px;
	background: currentColor;
	transition: transform 0.2s ease, opacity 0.2s ease;
}

.sc-nav-toggle:checked ~ .sc-nav-actions .sc-nav-burger span:nth-child(1) {
	transform: translateY(5.5px) rotate(45deg);
}

.sc-nav-toggle:checked ~ .sc-nav-actions .sc-nav-burger span:nth-child(2) {
	opacity: 0;
}

.sc-nav-toggle:checked ~ .sc-nav-actions .sc-nav-burger span:nth-child(3) {
	transform: translateY(-5.5px) rotate(-45deg);
}

.sc-nav-backdrop {
	display: none;
}

/* Mobile: one hamburger, floating card under the bar */

@media (max-width: 1023px) {
	.sc-nav-inner {
		display: flex;
		justify-content: space-between;
	}

	.sc-nav-burger {
		display: inline-flex;
	}

	.sc-nav-menu {
		position: fixed;
		top: calc(var(--sc-nav-h) + 8px);
		left: 8px;
		right: 8px;
		z-index: 2;
		display: grid;
		grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
		align-items: start;
		gap: 0.5rem;
		height: auto;
		max-height: calc(100vh - var(--sc-nav-h) - 16px);
		overflow-y: auto;
		padding: 0.75rem;
		border-radius: 16px;
		background: var(--sc-nav-panel);
		box-shadow: 0 0 0 1px var(--sc-nav-line), 0 24px 48px -16px var(--sc-nav-shadow);
		opacity: 0;
		visibility: hidden;
		transform: translateY(-4px);
		transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
	}

	.sc-nav-toggle:checked ~ .sc-nav-menu {
		opacity: 1;
		visibility: visible;
		transform: none;
	}

	.sc-nav-toggle:checked ~ .sc-nav-backdrop {
		display: block;
		position: fixed;
		inset: var(--sc-nav-h) 0 0 0;
		z-index: 1;
		margin: 0;
		background: var(--sc-nav-overlay);
		cursor: pointer;
	}

	/* every li becomes a cell of the card grid */
	.sc-nav-links {
		display: contents;
	}

	.sc-nav-divider {
		display: none;
	}

	.sc-nav-links > li {
		display: block;
		height: auto;
	}

	/* plain links: full-width rows on top */
	.sc-nav-links > li:not(.sc-nav-dropdown) {
		grid-column: 1 / -1;
		order: -1;
	}

	.sc-nav-link {
		width: 100%;
		height: 40px;
		padding: 0 0.85rem;
		border-radius: 10px;
		color: var(--sc-nav-ink);
		font-size: 0.95rem;
		font-weight: 500;
	}

	.sc-nav-links > li:not(.sc-nav-dropdown) > .sc-nav-link:hover {
		background: var(--sc-nav-soft);
	}

	/* groups (Resources, Docs, Community): a soft box, small heading followed by a line on the
	   same row, then the links */
	.sc-nav-dropdown {
		margin-top: 0.25rem;
		padding: 0.8rem 0.35rem 0.35rem;
		border-radius: 12px;
		background: color-mix(in srgb, var(--sc-nav-ink) 3%, var(--sc-nav-panel));
	}

	.sc-nav-dropdown > .sc-nav-link,
	.sc-nav-dropdown:hover > .sc-nav-link,
	.sc-nav-dropdown:focus-within > .sc-nav-link {
		display: flex;
		align-items: center;
		gap: 0.75rem;
		height: auto;
		padding: 0 0.6rem 0.45rem;
		background: none;
		color: var(--sc-nav-muted);
		font-size: 0.7rem;
		font-weight: 600;
		letter-spacing: 0.06em;
		text-transform: uppercase;
		pointer-events: none;
	}

	.sc-nav-dropdown > .sc-nav-link::after {
		content: "";
		flex: 1;
		height: 1px;
		background: var(--sc-nav-line);
	}

	.sc-nav-dropdown > .sc-nav-link .fa-chevron-down {
		display: none;
	}

	.sc-nav-submenu,
	.sc-nav-dropdown:hover > .sc-nav-submenu,
	.sc-nav-dropdown:focus-within > .sc-nav-submenu {
		position: static;
		min-width: 0;
		padding: 0;
		border-radius: 0;
		background: none;
		box-shadow: none;
		opacity: 1;
		visibility: inherit;
		transform: none;
		transition: none;
	}

	.sc-nav-submenu::before {
		display: none;
	}

	.sc-nav-submenu a {
		padding: 0.5rem 0.6rem;
		border-radius: 8px;
		color: var(--sc-nav-ink);
		font-size: 0.9rem;
		white-space: normal;
	}

	.sc-nav-submenu a:hover {
		background: var(--sc-nav-panel);
		color: var(--sc-nav-accent);
	}
}

@media (max-width: 419px) {
	.sc-nav-inner,
	.sc-toolbar-inner {
		gap: 1rem;
		padding: 0 1rem;
	}

	.sc-nav-wordmark {
		display: none;
	}

	.sc-toolbar-search {
		flex: 1;
		width: auto;
	}
}

/* Site toolbar: search + login, detached from the navbar, no background */

.sc-toolbar {
	position: absolute;
	top: 50px;
	left: 0;
	right: 0;
	z-index: 1029; /* below the navbar, so its dropdowns open over the toolbar */
	font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	font-size: 0.8125rem;
	letter-spacing: -0.011em;
	-webkit-font-smoothing: antialiased;
}

.sc-toolbar-inner {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 0.75rem;
	height: 56px;
	max-width: 1240px;
	margin: 0 auto;
	padding: 0 1.5rem;
}

.sc-toolbar-search {
	position: relative;
	display: flex;
	align-items: center;
	width: 240px;
	margin: 0;
	color: #8a99a3;
}

.sc-toolbar-search .fa-search {
	position: absolute;
	left: 0.85rem;
	font-size: 0.7rem;
	pointer-events: none;
}

.sc-toolbar-search input {
	width: 100%;
	height: 32px;
	padding: 0 0.9rem 0 2.1rem;
	border: 1px solid transparent;
	border-radius: 999px;
	outline: 0;
	background: rgba(11, 30, 42, 0.05);
	color: #0b1e2a;
	font: inherit;
	transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.sc-toolbar-search input:focus {
	border-color: rgba(0, 116, 199, 0.35);
	background: #fff;
	box-shadow: 0 0 0 3px rgba(0, 116, 199, 0.1);
}

.sc-toolbar-search input::placeholder {
	color: #8a99a3;
}

/* hide the browser's built-in search buttons */
.sc-toolbar-search input::-webkit-search-decoration,
.sc-toolbar-search input::-webkit-search-cancel-button,
.sc-toolbar-search input::-webkit-search-results-button,
.sc-toolbar-search input::-webkit-search-results-decoration {
	display: none;
	-webkit-appearance: none;
}

.sc-toolbar-login {
	display: inline-flex;
	align-items: center;
	height: 32px;
	padding: 0 1rem;
	border: 1px solid rgba(11, 30, 42, 0.12);
	border-radius: 999px;
	background: #fff;
	color: #0b1e2a;
	font-weight: 500;
	white-space: nowrap;
	text-decoration: none;
	transition: border-color 0.15s ease;
}

.sc-toolbar-login:hover,
.sc-toolbar-login:focus {
	border-color: rgba(11, 30, 42, 0.3);
	color: #0b1e2a;
	text-decoration: none !important;
}

.sc-toolbar-avatar {
	display: flex;
}

.sc-toolbar-avatar img {
	width: 32px;
	height: 32px;
	border-radius: 50%;
	box-shadow: 0 0 0 1px rgba(11, 30, 42, 0.1);
	object-fit: cover;
}
