/* site.css — all tokens come from themes.css */

* { box-sizing: border-box; }

html {
	scroll-behavior: smooth;
	scroll-padding-top: 80px;
}

body {
	margin: 0;
	font-family: var(--font-body);
	font-weight: var(--body-weight);
	letter-spacing: var(--body-tracking);
	color: var(--fg);
	background: var(--bg);
	line-height: 1.7;
	font-size: 16px;
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
}

a {
	color: var(--accent);
	text-decoration: none;
	transition: color 0.15s;
}
a:hover { color: var(--accent-hover); }

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

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

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

.site-header {
	display: flex;
	gap: 1rem;
	padding: 1rem 2rem;
	align-items: center;
	background: color-mix(in srgb, var(--bg) 85%, transparent);
	font-family: var(--font-ui);
	letter-spacing: var(--body-tracking);
	position: sticky;
	top: 0;
	z-index: 20;
	backdrop-filter: saturate(180%) blur(10px);
	-webkit-backdrop-filter: saturate(180%) blur(10px);
	box-shadow: 0 1px 0 var(--border-subtle);
}
.brand {
	font-weight: 700;
	color: var(--fg);
	font-size: 1.05rem;
	letter-spacing: -0.02em;
}
.site-header nav {
	display: flex;
	gap: 1.5rem;
	align-items: center;
	margin-left: auto;
}
.site-header nav a {
	color: var(--fg-muted);
	font-size: 0.9rem;
	font-weight: 500;
	position: relative;
}
.site-header nav a:hover { color: var(--fg); }
.site-header nav a::after {
	content: '';
	position: absolute;
	left: 0;
	right: 0;
	bottom: -4px;
	height: 2px;
	background: var(--accent);
	transform: scaleX(0);
	transform-origin: center;
	transition: transform 0.18s ease;
	border-radius: var(--radius-pill);
}
.site-header nav a:hover::after {
	transform: scaleX(0.6);
}

.theme-switcher {
	background: var(--bg-card);
	border: 1px solid var(--border);
	color: var(--fg-muted);
	padding: 0.4rem 2rem 0.4rem 0.75rem;
	border-radius: var(--radius-sm);
	font-family: var(--font-ui);
	font-size: 0.8rem;
	font-weight: 500;
	cursor: pointer;
	appearance: none;
	-webkit-appearance: none;
	background-image:
		linear-gradient(45deg, transparent 50%, currentColor 50%),
		linear-gradient(135deg, currentColor 50%, transparent 50%);
	background-position: calc(100% - 13px) center, calc(100% - 9px) center;
	background-size: 4px 4px;
	background-repeat: no-repeat;
	box-shadow: var(--shadow-card);
	transition: all 0.18s ease;
}
.theme-switcher:hover {
	color: var(--fg);
	transform: translateY(-1px);
	box-shadow: var(--shadow-lift);
}
.theme-switcher:focus {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

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

main {
	max-width: 760px;
	margin: 3rem auto 4rem;
	padding: 0 1.25rem;
}

.post-layout {
	max-width: 1080px;
	margin: 3rem auto 4rem;
	padding: 0 1.25rem;
	display: grid;
	grid-template-columns: minmax(0, 760px) 220px;
	gap: 3rem;
}
@media (max-width: 1080px) {
	.post-layout {
		grid-template-columns: 1fr;
		max-width: 760px;
	}
	.post-toc { display: none; }
}

/* ---------- Hero (home) ---------- */

.hero {
	margin-bottom: 3.5rem;
	padding: 3rem 0 2.5rem;
	position: relative;
	overflow: hidden;
}
.hero::before {
	content: '';
	position: absolute;
	inset: -40% -40% auto auto;
	width: 70%;
	height: 140%;
	background: radial-gradient(circle at center, var(--accent-weak), transparent 70%);
	pointer-events: none;
	opacity: 0.8;
}
.hero-grid {
	display: grid;
	grid-template-columns: 1fr auto;
	gap: 2rem;
	align-items: center;
	position: relative;
}
.hero h1 {
	font-family: var(--font-ui);
	font-size: clamp(2rem, 5vw, 3.25rem);
	font-weight: var(--hero-weight);
	margin: 0 0 0.5rem;
	letter-spacing: var(--heading-tracking);
	line-height: 1.08;
	color: var(--fg);
}
.hero p {
	color: var(--fg-muted);
	margin: 0;
	font-size: 1.1rem;
	font-family: var(--font-ui);
}

.profile-card {
	display: flex;
	gap: 0.85rem;
	align-items: center;
	padding: 0.85rem 1.1rem;
	background: var(--bg-card);
	border-radius: var(--radius-pill);
	box-shadow: var(--shadow-card);
	font-family: var(--font-ui);
	font-size: 0.85rem;
}
.profile-card .avatar {
	width: 42px;
	height: 42px;
	border-radius: 50%;
	background: var(--accent-weak);
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--accent);
	font-weight: 700;
	font-size: 1rem;
	flex-shrink: 0;
}
.profile-card .meta strong { display: block; color: var(--fg); font-weight: 600; }
.profile-card .meta span { color: var(--fg-subtle); font-size: 0.78rem; }

