/*
  derekjbohman.com: styles for the whole site.
  Colors, fonts and spacing live in the :root block, so most changes start there.
*/

@font-face {
	font-family: "Space Grotesk";
	src: url("/assets/fonts/space-grotesk-latin-wght-normal.woff2") format("woff2");
	font-weight: 300 700;
	font-style: normal;
	font-display: swap;
}
@font-face {
	font-family: "Inter";
	src: url("/assets/fonts/inter-latin-wght-normal.woff2") format("woff2");
	font-weight: 100 900;
	font-style: normal;
	font-display: swap;
}
@font-face {
	font-family: "Inter";
	src: url("/assets/fonts/inter-latin-wght-italic.woff2") format("woff2");
	font-weight: 100 900;
	font-style: italic;
	font-display: swap;
}
@font-face {
	font-family: "JetBrains Mono";
	src: url("/assets/fonts/jetbrains-mono-latin-400-normal.woff2") format("woff2");
	font-weight: 400;
	font-style: normal;
	font-display: swap;
}

:root {
	/* Colors (dark, blue) */
	--base: #0C1E33;
	--surface: #12304D;
	--line: #26486B;
	--text: #E8F0F8;
	--muted: #A6BED6;
	--accent: #5BB1FF;
	--signal: #86D7F0;
	--btn-bg: var(--accent);
	--btn-fg: var(--base);

	/* Fonts */
	--display: "Space Grotesk", system-ui, sans-serif;
	--body: Inter, system-ui, sans-serif;
	--mono: "JetBrains Mono", ui-monospace, monospace;

	/* Layout */
	--gutter: clamp(1rem, 4vw, 2.5rem);
	--wide: 1200px;
	--narrow: 720px;

	color-scheme: dark;
}

/* To use the light version, add data-theme="light" to the <html> tag on every page. */
:root[data-theme="light"] {
	--base: #F4F7FB;
	--surface: #E4ECF6;
	--line: #C5D3E4;
	--text: #0C1E33;
	--muted: #4A6280;
	--accent: #0B5CAD;
	--signal: #0C6B84;
	--btn-bg: var(--text);
	--btn-fg: var(--base);
	color-scheme: light;
}

/* ---------- Base ---------- */

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

html {
	scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
	html {
		scroll-behavior: auto;
	}
}

body {
	margin: 0;
	background: var(--base);
	color: var(--text);
	font: 1.0625rem/1.65 var(--body);
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4 {
	font-family: var(--display);
	font-weight: 600;
	line-height: 1.12;
	letter-spacing: -0.02em;
	margin: 0 0 0.6em;
}

h1 { font-size: clamp(2.5rem, 6vw, 4.25rem); letter-spacing: -0.035em; line-height: 1.02; }
h2 { font-size: clamp(1.625rem, 3.2vw, 2.25rem); }
h3 { font-size: clamp(1.1875rem, 2vw, 1.375rem); letter-spacing: -0.01em; }

p {
	margin: 0 0 1.25rem;
}

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

a:hover {
	text-decoration: none;
}

:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 3px;
	border-radius: 2px;
}

::selection {
	background: var(--accent);
	color: var(--base);
}

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

.muted {
	color: var(--muted);
}

.skip-link {
	position: absolute;
	left: -999px;
	top: 0;
	z-index: 10;
	padding: 0.5rem 1rem;
	background: var(--accent);
	color: var(--base);
}

.skip-link:focus {
	left: var(--gutter);
	top: 0.5rem;
}

.wrap {
	width: 100%;
	max-width: calc(var(--wide) + 2 * var(--gutter));
	margin-inline: auto;
	padding-inline: var(--gutter);
}

.wrap--narrow {
	max-width: calc(var(--narrow) + 2 * var(--gutter));
}

/* ---------- Header and footer ---------- */

.site-header {
	border-bottom: 1px solid var(--line);
	padding-block: 1.25rem;
}

.site-header .wrap {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
}

.site-title {
	font-family: var(--display);
	font-size: 1.125rem;
	font-weight: 600;
	letter-spacing: -0.01em;
	color: var(--text);
	text-decoration: none;
}

