/* Zhikang Niu — personal homepage
   Palette sampled from the Sydney Harbour photo: harbour water, the navy
   sweater, the timber rail. */

:root {
	--navy: #141a24;
	--ink: #232a36;
	--muted: #5d6676;
	--faint: #8b93a1;
	--harbour: #0e6f8f;
	--harbour-soft: #e3f1f6;
	--harbour-line: #b9dbe7;
	--timber: #a8662d;
	--timber-soft: #f6ece2;
	--paper: #fbfaf7;
	--card: #ffffff;
	--rule: #e6e3dc;
	--rule-strong: #d3cfc6;

	--serif: "Instrument Serif", "Songti SC", "STSong", Georgia, serif;
	--sans: "Inter", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
	--mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

	--wrap: 1120px;
	--gutter: clamp(20px, 4vw, 40px);
	--bar-h: 54px;
	--radius: 14px;
}

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

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

html {
	scroll-behavior: smooth;
	scroll-padding-top: calc(var(--bar-h) + 24px);
	-webkit-text-size-adjust: 100%;
}

body {
	margin: 0;
	background: var(--paper);
	color: var(--ink);
	font-family: var(--sans);
	font-size: 16px;
	line-height: 1.65;
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
}

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

a:hover {
	text-decoration: underline;
	text-decoration-thickness: 1px;
}

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

img {
	display: block;
	max-width: 100%;
}

h1,
h2,
h3,
p {
	margin: 0;
}

.wrap {
	max-width: var(--wrap);
	margin: 0 auto;
	padding: 0 var(--gutter);
}

.icon {
	width: 1em;
	height: 1em;
	fill: currentColor;
	flex-shrink: 0;
}

.skip-link {
	position: absolute;
	left: 12px;
	top: -60px;
	z-index: 100;
	padding: 8px 14px;
	border-radius: 8px;
	background: var(--navy);
	color: #fff;
}

.skip-link:focus {
	top: 12px;
}

/* ---------- Top bar ---------- */

.bar {
	position: sticky;
	top: 0;
	z-index: 50;
	height: var(--bar-h);
	background: rgba(251, 250, 247, 0.88);
	-webkit-backdrop-filter: saturate(160%) blur(14px);
	backdrop-filter: saturate(160%) blur(14px);
	box-shadow: 0 1px 0 var(--rule);
}

.bar-inner {
	display: flex;
	align-items: center;
	gap: 24px;
	height: 100%;
}

.bar-name {
	color: var(--navy);
	font-size: 0.95rem;
	font-weight: 600;
	line-height: 1;
	white-space: nowrap;
}

.bar-name:hover {
	text-decoration: none;
}

.bar-nav {
	display: flex;
	gap: 4px;
	margin-left: auto;
	overflow-x: auto;
	scrollbar-width: none;
}

.bar-nav::-webkit-scrollbar {
	display: none;
}

.bar-nav a {
	padding: 6px 10px;
	border-radius: 999px;
	color: var(--ink);
	font-size: 0.875rem;
	font-weight: 500;
	white-space: nowrap;
	transition: background-color 0.2s ease, color 0.2s ease;
}

.bar-nav a:hover {
	background: rgba(20, 26, 36, 0.06);
	text-decoration: none;
}

.bar-nav .nav-short {
	display: none;
}

.bar-nav a.is-active {
	color: var(--harbour);
	background: var(--harbour-soft);
}

/* ---------- Profile ---------- */

.profile {
	--photo-w: 300px;
	display: grid;
	grid-template-columns: var(--photo-w) minmax(0, 1fr);
	gap: clamp(24px, 4vw, 44px);
	align-items: stretch;
	padding: clamp(28px, 4.5vw, 48px) 0 0;
}

.photo {
	display: flex;
	flex-direction: column;
	margin: 0;
}

.photo-frame {
	position: relative;
	flex: 1 1 auto;
	min-height: var(--photo-w);
	max-height: calc(var(--photo-w) * 1.3);
	overflow: hidden;
	border-radius: 18px;
	background: #cfe9f6;
	box-shadow: 0 24px 48px -28px rgba(20, 26, 36, 0.45), 0 0 0 1px rgba(20, 26, 36, 0.06);
}

.photo-frame picture,
.photo-frame img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
}

.photo-frame img {
	object-fit: cover;
	object-position: 50% 30%;
}

