/* Defaults - System fonts only, no external dependencies */
:root {
	/* Technical, standards-focused font stack - system fonts only for privacy and performance */
	--font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
	--font-family-monospace: ui-monospace, "SF Mono", "Monaco", "Cascadia Code", "Segoe UI Mono", "Roboto Mono", "Oxygen Mono", "Ubuntu Monospace", "Source Code Pro", "Fira Mono", "Droid Sans Mono", "Courier New", monospace;
}

/* Theme colors - Accessible palette with WCAG AA compliance */
:root {
	/* Color palette from provided swatches */
	--color-doctor: #F9F9F9;              /* Off-white, 19.95:1 contrast */
	--color-crow-black-blue: #112F4B;      /* Dark navy, 13.71:1 contrast */
	--color-scandinavian-sky: #B6DCAD;     /* Light sage green, 12.33:1 contrast */
	--color-purple-emperor: #6633BB;       /* Medium purple, 7.62:1 contrast */
	--color-spring-sun: #F1F1C6;          /* Pale yellow/cream, 18.14:1 contrast */
	--color-prairie: #0B9D6A;              /* Vibrant green, 3.47:1 contrast (use carefully) */
	
	/* Light mode - WCAG AA compliant */
	--background-color: var(--color-doctor);
	--text-color: var(--color-crow-black-blue);
	--text-color-link: #008050; /* Darker prairie green for 4.5:1+ contrast on white */
	--text-color-link-active: var(--color-crow-black-blue);
	--text-color-link-visited: #006640; /* Even darker for visited links */
	
	/* Accent colors */
	--color-accent: var(--color-scandinavian-sky);
	--color-accent-secondary: var(--color-purple-emperor);
	
	/* Borders and dividers */
	--color-border: var(--color-scandinavian-sky);
	--color-border-subtle: #e0e0e0;
	
	/* Muted text for dates, metadata - accessible contrast */
	--color-text-muted: #6b7280; /* Gray that works on light background, 4.5:1+ contrast */
	
	/* Code blocks */
	--color-code-bg: var(--color-spring-sun);
	--color-code-text: var(--color-crow-black-blue);
	--color-code-border: var(--color-scandinavian-sky);

	--syntax-tab-size: 2;
}

/* Dark mode - class-based toggle with media query fallback */
@media (prefers-color-scheme: dark) {
	:root:not(.light-mode) {
		/* Dark mode - WCAG AA compliant */
		--background-color: var(--color-crow-black-blue);
		--text-color: var(--color-doctor);
		--text-color-link: #c8e8c0; /* Lighter Scandinavian Sky for 4.5:1+ contrast on dark blue */
		--text-color-link-active: var(--color-doctor);
		--text-color-link-visited: #b0dca8; /* Slightly lighter for visited links */
		
		/* Accent colors for dark mode */
		--color-accent: var(--color-scandinavian-sky);
		--color-accent-secondary: #8b6fc7; /* Lighter purple for dark mode */
		
		/* Borders and dividers for dark mode */
		--color-border: #2a4a5f; /* Darker blue-gray */
		--color-border-subtle: #1a2f3f;
		
		/* Muted text for dates, metadata - accessible contrast */
		--color-text-muted: #9ca3af; /* Light gray that works on dark background, 4.5:1+ contrast */
		
		/* Code blocks for dark mode */
		--color-code-bg: #1a2f3f;
		--color-code-text: #c8e8c0; /* Lighter for better contrast in code blocks */
		--color-code-border: #2a4a5f;
	}
}

/* Manual dark mode toggle */
.dark-mode {
	--background-color: var(--color-crow-black-blue);
	--text-color: var(--color-doctor);
	--text-color-link: #c8e8c0; /* Lighter Scandinavian Sky for 4.5:1+ contrast on dark blue */
	--text-color-link-active: var(--color-doctor);
	--text-color-link-visited: #b0dca8; /* Slightly lighter for visited links */
	
	--color-accent: var(--color-scandinavian-sky);
	--color-accent-secondary: #8b6fc7;
	
	--color-border: #2a4a5f;
	--color-border-subtle: #1a2f3f;
	
	--color-text-muted: #9ca3af; /* Light gray that works on dark background, 4.5:1+ contrast */
	
	--color-code-bg: #1a2f3f;
	--color-code-text: #c8e8c0; /* Lighter for better contrast in code blocks */
	--color-code-border: #2a4a5f;
}

