/* Haoyue Xiao — site styles */

:root {
	--bg: #fbfbfa;
	--surface: #ffffff;
	--surface-2: #f2f3f5;
	--text: #1d2127;
	--text-2: #4a515c;
	--muted: #7b828d;
	--line: #e4e6ea;
	--accent: #1f5fa8;
	--accent-hover: #174a85;
	--accent-soft: rgba(31, 95, 168, 0.09);
	--gold: #c9951c;
	--shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 6px 20px rgba(16, 24, 40, 0.06);
	--shadow-hover: 0 2px 4px rgba(16, 24, 40, 0.06), 0 14px 32px rgba(16, 24, 40, 0.1);
	--radius: 12px;
	--serif: "Source Serif 4", Georgia, serif;
	--sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
	--mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	color-scheme: light;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--bg: #111316;
		--surface: #181b20;
		--surface-2: #20242a;
		--text: #e8eaed;
		--text-2: #b8bdc5;
		--muted: #8a919b;
		--line: #2a2f36;
		--accent: #7fb0ec;
		--accent-hover: #a5c8f3;
		--accent-soft: rgba(127, 176, 236, 0.12);
		--shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
		--shadow-hover: 0 8px 28px rgba(0, 0, 0, 0.45);
		color-scheme: dark;
	}
}

:root[data-theme="dark"] {
	--bg: #111316;
	--surface: #181b20;
	--surface-2: #20242a;
	--text: #e8eaed;
	--text-2: #b8bdc5;
	--muted: #8a919b;
	--line: #2a2f36;
	--accent: #7fb0ec;
	--accent-hover: #a5c8f3;
	--accent-soft: rgba(127, 176, 236, 0.12);
	--shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
	--shadow-hover: 0 8px 28px rgba(0, 0, 0, 0.45);
	color-scheme: dark;
}

/* Base */

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: 16px/1.7 var(--sans);
	-webkit-font-smoothing: antialiased;
	display: flex;
	flex-direction: column;
	min-height: 100vh;
}

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

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 3px; }

h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; line-height: 1.25; color: var(--text); margin: 0 0 0.5em; }

p { margin: 0 0 1em; }

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

.container { width: 100%; max-width: 960px; margin: 0 auto; padding: 0 24px; }

@media (max-width: 600px) {
	.container { padding: 0 16px; }
}

.main { flex: 1; padding-top: 56px; padding-bottom: 80px; }

/* Header / nav */

.site-header {
	position: sticky;
	top: 0;
	z-index: 100;
	background: color-mix(in srgb, var(--bg) 85%, transparent);
	-webkit-backdrop-filter: saturate(180%) blur(12px);
	backdrop-filter: saturate(180%) blur(12px);
	border-bottom: 1px solid var(--line);
}

.nav { display: flex; align-items: center; justify-content: space-between; height: 64px; }

.brand { font-family: var(--serif); font-weight: 700; font-size: 1.2rem; color: var(--text); }
.brand:hover { color: var(--text); text-decoration: none; }

.nav-links { display: flex; align-items: center; gap: 4px; }

.nav-links a {
	color: var(--text-2);
	font-size: 0.93rem;
	font-weight: 500;
	padding: 6px 12px;
	border-radius: 8px;
}

.nav-links a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.nav-links a[aria-current="page"] { color: var(--accent); }

.theme-toggle {
	border: 0;
	background: none;
	color: var(--text-2);
	width: 36px;
	height: 36px;
	border-radius: 8px;
	cursor: pointer;
	font-size: 0.95rem;
	margin-left: 4px;
}

.theme-toggle:hover { background: var(--surface-2); color: var(--text); }
.theme-toggle .fa-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .fa-sun { display: inline; }
:root[data-theme="dark"] .theme-toggle .fa-moon { display: none; }
@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) .theme-toggle .fa-sun { display: inline; }
	:root:not([data-theme="light"]) .theme-toggle .fa-moon { display: none; }
}

.nav-toggle, .nav-burger { display: none; }

