/* Sajt default theme.
 *
 * Fonts are bundled under static/fonts/ and licensed under the SIL Open Font
 * License 1.1 (see static/fonts/FONTS.md and each family's OFL.txt):
 *   Rajdhani — headings, navigation and text
 *   0xProto  — code
 */

/* ── fonts ──────────────────────────────────────────────────────────────── */

@font-face {
	font-family: "Rajdhani";
	src: url("/static/fonts/rajdhani/Rajdhani-Regular.woff2") format("woff2");
	font-weight: 400;
	font-style: normal;
	font-display: swap;
}

@font-face {
	font-family: "Rajdhani";
	src: url("/static/fonts/rajdhani/Rajdhani-Medium.woff2") format("woff2");
	font-weight: 500;
	font-style: normal;
	font-display: swap;
}

@font-face {
	font-family: "Rajdhani";
	src: url("/static/fonts/rajdhani/Rajdhani-SemiBold.woff2") format("woff2");
	font-weight: 600;
	font-style: normal;
	font-display: swap;
}

@font-face {
	font-family: "Rajdhani";
	src: url("/static/fonts/rajdhani/Rajdhani-Bold.woff2") format("woff2");
	font-weight: 700;
	font-style: normal;
	font-display: swap;
}

@font-face {
	font-family: "0xProto";
	src: url("/static/fonts/0xproto/0xProto-Regular.woff2") format("woff2");
	font-weight: 400;
	font-style: normal;
	font-display: swap;
}

@font-face {
	font-family: "0xProto";
	src: url("/static/fonts/0xproto/0xProto-Bold.woff2") format("woff2");
	font-weight: 700;
	font-style: normal;
	font-display: swap;
}

@font-face {
	font-family: "0xProto";
	src: url("/static/fonts/0xproto/0xProto-Italic.woff2") format("woff2");
	font-weight: 400;
	font-style: italic;
	font-display: swap;
}

/* ── tokens ─────────────────────────────────────────────────────────────── */

:root {
	--font-text: "Rajdhani", system-ui, -apple-system, "Segoe UI", sans-serif;
	--font-code: "0xProto", ui-monospace, "SFMono-Regular", Menlo, monospace;

	--bg: #fbfbfd;
	--surface: #ffffff;
	--sidebar-bg: #f3f5f9;
	--text: #1c2230;
	--muted: #5f687a;
	--border: #e2e6ee;
	--accent: #0a5fd6;
	--accent-strong: #0848a3;
	--accent-soft: rgba(10, 95, 214, 0.08);
	--code-bg: #f5f7fb;

	--radius: 10px;
	--sidebar-width: 300px;
	--content-width: 760px;
}

/* ── base ───────────────────────────────────────────────────────────────── */

*,
*::before,
*::after {
	box-sizing: border-box;
}

html {
	scroll-behavior: smooth;
	-webkit-text-size-adjust: 100%;
}

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: 500 18px/1.6 var(--font-text);
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
	border-top: 4px solid transparent;
	border-image: linear-gradient(90deg, var(--accent), #6a4cff) 1;
}

h1,
h2,
h3,
h4,
h5,
h6 {
	font-family: var(--font-text);
	font-weight: 700;
	line-height: 1.2;
	letter-spacing: 0.01em;
	color: var(--text);
	margin: 1.6em 0 0.5em;
}

h1 { font-size: 2.4rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.4rem; }
h4 { font-size: 1.2rem; }
h5,
h6 { font-size: 1rem; text-transform: uppercase; letter-spacing: 0.06em; }

p {
	margin: 0 0 1.1em;
}

a {
	color: var(--accent);
	text-decoration: none;
	text-underline-offset: 0.18em;
}

a:hover,
a:focus-visible {
	color: var(--accent-strong);
	text-decoration: underline;
}

strong {
	font-weight: 700;
}

em {
	font-style: italic;
}

hr {
	border: 0;
	border-top: 1px solid var(--border);
	margin: 2em 0;
}

img,
svg {
	max-width: 100%;
	height: auto;
}

/* ── layout ─────────────────────────────────────────────────────────────── */

.container {
	display: flex;
	min-height: calc(100vh - 4px);
}

.sidebar {
	flex: 0 0 var(--sidebar-width);
	position: sticky;
	top: 0;
	height: 100vh;
	overflow-y: auto;
	background: var(--sidebar-bg);
	border-right: 1px solid var(--border);
	padding: 2rem 1.5rem;
}

.scroll {
	flex: 1 1 auto;
	min-width: 0;
}

.content {
	max-width: calc(var(--content-width) + 6rem);
	margin: 0 auto;
	padding: 0 3rem 3rem;
}

/* ── sidebar ────────────────────────────────────────────────────────────── */

.sidebar .intro {
	margin: 0;
	font-size: 1.45rem;
	line-height: 1.2;
}

.sidebar .intro a {
	color: var(--text);
}

.sidebar .intro a:hover {
	color: var(--accent);
	text-decoration: none;
}

.sidebar .tagline {
	margin: 0.2em 0 0;
	font-size: 1rem;
	font-weight: 500;
	color: var(--muted);
}

