/* BittyBlog — a small, sweet space on the internet */

:root {
	--bg: #fdf7ee;
	--surface: #fffdf8;
	--surface-soft: #fff1e8;
	--ink: #3d352c;
	--muted: #8a7a67;
	--accent: #e4634f;
	--accent-soft: #ffe1d6;
	--accent-deep: #b03e2d;
	--border: #f0e2d0;
	--shadow-sm: 0 1px 2px rgba(61, 53, 44, 0.06);
	--shadow-md: 0 2px 4px rgba(61, 53, 44, 0.06), 0 10px 28px rgba(61, 53, 44, 0.08);

	--font-ui: ui-rounded, "Hiragino Maru Gothic ProN", Quicksand, Comfortaa, ui-sans-serif, system-ui, sans-serif;
	--font-body: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;

	--radius: 1.25rem;
	--max-width: 42rem;

	color-scheme: light;
}

@media (prefers-color-scheme: dark) {
	:root:not(.theme-light) {
		--bg: #251f19;
		--surface: #2f2821;
		--surface-soft: #3a2c26;
		--ink: #f3e9dc;
		--muted: #bcab96;
		--accent: #ff8a76;
		--accent-soft: #462c25;
		--accent-deep: #ffa893;
		--border: #453a30;
		--shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
		--shadow-md: 0 2px 4px rgba(0, 0, 0, 0.35), 0 12px 30px rgba(0, 0, 0, 0.4);

		color-scheme: dark;
	}
}

/* Explicit dark mode always wins over the system preference. */
:root.theme-dark {
	--bg: #251f19;
	--surface: #2f2821;
	--surface-soft: #3a2c26;
	--ink: #f3e9dc;
	--muted: #bcab96;
	--accent: #ff8a76;
	--accent-soft: #462c25;
	--accent-deep: #ffa893;
	--border: #453a30;
	--shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
	--shadow-md: 0 2px 4px rgba(0, 0, 0, 0.35), 0 12px 30px rgba(0, 0, 0, 0.4);

	color-scheme: dark;
}

* {
	box-sizing: border-box;
}

html {
	overflow-y: scroll;
	scroll-behavior: smooth;
}

body {
	margin: 0;
	font-family: var(--font-body);
	font-size: 1.0625rem;
	line-height: 1.7;
	color: var(--ink);
	background-color: var(--bg);
}

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

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

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

/* Skip link */
.skip-link {
	position: absolute;
	left: -999px;
	top: 0;
	background: var(--accent);
	color: #fff;
	padding: 0.6rem 1rem;
	border-radius: 0 0 0.75rem 0.75rem;
	font-family: var(--font-ui);
	z-index: 10;
}

.skip-link:focus {
	left: 0;
}

/* ---------- Header ---------- */

.site-header {
	background: linear-gradient(180deg, var(--surface-soft), var(--bg));
	border-bottom: 2px dashed var(--border);
	border-radius: 0 0 2.25rem 2.25rem;
	padding: 3rem 1.5rem 2rem;
	text-align: center;
}

.site-title {
	display: inline-block;
	font-family: var(--font-ui);
	font-size: 2.1rem;
	font-weight: 800;
	letter-spacing: -0.02em;
	color: var(--accent-deep);
	text-decoration: none;
	padding: 0.15em 0.6em;
	background: var(--surface);
	border: 2px solid var(--accent);
	border-radius: 999px;
	box-shadow: var(--shadow-sm);
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.site-title:hover {
	transform: rotate(-2deg) scale(1.02);
	box-shadow: var(--shadow-md);
}

.site-nav {
	display: flex;
	gap: 1.5rem;
	justify-content: center;
	margin-top: 1.4rem;
	font-family: var(--font-ui);
	font-size: 0.95rem;
	font-weight: 600;
}

.site-nav a {
	text-decoration: none;
	color: var(--muted);
	padding: 0.35em 0.9em;
	border-radius: 999px;
}

.site-nav a:hover {
	color: var(--accent-deep);
	background: var(--accent-soft);
}

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

/* Theme toggle */
.theme-toggle {
	position: absolute;
	top: 1rem;
	right: 1rem;
	display: grid;
	place-items: center;
	width: 2.5rem;
	height: 2.5rem;
	padding: 0.55rem;
	border: 2px solid var(--border);
	border-radius: 999px;
	background: var(--surface);
	color: var(--ink);
	cursor: pointer;
	box-shadow: var(--shadow-sm);
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.theme-toggle:hover {
	transform: translateY(-2px) rotate(-6deg);
	box-shadow: var(--shadow-md);
}

.theme-toggle svg {
	width: 100%;
	height: 100%;
}

.theme-toggle .icon-moon {
	display: none;
}

html.theme-dark .theme-toggle .icon-sun {
	display: none;
}

html.theme-dark .theme-toggle .icon-moon {
	display: block;
}

/* ---------- Layout ---------- */

main {
	max-width: var(--max-width);
	margin: 0 auto;
	padding: 2.5rem 1.5rem 3rem;
}

.page-title {
	font-family: var(--font-ui);
	font-size: 1.75rem;
	font-weight: 800;
	margin: 0 0 1.5rem;
}

.page-title::after {
	content: "";
	display: block;
	width: 3.5rem;
	height: 0.35rem;
	margin-top: 0.5rem;
	border-radius: 999px;
	background: var(--accent);
}

/* ---------- Home: post cards ---------- */

.post-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	gap: 1.1rem;
}

.post-card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow-sm);
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.post-card:hover {
	transform: translateY(-3px);
	box-shadow: var(--shadow-md);
}

