/* ==========================================================================
   Coralbit theme
   Layout: one calm reading column on cream, beige panels, warm-grey hairlines,
   one soft-charcoal band for contact. Phones first, scales up to desktop.
   ========================================================================== */

/* ---------- Fonts (self-hosted, see README.md) ---------- */
@font-face {
	font-family: "Fira Sans";
	src: url("../fonts/fira-sans-400.woff2") format("woff2");
	font-weight: 400;
	font-style: normal;
	font-display: swap;
}
@font-face {
	font-family: "Fira Sans";
	src: url("../fonts/fira-sans-500.woff2") format("woff2");
	font-weight: 500;
	font-style: normal;
	font-display: swap;
}
@font-face {
	font-family: "Fira Sans";
	src: url("../fonts/fira-sans-600.woff2") format("woff2");
	font-weight: 600;
	font-style: normal;
	font-display: swap;
}
@font-face {
	font-family: "Fira Code";
	src: url("../fonts/fira-code-500.woff2") format("woff2");
	font-weight: 500;
	font-style: normal;
	font-display: swap;
}

/* ---------- Colour and type tokens ---------- */
:root {
	--bg: #faf8f3;          /* cream white */
	--panel: #f1ede4;       /* light beige */
	--line: #dcd8cf;        /* light warm grey */
	--text: #262522;        /* soft black */
	--text-2: #5a5852;      /* medium warm grey */
	--accent: #fb4d4c;      /* brand accent and links */
	--sage: #4a6b50;        /* category tags */
	--band: #2a2926;        /* soft charcoal */
	--band-text: #f3f0e8;
	--band-text-2: #c9c4ba;
	--code-string: #e6c07b;
	--inline-code-bg: #ece7dc;

	/* Code blocks: Monokai Pro */
	--code-bg: #2d2a2e;
	--code-text: #fcfcfa;
	--code-comment: #727072;
	--code-punctuation: #939293;
	--code-pink: #ff6188;
	--code-orange: #fc9867;
	--code-yellow: #ffd866;
	--code-green: #a9dc76;
	--code-cyan: #78dce8;
	--code-purple: #ab9df2;

	--font-text: "Fira Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	--font-code: "Fira Code", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

	--measure: 44rem;
	--gutter: clamp(1rem, 4vw, 1.5rem);
	--header-height: 3.5rem;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #1d1c1a;
		--panel: #272623;
		--line: #3a3935;
		--text: #e9e5dd;
		--text-2: #b4afa5;
		--sage: #9dbea2;
		--band: #2a2926;
		--inline-code-bg: #2f2e2a;
		color-scheme: dark;
	}
}

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

html {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
	scroll-padding-top: calc(var(--header-height) + 1rem);
}

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font-family: var(--font-text);
	font-size: 1.0625rem;
	line-height: 1.65;
	-webkit-font-smoothing: antialiased;
	overflow-wrap: break-word;
}

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

a {
	color: var(--accent);
}

a:focus-visible,
button:focus-visible {
	outline: 3px solid var(--accent);
	outline-offset: 3px;
}

h1,
h2,
h3,
h4 {
	text-wrap: balance;
}

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

.skip-link {
	position: absolute;
	left: var(--gutter);
	top: -3rem;
	background: var(--band);
	color: var(--band-text);
	padding: 0.5rem 0.75rem;
	z-index: 100;
	text-decoration: none;
}

.skip-link:focus {
	top: 0.5rem;
}

.label {
	font-family: var(--font-code);
	font-size: 0.75rem;
	font-weight: 500;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--text-2);
	margin: 0;
}

.tag {
	font-family: var(--font-code);
	font-size: 0.72rem;
	font-weight: 500;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--sage);
	text-decoration: none;
	margin: 0;
}

a.tag:hover {
	text-decoration: underline;
	text-underline-offset: 3px;
}

.empty {
	color: var(--text-2);
	margin: 0;
}

/* ---------- Header ---------- */
.site-header {
	position: sticky;
	top: 0;
	z-index: 50;
	background: var(--band);
	color: var(--band-text);
	padding-top: env(safe-area-inset-top, 0px);
}

.site-header-inner {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	column-gap: 1.5rem;
	min-height: var(--header-height);
}

