/* ==========================================================================
   chenyangsu.github.io — main stylesheet
   Clean single-page academic layout: sticky top nav, hero bio, scrollable
   news feed, venue-tagged publication cards, invited-talk list.
   ========================================================================== */

:root {
	--accent: #1558b0;        /* links, dates, venue tags */
	--accent-dark: #0d3d7c;   /* headings, institutions */
	--ink: #222;              /* body text */
	--ink-light: #555;        /* secondary text */
	--award: #c0392b;         /* award / highlight lines */
	--rule: #e3e7ee;          /* borders and dividers */
	--tag-bg: #eef3fb;        /* venue tag background */
	--paper-bg: #ffffff;
	--nav-bg: rgba(255, 255, 255, 0.97);
	--panel-bg: #fcfdff;      /* boxes: news, hit counter, mobile cards */
	--chip-bg: #f6f8fc;       /* date chips */
	--tag-border: #d8e3f5;
	--flag-bg: #fbf7ec;       /* flagship talk cards */
	--flag-border: #eadfc0;
	--serif-ink: #4a4a4a;     /* motivation quote text */
	--caption-ink: #5a5a5a;
	--gold-ink: #8a6d3b;
	--gold-hl-ink: #a5813c;
}

* { box-sizing: border-box; }

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

body {
	margin: 0;
	font-family: 'Lato', 'Helvetica Neue', Arial, sans-serif;
	font-size: 16px;
	line-height: 1.55;
	color: var(--ink);
	background: var(--paper-bg);
}

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

/* ---------- Top navigation ---------- */