@media (max-width: 720px) {
	.nav-burger {
		display: flex;
		align-items: center;
		justify-content: center;
		width: 40px;
		height: 40px;
		cursor: pointer;
		border-radius: 8px;
	}

	.nav-burger span, .nav-burger span::before, .nav-burger span::after {
		display: block;
		width: 18px;
		height: 2px;
		background: var(--text);
		border-radius: 2px;
		position: relative;
		transition: transform 0.2s ease, background 0.2s ease;
	}

	.nav-burger span::before, .nav-burger span::after { content: ''; position: absolute; left: 0; }
	.nav-burger span::before { top: -6px; }
	.nav-burger span::after { top: 6px; }

	.nav-toggle:checked + .nav-burger span { background: transparent; }
	.nav-toggle:checked + .nav-burger span::before { transform: translateY(6px) rotate(45deg); }
	.nav-toggle:checked + .nav-burger span::after { transform: translateY(-6px) rotate(-45deg); }

	.nav-links {
		display: none;
		position: absolute;
		top: 64px;
		left: 0;
		right: 0;
		flex-direction: column;
		align-items: stretch;
		padding: 8px 16px 16px;
		background: var(--bg);
		border-bottom: 1px solid var(--line);
		box-shadow: var(--shadow);
	}

	.nav-links a { padding: 10px 12px; font-size: 1rem; }
	.nav-toggle:checked ~ .nav-links { display: flex; }
	.theme-toggle { align-self: flex-start; margin: 4px 0 0 4px; }
}

/* Hero */

.hero {
	display: grid;
	grid-template-columns: 1fr 260px;
	gap: 56px;
	align-items: center;
	margin-bottom: 72px;
}

.hero h1 { font-size: 2.75rem; margin-bottom: 0.15em; letter-spacing: -0.01em; }

.hero-role {
	color: var(--muted);
	font-size: 0.95rem;
	font-weight: 500;
	margin-bottom: 1.5em;
}

.hero-text p { color: var(--text-2); }
.hero-text strong { color: var(--text); font-weight: 600; }

.hero-photo img {
	display: block;
	width: 100%;
	aspect-ratio: 1;
	object-fit: cover;
	border-radius: 20px;
	box-shadow: var(--shadow-hover);
}

@media (max-width: 760px) {
	.hero { grid-template-columns: 1fr; gap: 28px; margin-bottom: 56px; }
	.hero-photo { order: -1; }
	.hero-photo img { width: 160px; border-radius: 50%; }
	.hero h1 { font-size: 2.2rem; }
}

.social { list-style: none; padding: 0; margin: 1.75em 0 0; display: flex; flex-wrap: wrap; gap: 8px; }

.social a {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 7px 14px;
	border: 1px solid var(--line);
	border-radius: 999px;
	color: var(--text-2);
	background: var(--surface);
	font-size: 0.88rem;
	font-weight: 500;
	transition: border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.social a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; transform: translateY(-1px); }

/* Sections */

.section { margin-bottom: 64px; }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }

.section-title {
	font-size: 1.5rem;
	padding-bottom: 10px;
	margin-bottom: 24px;
	border-bottom: 1px solid var(--line);
	flex: 1;
}

.section-head .section-title { border-bottom: 0; }
.section-head { border-bottom: 1px solid var(--line); margin-bottom: 24px; }
.section-head .section-title { margin-bottom: 0; }

.more { font-size: 0.9rem; font-weight: 500; white-space: nowrap; }

/* News */

.news { list-style: none; margin: 0; padding: 0; }

.news li {
	display: grid;
	grid-template-columns: 96px 1fr;
	gap: 16px;
	padding: 10px 0;
	color: var(--text-2);
}

.news time {
	color: var(--muted);
	font-size: 0.85rem;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
	padding-top: 2px;
}

@media (max-width: 520px) {
	.news li { grid-template-columns: 1fr; gap: 0; }
}

/* Project cards */

.cards {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
	gap: 20px;
}

.card {
	display: flex;
	flex-direction: column;
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	overflow: hidden;
	color: var(--text);
	box-shadow: var(--shadow);
	transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); color: var(--text); text-decoration: none; }

.card-img { aspect-ratio: 16 / 10; overflow: hidden; background: var(--surface-2); }
.card-img img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.5s ease; }
.card:hover .card-img img { transform: scale(1.04); }