.hr-text {
	border: 0;
	margin: 1.8rem 0 0.8rem;
	height: auto;
	overflow: visible;
	text-align: left;
}

.hr-text::before {
	content: attr(data-content);
	font-size: 0.78rem;
	font-weight: 700;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--muted);
}

ul.posts {
	list-style: none;
	margin: 0;
	padding: 0;
}

ul.posts li {
	margin: 0;
}

ul.posts li span {
	display: none;
}

ul.posts a {
	display: block;
	/* the 3px accent border is part of the inset, so the text lines up
	   with the heading above */
	padding: 0.32rem 0.75rem 0.32rem calc(0.75rem - 3px);
	margin-left: -0.75rem;
	border-radius: 8px;
	border-left: 3px solid transparent;
	color: var(--text);
	font-weight: 600;
	font-size: 1.05rem;
	line-height: 1.3;
	transition: background-color 0.15s ease, color 0.15s ease;
}

ul.posts a:hover {
	background: var(--accent-soft);
	color: var(--accent-strong);
	text-decoration: none;
}

ul.posts a.current {
	background: var(--accent-soft);
	border-left-color: var(--accent);
	color: var(--accent-strong);
}

/* ── the page ───────────────────────────────────────────────────────────── */

h1.title {
	position: sticky;
	top: 0;
	z-index: 1;
	margin: 0 -3rem 1rem;
	padding: 1.6rem 3rem 0.9rem;
	background: rgba(251, 251, 253, 0.86);
	-webkit-backdrop-filter: saturate(160%) blur(10px);
	backdrop-filter: saturate(160%) blur(10px);
	border-bottom: 1px solid var(--border);
}

h1.title:empty {
	display: none;
}

#post > :first-child {
	margin-top: 1.2rem;
}

#post ul,
#post ol {
	padding-left: 1.4em;
	margin: 0 0 1.1em;
}

#post ul {
	list-style: none;
}

#post ul > li {
	position: relative;
}

#post ul > li::before {
	content: "";
	position: absolute;
	left: -1em;
	top: 0.68em;
	width: 0.36em;
	height: 0.36em;
	border-radius: 2px;
	background: var(--accent);
	opacity: 0.7;
}

#post li {
	margin: 0.25em 0;
}

#post li > ul,
#post li > ol {
	margin: 0.25em 0;
}

blockquote {
	margin: 1.4em 0;
	padding: 0.8em 1.2em;
	border-left: 3px solid var(--accent);
	background: var(--accent-soft);
	border-radius: 0 var(--radius) var(--radius) 0;
	color: var(--muted);
}

blockquote p:last-child {
	margin-bottom: 0;
}

table {
	width: 100%;
	border-collapse: collapse;
	margin: 1.4em 0;
	font-size: 0.95em;
}

th,
td {
	padding: 0.5em 0.8em;
	text-align: left;
	border-bottom: 1px solid var(--border);
}

thead th {
	font-weight: 700;
	color: var(--accent-strong);
	border-bottom: 2px solid var(--accent);
}

/* images and diagrams get a quiet frame, as before */
p:has(> img),
p:has(> svg) {
	padding: 1rem;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
}

p > img,
p > svg {
	display: block;
	margin: 0 auto;
}

/* ── code ───────────────────────────────────────────────────────────────── */

code,
pre,
kbd,
samp {
	font-family: var(--font-code);
	font-variant-ligatures: contextual;
}

#post :not(pre) > code {
	font-size: 0.8em;
	padding: 0.12em 0.4em;
	border-radius: 6px;
	background: var(--code-bg);
	border: 1px solid var(--border);
	white-space: nowrap;
}

#post pre {
	margin: 1.3em 0;
	padding: 1em 1.2em;
	overflow: auto;
	white-space: pre;
	font-size: 0.78em;
	line-height: 1.6;
	background: var(--code-bg);
	border: 1px solid var(--border);
	border-radius: var(--radius);
}

#post pre code {
	font-size: inherit;
	padding: 0;
	border: 0;
	background: none;
}

.hljs {
	background: transparent !important;
	padding: 0 !important;
}

/* diagrams render text with the page's font */
svg text,
svg g {
	font-family: var(--font-text);
	font-weight: 500;
}

/* ── footer ─────────────────────────────────────────────────────────────── */

.footer {
	margin-top: 3rem;
	padding-top: 1.2rem;
	border-top: 1px solid var(--border);
}

.disclaimer {
	color: var(--muted);
	font-size: 0.9rem;
	font-weight: 600;
}

.disclaimer p {
	margin: 0;
}

/* ── narrow screens: the sidebar goes on top ────────────────────────────── */

@media (max-width: 860px) {
	body {
		font-size: 17px;
	}

	.container {
		flex-direction: column;
	}

	.sidebar {
		position: static;
		height: auto;
		flex-basis: auto;
		border-right: 0;
		border-bottom: 1px solid var(--border);
		padding: 1.4rem 1.25rem;
	}

	.content {
		padding: 0 1.25rem 2rem;
	}

	h1.title {
		margin: 0 -1.25rem 1rem;
		padding: 1.1rem 1.25rem 0.7rem;
		font-size: 1.9rem;
	}
}