.email {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	gap: 8px;
	margin-top: 14px;
	padding: 9px 10px;
	border-radius: 10px;
	background: var(--navy);
	color: #fff;
	font-size: 0.875rem;
	font-weight: 500;
	white-space: nowrap;
	transition: background-color 0.2s ease, transform 0.2s ease;
}

.email:hover {
	background: #263042;
	text-decoration: none;
	transform: translateY(-1px);
}

.links {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

/* the text column is at least as tall as photo + email button, and the links
   row sits at its bottom, so both columns share a top edge and a bottom edge */
.profile-body {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.profile-body .links {
	margin-top: auto;
	padding-top: 20px;
}

.profile h1 {
	color: var(--navy);
	font-size: 1.6rem;
	font-weight: 600;
	line-height: 1.25;
	letter-spacing: -0.01em;
}

.profile h1 .alt {
	margin-left: 0.4em;
	color: var(--muted);
	font-size: 0.7em;
	font-weight: 400;
	letter-spacing: 0;
	white-space: nowrap;
}

.intro-role {
	margin-top: 4px;
	color: var(--navy);
	font-size: 1.05rem;
	font-weight: 500;
	line-height: 1.45;
}

.intro-affil {
	margin-top: 8px;
	color: var(--muted);
	font-size: 0.95rem;
}

.intro-affil a {
	color: inherit;
	text-decoration: underline;
	text-decoration-color: var(--rule-strong);
}

.intro-affil a:hover {
	color: var(--harbour);
	text-decoration-color: currentColor;
}

.intro-bio {
	margin-top: 18px;
	font-size: 1rem;
}

.topics {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 18px 0 0;
	padding: 0;
	list-style: none;
}

.topics li {
	padding: 6px 12px;
	border: 1px solid var(--harbour-line);
	border-radius: 999px;
	background: var(--harbour-soft);
	color: #0b5670;
	font-size: 0.85rem;
	font-weight: 500;
	line-height: 1.3;
}

.topics li.is-now {
	border-color: #e2c2a3;
	background: var(--timber-soft);
	color: #7c4517;
}

.topics li.is-now::before {
	content: "";
	display: inline-block;
	width: 6px;
	height: 6px;
	margin-right: 7px;
	border-radius: 50%;
	background: var(--timber);
	vertical-align: 2px;
	box-shadow: 0 0 0 3px rgba(168, 102, 45, 0.18);
}

.side-label {
	margin-bottom: 6px;
	color: var(--faint);
	font-size: 0.72rem;
	font-weight: 600;
	letter-spacing: 0.14em;
	text-transform: uppercase;
}

.links a {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 7px 14px;
	border: 1px solid var(--rule-strong);
	border-radius: 999px;
	background: var(--card);
	white-space: nowrap;
	color: var(--navy);
	font-size: 0.875rem;
	font-weight: 500;
	transition: border-color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
}

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

.links .icon {
	font-size: 1.05rem;
}

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

.section {
	padding-top: clamp(40px, 5.5vw, 60px);
}

.section h2 {
	margin-bottom: 4px;
	padding-bottom: 10px;
	border-bottom: 1px solid var(--rule-strong);
	color: var(--navy);
	font-family: var(--sans);
	font-size: 1.15rem;
	font-weight: 600;
	letter-spacing: -0.01em;
	line-height: 1.3;
}

/* ---------- News / timeline rows ---------- */

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

.rows > li {
	display: grid;
	grid-template-columns: 132px minmax(0, 1fr);
	gap: 20px;
	padding: 16px 0;
	border-top: 1px solid var(--rule);
}

.rows > li:first-child {
	border-top: 0;
}

.rows .when {
	padding-top: 2px;
	color: var(--faint);
	font-family: var(--mono);
	font-size: 0.8rem;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

.rows .when.is-now {
	color: var(--timber);
}

.rows .what {
	min-width: 0;
}

.rows .title {
	color: var(--navy);
	font-weight: 600;
	line-height: 1.45;
}

.rows .title a {
	color: inherit;
}

.rows .title a:hover {
	color: var(--harbour);
}

.rows .sub {
	margin-top: 2px;
	color: var(--muted);
	font-size: 0.925rem;
}

.rows .sub a {
	color: inherit;
	text-decoration: underline;
	text-decoration-color: var(--rule-strong);
}

.rows .sub a:hover {
	color: var(--harbour);
	text-decoration-color: currentColor;
}

.badge {
	display: inline-block;
	margin-left: 6px;
	padding: 1px 7px;
	border-radius: 999px;
	background: var(--timber-soft);
	color: #7c4517;
	font-size: 0.72rem;
	font-weight: 600;
	letter-spacing: 0.02em;
	vertical-align: 2px;
}

/* ---------- Publications ---------- */

.pub-tools {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 8px;
}

.filters {
	display: inline-flex;
	flex-wrap: wrap;
	gap: 4px;
	padding: 4px;
	border: 1px solid var(--rule);
	border-radius: 999px;
	background: var(--card);
}

.filters button {
	padding: 6px 14px;
	border: 0;
	border-radius: 999px;
	background: transparent;
	color: var(--muted);
	font: inherit;
	font-size: 0.85rem;
	font-weight: 500;
	cursor: pointer;
	transition: background-color 0.2s ease, color 0.2s ease;
}

.filters button:hover {
	color: var(--navy);
}

.filters button[aria-pressed="true"] {
	background: var(--navy);
	color: #fff;
}

.filters .count {
	margin-left: 5px;
	font-variant-numeric: tabular-nums;
	opacity: 0.6;
}

.legend {
	color: var(--faint);
	font-size: 0.8rem;
}

.pub-list {
	margin-top: 12px;
}

.pub[hidden] {
	display: none;
}

.pub {
	position: relative;
	padding: 18px 0 18px 18px;
	border-top: 1px solid var(--rule);
}

.pub::before {
	content: "";
	position: absolute;
	left: 0;
	top: 22px;
	bottom: 22px;
	width: 3px;
	border-radius: 3px;
	background: var(--rule);
	transition: background-color 0.2s ease;
}

.pub.is-first::before {
	background: var(--timber);
}

.pub:hover::before {
	background: var(--harbour);
}

.pub-title {
	color: var(--navy);
	font-size: 1.04rem;
	font-weight: 600;
	line-height: 1.42;
	letter-spacing: -0.005em;
}

.pub-authors {
	margin-top: 5px;
	color: var(--muted);
	font-size: 0.9rem;
	line-height: 1.55;
}

.pub-authors .me {
	color: var(--navy);
	font-weight: 600;
	box-shadow: inset 0 -0.42em 0 rgba(168, 102, 45, 0.18);
}

.pub-meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px 14px;
	margin-top: 10px;
	font-size: 0.82rem;
}

.venue {
	padding: 2px 8px;
	border-radius: 5px;
	background: var(--navy);
	color: #fff;
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.02em;
}

.venue.is-oral {
	background: var(--timber);
}

.venue.is-pre {
	border: 1px solid var(--rule-strong);
	background: transparent;
	color: var(--muted);
}

.pub-meta a {
	color: var(--harbour);
	font-weight: 500;
}

.stars {
	margin-left: 4px;
	color: var(--faint);
	font-variant-numeric: tabular-nums;
}

.pub-note {
	margin-top: 8px;
	color: var(--muted);
	font-size: 0.875rem;
}

.pub-note b {
	color: #7c4517;
}

.pub-empty {
	padding: 24px 0;
	color: var(--muted);
}

/* ---------- Projects ---------- */

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

.card {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 20px;
	border: 1px solid var(--rule);
	border-radius: var(--radius);
	background: var(--card);
	color: inherit;
	transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

a.card:hover {
	border-color: var(--rule-strong);
	text-decoration: none;
	transform: translateY(-2px);
	box-shadow: 0 16px 30px -18px rgba(20, 26, 36, 0.3);
}

.card-top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	color: var(--faint);
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.1em;
	text-transform: uppercase;
}

.card h3 {
	color: var(--navy);
	font-family: var(--mono);
	font-size: 1rem;
	font-weight: 500;
}

.card p {
	color: var(--muted);
	font-size: 0.9rem;
}

.card-stat {
	margin-top: auto;
	padding-top: 6px;
	color: #7c4517;
	font-size: 0.85rem;
	font-weight: 600;
}

.more {
	margin-top: 16px;
	color: var(--muted);
	font-size: 0.9rem;
}

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

.footer {
	margin-top: clamp(64px, 9vw, 110px);
	padding: 40px 0 48px;
	border-top: 1px solid var(--rule);
}

.footer-inner {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	justify-content: space-between;
	gap: 24px;
}

.footer-sign {
	color: var(--navy);
	font-weight: 600;
	line-height: 1.3;
}

.footer-sign span {
	display: block;
	margin-top: 6px;
	color: var(--muted);
	font-family: var(--sans);
	font-size: 0.85rem;
}

.footer-meta {
	color: var(--faint);
	font-size: 0.8rem;
	text-align: right;
}

.visitor-map {
	margin-top: 10px;
	opacity: 0.85;
}

.visitor-map:empty {
	display: none;
}

.to-top {
	position: fixed;
	right: 22px;
	bottom: 22px;
	z-index: 40;
	display: grid;
	place-items: center;
	width: 42px;
	height: 42px;
	border: 1px solid var(--rule-strong);
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.92);
	color: var(--navy);
	font-size: 1.05rem;
	cursor: pointer;
	opacity: 0;
	visibility: hidden;
	transform: translateY(8px);
	transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
}

.to-top.is-visible {
	opacity: 1;
	visibility: visible;
	transform: none;
}

/* ---------- Reveal on scroll ---------- */

.reveal-ready .reveal {
	opacity: 0;
	transform: translateY(16px);
	transition: opacity 0.7s ease, transform 0.7s ease;
}

.reveal-ready .reveal.is-in {
	opacity: 1;
	transform: none;
}

/* ---------- Responsive ---------- */

@media (max-width: 1020px) {
	/* the text wraps onto more lines here; a narrower photo that may grow a
	   little taller keeps both columns' edges aligned */
	.profile {
		--photo-w: 240px;
	}

	.photo-frame {
		max-height: calc(var(--photo-w) * 1.75);
	}
}

/* tablets: the bio is too long beside the photo; stack like on phones */
@media (max-width: 880px) {
	.profile {
		grid-template-columns: 1fr;
		gap: 24px;
	}

	.photo-frame {
		flex: none;
		width: min(240px, 70%);
		min-height: 0;
		max-height: none;
		aspect-ratio: 1;
	}

	.email {
		width: min(240px, 70%);
	}

	.profile-body .links {
		margin-top: 0;
	}
}

@media (max-width: 720px) {
	.bar-name {
		display: none;
	}

	.bar-inner {
		gap: 10px;
	}

	.bar-nav {
		margin-left: 0;
		flex: 1;
	}

	.bar-nav {
		gap: 0;
		/* fade the right edge so a clipped link reads as scrollable */
		-webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 18px), transparent);
		mask-image: linear-gradient(90deg, #000 calc(100% - 18px), transparent);
	}

	.bar-nav a {
		padding: 6px 7px;
		font-size: 0.82rem;
	}

	.bar-nav a.nav-about {
		display: none;
	}

	.bar-nav .nav-long {
		display: none;
	}

	.bar-nav .nav-short {
		display: inline;
	}

	.profile {
		padding-top: 28px;
	}

	.photo-frame {
		border-radius: 16px;
	}

	.links {
		gap: 6px;
	}

	.links a {
		gap: 6px;
		padding: 6px 11px;
		font-size: 0.84rem;
	}

	.links .nav-long {
		display: none;
	}

	.rows > li {
		grid-template-columns: 1fr;
		gap: 2px;
	}

	.pub {
		padding-left: 14px;
	}

	/* plain chips instead of a pill-shaped track once the buttons wrap */
	.filters {
		gap: 6px;
		padding: 0;
		border: 0;
		background: none;
	}

	.filters button {
		border: 1px solid var(--rule);
		background: var(--card);
	}

	.filters button[aria-pressed="true"] {
		border-color: var(--navy);
	}

	.footer-inner {
		flex-direction: column;
		align-items: flex-start;
	}

	.footer-meta {
		text-align: left;
	}
}

@media (max-width: 380px) {
	.bar-nav a {
		padding: 6px 5px;
		font-size: 0.78rem;
	}
}

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

	*,
	*::before,
	*::after {
		transition: none !important;
		animation: none !important;
	}

	.reveal-ready .reveal {
		opacity: 1;
		transform: none;
	}
}

@media print {
	.bar,
	.to-top,
	.filters,
	.visitor-map {
		display: none;
	}

	.photo-frame {
		box-shadow: none;
	}

	.reveal-ready .reveal {
		opacity: 1;
		transform: none;
	}
}