.card-body { padding: 16px 18px 20px; }
.card-body h3 { font-size: 1.1rem; margin: 4px 0 6px; }
.card-body p { color: var(--text-2); font-size: 0.9rem; line-height: 1.55; margin: 0; }

.eyebrow {
	color: var(--accent);
	font-size: 0.72rem;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

/* Post list (home) */

.post-list { list-style: none; margin: 0; padding: 0; }

.post-list li {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 16px;
	padding: 10px 0;
	border-bottom: 1px dashed var(--line);
}

.post-list li:last-child { border-bottom: 0; }
.post-list a { font-weight: 500; color: var(--text); }
.post-list a:hover { color: var(--accent); }
.post-list time { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }

/* Education */

.edu {
	display: flex;
	gap: 20px;
	align-items: flex-start;
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 20px 22px;
}

.edu + .edu { margin-top: 12px; }
.edu > img { width: 96px; height: 56px; object-fit: contain; flex-shrink: 0; border-radius: 8px; background: #fff; padding: 4px; }
.edu h3 { font-size: 1.15rem; margin-bottom: 2px; }
.edu h4 { font-size: 1rem; margin: 1.25em 0 0.5em; }
.edu .muted { margin-bottom: 0.5em; }

details summary { cursor: pointer; color: var(--accent); font-size: 0.9rem; font-weight: 500; }
details[open] summary { margin-bottom: 10px; }

.chips { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }

.chips li {
	font-size: 0.8rem;
	padding: 4px 10px;
	border-radius: 6px;
	background: var(--surface-2);
	color: var(--text-2);
}

/* Photo strip */

.photo-strip {
	display: grid;
	grid-template-columns: repeat(6, 1fr);
	gap: 8px;
	margin: 1.5em 0;
}

.prose .photo-strip { grid-template-columns: repeat(4, 1fr); }

.photo-strip a { display: block; aspect-ratio: 1; overflow: hidden; border-radius: 8px; background: var(--surface-2); }
.photo-strip img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.5s ease; }
.photo-strip a:hover img { transform: scale(1.06); }

@media (max-width: 600px) {
	.photo-strip, .prose .photo-strip { grid-template-columns: repeat(3, 1fr); gap: 6px; }
	.photo-strip a:nth-child(n+4) { display: none; }
	.prose .photo-strip a:nth-child(n+4) { display: block; }
	.prose .photo-strip { grid-template-columns: repeat(2, 1fr); }
}

/* Generic pages */

.page-header { margin-bottom: 40px; }
.page-header h1 { font-size: 2.4rem; letter-spacing: -0.01em; }
.lead { color: var(--muted); font-size: 1.05rem; }

.wide-img { display: block; width: 100%; border-radius: var(--radius); margin-bottom: 32px; box-shadow: var(--shadow); }

.btn {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 10px 18px;
	border: 0;
	border-radius: 10px;
	background: var(--accent);
	color: #fff;
	font: 500 0.95rem var(--sans);
	cursor: pointer;
	transition: background 0.2s ease;
}

.btn:hover { background: var(--accent-hover); color: #fff; text-decoration: none; }
:root[data-theme="dark"] .btn, :root[data-theme="dark"] .btn:hover { color: #0d1117; }
@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) .btn, :root:not([data-theme="light"]) .btn:hover { color: #0d1117; }
}

.pdf { width: 100%; height: 80vh; min-height: 480px; border: 1px solid var(--line); border-radius: var(--radius); }

.form { display: grid; gap: 16px; max-width: 560px; }
.form label { display: grid; gap: 6px; font-size: 0.9rem; font-weight: 500; color: var(--text-2); }

.form input, .form textarea {
	font: 1rem var(--sans);
	color: var(--text);
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: 10px;
	padding: 10px 12px;
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form input:focus, .form textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.form .btn { justify-self: start; }

/* Blog index */

.tag-filter { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 32px; }

.tag {
	display: inline-block;
	font: 500 0.8rem var(--sans);
	padding: 4px 12px;
	border-radius: 999px;
	border: 1px solid var(--line);
	background: var(--surface);
	color: var(--text-2);
	cursor: pointer;
}

.tag:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.tag.is-active { background: var(--accent); border-color: var(--accent); color: var(--bg); }

.year { font-size: 1.1rem; color: var(--muted); margin: 0 0 8px; }
.year-group { margin-bottom: 40px; }

.blog-list { list-style: none; margin: 0; padding: 0; }

.blog-list li {
	display: grid;
	grid-template-columns: 72px 1fr;
	gap: 16px;
	padding: 16px 0;
	border-bottom: 1px solid var(--line);
}

.blog-list time { color: var(--muted); font-size: 0.85rem; padding-top: 3px; font-variant-numeric: tabular-nums; }
.blog-title { font-family: var(--serif); font-size: 1.2rem; font-weight: 600; color: var(--text); }
.blog-title:hover { color: var(--accent); }
.blog-list p { color: var(--text-2); font-size: 0.92rem; margin: 4px 0 0; }

/* Blog post */

.post { max-width: 720px; margin: 0 auto; }
.post-header { margin-bottom: 32px; }
.post-header h1 { font-size: 2.5rem; letter-spacing: -0.01em; margin: 12px 0 12px; }
.back { font-size: 0.9rem; font-weight: 500; }
.post-meta { color: var(--muted); font-size: 0.9rem; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.post-meta .tag { margin-left: 4px; }
.post-cover { width: 100%; border-radius: var(--radius); margin-bottom: 32px; }

.prose { font-size: 1.05rem; color: var(--text); }
.prose h2 { font-size: 1.6rem; margin-top: 1.8em; }
.prose h3 { font-size: 1.3rem; margin-top: 1.5em; }
.prose img { border-radius: 8px; display: block; margin: 1.5em auto; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li { margin-bottom: 0.3em; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.5em 0; }

.prose blockquote {
	margin: 1.5em 0;
	padding: 4px 20px;
	border-left: 3px solid var(--accent);
	color: var(--text-2);
	background: var(--accent-soft);
	border-radius: 0 8px 8px 0;
}

.prose code { font: 0.88em var(--mono); background: var(--surface-2); padding: 2px 6px; border-radius: 5px; }

.prose pre {
	background: #16191e;
	color: #e6e6e6;
	padding: 16px 20px;
	border-radius: 10px;
	overflow-x: auto;
	font-size: 0.88rem;
	line-height: 1.6;
}

.prose pre code { background: none; padding: 0; color: inherit; }
.prose table { border-collapse: collapse; width: 100%; margin: 1.5em 0; font-size: 0.95rem; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line); padding: 8px 12px; text-align: left; }
.prose th { background: var(--surface-2); }

/* Rouge syntax highlighting (GitHub-dark-ish) */
.highlight .k, .highlight .kd, .highlight .kn, .highlight .kc, .highlight .kr { color: #ff7b72; }
.highlight .s, .highlight .s1, .highlight .s2, .highlight .sa, .highlight .si { color: #a5d6ff; }
.highlight .c, .highlight .c1, .highlight .cm { color: #8b949e; font-style: italic; }
.highlight .nf, .highlight .fm { color: #d2a8ff; }
.highlight .nb, .highlight .bp { color: #79c0ff; }
.highlight .mi, .highlight .mf { color: #79c0ff; }
.highlight .o, .highlight .p { color: #e6e6e6; }

.post-nav {
	display: flex;
	justify-content: space-between;
	gap: 16px;
	margin-top: 56px;
	padding-top: 24px;
	border-top: 1px solid var(--line);
}

.post-nav a { display: flex; flex-direction: column; font-weight: 500; max-width: 48%; }
.post-nav a.next { text-align: right; margin-left: auto; }
.post-nav small { color: var(--muted); font-size: 0.8rem; font-weight: 400; }

/* Footer */

.site-footer { border-top: 1px solid var(--line); padding: 24px 0; color: var(--muted); font-size: 0.88rem; }
.site-footer .container { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.footer-links { display: flex; gap: 16px; }
.footer-links a { color: var(--muted); }
.footer-links a:hover { color: var(--accent); text-decoration: none; }

/* Photo gallery: justified rows that keep each photo's aspect ratio */

.album { margin-bottom: 56px; }

.album-header {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 8px;
	border-bottom: 1px solid var(--line);
	padding-bottom: 10px;
	margin-bottom: 16px;
}

.album-header h2 { font-size: 1.4rem; margin: 0; }
.album-header .muted { font-size: 0.88rem; }

.gallery { display: flex; flex-wrap: wrap; gap: 8px; }
.gallery::after { content: ''; flex-grow: 999; }

.gallery-item {
	flex-grow: var(--ar, 1.5);
	flex-basis: calc(var(--ar, 1.5) * 220px);
	overflow: hidden;
	border-radius: 8px;
	background: var(--surface-2);
	cursor: zoom-in;
}

.gallery-item img {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: var(--ar, 1.5);
	object-fit: cover;
	transition: transform 0.5s ease, filter 0.3s ease;
}

.gallery-item:hover img { transform: scale(1.04); filter: brightness(1.06); }
.gallery-item:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

@media (max-width: 600px) {
	.gallery { gap: 4px; }
	.gallery-item { flex-basis: calc(var(--ar, 1.5) * 140px); border-radius: 4px; }
}

/* Lightbox */

html.lb-lock, html.lb-lock body { overflow: hidden; }

.lb {
	position: fixed;
	inset: 0;
	z-index: 1000;
	background: rgba(8, 10, 12, 0.95);
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.25s ease, visibility 0.25s ease;
	-webkit-user-select: none;
	user-select: none;
}

.lb.is-open { opacity: 1; visibility: visible; }

.lb-stage { position: absolute; inset: 56px 72px 64px; display: flex; align-items: center; justify-content: center; }

.lb-img {
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
	border-radius: 4px;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
	transition: opacity 0.2s ease;
}

.lb.is-loading .lb-img { opacity: 0.25; }

.lb-spinner {
	position: absolute;
	width: 36px;
	height: 36px;
	border: 3px solid rgba(255, 255, 255, 0.2);
	border-top-color: #fff;
	border-radius: 50%;
	animation: lb-spin 0.8s linear infinite;
	display: none;
}

.lb.is-loading .lb-spinner { display: block; }

@keyframes lb-spin { to { transform: rotate(360deg); } }

.lb-btn {
	position: absolute;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.08);
	color: #fff;
	font: 26px/1 Helvetica, Arial, sans-serif;
	cursor: pointer;
	transition: background 0.2s ease;
}

.lb-btn:hover, .lb-btn:focus-visible { background: rgba(255, 255, 255, 0.2); }
.lb-close { top: 10px; right: 10px; }
.lb-prev, .lb-next { top: 50%; margin-top: -22px; }
.lb-prev { left: 12px; }
.lb-next { right: 12px; }

.lb-bar {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: 16px 24px;
	color: rgba(255, 255, 255, 0.85);
	font-size: 0.85rem;
}

.lb-right { display: flex; gap: 20px; white-space: nowrap; }
.lb-count { color: rgba(255, 255, 255, 0.55); font-variant-numeric: tabular-nums; }
.lb-original { color: rgba(255, 255, 255, 0.85); }
.lb-original:hover { color: #fff; }

@media (max-width: 600px) {
	.lb-stage { inset: 56px 0; }
	.lb-prev, .lb-next { top: auto; bottom: 56px; margin-top: 0; }
	.lb-bar { font-size: 0.75rem; padding: 16px; }
}

/* Blog list extras */

.blog-list li:has(.blog-cover) { grid-template-columns: 72px 1fr 128px; }
.blog-cover { display: block; aspect-ratio: 16 / 10; overflow: hidden; border-radius: 8px; background: var(--surface-2); }
.blog-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.blog-title .ext { font-size: 0.65em; color: var(--muted); vertical-align: 0.2em; margin-left: 2px; }

@media (max-width: 600px) {
	.blog-list li, .blog-list li:has(.blog-cover) { grid-template-columns: 1fr 96px; gap: 4px 12px; }
	.blog-list time { grid-column: 1 / -1; }
}

/* MathJax: let wide display equations scroll instead of overflowing */
mjx-container[display="true"] { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