.topnav {
	position: sticky;
	top: 0;
	z-index: 100;
	background: var(--nav-bg);
	border-bottom: 1px solid var(--rule);
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.topnav-inner {
	max-width: 980px;
	margin: 0 auto;
	padding: 10px 20px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 6px 16px;
}

.brand {
	font-size: 18px;
	font-weight: 900;
	color: var(--accent-dark);
	letter-spacing: 0.2px;
}

.nav-links {
	display: flex;
	flex-wrap: wrap;
	gap: 4px 14px;
	font-size: 14.5px;
}

.nav-links a { color: var(--ink-light); font-weight: 700; }
.nav-links a:hover { color: var(--accent); text-decoration: none; }
.nav-links a.active { color: var(--accent); border-bottom: 2px solid var(--accent); padding-bottom: 2px; }

/* ---------- Page shell ---------- */

.page {
	max-width: 980px;
	margin: 0 auto;
	padding: 28px 20px 40px;
}

section { margin-top: 40px; }

h2 {
	font-size: 26px;
	font-weight: 900;
	color: var(--accent-dark);
	border-bottom: 2px solid var(--rule);
	padding-bottom: 6px;
	margin: 0 0 16px;
}

h3 {
	font-size: 19px;
	font-weight: 700;
	color: var(--accent-dark);
	margin: 26px 0 10px;
}

.fineprint { font-size: 14px; color: var(--ink-light); }

/* ---------- Hero / about ---------- */

.hero {
	display: flex;
	align-items: center;
	gap: 34px;
	margin-top: 12px;
}

.hero-photo img {
	width: 230px;
	max-width: 100%;
	border-radius: 12px;
	display: block;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}

.hero-text h1 {
	font-size: 34px;
	font-weight: 900;
	margin: 0 0 6px;
	color: var(--ink);
}

.degree { font-size: 20px; font-weight: 400; color: var(--ink-light); }

.position { font-size: 17px; margin: 4px 0; }

.tagline {
	font-size: 16px;
	font-weight: 700;
	color: var(--accent-dark);
	letter-spacing: 0.3px;
	margin: 6px 0 2px;
}

.location { color: var(--ink-light); font-size: 15px; margin: 4px 0 10px; }

.link-row { font-size: 15px; line-height: 1.9; margin: 0; }
.link-row a { font-weight: 700; }

.bio { margin-top: 24px; }
.bio p { margin: 0 0 14px; text-align: justify; }
.bio a { font-weight: 700; }

/* ---------- News ---------- */

.news-box {
	max-height: 420px;
	overflow-y: auto;
	border: 1px solid var(--rule);
	border-radius: 8px;
	padding: 6px 16px;
	background: var(--panel-bg);
}

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

.news-list li {
	padding: 8px 0;
	border-bottom: 1px solid var(--rule);
	font-size: 15px;
}

.news-list li:last-child { border-bottom: none; }

.date {
	font-weight: 900;
	color: var(--accent);
	white-space: nowrap;
}

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

.pub {
	display: flex;
	gap: 18px;
	padding: 14px 0;
	border-bottom: 1px solid var(--rule);
}

.pub:last-child { border-bottom: none; }

.venue-tag {
	flex: 0 0 118px;
	align-self: flex-start;
	text-align: center;
	background: var(--tag-bg);
	color: var(--accent-dark);
	font-weight: 900;
	font-size: 13.5px;
	padding: 8px 6px;
	border-radius: 6px;
	border: 1px solid var(--tag-border);
	margin-top: 3px;
}

.pub-side {
	flex: 0 0 118px;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.pub-side .venue-tag { flex: none; width: 100%; margin-top: 3px; }

.pub-thumb {
	width: 100%;
	height: auto;
	border-radius: 6px;
	border: 1px solid var(--rule);
	display: block;
}

.pub-thumb-logo { background: #fff; padding: 12px 6px; }

.pub-body { flex: 1; min-width: 0; }
.pub-body p { margin: 0 0 4px; }

.pub-title { font-weight: 700; font-size: 16px; color: var(--ink); }
.pub-authors { font-size: 14.5px; color: var(--ink-light); }
.pub-authors b { color: var(--ink); }
.pub-venue { font-size: 14.5px; }
.pub-links { font-size: 14.5px; }
.pub-links a { font-weight: 700; }

.award {
	font-size: 14px;
	color: var(--award);
	font-weight: 700;
}

/* ---------- Talks ---------- */

.talk {
	display: flex;
	gap: 14px;
	padding: 12px 0;
	border-bottom: 1px solid var(--rule);
}

.talk:last-of-type { border-bottom: none; }

.talk-date {
	flex: 0 0 84px;
	font-weight: 900;
	color: var(--accent);
	font-size: 15px;
	margin-top: 1px;
}

.talk-body { flex: 1; min-width: 0; }
.talk-body p { margin: 0 0 3px; }

.talk-venue { font-weight: 900; color: var(--accent-dark); font-size: 15.5px; }
.talk-title { font-size: 15px; }
.talk-note { font-size: 14px; color: var(--ink-light); }

/* Flagship invited talks (Stanford, Broad, Academia Sinica, NTU) */
.talk-flagship {
	background: var(--flag-bg);
	border: 1px solid var(--flag-border);
	border-radius: 8px;
	padding: 12px 14px;
	margin: 8px 0;
}
.talk-flagship + .talk-flagship { border-top: 1px solid var(--flag-border); }

/* ---------- Compact lists (awards, experience, conference talks) ---------- */

.compact-list {
	list-style: none;
	margin: 0 0 12px;
	padding: 0;
}

.compact-list li {
	padding: 6px 0;
	font-size: 15px;
	border-bottom: 1px dashed var(--rule);
}

.compact-list li:last-child { border-bottom: none; }

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

.footer {
	margin-top: 48px;
	padding-top: 18px;
	border-top: 1px solid var(--rule);
	text-align: center;
	color: var(--ink-light);
	font-size: 14px;
}

.footer::before {
	content: '';
	display: block;
	width: 64px;
	height: 3px;
	background: var(--accent);
	margin: 0 auto 16px;
	border-radius: 2px;
}

.footer-main { font-size: 16px; color: var(--ink); }
.footer-main b { color: var(--accent-dark); font-weight: 900; }
#lastUpdated { font-weight: 700; color: var(--accent); }

.footer p { margin: 4px 0; }

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

@media (max-width: 720px) {
	.hero { flex-direction: column; align-items: flex-start; gap: 18px; }
	.hero-photo img { width: 200px; }
	.bio p { text-align: left; }
	.pub { flex-direction: column; gap: 6px; }
	.venue-tag { flex: none; align-self: flex-start; padding: 4px 10px; }
	.pub-side { flex: none; flex-direction: row; align-items: center; gap: 10px; }
	.pub-thumb { width: 96px; }
	.talk { flex-direction: column; gap: 2px; }
	.talk-date { flex: none; }
}

/* ---------- Education & Experience timeline ---------- */
/* Adapted from the alternating-flag timeline used on bridgetilin.github.io */

.timeline {
	position: relative;
	width: 100%;
	max-width: 880px;
	margin: 20px auto 0;
	padding: 1em 0;
	list-style: none;
}

.timeline:before {
	position: absolute;
	left: 50%;
	top: 0;
	content: ' ';
	display: block;
	width: 4px;
	height: 100%;
	margin-left: -2px;
	background: linear-gradient(to bottom,
		rgba(21, 88, 176, 0) 0%,
		#9dbce0 6%,
		#9dbce0 94%,
		rgba(21, 88, 176, 0) 100%);
	z-index: 5;
}

.timeline li { padding: 1em 0; }

.timeline li:after {
	content: "";
	display: block;
	height: 0;
	clear: both;
	visibility: hidden;
}

.direction-l {
	position: relative;
	width: calc(50% - 40px);
	float: left;
	text-align: right;
}

.direction-r {
	position: relative;
	width: calc(50% - 40px);
	float: right;
}

.flag-wrapper {
	position: relative;
	display: inline-flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 4px;
}

.direction-l .flag-wrapper { align-items: flex-end; }

.flag {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 7px;
	background: var(--tag-bg);
	color: var(--accent-dark);
	padding: 6px 12px;
	border-radius: 6px;
	border: 1px solid var(--tag-border);
	font-weight: 900;
	font-size: 15.5px;
	text-align: left;
}

.direction-l .flag { text-align: right; }

/* Dot on the center line */
.direction-l .flag:before,
.direction-r .flag:before {
	position: absolute;
	top: 50%;
	right: -50px;
	content: ' ';
	display: block;
	width: 12px;
	height: 12px;
	margin-top: -10px;
	background: #fff;
	border-radius: 10px;
	border: 4px solid var(--accent);
	z-index: 10;
}

.direction-r .flag:before { left: -50px; right: auto; }

/* Arrow from flag toward the line */
.direction-l .flag:after {
	content: "";
	position: absolute;
	left: 100%;
	top: 50%;
	height: 0;
	width: 0;
	margin-top: -8px;
	border: solid transparent;
	border-left-color: var(--tag-bg);
	border-width: 8px;
	pointer-events: none;
}

.direction-r .flag:after {
	content: "";
	position: absolute;
	right: 100%;
	top: 50%;
	height: 0;
	width: 0;
	margin-top: -8px;
	border: solid transparent;
	border-right-color: var(--tag-bg);
	border-width: 8px;
	pointer-events: none;
}

.time-wrapper { display: inline; line-height: 1em; }

.time {
	display: inline-block;
	padding: 3px 8px;
	background: var(--chip-bg);
	border-radius: 4px;
	font-weight: 900;
	font-size: 12.5px;
	color: var(--accent);
	white-space: nowrap;
}

.timeline .desc {
	margin: 0.7em 0.75em 0 0;
	font-size: 14px;
	line-height: 1.5em;
	color: var(--ink);
}

.direction-r .desc { margin: 0.7em 0 0 0.75em; }

@media screen and (max-width: 660px) {
	.timeline { padding: 3em 0 1em; }
	.timeline li { padding: 1.6em 0; }

	.direction-l,
	.direction-r {
		float: none;
		width: 100%;
		text-align: center;
	}

	.flag-wrapper, .direction-l .flag-wrapper { align-items: center; text-align: center; }

	.flag { z-index: 15; }
	.direction-l .flag { text-align: center; }

	.direction-l .flag:before,
	.direction-r .flag:before {
		position: absolute;
		top: -26px;
		left: 50%;
		right: auto;
		margin-left: -10px;
	}

	.direction-l .flag:after,
	.direction-r .flag:after { display: none; }

	.time-wrapper { display: block; position: relative; margin: 2px 0 0; z-index: 14; }

	.timeline .desc,
	.direction-l .desc,
	.direction-r .desc {
		position: relative;
		margin: 0.8em 1em 0;
		padding: 0.9em 1em;
		background: var(--panel-bg);
		border: 1px solid var(--rule);
		border-radius: 8px;
		z-index: 15;
	}
}

/* ---------- Hero icon widgets ---------- */

.icon-row {
	display: flex;
	flex-wrap: wrap;
	gap: 15px;
	font-size: 27px;
	margin: 8px 0 2px;
}

.icon-row a {
	line-height: 1;
	transition: transform 0.15s ease, filter 0.15s ease;
}
.icon-row a:hover {
	text-decoration: none;
	transform: translateY(-3px) scale(1.12);
	filter: brightness(1.15);
}

/* Monochrome by default, brand color on hover */
.icon-row a { color: #8a8f98; }
.ic-email:hover    { color: #d44638; }
.ic-scholar:hover  { color: #4285f4; }
.ic-github:hover   { color: #24292e; }
.ic-x:hover        { color: #0f1419; }
.ic-bluesky:hover  { color: #1185fe; }
.ic-linkedin:hover { color: #0a66c2; }
.ic-orcid:hover    { color: #a6ce39; }
.ic-rg:hover       { color: #00ccbb; }

.follow-row { margin: 8px 0 0; text-align: left; }

/* ---------- Talk video embeds ---------- */

.video-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
	gap: 18px;
	margin: 6px 0 24px;
}

.video-card { margin: 0; }

.video-card iframe,
.video-card video {
	width: 100%;
	aspect-ratio: 16 / 9;
	border: 0;
	border-radius: 8px;
	background: #000;
	display: block;
}

.video-card figcaption {
	font-size: 13.5px;
	color: var(--ink-light);
	margin-top: 6px;
	line-height: 1.45;
}

.flag-logo {
	height: 20px;
	width: auto;
	flex: none;
}

/* ---------- Personal section photo ---------- */

.personal-photo { margin: 14px 0 6px; }
.personal-photo img { width: 100%; border-radius: 8px; display: block; }
.personal-photo figcaption { font-size: 13px; color: var(--ink-light); margin-top: 6px; }

/* ---------- Motivation (quote styling after kejunying.com) ---------- */

@keyframes fadeInUp {
	from { opacity: 0; transform: translateY(14px); }
	to { opacity: 1; transform: none; }
}

@keyframes pulse-glow {
	0%, 100% { box-shadow: 0 0 0 rgba(201, 169, 89, 0); }
	50% { box-shadow: 0 0 12px rgba(201, 169, 89, 0.4); }
}

.motivation-row {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 18px;
	align-items: stretch;
	margin: 14px 0 10px;
}

.quote-section {
	display: flex;
	flex-direction: column;
	gap: 1rem;
	align-items: center;
	margin: 0;
	padding: 1.25rem;
	background: linear-gradient(135deg, rgba(201, 169, 89, 0.05) 0%, rgba(201, 169, 89, 0.01) 100%);
	border: 1px solid rgba(201, 169, 89, 0.2);
	border-radius: 12px;
	animation: fadeInUp 0.6s ease-out 0.15s both;
}

.quote-portrait { flex-shrink: 0; text-align: center; }

.quote-portrait img {
	width: 120px;
	height: 120px;
	object-fit: cover;
	object-position: top;
	border-radius: 8px;
	box-shadow: 0 4px 15px rgba(0, 0, 0, 0.12);
	transition: transform 0.3s ease;
}

.quote-portrait img:hover { transform: scale(1.05); }

.quote-caption { margin-top: 0.5rem; font-size: 0.75rem; font-weight: 600; color: var(--caption-ink); line-height: 1.4; }
.quote-caption b { color: var(--gold-ink); }

.quote-main {
	flex: 1;
	margin: 0;
	padding: 0;
	border: none;
	font-family: 'Source Serif 4', Georgia, serif;
	font-style: italic;
	font-size: 0.93rem;
	line-height: 1.7;
	color: var(--serif-ink);
}

.quote-highlight {
	font-weight: 600;
	font-style: italic;
	color: var(--gold-hl-ink);
	background: linear-gradient(120deg, rgba(201, 169, 89, 0.15) 0%, rgba(201, 169, 89, 0.28) 100%);
	padding: 0.1rem 0.3rem;
	border-radius: 3px;
	animation: pulse-glow 3s ease-in-out infinite;
}

.quote-attrib {
	display: block;
	margin-top: 0.7rem;
	font-style: normal;
	font-family: 'Lato', sans-serif;
	font-weight: 700;
	font-size: 0.82rem;
	color: var(--gold-ink);
}

.motivation-grid { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }



.quote-small {
	margin: 12px 0 0;
	padding: 1rem 1.5rem;
	font-family: 'Source Serif 4', Georgia, serif;
	font-style: italic;
	font-size: 0.98rem;
	line-height: 1.8;
	color: var(--serif-ink);
	border-left: 3px solid rgba(201, 169, 89, 0.55);
	background: rgba(201, 169, 89, 0.05);
	border-radius: 0 8px 8px 0;
}

.quote-small .quote-attrib { margin-top: 0.3rem; font-size: 0.78rem; }

@media (max-width: 950px) {
	.motivation-row { grid-template-columns: 1fr; }
	.quote-portrait img { width: 100px; height: 100px; }
}

/* ---------- Back-to-top button ---------- */

#backToTop {
	position: fixed;
	right: 22px;
	bottom: 22px;
	width: 48px;
	height: 48px;
	border-radius: 50%;
	border: none;
	background: var(--accent);
	color: #fff;
	box-shadow: 0 4px 14px rgba(21, 88, 176, 0.45);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	visibility: hidden;
	transform: translateY(8px);
	transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
	z-index: 200;
}

#backToTop.visible { opacity: 1; visibility: visible; transform: none; }

#backToTop:hover { background: var(--accent-dark); transform: translateY(-3px) scale(1.06); box-shadow: 0 6px 18px rgba(13, 61, 124, 0.5); }

/* ---------- Hit counter badge (same counter since 2020) ---------- */

.hit-counter {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	margin-top: 8px;
	padding: 6px 14px;
	background: var(--panel-bg);
	border: 1px solid var(--rule);
	border-radius: 999px;
	font-size: 13px;
	color: var(--ink-light);
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.hit-digits { display: inline-flex; align-items: center; line-height: 0; }
.hit-digits a { display: inline-flex; line-height: 0; }
.hit-digits img { border: 0; border-radius: 3px; }
.hit-label { font-weight: 700; letter-spacing: 0.2px; }


.talk-logo {
	height: 22px;
	width: auto;
	vertical-align: -5px;
	margin-right: 8px;
	border-radius: 4px;
}


/* ---------- Theme toggle ---------- */

#themeToggle {
	position: fixed;
	right: 22px;
	bottom: 80px;              /* stacked above #backToTop */
	width: 44px;
	height: 44px;
	padding: 0;
	border-radius: 50%;
	border: 1px solid var(--rule);
	background: var(--panel-bg);
	color: var(--ink-light);
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
	cursor: pointer;
	align-items: center;
	justify-content: center;
	transition: color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
	z-index: 200;
	display: none;             /* revealed once theme.js sets data-theme */
}

/* Visitors without JS are not shown a control that cannot do anything. */
:root[data-theme] #themeToggle { display: flex; }

#themeToggle:hover { color: var(--accent); border-color: var(--accent); transform: translateY(-2px) scale(1.06); }

#themeToggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Moon in light mode, sun in dark mode. */
#themeToggle .icon-sun { display: none; }
:root[data-theme="dark"] #themeToggle .icon-sun { display: block; }
:root[data-theme="dark"] #themeToggle .icon-moon { display: none; }


/* ---------- Dark mode ----------
   The palette is applied by two routes: the media query for visitors who have
   not picked a theme (and for anyone without JS), and [data-theme="dark"] for
   an explicit choice from the toggle. Keep the two blocks in sync.
   -------------------------------------------------------------------------- */

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--accent: #6ea8ff;
		--accent-dark: #a8c7f0;
		--ink: #dde3ec;
		--ink-light: #9aa4b2;
		--award: #f28b82;
		--rule: #263041;
		--tag-bg: #1b2536;
		--paper-bg: #0f1520;
		--nav-bg: rgba(15, 21, 32, 0.96);
		--panel-bg: #141c2b;
		--chip-bg: #1b2536;
		--tag-border: #2c3a52;
		--flag-bg: #221c10;
		--flag-border: #4a3f26;
		--serif-ink: #c9cfd8;
		--caption-ink: #9aa4b2;
		--gold-ink: #d4b66a;
		--gold-hl-ink: #d4b66a;
	}

	:root:not([data-theme="light"]) .hero-photo img, :root:not([data-theme="light"]) .personal-photo img { box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5); }
	:root:not([data-theme="light"]) .icon-row a { color: #7d8794; }
	:root:not([data-theme="light"]) .ic-github:hover { color: #e6edf3; }
	:root:not([data-theme="light"]) .ic-x:hover { color: #e6edf3; }
	:root:not([data-theme="light"]) .quote-portrait img { border-color: #263041; }
	:root:not([data-theme="light"]) #backToTop { box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5); }
	:root:not([data-theme="light"]) #themeToggle { box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5); }
}

:root[data-theme="dark"] {
	--accent: #6ea8ff;
	--accent-dark: #a8c7f0;
	--ink: #dde3ec;
	--ink-light: #9aa4b2;
	--award: #f28b82;
	--rule: #263041;
	--tag-bg: #1b2536;
	--paper-bg: #0f1520;
	--nav-bg: rgba(15, 21, 32, 0.96);
	--panel-bg: #141c2b;
	--chip-bg: #1b2536;
	--tag-border: #2c3a52;
	--flag-bg: #221c10;
	--flag-border: #4a3f26;
	--serif-ink: #c9cfd8;
	--caption-ink: #9aa4b2;
	--gold-ink: #d4b66a;
	--gold-hl-ink: #d4b66a;
}

:root[data-theme="dark"] .hero-photo img, :root[data-theme="dark"] .personal-photo img { box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5); }
:root[data-theme="dark"] .icon-row a { color: #7d8794; }
:root[data-theme="dark"] .ic-github:hover { color: #e6edf3; }
:root[data-theme="dark"] .ic-x:hover { color: #e6edf3; }
:root[data-theme="dark"] .quote-portrait img { border-color: #263041; }
:root[data-theme="dark"] #backToTop { box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5); }
:root[data-theme="dark"] #themeToggle { box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5); }
