/*
 * Shared by every page: colour tokens for the light and dark theme, the site header and the theme switch.
 * The dark theme applies when the visitor chose it (data-theme="dark", set by theme.js)
 * or, without a choice, when the device is in dark mode.
 */

:root {
	--bg: #f5f7fa;
	--surface: #ffffff;
	--surface-2: #eef2f7;
	--border: #dde3ea;
	--text: #18212b;
	--muted: #5d6b7a;
	--accent: #1f6feb;
	--accent-ink: #ffffff;
	--accent-soft: #e6effd;
	--good: #157f3b;
	--good-soft: #e3f5e9;
	--warn: #9a5b00;
	--shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
	--radius: 14px;
	--radius-sm: 10px;
	--mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	--font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--header-max: 1040px;
	color-scheme: light;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--bg: #0f1720;
		--surface: #17212c;
		--surface-2: #1e2a37;
		--border: #2a3746;
		--text: #e6edf3;
		--muted: #93a1b0;
		--accent: #4c8dff;
		--accent-ink: #0b1220;
		--accent-soft: #1b2b45;
		--good: #4cc47a;
		--good-soft: #15301f;
		--warn: #e0a84a;
		--shadow: none;
		color-scheme: dark;
	}
}

:root[data-theme="dark"] {
	--bg: #0f1720;
	--surface: #17212c;
	--surface-2: #1e2a37;
	--border: #2a3746;
	--text: #e6edf3;
	--muted: #93a1b0;
	--accent: #4c8dff;
	--accent-ink: #0b1220;
	--accent-soft: #1b2b45;
	--good: #4cc47a;
	--good-soft: #15301f;
	--warn: #e0a84a;
	--shadow: none;
	color-scheme: dark;
}

/* ---------- site header ---------- */

.site-header {
	position: relative;
	z-index: 100;
	background: var(--surface);
	border-bottom: 1px solid var(--border);
	font: 16px/1.4 var(--font);
	color: var(--text);
}
.site-header *, .site-header *::before, .site-header *::after { box-sizing: border-box; }

.site-header__inner {
	max-width: var(--header-max);
	margin: 0 auto;
	padding: 0 16px;
}
.site-header__row {
	display: flex;
	align-items: center;
	gap: 8px;
	min-height: 52px;
}

.site-logo {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	margin-right: auto;
	color: var(--text);
	font-weight: 700;
	font-size: 18px;
	text-decoration: none;
}
.site-logo:hover, .site-logo:focus { color: var(--text); text-decoration: none; }
.site-logo__mark {
	flex: none;
	width: 22px;
	height: 16px;
	border: 2.5px solid var(--accent);
	border-radius: 4px;
	position: relative;
}
.site-logo__mark::after {
	content: "";
	position: absolute;
	left: 50%;
	bottom: -7px;
	width: 10px;
	height: 2.5px;
	margin-left: -5px;
	background: var(--accent);
	border-radius: 2px;
}

/* ---------- header links and the menu button ---------- */

.site-logo__text { line-height: 1.15; }

.site-blog {
	flex: none;
	display: inline-flex;
	align-items: center;
	height: 40px;
	padding: 0 14px;
	border-radius: 10px;
	color: var(--text);
	font-size: 15px;
	font-weight: 600;
	text-decoration: none;
}
.site-blog:hover, .site-blog:focus { background: var(--surface-2); color: var(--text); text-decoration: none; }
.site-blog[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }

.site-menu-btn {
	flex: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	margin-left: -6px;
	padding: 0;
	border: 0;
	border-radius: 10px;
	background: none;
	color: var(--text);
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}
.site-menu-btn:hover { background: var(--surface-2); }
.site-menu-btn svg { display: block; }
html:not(.has-side) .site-menu-btn { display: none; }   /* JavaScript is off: the sidebar is shown as a plain list */

/* phones: the logo text may wrap onto two lines to leave room for the buttons */
@media (max-width: 479px) {
	.site-header__row { gap: 4px; }
	.site-logo { gap: 8px; font-size: 15px; }
	.site-logo__text { max-width: 6.5em; }
	.site-blog { padding: 0 10px; }
}