.wordmark {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	min-height: 44px;
	font-family: var(--font-code);
	font-size: 1rem;
	font-weight: 500;
	color: var(--band-text);
	text-decoration: none;
	white-space: nowrap;
	flex-shrink: 0;
}

.wordmark-accent {
	color: var(--accent);
}

.wordmark-logo {
	display: block;
	width: 32px;
	height: 32px;
	flex-shrink: 0;
}

.nav {
	display: flex;
	flex-wrap: wrap;
	column-gap: 1.25rem;
	min-width: 0;
}

.nav a {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	font-size: 0.95rem;
	color: var(--band-text-2);
	text-decoration: none;
	white-space: nowrap;
}

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

.nav a[aria-current="page"] {
	box-shadow: inset 0 -2px 0 var(--accent);
}

/* ---------- Home intro ---------- */
.intro {
	display: grid;
	gap: 1rem;
	padding-block: clamp(2.25rem, 7vw, 3.75rem) clamp(1.75rem, 5vw, 2.5rem);
}

.intro h1 {
	margin: 0;
	font-size: clamp(1.85rem, 6vw, 2.75rem);
	font-weight: 600;
	line-height: 1.12;
	letter-spacing: -0.01em;
}

.intro-text {
	margin: 0;
	max-width: 36rem;
	color: var(--text-2);
}

.tools {
	margin: 0;
	font-family: var(--font-code);
	font-size: 0.85rem;
	font-weight: 500;
	color: var(--text);
}

/* ---------- Sections ---------- */
.section {
	border-top: 1px solid var(--line);
	padding-block: clamp(2rem, 5vw, 2.5rem);
}

.section-flush {
	border-top: none;
	padding-top: 0;
}

.section-head {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: baseline;
	gap: 0.5rem 1rem;
	margin-bottom: 1.25rem;
}

.section-head a {
	font-size: 0.92rem;
	font-weight: 500;
	text-underline-offset: 4px;
}

/* ---------- Page heading for list pages ---------- */
.page-head {
	display: grid;
	gap: 0.5rem;
	padding-block: clamp(2rem, 6vw, 3rem) 1.5rem;
}

.page-head h1 {
	margin: 0;
	font-size: clamp(1.7rem, 5vw, 2.25rem);
	font-weight: 600;
	line-height: 1.15;
}

.page-intro {
	color: var(--text-2);
}

/* ---------- Article list ---------- */
.articles {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
}

.article {
	display: grid;
	grid-template-columns: 1fr;
	gap: 0.25rem;
	padding-block: 1.1rem;
	border-bottom: 1px solid var(--line);
}

.article:first-child {
	padding-top: 0;
}

.article time {
	font-family: var(--font-code);
	font-size: 0.8rem;
	font-weight: 500;
	color: var(--text-2);
	font-variant-numeric: tabular-nums;
}

.article-body {
	display: grid;
	gap: 0.25rem;
	justify-items: start;
	min-width: 0;
}

.article h3 {
	margin: 0;
	font-size: 1.125rem;
	font-weight: 600;
	line-height: 1.35;
}

.article h3 a {
	color: var(--text);
	text-decoration: none;
}

.article h3 a:hover {
	color: var(--accent);
}

.summary {
	margin: 0;
	font-size: 0.98rem;
	color: var(--text-2);
}

/* ---------- Project cards ---------- */
.projects {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(17rem, 100%), 1fr));
	gap: 1rem;
}

.project {
	display: grid;
	align-content: start;
	gap: 0.6rem;
	min-width: 0;
	padding: 1.25rem;
	background: var(--panel);
}

.project h3 {
	margin: 0;
	font-size: 1.1rem;
	font-weight: 600;
	line-height: 1.3;
}

.project h3 a {
	color: var(--text);
	text-decoration: none;
}

.project h3 a:hover {
	color: var(--accent);
}

.project-text {
	margin: 0;
	font-size: 0.96rem;
	color: var(--text-2);
}

.flow {
	margin: 0;
	padding-bottom: 0.15rem;
	font-family: var(--font-code);
	font-size: 0.78rem;
	font-weight: 500;
	line-height: 1.6;
	color: var(--text);
}

.flow b {
	color: var(--accent);
	font-weight: 500;
}

.links {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem 1.25rem;
	font-size: 0.92rem;
	font-weight: 500;
}

.links a {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	text-underline-offset: 4px;
}