.site-nav {
	display: flex;
	gap: 1.5rem;
	font-size: 0.875rem;
	font-weight: 500;
}

.site-nav a {
	color: var(--text);
	text-decoration: none;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
	color: var(--accent);
}

.site-footer {
	border-top: 1px solid var(--line);
	padding-block: clamp(2rem, 4vw, 3rem);
	color: var(--muted);
	font-size: 0.875rem;
}

.site-footer .wrap {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 1rem 1.5rem;
}

.site-footer a {
	color: var(--text);
}

.footer-links {
	display: flex;
	flex-wrap: wrap;
	gap: 1.5rem;
}

/* ---------- Buttons ---------- */

.btn {
	display: inline-block;
	padding: 0.8rem 1.4rem;
	border: 1px solid var(--btn-bg);
	border-radius: 6px;
	background: var(--btn-bg);
	color: var(--btn-fg);
	font: 600 1rem/1.2 var(--display);
	text-decoration: none;
	transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.btn:hover {
	background: var(--text);
	border-color: var(--text);
	color: var(--base);
}

.btn--outline {
	background: transparent;
	border-color: var(--line);
	color: var(--text);
}

.btn--outline:hover {
	background: transparent;
	border-color: var(--text);
	color: var(--text);
}

.actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem;
	margin-top: 1.75rem;
}

/* ---------- Sections ---------- */

.section {
	padding-block: clamp(3rem, 7vw, 5.5rem);
}

.section + .section {
	border-top: 1px solid var(--line);
}

.lead {
	max-width: 38rem;
	color: var(--muted);
	font-size: clamp(1.1875rem, 2vw, 1.375rem);
	line-height: 1.5;
}

/* ---------- Hero (dot grid and soft glow, fading out) ---------- */

.hero {
	position: relative;
	isolation: isolate;
	overflow: hidden;
	padding-block: clamp(4rem, 10vw, 8rem) clamp(3rem, 7vw, 5.5rem);
}

.hero h1 {
	max-width: 14ch;
	text-wrap: balance;
}

.hero::before,
.hero::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: -1;
	pointer-events: none;
}