.post-card-link {
	display: block;
	padding: 1.1rem 1.4rem;
	text-decoration: none;
	color: inherit;
}

.post-card-link h2 {
	font-family: var(--font-ui);
	font-size: 1.3rem;
	font-weight: 700;
	margin: 0.15rem 0 0.4rem;
	color: var(--ink);
}

.post-card-link:hover h2 {
	color: var(--accent-deep);
}

.post-card-date {
	font-family: var(--font-ui);
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--accent);
}

.post-card-excerpt {
	margin: 0;
	color: var(--muted);
	font-size: 0.95rem;
	line-height: 1.55;
}

/* ---------- Post page ---------- */

.post-header {
	margin-bottom: 2rem;
	padding-bottom: 1.25rem;
	border-bottom: 2px dashed var(--border);
}

.post-header h1 {
	font-family: var(--font-ui);
	font-size: 2.1rem;
	font-weight: 800;
	line-height: 1.15;
	margin: 0.35rem 0 0;
	color: var(--ink);
}

.post-date {
	font-family: var(--font-ui);
	font-size: 0.8rem;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--accent);
}

/* Reading the post itself */
.post-body > :first-child {
	margin-top: 0;
}

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

.post-body p {
	margin: 0 0 1.4rem;
}

.post-body > p:first-of-type::first-letter {
	font-family: var(--font-ui);
	font-weight: 800;
	font-size: 3.1em;
	float: left;
	line-height: 0.9;
	margin: 0.06em 0.12em 0 0;
	color: var(--accent-deep);
}

.post-body h2,
.post-body h3,
.post-body h4 {
	font-family: var(--font-ui);
	line-height: 1.25;
	margin: 2.2em 0 0.7em;
	color: var(--ink);
}

.post-body h2 {
	font-size: 1.5rem;
	font-weight: 800;
	padding-bottom: 0.25em;
	border-bottom: 2px dashed var(--border);
}

.post-body h3 {
	font-size: 1.2rem;
	font-weight: 700;
	color: var(--accent-deep);
}

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

.post-body ul,
.post-body ol {
	margin: 0 0 1.4rem;
	padding-left: 1.5rem;
}

.post-body li {
	margin-bottom: 0.4rem;
}

.post-body blockquote {
	margin: 1.6rem 0;
	padding: 0.6rem 1.2rem;
	border-left: 4px solid var(--accent);
	background: var(--surface-soft);
	border-radius: 0 var(--radius) var(--radius) 0;
	color: var(--muted);
	font-style: italic;
}

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

.post-body code {
	font-family: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
	font-size: 0.88em;
	background: var(--surface-soft);
	border: 1px solid var(--border);
	border-radius: 0.4rem;
	padding: 0.15em 0.4em;
}

.post-body pre {
	background: #2f2821;
	color: #f3e9dc;
	border-radius: var(--radius);
	padding: 1.1rem 1.3rem;
	overflow-x: auto;
	margin: 0 0 1.4rem;
	line-height: 1.55;
	font-size: 0.9rem;
}

.post-body pre code {
	background: none;
	border: 0;
	padding: 0;
	font-size: 1em;
}

.post-body img {
	max-width: 100%;
	height: auto;
	border-radius: var(--radius);
	box-shadow: var(--shadow-md);
}

.post-body hr {
	border: 0;
	border-top: 2px dashed var(--border);
	margin: 2.5rem 0;
}

/* Prev / next post navigation */
.post-nav {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	gap: 1rem;
	margin-top: 2.5rem;
	padding-top: 1.5rem;
	border-top: 2px dashed var(--border);
}

.post-nav-card {
	flex-basis: calc(50% - 0.5rem);
	display: flex;
	align-items: center;
	gap: 0.75rem;
	padding: 0.9rem 1.1rem;
	background: var(--surface);
	border: 2px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow-sm);
	text-decoration: none;
	color: inherit;
	transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.post-nav-card:hover {
	transform: translateY(-2px);
	box-shadow: var(--shadow-md);
	border-color: var(--accent);
}

.post-nav-arrow {
	font-family: var(--font-ui);
	font-size: 1.15rem;
	color: var(--accent);
	flex-shrink: 0;
}

.post-nav-newer {
	margin-left: auto;
}

.post-nav-newer .post-nav-arrow {
	order: 2;
}

.post-nav-text {
	display: flex;
	flex-direction: column;
	gap: 0.15rem;
	min-width: 0;
}

.post-nav-label {
	font-family: var(--font-ui);
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--accent);
}

.post-nav-title {
	font-family: var(--font-ui);
	font-weight: 700;
	font-size: 0.95rem;
	line-height: 1.3;
	color: var(--ink);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.post-nav-card:hover .post-nav-title {
	color: var(--accent-deep);
}

/* ---------- Footer ---------- */

.site-footer {
	max-width: var(--max-width);
	margin: 0 auto;
	padding: 1.5rem;
	border-top: 2px dashed var(--border);
	text-align: center;
	font-family: var(--font-ui);
	font-size: 0.85rem;
	color: var(--muted);
}

.site-footer p {
	margin: 0;
}

/* ---------- Small screens ---------- */

@media (max-width: 480px) {
	.site-title {
		font-size: 1.7rem;
	}

	.post-header h1 {
		font-size: 1.7rem;
	}
}