/* ---------- Single article / page ---------- */
.post {
	padding-block: clamp(2rem, 6vw, 3rem) clamp(2rem, 5vw, 3rem);
}

.post-head {
	display: grid;
	gap: 0.75rem;
	margin-bottom: 2rem;
}

.post-meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.25rem 0.5rem;
	margin: 0;
	font-family: var(--font-code);
	font-size: 0.8rem;
	font-weight: 500;
	color: var(--text-2);
}

.post-head h1 {
	margin: 0;
	font-size: clamp(1.75rem, 5.5vw, 2.5rem);
	font-weight: 600;
	line-height: 1.15;
	letter-spacing: -0.01em;
}

.post-lead {
	margin: 0;
	font-size: 1.15rem;
	color: var(--text-2);
}

.post-project {
	display: grid;
	gap: 0.5rem;
	padding: 1rem 1.1rem;
	background: var(--panel);
}

.post-project a {
	font-size: 0.92rem;
	font-weight: 500;
	text-underline-offset: 4px;
}

.post-cover {
	margin: 0 0 2rem;
}

.post-cover img {
	display: block;
	width: 100%;
}

.post-tags {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem 1rem;
	margin-top: 2.5rem;
	padding-top: 1.25rem;
	border-top: 1px solid var(--line);
	font-family: var(--font-code);
	font-size: 0.85rem;
	font-weight: 500;
}

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

.post-tags a:hover {
	color: var(--accent);
}

/* ---------- Article body text (whatever the editor produces) ---------- */
.prose > :first-child {
	margin-top: 0;
}

.prose > :last-child {
	margin-bottom: 0;
}

.prose p,
.prose ul,
.prose ol,
.prose blockquote,
.prose figure,
.prose pre,
.prose table {
	margin: 0 0 1.25rem;
}

.prose h2 {
	margin: 2.5rem 0 0.75rem;
	font-size: 1.5rem;
	font-weight: 600;
	line-height: 1.25;
}

.prose h3 {
	margin: 2rem 0 0.5rem;
	font-size: 1.2rem;
	font-weight: 600;
	line-height: 1.3;
}

.prose h4 {
	margin: 1.5rem 0 0.5rem;
	font-size: 1.05rem;
	font-weight: 600;
}

.prose a {
	font-weight: 500;
	text-underline-offset: 3px;
	overflow-wrap: anywhere;
}

.prose strong {
	font-weight: 600;
}

.prose ul,
.prose ol {
	padding-left: 1.4rem;
}

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

.prose li::marker {
	color: var(--text-2);
}

.prose blockquote {
	padding: 0.25rem 0 0.25rem 1rem;
	border-left: 3px solid var(--line);
	color: var(--text-2);
}

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

.prose img {
	display: block;
}

.prose figcaption {
	margin-top: 0.5rem;
	font-size: 0.9rem;
	color: var(--text-2);
}

.prose iframe,
.prose video {
	display: block;
	width: 100%;
	max-width: 100%;
	aspect-ratio: 16 / 9;
	height: auto;
	border: 0;
}

.prose code {
	font-family: var(--font-code);
	font-size: 0.88em;
	font-weight: 500;
	padding: 0.1em 0.35em;
	background: var(--inline-code-bg);
	overflow-wrap: anywhere;
}

.prose pre {
	padding: 1rem 1.1rem;
	background: var(--code-bg);
	color: var(--code-text);
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	font-size: 0.85rem;
	line-height: 1.6;
	tab-size: 4;
}

.prose pre code {
	padding: 0;
	background: none;
	font-size: inherit;
	color: inherit;
	overflow-wrap: normal;
	white-space: pre;
}

/* ---------- Syntax colours (Monokai Pro), applied by js/prism.js ---------- */
.prose .token.comment,
.prose .token.prolog,
.prose .token.doctype,
.prose .token.cdata {
	color: var(--code-comment);
	font-style: italic;
}

.prose .token.punctuation {
	color: var(--code-punctuation);
}

.prose .token.keyword,
.prose .token.operator,
.prose .token.tag,
.prose .token.important,
.prose .token.deleted,
.prose .token.atrule .token.rule {
	color: var(--code-pink);
}

.prose .token.string,
.prose .token.char,
.prose .token.attr-value,
.prose .token.regex,
.prose .token.url,
.prose .token.template-string {
	color: var(--code-yellow);
}

