@font-face {
	font-family: "Fira Sans";
	src: local("Fira Sans"), url("/fonts/fs.r.woff2") format("woff2");
	font-style: normal;
	font-weight: normal;
	font-display: swap;
}

@font-face {
	font-family: "Fira Sans";
	src: local("Fira Sans Bold"), local("Fira Sans:bold"), url("/fonts/fs.b.woff2") format("woff2");
	font-style: normal;
	font-weight: 600;
	font-display: swap;
}

@font-face {
	font-family: "Fira Sans";
	src: local("Fira Sans Italic"), local("Fira Sans:italic"), url("/fonts/fs.i.woff2") format("woff2");
	font-style: italic;
	font-weight: normal;
	font-display: swap;
}

@font-face {
	font-family: "Fira Sans";
	src: local("Fira Sans Bold Italic"), local("Fira Sans:bold:italic"), url("/fonts/fs.bi.woff2") format("woff2");
	font-style: italic;
	font-weight: 600;
	font-display: swap;
}


:root {
	--bg-color: #F4F5F7;
	--surface-color: #E8EAEF;
	--text-primary: #383A42;
	--text-secondary: #696C77;
	--text-muted: #696C77;
	--border-color: #E1E4EA;
	--accent-color: #B85C19;
	--accent-hover: #8F4512;
	--code-bg: #E8EAEF;
	--quote-bg: #E8EAEF;
	--mark-bg: #986800;
	--mark-text: #F4F5F7;

	--font-sans: "Fira Sans", system-ui, -apple-system, sans-serif;
	--font-mono: ui-monospace, monospace;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg-color: #2B303B;
		--surface-color: #1D232F;
		--text-primary: #D1D5D8;
		--text-secondary: #939CA8;
		--text-muted: #939CA8;
		--border-color: #414859;
		--accent-color: #ECA671;
		--accent-hover: #FFC299;
		--code-bg: #1D232F;
		--quote-bg: #1D232F;
		--mark-bg: #E5D070;
		--mark-text: #2B303B;
	}
}


/* Generic Styling */

