/* standard classes and general style */

:root {
	--text: #333;
	--accent: #fff;
	--bg: #fdfdfd;
	--nav-bg: linear-gradient(#4965f2,#1835f6);
	--nav-fg: #fafafa;
	--link-fg: #000;
	--code-fg: #111;
	--code-bg: #ddd;
	--hovered-menu-bg:linear-gradient(#a0affb,#7183f9);
	--hovered-link-bg: #a0affbaa;
	--search-panel-wrapper-bg: #fffe;
	--search-result-border: none;
	--search-results-bg: linear-gradient(#dde3ff,#c0c7f6);
	--search-result-link-fg: #000c;
	--hovered-search-result-link-fg: #000;
}

html, body, div, nav, header {
	margin: 0;
	padding: 0;
}
html {
	scroll-padding-top: 100px;
}
body {
	color: var(--text);
	background: var(--bg);
	font-family: Arial, sans-serif;
	font-size: 17px;
	font-weight: 400;
	line-height: 1.5;
}

nav ul {
	list-style-type: none;
}
nav li {
	list-style: none;
	display: inline-block;
}

kbd {
	padding: 2px 4px;
	color: var(--accent);
	background: var(--nav-bg);
	border-radius: 2px;
	box-shadow: none;
	font-weight: bold;
	margin: 1px;
}

kbd.b {
	font-size: 18px;
	padding: 0 5px;
}

/* Common nav */

nav ul, nav li, nav a {
	margin: 0;
	padding: 0;
}
nav a {
	color: var(--nav-fg);
	text-decoration: none;
}

/* Top navigation bar */

@media (max-width: 768px) { /* mobile */
	body:has(#nav-toggle:checked) {
		overflow-y: hidden; /* prevent scrolling when menu is open */
	}
	ul.nav-menu {
		background: var(--nav-bg);
		color: var(--nav-fg);
		width: 100%;
		flex-direction: column;
	}
	nav.site-nav {
		flex-direction: column;
	}
	nav.site-nav > ul.nav-menu {
		position: absolute;
		top: 42px;
		left: 0;
		min-width: 200px;
		opacity: 0;
		visibility: hidden;
		transform: translateY(-10px);
		transition: all 0.3s ease;
		flex-direction: column;
		overflow-y: auto;
		max-height: calc(100vh - 42px);
	}
	#nav-toggle {
		display: none; /* hide checkbox */
	}
	.nav-toggle-label {
		padding: 8px 14px;
		border-radius: 5px;
		cursor: pointer;
		display: inline-block;
		user-select: none;
	}
	/* Show menu when hamburger checkbox is checked */
	nav.site-nav #nav-toggle:checked ~ ul.nav-menu {
		opacity: 1;
		visibility: visible;
		transform: translateY(0);
	}
	ul.nav-menu ul.nav-menu .nav-item {
		padding-left: 20px;
	}
}
@media (min-width: 768px) { /* wide screens */
	nav.site-nav > ul.nav-menu {
		flex-direction: row;
	}
	.nav-item .nav-menu { /* revealed on hover */
		display: none;
		position: relative;
	}
	.nav-item:hover .nav-menu {
		position: absolute;
	}
	#nav-toggle, .nav-toggle-label { /* hide hamburger on wide screens */
		display: none;
	}
	nav.site-nav {
		flex-direction: row;
		align-items: center;
	}
	nav.before-menu, nav.after-menu {
		flex-direction: row;
		align-items: center;
	}
	nav.site-nav .nav-item:has(.selected) > a {
		background: var(--hovered-menu-bg);
		color: var(--accent);
	}
}

header {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	z-index: 100;
	display: flex;
	flex-direction: row;
	align-items: center;
	background: var(--nav-bg);
	border-bottom: 1px solid var(--accent);
	justify-content: space-between;
	color: var(--nav-fg);
}
.nav-link img, .nav-link svg {
	max-width: 40px;
	max-height: 40px;
	margin: 0 10px;
}
.nav-link svg, .nav-link svg path {
    fill: var(--nav-fg);
    stroke: var(--nav-fg);
}
.nav-link:hover {
    color: var(--nav-fg-accent);
}
.nav-link.search-opener svg {
	max-width: 30px;
	max-height: 30px;
	margin: 0 5px 0 5px;
}
.nav-link.previous-page-link svg, .nav-link.next-page-link svg {
	max-width: 30px;
	max-height: 30px;
	margin: 0 0 0 10px;
}
.nav-link.github {
	margin-left: 20px;
}
.nav-link.search-opener img {
	transform: scale(0.7);
	margin: 0 5px 0 5px;
}
.nav-link.previous-page-link img, .nav-link.next-page-link img {
	transform: scale(0.5);
	margin: 0 0 0 10px;
}
.search-opener, .previous-page-link, .next-page-link {
	opacity: 0.65;
}
.search-opener:hover, .previous-page-link:hover, .next-page-link:hover {
	opacity: 1;
}
header .nav-link.home-link span {
	margin: 0 20px 0 10px;
	font-weight: bold;
}
nav.before-menu, nav.after-menu {
	flex: 1 1 10%;
	display: flex;
}
nav.before-menu {
	justify-content: space-between;
}
nav.after-menu {
	justify-content: flex-end;
}
nav.site-nav {
	flex: 0 0 auto;
	display: flex;
}
ul.nav-menu {
	flex: 0 0 auto;
	display: flex;
}
nav.site-nav > ul.nav-menu {
	align-items: stretch;
}