@media (max-width: 640px) {
	.hero-grid { grid-template-columns: 1fr; }
	.profile-card { justify-self: start; }
}

/* ---------- Section blocks ---------- */

.block { margin-bottom: 3.5rem; }
.block-title {
	font-family: var(--font-ui);
	font-size: 0.75rem;
	margin: 0 0 1.25rem;
	color: var(--fg-subtle);
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.1em;
}

.page-header {
	margin-bottom: 2.5rem;
	padding: 2rem 0 1.5rem;
}
.page-header h1 {
	font-family: var(--font-ui);
	margin: 0 0 0.25rem;
	font-size: clamp(1.75rem, 4vw, 2.5rem);
	font-weight: var(--hero-weight);
	letter-spacing: var(--heading-tracking);
}

/* ---------- Post cards ---------- */

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

.post-card {
	background: var(--bg-card);
	border-radius: var(--radius);
	box-shadow: var(--shadow-card);
	overflow: hidden;
	transform: translateZ(0);
	transition: transform 0.28s ease, box-shadow 0.28s ease;
	will-change: transform;
}
.post-card:hover {
	transform: translateY(-4px);
	box-shadow: var(--shadow-lift);
}
.post-card a {
	display: grid;
	grid-template-columns: 200px 1fr;
	color: var(--fg);
	align-items: stretch;
}
.post-card .thumb {
	background-size: cover;
	background-position: center;
	min-height: 140px;
}
.post-card .body {
	padding: 1.35rem 1.6rem;
}
.post-card h3 {
	font-family: var(--font-ui);
	margin: 0.25rem 0 0.35rem;
	font-size: 1.22rem;
	font-weight: var(--heading-weight);
	letter-spacing: var(--heading-tracking);
	line-height: 1.3;
}
.post-card-meta {
	font-family: var(--font-ui);
	font-size: 0.72rem;
	color: var(--fg-subtle);
	margin: 0 0 0.2rem;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	font-weight: 600;
	display: flex;
	gap: 0.5rem;
	align-items: center;
	flex-wrap: wrap;
}
.post-card-meta .chip {
	background: var(--accent-weak);
	color: var(--accent);
	padding: 0.2rem 0.55rem;
	border-radius: var(--radius-pill);
	font-size: 0.68rem;
	letter-spacing: 0.05em;
}
.post-card-summary {
	margin: 0.5rem 0 0;
	color: var(--fg-muted);
	font-size: 0.94rem;
	line-height: 1.55;
	font-family: var(--font-ui);
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

@media (max-width: 640px) {
	.post-card a { grid-template-columns: 1fr; }
	.post-card .thumb { min-height: 160px; }
}

/* ---------- Category grid ---------- */

.category-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
	gap: 1rem;
}
.category-card {
	display: block;
	padding: 1.35rem 1.5rem;
	background: var(--bg-card);
	border-radius: var(--radius);
	color: var(--fg);
	box-shadow: var(--shadow-card);
	transition: transform 0.28s ease, box-shadow 0.28s ease;
}
.category-card:hover {
	transform: translateY(-3px);
	box-shadow: var(--shadow-lift);
	color: var(--fg);
}
.category-card h3 {
	font-family: var(--font-ui);
	margin: 0 0 0.3rem;
	font-size: 1.1rem;
	font-weight: var(--heading-weight);
	letter-spacing: var(--heading-tracking);
}
.category-card p {
	margin: 0;
	color: var(--fg-subtle);
	font-size: 0.85rem;
	font-family: var(--font-ui);
}