/* Manual light mode override */
.light-mode {
	--background-color: var(--color-doctor);
	--text-color: var(--color-crow-black-blue);
	--text-color-link: #008050; /* Darker prairie green for 4.5:1+ contrast on white */
	--text-color-link-active: var(--color-crow-black-blue);
	--text-color-link-visited: #006640; /* Even darker for visited links */
	
	--color-accent: var(--color-scandinavian-sky);
	--color-accent-secondary: var(--color-purple-emperor);
	
	--color-border: var(--color-scandinavian-sky);
	--color-border-subtle: #e0e0e0;
	
	--color-text-muted: #6b7280; /* Gray that works on light background, 4.5:1+ contrast */
	
	--color-code-bg: var(--color-spring-sun);
	--color-code-text: var(--color-crow-black-blue);
	--color-code-border: var(--color-scandinavian-sky);
}


/* Global stylesheet */
* {
	box-sizing: border-box;
}

@view-transition {
	navigation: auto;
}

html,
body {
	padding: 0;
	margin: 0 auto;
	font-family: var(--font-family);
	color: var(--text-color);
	background-color: var(--background-color);
}
html {
	overflow-y: scroll;
}
body {
	max-width: 40em;
}

/* https://www.a11yproject.com/posts/how-to-hide-content/ */
.visually-hidden:not(:focus):not(:active) {
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	height: 1px;
	overflow: hidden;
	position: absolute;
	white-space: nowrap;
	width: 1px;
}

/* Fluid images via https://www.zachleat.com/web/fluid-images/ */
img{
  max-width: 100%;
}
img[width][height] {
  height: auto;
}
img[src$=".svg"] {
  width: 100%;
  height: auto;
  max-width: none;
}
video,
iframe {
	width: 100%;
	height: auto;
}
iframe {
	aspect-ratio: 16/9;
}

p:last-child {
	margin-bottom: 0;
}
p {
	line-height: 1.5;
}

li {
	line-height: 1.5;
}

/* Headings - ensure proper color inheritance */
h1, h2, h3, h4, h5, h6 {
	color: var(--text-color);
	font-weight: 700;
	line-height: 1.2;
	margin-top: 1.5em;
	margin-bottom: 0.5em;
}

h1 {
	font-size: 2em;
}

h2 {
	font-size: 1.5em;
}

h3 {
	font-size: 1.25em;
}

h4, h5, h6 {
	font-size: 1em;
}

a[href] {
	color: var(--text-color-link);
	text-decoration: underline;
	text-decoration-thickness: 2px;
	text-underline-offset: 2px;
	transition: color 0.2s ease, text-decoration-color 0.2s ease;
}
a[href]:visited {
	color: var(--text-color-link-visited);
}
a[href]:hover,
a[href]:active {
	color: var(--text-color-link-active);
	text-decoration-thickness: 3px;
}

main,
footer {
	padding: 1rem;
}
main :first-child {
	margin-top: 0;
}

header {
	border-bottom: 1px solid var(--color-border);
}

#skip-link {
	text-decoration: none;
	background: var(--background-color);
	color: var(--text-color);
	padding: 0.5rem 1rem;
	border: 1px solid var(--color-gray-90);
	border-radius: 2px;
}

/* Prevent visually-hidden skip link fom pushing content around when focused */
#skip-link.visually-hidden:focus {
	position: absolute;
	top: 1rem;
	left: 1rem;
	/* Ensure it is positioned on top of everything else when it is shown */
	z-index: 999;
}

.links-nextprev {
	display: flex;
	justify-content: space-between;
	gap: .5em 1em;
	list-style: "";
	border-top: 1px solid var(--color-border);
	padding: 1em 0;
}
.links-nextprev > * {
	flex-grow: 1;
}
.links-nextprev-next {
	text-align: right;
}