* {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

html {
	scroll-behavior: smooth;
}

body {
	font-family: var(--font-sans);
	background-color: var(--bg-color);
	color: var(--text-primary);
	line-height: 1.5;
	transition: background-color 0.3s ease, color 0.3s ease;
}

body > :where(header, main, footer) {
	width: 100%;
	max-width: 760px;
	margin: 0 auto;
	padding: 0 24px;
}

main {
	padding: 48px 24px;
	display: flex;
	flex-direction: column;

	p {
		text-align: justify;
	}
}

section, article, aside {
	width: 100%;
}

nav {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 32px 0;
	border-bottom: 1px solid var(--border-color);

	a {
		text-decoration: none;
		color: var(--text-primary);
		font-weight: 600;
		transition: color 0.2s ease;
	}

	.root {
		font-size: 1.25rem;
		letter-spacing: -0.025em;
	}
}

.nav-links {
	display: flex;
	gap: 24px;

	a {
		color: var(--text-secondary);
		font-size: 0.95rem;
	}
}

h1, h2, h3, h4, h5, h6 {
	color: var(--text-primary);
	font-weight: 600;
	line-height: 1.3;
	margin-top: 2em;
	margin-bottom: 0.75em;
	letter-spacing: -0.025em;
}

h1 {
	font-size: 2.5rem;
	margin-top: 0;
}

h2 {
	font-size: 1.75rem;
	border-bottom: 1px solid var(--border-color);
	padding-bottom: 0.3em;
}

h3 {
	font-size: 1.5rem;
}

h4 {
	font-size: 1.25rem;
}

h5 {
	font-size: 1.125rem;
}

h6 {
	font-size: 1rem;
	color: var(--text-secondary);
}

p {
	margin-bottom: 1.25em;
	font-size: 1.125rem;
}

a {
	color: var(--accent-color);
	text-decoration: none;
	border-bottom: 1px solid transparent;
	transition: border-color 0.2s ease, color 0.2s ease;

	&:hover {
		border-color: var(--accent-color);
		color: var(--accent-hover);
	}
}

strong, b {
	font-weight: 600;
	color: var(--text-primary);
}

em, i {
	font-style: italic;
}

mark {
	background-color: var(--mark-bg);
	color: var(--mark-text);
	padding: 0.1em 0.3em;
	border-radius: 4px;
}

small {
	font-size: 0.875em;
	color: var(--text-secondary);
}

sub, sup {
	font-size: 0.75em;
}

abbr[title] {
	text-decoration: underline dotted;
	cursor: help;
}

blockquote {
	margin: 1.5em 0;
	padding: 1em 1.5em;
	background-color: var(--quote-bg);
	border-left: 4px solid var(--accent-color);
	border-radius: 0 8px 8px 0;
	color: var(--text-secondary);
	font-style: italic;
}

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

blockquote + p:has(> cite) {
	text-align: right;

	> cite {
		font-size: 0.9em;
		color: var(--text-muted);
		font-style: normal;
	}
	> cite::before {
		content: "— ";
	}
}

blockquote {
	p:first-of-type::before {
		content: "‘";
	}
	p:last-of-type::after {
		content: "’";
	}
	code {
		background-color: unset;
		padding: unset;
	}
}

ul, ol {
	margin: 0 1.5em 1.5em 1.5em;
	padding: 0;
}

li {
	margin-bottom: 0.5em;
	font-size: 1.125rem;
}

li > ul, li > ol {
	margin-top: 0.5em;
	margin-bottom: 0;
}

dl {
	margin-bottom: 1.5em;
}

dt {
	font-weight: 600;
	margin-top: 1em;
}

dd {
	margin-left: 1.5em;
	color: var(--text-secondary);
	margin-bottom: 0.5em;
}

pre {
	background-color: var(--code-bg);
	padding: 16px;
	border-radius: 8px;
	overflow-x: auto;
	margin-bottom: 1.5em;
	border: 1px solid var(--border-color);
	tab-size: 4;
}

code {
	font-family: var(--font-mono);
	font-size: 0.9em;
	border-radius: 4px;
	color: var(--text-primary);
	text-wrap: nowrap;
	background-color: var(--code-bg);
	padding: 0.2em 0.4em;
}

pre code {
	background-color: transparent;
	padding: 0;
	border-radius: 0;
	font-size: 0.875rem;
}

kbd {
	font-family: var(--font-mono);
	font-size: 0.85em;
	background-color: var(--surface-color);
	color: var(--text-primary);
	border: 1px solid var(--border-color);
	border-bottom-width: 2px;
	border-radius: 4px;
	padding: 0.1em 0.4em;
}

figure {
	margin: 2em 0;
	text-align: center;

	img, video {
		border: 2px solid transparent;
		background:
			linear-gradient(var(--bg-color), var(--bg-color)) padding-box,
			/* TODO: Make this green a variable */
			linear-gradient(150deg, var(--accent-color), #A6E22E) border-box;
	}
}

img, video {
	max-width: 100%;
	height: auto;
	border-radius: 8px;
	display: block;
	margin: 0 auto;
}

figcaption {
	margin-top: 0.75em;
	font-size: 0.875rem;
	color: var(--text-muted);
}

table {
	width: 100%;
	border-collapse: collapse;
	margin-bottom: 1.5em;
	font-size: 0.95rem;
}

th, td {
	padding: 12px 16px;
	text-align: left;
	border-bottom: 1px solid var(--border-color);
}

th {
	font-weight: 600;
	background-color: var(--surface-color);
	color: var(--text-primary);
}

tr:nth-child(even) td {
	background-color: var(--quote-bg);
}

details {
	background-color: var(--surface-color);
	border: 1px solid var(--border-color);
	border-radius: 8px;
	padding: 12px 16px;
	margin-bottom: 1.5em;
}

summary {
	font-weight: 600;
	cursor: pointer;
	list-style: none;
	display: flex;
	justify-content: space-between;
	align-items: center;
}

summary::-webkit-details-marker {
	display: none;
}

summary::after {
	content: "↓";
	transition: transform 0.2s ease;
	color: var(--text-secondary);
}

details[open] summary {
	margin-bottom: 12px;
	border-bottom: 1px solid var(--border-color);
	padding-bottom: 12px;
}

details[open] summary::after {
	transform: rotate(180deg);
}

form {
	margin-bottom: 1.5em;
}

fieldset {
	border: 1px solid var(--border-color);
	border-radius: 8px;
	padding: 16px;
	margin-bottom: 1.5em;
}

legend {
	font-weight: 600;
	padding: 0 8px;
	color: var(--text-primary);
}

label {
	display: block;
	margin-bottom: 0.5em;
	font-weight: 600;
}

input[type="text"],
input[type="email"],
input[type="url"],
input[type="password"],
input[type="number"],
textarea,
select {
	width: 100%;
	padding: 10px 12px;
	background-color: var(--surface-color);
	color: var(--text-primary);
	border: 1px solid var(--border-color);
	border-radius: 6px;
	font-family: inherit;
	font-size: 1rem;
	margin-bottom: 1em;
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
textarea:focus,
select:focus {
	outline: none;
	border-color: var(--accent-color);
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

button,
input[type="submit"],
input[type="reset"] {
	display: inline-block;
	background-color: var(--accent-color);
	color: #FFFFFF;
	border: none;
	border-radius: 6px;
	padding: 10px 20px;
	font-size: 1rem;
	font-weight: 600;
	cursor: pointer;
	transition: background-color 0.2s ease;
	font-family: inherit;
}

button:hover,
input[type="submit"]:hover {
	background-color: var(--accent-hover);
}

button:disabled,
input:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

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

.article-header time {
	color: var(--text-secondary);
	font-size: 0.9rem;
	display: block;
	margin-bottom: 2em;
}

footer {
	padding: 32px 24px;
	text-align: center;
	color: var(--text-secondary);
	font-size: 0.875rem;
	border-top: 1px solid var(--border-color);
	margin-top: 48px;
}

.read-more {
	text-align: center;
	a:not(:hover) {
		color: var(--text-secondary);
	}
}

@media (max-width: 600px) {
	h1 {
		font-size: 2rem;
	}

	h2 {
		font-size: 1.5rem;
	}

	main {
		padding: 32px 16px;

		p {
			text-align: left;
		}
	}

	pre {
		tab-size: 2;
	}

	blockquote {
		margin: 1.25em 0;
		padding: 1em;
	}

	ul.article-list {
		list-style: none;

		li > a {
			display: block;
			width: fit-content;
		}
	}

	.nav-links {
		justify-content: flex-end;
		gap: 1rem;
	}
}

@media (min-width: 601px) {
	ul.article-list li {
		display: flex;
		justify-content: space-between;
	}
}


/* Inline reference marker */

sup.ref {
    color: var(--accent-color);
    scroll-margin-top: 2rem;

	a {
		border-bottom: none;
	}
}

aside[data-ref] {
    display: flex;
    gap: 0.75rem;
    margin: 1.5em 0;
    padding-left: 1rem;
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.5;
    scroll-margin-top: 2rem;

	&::before {
		content: attr(data-ref) ".";
		display: block;
		flex-shrink: 0;
		font-family: var(--font-mono);
		font-weight: 600;
		margin-top: 0.2em;
	}
}

@media (max-width: 600px) {
    aside[data-ref] {
        gap: 0.5rem;
        padding-left: 0.75rem;
        font-size: 0.9rem;
    }
}


/* Manual Grid */

.manual-grid {
	--cols: 3;
	display: grid;
	grid-template-columns: repeat(var(--cols), 1fr);
	font-size: 1.125rem;
}

@media (max-width: 500px) {
	.manual-grid {
		--cols: 2;
	}
}

@media (max-width: 300px) {
	.manual-grid {
		--cols: 1;
	}
}