/* ---------- Post detail ---------- */

.post { background: transparent; padding: 0; box-shadow: none; }

.post-cover {
	width: 100%;
	aspect-ratio: 16 / 8;
	border-radius: var(--radius);
	overflow: hidden;
	background: var(--bg-alt);
	margin-bottom: 2rem;
	box-shadow: var(--shadow-card);
}
.post-cover img,
.post-cover svg {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.post-header { margin-bottom: 2.25rem; }
.post-header h1 {
	font-family: var(--font-ui);
	margin: 0.75rem 0;
	font-size: clamp(1.85rem, 3.8vw, 2.6rem);
	line-height: 1.2;
	font-weight: var(--hero-weight);
	letter-spacing: var(--heading-tracking);
}
.post-meta {
	margin: 0;
	font-size: 0.78rem;
	color: var(--fg-subtle);
	font-family: var(--font-ui);
	text-transform: uppercase;
	letter-spacing: 0.08em;
	font-weight: 600;
	display: flex;
	gap: 0.75rem;
	align-items: center;
	flex-wrap: wrap;
}
.post-meta .chip {
	background: var(--accent-weak);
	color: var(--accent);
	padding: 0.25rem 0.65rem;
	border-radius: var(--radius-pill);
	font-size: 0.7rem;
}
.post-meta a { color: inherit; }
.post-meta a:hover { color: var(--fg); }
.post-meta .dot { color: var(--fg-subtle); }

.post-summary {
	margin: 1rem 0 0;
	color: var(--fg-muted);
	font-size: 1.05rem;
	padding-left: 1rem;
	border-left: 3px solid var(--accent);
	font-family: var(--font-ui);
	line-height: 1.6;
}

/* ---------- Post body ---------- */

.post-body {
	font-family: var(--font-body);
	font-size: 1.06rem;
	line-height: 1.85;
	color: var(--fg);
}
.post-body h2 {
	font-family: var(--font-ui);
	font-size: 1.5rem;
	margin: 2.5rem 0 1rem;
	font-weight: var(--heading-weight);
	letter-spacing: var(--heading-tracking);
}
.post-body h3 {
	font-family: var(--font-ui);
	font-size: 1.2rem;
	margin: 1.75rem 0 0.75rem;
	font-weight: var(--heading-weight);
}
.post-body p { margin: 1rem 0; }
.post-body ul, .post-body ol { margin: 1rem 0; padding-left: 1.5rem; }
.post-body li { margin: 0.35rem 0; }

.post-body code {
	background: var(--bg-code);
	padding: 0.15rem 0.45rem;
	border-radius: 4px;
	font-size: 0.88em;
	font-family: var(--font-mono);
	color: var(--fg);
	box-shadow: 0 0 0 1px var(--border-subtle);
}
.post-body pre {
	background: var(--bg-code);
	color: var(--fg);
	padding: 1.15rem 1.35rem;
	border-radius: var(--radius);
	overflow-x: auto;
	font-size: 0.86rem;
	line-height: 1.6;
	font-family: var(--font-mono);
	box-shadow: inset 0 0 0 1px var(--border);
	margin: 1.25rem 0;
}
.post-body pre code {
	background: none;
	padding: 0;
	box-shadow: none;
}

.post-body blockquote {
	margin: 1.5rem 0;
	padding: 0.75rem 1.25rem;
	border-left: 4px solid var(--accent);
	color: var(--fg-muted);
	background: var(--accent-weak);
	border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
	font-style: italic;
}

.post-body table {
	border-collapse: collapse;
	width: 100%;
	margin: 1.25rem 0;
	font-size: 0.93rem;
	font-family: var(--font-ui);
	background: var(--bg-card);
	border-radius: var(--radius-sm);
	overflow: hidden;
	box-shadow: var(--shadow-card);
}
.post-body th, .post-body td {
	padding: 0.6rem 0.85rem;
	text-align: left;
	border-bottom: 1px solid var(--border-subtle);
}
.post-body tr:last-child td { border-bottom: 0; }
.post-body th {
	background: var(--bg-alt);
	font-weight: 600;
	color: var(--fg);
}

.post-body img, .post-body video {
	max-width: 100%;
	height: auto;
	border-radius: var(--radius);
	margin: 1.5rem 0;
	box-shadow: var(--shadow-card);
}
.post-body a {
	color: var(--accent);
	border-bottom: 1px dashed currentColor;
	transition: border-bottom-style 0.15s;
}
.post-body a:hover { border-bottom-style: solid; }

.post-footer {
	margin-top: 3rem;
	padding-top: 1.5rem;
	border-top: 1px solid var(--border-subtle);
	font-size: 0.9rem;
	font-family: var(--font-ui);
}

/* ---------- TOC sidebar ---------- */

.post-toc {
	position: sticky;
	top: 96px;
	align-self: start;
	max-height: calc(100vh - 120px);
	overflow-y: auto;
	font-family: var(--font-ui);
	font-size: 0.83rem;
}
.post-toc-title {
	font-size: 0.7rem;
	font-weight: 600;
	color: var(--fg-subtle);
	text-transform: uppercase;
	letter-spacing: 0.12em;
	margin: 0 0 0.85rem;
}
.post-toc ul {
	list-style: none;
	padding: 0;
	margin: 0;
	border-left: 1px solid var(--border);
}
.post-toc li { margin: 0; }
.post-toc a {
	display: block;
	padding: 0.35rem 0 0.35rem 0.85rem;
	color: var(--fg-subtle);
	margin-left: -1px;
	border-left: 1px solid transparent;
	transition: all 0.15s ease;
	line-height: 1.45;
}
.post-toc a:hover {
	color: var(--fg);
	border-left-color: var(--fg-muted);
}
.post-toc a.h3 {
	padding-left: 1.75rem;
	font-size: 0.78rem;
}
.post-toc a.active {
	color: var(--accent);
	border-left-color: var(--accent);
	font-weight: 500;
}

.empty {
	color: var(--fg-subtle);
	text-align: center;
	padding: 3rem 0;
	font-family: var(--font-ui);
}

/* ---------- HTMX like button ---------- */

.like-btn {
	font-size: 0.93rem;
	padding: 0.6rem 1.35rem;
	border: 1px solid var(--accent);
	background: transparent;
	color: var(--accent);
	border-radius: var(--radius-sm);
	cursor: pointer;
	font-family: var(--font-ui);
	font-weight: 500;
	transition: all 0.18s ease;
}
.like-btn:hover {
	background: var(--accent);
	color: var(--accent-contrast);
	transform: translateY(-1px);
	box-shadow: var(--shadow-card);
}
.like-btn:active { transform: translateY(0); }

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

.site-footer {
	text-align: center;
	padding: 2.5rem 2rem;
	color: var(--fg-subtle);
	margin-top: 4rem;
	background: var(--bg);
	box-shadow: 0 -1px 0 var(--border-subtle);
	font-family: var(--font-ui);
	font-size: 0.83rem;
}

/* ---------- Reveal animations ---------- */

.reveal {
	opacity: 0;
	transform: translateY(16px);
	transition:
		opacity 0.5s cubic-bezier(0.2, 0.6, 0.2, 1),
		transform 0.5s cubic-bezier(0.2, 0.6, 0.2, 1);
	will-change: opacity, transform;
}
.reveal.in-view {
	opacity: 1;
	transform: translateY(0);
}
.reveal.stagger-1 { transition-delay: 0.08s; }
.reveal.stagger-2 { transition-delay: 0.16s; }
.reveal.stagger-3 { transition-delay: 0.24s; }
.reveal.stagger-4 { transition-delay: 0.32s; }

@media (prefers-reduced-motion: reduce) {
	.reveal { opacity: 1; transform: none; transition: none; }
	html { scroll-behavior: auto; }
	* { animation-duration: 0s !important; transition-duration: 0.01s !important; }
}

/* ---------- Video wrapper ---------- */

.video-wrapper {
	position: relative;
	padding-top: 56.25%;
	margin: 1rem 0;
}
.video-wrapper iframe {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
	border-radius: var(--radius);
}