nav.site-nav a:hover {
	background: var(--hovered-menu-bg);
}
nav.site-nav .selected > a {
	background: var(--hovered-menu-bg);
	color: var(--accent);
}

.nav-item a {
	flex: 0 0 auto;
	padding: 0.8rem 0.5rem;
	display: flex;
}
.nav li {
	flex: 0 0 auto;
	display: flex;
}
.nav-item:has(.nav-menu) > a:after {
	content: " ▼";
	font-size: 0.9rem;
	margin-top: 2px;
	margin-left: 4px;
}
.nav-item:hover .nav-menu {
	display: flex;
	flex-direction: column;
	justify-content: flex-start;
	align-items: stretch;
	background: var(--nav-bg);
}
.nav-item:hover .nav-menu .nav-item {
	flex: 0 0 auto;
}
.nav-item .nav-menu .nav-item a {
	padding: 8px 24px 8px 12px;
}
.nav-item .nav-menu .nav-item a:hover {
	background: var(--hovered-menu-bg);
	color: var(--accent);
}

.before-menu, .after-menu {
	display: flex;
	flex-direction: row;
	align-items: stretch;
}
.nav-link {
	display: flex;
	flex-direction: row;
	align-items: center;
}
.nav-link.unexpanded,  .nav-link.unexpanded:hover {
	opacity: 0.1;
}
.nav-link img {
	max-width: 40px;
	max-height: 40px;
	margin: 0 10px;
}
.nav-link span {
	margin: 0 5px;
}
.nav-link:hover {
	color: var(--accent);
}

.external-nav-link {
	opacity: .6;
	transition: opacity .5s;
}
.external-nav-link:hover {
	opacity: 1;
	transition: opacity .5s;
}

/* article layout */

@media (max-width: 768px) { /* mobile */
	aside.page-nav {
		/* display: none; */ /* uncomment to hide side nav on small screens */
	}
	nav.page-toc {
	}
	nav.page-toc ul.toc-content { /* hide TOC on small screens */
		display: none;
	}
	article nav.page-toc a.toc-title { /* still show page name */
		margin-top: 40px;
		margin-left: 0;
		margin-right: 0;
		margin-bottom: 10px;
		padding: 10px 0;
		background: var(--nav-bg);
		display: flex;
		justify-content: center;
		flex-direction: row;
		align-items: center;
		color: var(--nav-fg);
		font-size: 16px;
	}
	main {
		margin: 10px 20px 40px 20px;
	}
}
@media (min-width: 768px) { /* wide screens */
	article {
		margin: 80px auto 40px auto;
		max-width: 1000px;
		display: flex;
		flex-direction: row;
	}
	aside.page-nav {
		flex: 0 0 25%;
		max-width: 25%;
		position: relative;
		padding-right: 20px;
	}
	main {
		flex: 0 0 75%;
		min-width: 0;
	}
	nav.page-toc {
		padding: 7px;
	}
}

/* article's TOC */

nav.page-toc {
	top: 80px;
	position: sticky;
	overflow-x: hidden;
	overflow-y: auto;
	max-height: calc(100vh - 90px);
}

nav.page-toc a.toc-title {
	font-weight: bold;
	font-size: 18px;
	margin-left: 20px;
	padding-bottom: 8px;
	align-self: start;
	color: var(--text);
}
nav.page-toc .toc-content {
	background: var(--nav-bg);
	padding-top: 10px;
	padding-bottom: 10px;
	border-radius: 5px;
	width: 100%;
	display: flex;
	flex-direction: column;
	align-items: stretch;
	box-shadow: 0 2px 4px rgba(0,0,0,.6);
}