table {
	margin: 1em 0;
}
table td,
table th {
	padding-right: 1em;
}

pre,
code {
	font-family: var(--font-family-monospace);
}
pre:not([class*="language-"]) {
	margin: .5em 0;
	line-height: 1.375; /* 22px /16 */
	-moz-tab-size: var(--syntax-tab-size);
	-o-tab-size: var(--syntax-tab-size);
	tab-size: var(--syntax-tab-size);
	-webkit-hyphens: none;
	-ms-hyphens: none;
	hyphens: none;
	direction: ltr;
	text-align: left;
	white-space: pre;
	word-spacing: normal;
	word-break: normal;
	overflow-x: auto;
	background-color: var(--color-code-bg);
	border: 1px solid var(--color-code-border);
	border-radius: 4px;
	padding: 1em;
	color: var(--color-code-text);
}
code {
	word-break: break-all;
	color: var(--color-code-text);
	background-color: var(--color-code-bg);
	padding: 0.125em 0.25em;
	border-radius: 2px;
	font-size: 0.9em;
}

/* Header */
header {
	display: flex;
	gap: 1em;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: center;
	padding: 1em;
}
.home-link {
	flex-grow: 1;
	font-size: 1em; /* 16px /16 */
	font-weight: 700;
	color: var(--text-color);
}
.home-link:link:not(:hover) {
	text-decoration: none;
}

/* Nav */
.nav {
	display: flex;
	gap: .5em 1em;
	padding: 0;
	margin: 0;
	list-style: none;
	align-items: center;
}
.nav-item {
	display: inline-block;
}
.nav-item a[href]:not(:hover) {
	text-decoration: none;
}
.nav a[href][aria-current="page"] {
	text-decoration: underline;
}

/* Dark mode toggle - minimal, text-only, blends with nav */
.theme-toggle {
	background: none;
	border: none;
	color: var(--text-color-link);
	cursor: pointer;
	font-size: inherit;
	font-family: inherit;
	font-weight: inherit;
	padding: 0;
	margin: 0;
	text-decoration: none;
	transition: color 0.2s ease, opacity 0.2s ease;
	opacity: 0.8;
}

.theme-toggle:hover,
.theme-toggle:focus {
	color: var(--text-color-link-active);
	opacity: 1;
	text-decoration: underline;
	text-decoration-thickness: 2px;
	text-underline-offset: 2px;
	outline: none;
}

.theme-toggle:active {
	opacity: 0.9;
}

/* Posts list */
.postlist {
	counter-reset: start-from var(--postlist-index);
	list-style: none;
	padding: 0;
	padding-left: 1.5rem;
}
.postlist-item {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	counter-increment: start-from -1;
	margin-bottom: 1em;
}
.postlist-item:before {
	display: inline-block;
	pointer-events: none;
	content: "" counter(start-from, decimal-leading-zero) ". ";
	line-height: 100%;
	text-align: right;
	margin-left: -1.5rem;
}
.postlist-date,
.postlist-item:before {
	font-size: 0.8125em; /* 13px /16 */
	color: var(--color-text-muted);
}
.postlist-date {
	word-spacing: -0.5px;
}
.postlist-link {
	font-size: 1.1875em; /* 19px /16 */
	font-weight: 700;
	flex-basis: calc(100% - 1.5rem);
	padding-left: .25em;
	padding-right: .5em;
	text-underline-position: from-font;
	text-underline-offset: 0;
	text-decoration-thickness: 1px;
}
.postlist-item-active .postlist-link {
	font-weight: bold;
}

/* Tags */
.post-tag {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	text-transform: capitalize;
	font-style: italic;
}
.postlist-item > .post-tag {
	align-self: center;
}

/* Tags list */
.post-metadata {
	display: inline-flex;
	flex-wrap: wrap;
	gap: .5em;
	list-style: none;
	padding: 0;
	margin: 0;
}
.post-metadata time {
	margin-right: 1em;
}