.prose .token.number,
.prose .token.boolean,
.prose .token.constant,
.prose .token.symbol,
.prose .token.entity {
	color: var(--code-purple);
}

.prose .token.function,
.prose .token.attr-name,
.prose .token.selector,
.prose .token.inserted,
.prose .token.decorator,
.prose .token.annotation {
	color: var(--code-green);
}

.prose .token.class-name,
.prose .token.builtin,
.prose .token.property,
.prose .token.namespace,
.prose .token.key {
	color: var(--code-cyan);
}

.prose .token.parameter,
.prose .token.variable,
.prose .token.interpolation,
.prose .token.shebang {
	color: var(--code-orange);
}

.prose .token.bold,
.prose .token.important {
	font-weight: 600;
}

.prose .token.italic {
	font-style: italic;
}

.prose table {
	display: block;
	max-width: 100%;
	overflow-x: auto;
	border-collapse: collapse;
	font-size: 0.95rem;
	font-variant-numeric: tabular-nums;
}

.prose th,
.prose td {
	padding: 0.5rem 0.75rem;
	border-bottom: 1px solid var(--line);
	text-align: left;
	vertical-align: top;
}

.prose th {
	font-weight: 600;
	white-space: nowrap;
}

/* ---------- Contact band ---------- */
.contact {
	margin-top: 1rem;
	padding-block: clamp(2.25rem, 7vw, 3.25rem);
	background: var(--band);
	color: var(--band-text);
}

.contact .label {
	color: var(--band-text-2);
}

.contact h2 {
	margin: 0.5rem 0 0.75rem;
	font-size: clamp(1.45rem, 4.5vw, 2rem);
	font-weight: 600;
	line-height: 1.2;
}

.contact-text {
	max-width: 34rem;
	margin: 0 0 1.25rem;
	color: var(--band-text-2);
}

.contact-lines {
	display: grid;
	gap: 0.35rem;
	margin: 0;
	font-family: var(--font-code);
	font-size: 0.9rem;
	font-weight: 500;
}

.contact-lines div {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 0 1rem;
}

.contact-lines dt {
	min-width: 6.5rem;
	color: var(--band-text-2);
}

.contact-lines dd {
	margin: 0;
	min-width: 0;
}

.contact-lines a {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	text-underline-offset: 4px;
	overflow-wrap: anywhere;
}

/* ---------- Pagination ---------- */
.pager {
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	align-items: center;
	gap: 1rem;
	margin-top: 1.5rem;
	font-size: 0.95rem;
	font-weight: 500;
}

.pager a {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	text-underline-offset: 4px;
}

.pager a:last-child {
	justify-self: end;
}

.pager-count {
	font-family: var(--font-code);
	font-size: 0.8rem;
	color: var(--text-2);
}

/* ---------- 404 ---------- */
.not-found {
	display: grid;
	gap: 0.75rem;
	justify-items: start;
	padding-block: clamp(3rem, 10vw, 5rem);
}

.not-found h1 {
	margin: 0;
	font-size: clamp(1.7rem, 5vw, 2.25rem);
	font-weight: 600;
}

.not-found p:not(.label) {
	margin: 0;
	color: var(--text-2);
}

/* ---------- Footer ---------- */
.site-footer {
	padding-block: 1.5rem calc(1.5rem + env(safe-area-inset-bottom, 0px));
	font-size: 0.85rem;
	color: var(--text-2);
}

.site-footer-inner {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	gap: 0.5rem 1rem;
}

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

/* ---------- Narrow phones: menu gets its own row under the wordmark ---------- */
@media (max-width: 30rem) {
	.site-header-inner {
		padding-top: 0.6rem;
	}

	.nav {
		width: 100%;
		column-gap: 1.1rem;
	}

	.nav a {
		min-height: 40px;
	}
}

/* ---------- Wider screens ---------- */
@media (min-width: 40rem) {
	.article {
		grid-template-columns: 6.5rem 1fr;
		column-gap: 1.25rem;
	}

	.article time {
		padding-top: 0.2rem;
	}
}

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		transition: none !important;
		animation: none !important;
		scroll-behavior: auto !important;
	}
}

/* ---------- Print ---------- */
@media print {
	.site-header,
	.contact,
	.site-footer,
	.skip-link {
		display: none;
	}

	body {
		background: #fff;
		color: #000;
	}
}