nav.page-toc .toc-item.active {
	background: var(--hovered-menu-bg);
}
nav.page-toc .toc-item:hover {
	background: var(--hovered-menu-bg);
}
nav.page-toc a {
	display: inline-block;
	width: 100%;
}
nav.page-toc .toc-item:hover a {
	color: var(--accent);
}
nav.page-toc .h1, nav.page-toc .h2 {
	display: flex;
	align-items: stretch;
}
nav.page-toc .h1 {
	padding: 8px 10px 8px 15px;
	font-size: 100%;
}
nav.page-toc .h2 {
	padding: 6px 10px 6px 30px;
	font-size: 90%;
}
nav.page-toc .h3 {
	display: none; /* remove this line to show h3 in TOC */
	padding: 6px 10px 6px 40px;
	font-size: 85%;
}
nav.page-toc .h4 {
	display: none; /* remove this line to show h4 in TOC */
	padding: 6px 10px 6px 50px;
	font-size: 80%;
}

/* article main content */

main img {
	max-width: 100%;
	display: block;
	padding: 0;
	line-height: 1.428571429;
	border: none;
	border-radius: 0;
	margin: 10px auto 20px auto;
}

pre {
	overflow-x: auto;
}

code {
    padding: 2px 5px;
    background: #fff;
    white-space: pre-wrap;
    word-wrap: break-word;
	border-radius: 0;
	color: var(--code-fg);
	background: var(--code-bg);
    font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
	font-size: 80%;
}

pre code {
    display: block;
    background: transparent;
    border: none;
    white-space: pre;
    word-wrap: normal;
}

kbd {
    padding: 2px 4px;
    font-size: 90%;
    color: #fff;
    background-color: #333;
    border-radius: 3px;
    box-shadow: inset 0 -1px 0 rgba(0,0,0,.25);
}
pre {
	padding: 0;
	border-radius: 5px;
	color: var(--code-fg);
	background: var(--code-bg);
	border: solid 1px var(--code-bg);
	font-weight: normal;
	padding: 6px 0 4px 6px;
	max-width: 800px;
}

p {
	margin-top: 0;
	margin-bottom: 1rem;
}
ol, ul, dl {
	margin-top: 0;
	margin-bottom: 1rem;
}

main a {
	text-decoration: underline;
	color: var(--link-fg);
}
main a:hover {
	background: var(--hovered-link-bg);
}

/* search */
.ddoc-search-panel-wrapper {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: var(--search-panel-wrapper-bg);
	z-index: 200;
}
.ddoc-search-panel {
	position: fixed;
	z-index: 210;
	padding: 0;
	display: flex;
	flex-direction: column;
}
.ddoc-search-controls {
	display: flex;
	flex-direction: row;
	align-items: center;
	padding: 20px;
	border-radius: 10px 10px 0 0;
	background: var(--nav-bg);
}
.ddoc-search-controls input {
	flex: 1 1 auto;
	padding: 5px 5px;
	font-size: 16px;
}
.ddoc-search-close {
	margin-left: 10px;
	padding: 6px 10px;
	font-size: 20px;
	font-weight: bold;
	cursor: pointer;
	color: var(--nav-fg);
}
.ddoc-search-close:hover {
	color: var(--accent);
}
.ddoc-search-results {
	flex: 0 0 auto;
	display: flex;
	flex-direction: column;
	overflow-y: auto;
	background: var(--search-results-bg);
	padding: 10px;
	border-radius: 0 0 10px 10px;
}
.ddoc-search-result + .ddoc-search-result {
	border-top: var(--search-result-border);
}
.ddoc-search-result {
	flex: 0 0 auto;
	padding: 5px;
	display: flex;
	flex-direction: column;
	align-items: stretch;
}
.ddoc-search-result-path {
	flex: 0 0 auto;
	padding: 5px;
	display: flex;
	flex-direction: row;
	align-items: center;
}
.ddoc-search-result-path a {
	color: var(--search-result-link-fg);
}
.ddoc-search-result-path a:hover {
	color: var(--hovered-search-result-link-fg);
}
.ddoc-search-result-path .ddoc-search-result-sep {
	margin: 0 5px;
	color: var(--text);
}
.ddoc-search-result-extract {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	background: var(--bg);
	color: var(--text);
	margin-left: 10px;
	padding: 2px;
	font-size: 90%;
	opacity: 0.9;
}
@media (max-width: 880px) { /* mobile */
	.ddoc-search-panel {
		top: 30px;
		left: 10px;
		right: 10px;
	}
	.ddoc-search-results {
		max-height: calc(100vh - 150px);
	}
}
@media (min-width: 880px) { /* wide screens */
	.ddoc-search-panel {
		top: 100px;
		width: 760px;
		left: calc(50% - 380px);
	}
	.ddoc-search-results {
		max-height: calc(100vh - 240px);
	}
}