@media (min-width: 900px) {
	.site-header { position: sticky; top: 0; }
}

/* ---------- sidebar: section links by category ---------- */

.site-side {
	font: 15px/1.4 var(--font);
	color: var(--text);
	background: var(--surface);
	padding: 8px 12px 24px;
}
.site-side *, .site-side *::before, .site-side *::after { box-sizing: border-box; }
.site-side__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	min-height: 52px;
	margin: -8px -12px 6px;
	padding: 0 8px 0 20px;
	border-bottom: 1px solid var(--border);
	font-weight: 700;
}
.site-side__close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	border-radius: 10px;
	background: none;
	color: var(--text);
	cursor: pointer;
}
.site-side__close:hover { background: var(--surface-2); }
.site-side__group { margin-top: 10px; }
.site-side__title {
	margin: 0;
	padding: 6px 8px 4px;
	font-size: 12px;
	font-weight: 700;
	letter-spacing: .06em;
	text-transform: uppercase;
	color: var(--muted);
}
.site-side ul { list-style: none; margin: 0; padding: 0; }
.site-side li { margin: 1px 0; }
.site-side a {
	display: block;
	padding: 8px 10px;
	border-radius: 8px;
	color: var(--text);
	text-decoration: none;
}
.site-side a:hover, .site-side a:focus { background: var(--surface-2); color: var(--text); text-decoration: none; }
.site-side a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 650; }

/* without JavaScript: the sidebar is a plain list under the header */
html:not(.has-side) .site-side { border-bottom: 1px solid var(--border); }
html:not(.has-side) .site-side__head { display: none; }

/* narrow screens: a drawer sliding in from the left */
@media (max-width: 1023px) {
	html.has-side .site-side {
		position: fixed;
		top: 0;
		bottom: 0;
		left: 0;
		z-index: 300;
		width: min(300px, 86vw);
		overflow-y: auto;
		overscroll-behavior: contain;
		box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
		transform: translateX(-102%);
		visibility: hidden;   /* links of a closed drawer are not reachable with Tab */
		transition: transform .22s ease, visibility 0s linear .22s;
	}
	html.side-open .site-side { transform: none; visibility: visible; transition: transform .22s ease; }
	.site-side-backdrop { position: fixed; inset: 0; z-index: 290; background: rgba(8, 12, 18, .45); }
	html.side-open, html.side-open body { overflow: hidden; }
}

/* wide screens: docked on the left under a full-width header */
@media (min-width: 1024px) {
	html.has-side body { padding-left: var(--side-w, 240px); }
	html.has-side .site-header { margin-left: calc(-1 * var(--side-w, 240px)); }
	html.has-side .site-header__inner { width: auto; max-width: none; }
	html.has-side .site-menu-btn, .site-side__head, .site-side-backdrop { display: none !important; }
	html.has-side .site-side {
		position: fixed;
		top: 53px;   /* header: 52px row + 1px border */
		bottom: 0;
		left: 0;
		z-index: 90;
		width: var(--side-w, 240px);
		overflow-y: auto;
		border-right: 1px solid var(--border);
		padding-top: 6px;
	}
}

/* ---------- language versions (other domains) ---------- */

.lang-link {
	flex: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 40px;
	height: 40px;
	padding: 0 8px;
	border: 1px solid var(--border);
	border-radius: 10px;
	color: var(--text);
	font-size: 14px;
	font-weight: 700;
	letter-spacing: .02em;
	text-decoration: none;
}
.lang-link:hover, .lang-link:focus { border-color: var(--accent); color: var(--text); text-decoration: none; }

/* ---------- theme switch ---------- */

.theme-toggle {
	flex: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 1px solid var(--border);
	border-radius: 10px;
	background: var(--surface);
	color: var(--text);
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}
.theme-toggle:hover { border-color: var(--accent); }
.theme-toggle svg { display: block; }
.theme-toggle__sun { display: none !important; }
:root[data-theme="dark"] .theme-toggle__sun { display: block !important; }
:root[data-theme="dark"] .theme-toggle__moon { display: none !important; }
html:not([data-theme]) .theme-toggle { display: none; }   /* JavaScript is off: the switch would not work */