.hero::before {
	background-image: radial-gradient(circle, color-mix(in srgb, var(--accent) 45%, transparent) 1px, transparent 1.5px);
	background-size: 26px 26px;
	-webkit-mask-image: radial-gradient(ellipse 75% 100% at 88% 15%, #000 0%, transparent 72%);
	mask-image: radial-gradient(ellipse 75% 100% at 88% 15%, #000 0%, transparent 72%);
}

.hero::after {
	background: radial-gradient(ellipse 55% 80% at 88% 5%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%);
}

/* ---------- Article list ---------- */

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

.post-row {
	display: grid;
	grid-template-columns: 9rem minmax(0, 1fr);
	gap: 0.35rem 2rem;
	align-items: baseline;
	padding-block: 1.5rem;
	border-top: 1px solid var(--line);
}

.posts > li:last-child {
	border-bottom: 1px solid var(--line);
}

.post-row > * {
	margin: 0;
}

.post-date {
	color: var(--muted);
	font-size: 0.875rem;
}

.post-title {
	font-size: 1.375rem;
}

.post-title a {
	color: var(--text);
	text-decoration: none;
}

.post-title a:hover {
	color: var(--accent);
	text-decoration: underline;
}

.post-excerpt,
.post-topic {
	grid-column: 2;
}

.post-excerpt {
	color: var(--muted);
}

.post-topic {
	color: var(--signal);
	font-size: 0.875rem;
}

/* Optional thumbnail: add <a class="post-thumb"><img ...></a> to a row */
.post-row:has(.post-thumb) {
	grid-template-columns: 9rem minmax(0, 1fr) 112px;
	grid-template-rows: auto auto auto 1fr;
}

.post-thumb {
	grid-column: 3;
	grid-row: 1 / span 4;
	align-self: start;
}

.post-thumb img {
	display: block;
	width: 112px;
	height: 112px;
	object-fit: cover;
	border: 1px solid var(--line);
	border-radius: 6px;
}

@media (max-width: 600px) {
	.post-row,
	.post-row:has(.post-thumb) {
		grid-template-columns: 1fr;
		grid-template-rows: none;
	}
	.post-excerpt,
	.post-topic,
	.post-thumb {
		grid-column: 1;
	}
	.post-thumb {
		grid-row: 1;
	}
}

/* ---------- About band ---------- */

.about-band {
	padding: clamp(2rem, 4vw, 3rem) clamp(1.25rem, 4vw, 3rem);
	background: var(--surface);
	border-top: 3px solid var(--accent);
	border-radius: 0 0 8px 8px;
}

.about-band > * {
	margin-block: 0;
}

.about-band > * + * {
	margin-top: 1rem;
}

.about-band p {
	max-width: 38rem;
	color: var(--muted);
}

/* ---------- Article and page content ---------- */

.page-head {
	padding-block: clamp(3rem, 7vw, 5rem) 1rem;
}

.article-meta {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem 1rem;
	margin-bottom: 1rem;
	color: var(--muted);
	font-size: 0.875rem;
}

.article-meta .post-topic {
	grid-column: auto;
}

.page-head h1 {
	font-size: clamp(2rem, 4.5vw, 2.75rem);
	margin-bottom: 0.4em;
}

.page-body {
	padding-block: 1rem clamp(3rem, 7vw, 5rem);
}

.prose h2 { margin-top: 2.5em; }
.prose h3 { margin-top: 2em; }

.prose img {
	border-radius: 6px;
}

.prose figure {
	margin: 2rem 0;
}

.prose figcaption {
	margin-top: 0.5rem;
	color: var(--muted);
	font-size: 0.875rem;
}

.prose ul,
.prose ol {
	margin: 0 0 1.25rem;
	padding-left: 1.5rem;
}

.prose li + li {
	margin-top: 0.35rem;
}

.prose blockquote {
	margin: 2rem 0;
	padding-left: 1.25rem;
	border-left: 3px solid var(--accent);
	font-size: 1.375rem;
}

.prose hr {
	margin: 2.5rem 0;
	border: 0;
	border-top: 1px solid var(--line);
}

.prose code {
	font-family: var(--mono);
	font-size: 0.9em;
}

.prose pre {
	margin: 0 0 1.5rem;
	padding: 1.25rem;
	overflow-x: auto;
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: 6px;
	font-size: 0.875rem;
	line-height: 1.6;
}

.prose pre code {
	font-size: inherit;
}

/* Embedded YouTube video: wrap the iframe in <div class="video"> */
.video {
	aspect-ratio: 16 / 9;
	margin: 2rem 0;
}

.video iframe {
	width: 100%;
	height: 100%;
	border: 0;
	border-radius: 8px;
}

.back-link {
	display: inline-block;
	margin-top: 1rem;
	color: var(--muted);
}

/* ---------- Topic chips ---------- */

.topics {
	display: flex;
	flex-wrap: wrap;
	gap: 0.6rem;
	list-style: none;
	margin: 1rem 0 0;
	padding: 0;
}

.topics a {
	display: inline-block;
	padding: 0.4rem 1rem;
	border: 1px solid var(--line);
	border-radius: 999px;
	color: var(--text);
	font-size: 0.875rem;
	text-decoration: none;
	transition: border-color 0.15s ease, color 0.15s ease;
}

.topics a:hover {
	border-color: var(--accent);
	color: var(--accent);
}

/* ---------- About portrait ---------- */

.portrait {
	display: block;
	float: right;
	width: clamp(8rem, 28vw, 13rem);
	height: auto;
	aspect-ratio: 1;
	object-fit: cover;
	margin: 0 0 1rem 1.5rem;
	border: 1px solid var(--line);
	border-radius: 12px;
}

@media (max-width: 600px) {
	.portrait {
		float: none;
		margin: 0 0 1.5rem;
	}
}

/* ---------- Logo mark and legal note ---------- */

.site-title {
	display: inline-flex;
	align-items: center;
	gap: 0.6rem;
}

.site-mark {
	display: block;
}

.legal {
	max-width: 36rem;
	margin: 0.5rem 0 0;
	font-size: 0.8125rem;
	line-height: 1.5;
}
