/* ==========================================================================
   Kaiyuan (Eric) Chen — personal site
   Hand-rolled, dependency-free. Light theme default, dark theme via toggle.
   ========================================================================== */

:root {
  --bg: #fbfaf7;
  --bg-elev: #ffffff;
  --bg-soft: #f3f1ea;
  --text: #182234;
  --text-soft: #4c5a70;
  --muted-text: #6b7688;
  --line: #e6e2d6;
  --line-strong: #d5d0c0;
  --accent: #003262;            /* Berkeley blue */
  --accent-soft: #14508f;       /* link blue */
  --gold: #fdb515;              /* California gold */
  --gold-deep: #a87708;         /* accessible gold text on light */
  --gold-tint: #fdf3dc;
  --blue-tint: #e9f0f8;
  --card-shadow: 0 1px 2px rgba(24, 34, 52, 0.05), 0 8px 24px -12px rgba(24, 34, 52, 0.12);
  --card-shadow-hover: 0 2px 4px rgba(24, 34, 52, 0.06), 0 16px 36px -14px rgba(24, 34, 52, 0.22);
  --serif: "Newsreader", "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

html[data-theme="dark"] {
  --bg: #0c1322;
  --bg-elev: #131c30;
  --bg-soft: #182338;
  --text: #e9edf5;
  --text-soft: #b6c1d2;
  --muted-text: #8d99ad;
  --line: #24304a;
  --line-strong: #33415f;
  --accent: #9dc1ea;
  --accent-soft: #8ab8ec;
  --gold: #fdb515;
  --gold-deep: #f3b83c;
  --gold-tint: rgba(253, 181, 21, 0.12);
  --blue-tint: rgba(125, 170, 220, 0.12);
  --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 28px -12px rgba(0, 0, 0, 0.5);
  --card-shadow-hover: 0 2px 4px rgba(0, 0, 0, 0.35), 0 18px 40px -14px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1 !important; transform: none !important; transition: none !important; }
}

body {
  font-family: var(--sans);
  font-size: 15.5px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--gold); color: #182234; }

a { color: var(--accent-soft); text-decoration: none; }
a:hover { text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
a:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 4px;
}

b, strong { font-weight: 600; }

/* ------------------------------------------------------------------ layout */

.layout {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  gap: 64px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 56px 32px 40px;
}

main { min-width: 0; }

section { margin-bottom: 72px; scroll-margin-top: 24px; }
section:last-of-type { margin-bottom: 32px; }

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

.sidebar { position: relative; }

.sidebar-inner {
  position: sticky;
  top: 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.portrait {
  width: 180px;
  height: 180px;
  border-radius: 20px;
  object-fit: cover;
  border: 1px solid var(--line-strong);
  box-shadow: var(--card-shadow);
}

.identity h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 30px;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--text);
}

.identity .role {
  margin-top: 8px;
  font-size: 14.5px;
  color: var(--text-soft);
  line-height: 1.5;
}
.identity .role b { color: var(--text); font-weight: 600; }
.identity .role a { color: inherit; }

.contact-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 14px;
}
.contact-list a {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text-soft);
}
.contact-list a:hover { color: var(--accent-soft); text-decoration: none; }
.contact-list svg { width: 15px; height: 15px; fill: currentColor; opacity: 0.75; flex: none; }

.side-nav {
  border-top: 1px solid var(--line);
  padding-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.side-nav a {
  font-size: 13.5px;
  color: var(--muted-text);
  padding: 4px 10px;
  border-left: 2px solid transparent;
  border-radius: 0 6px 6px 0;
}
.side-nav a:hover { color: var(--text); text-decoration: none; background: var(--bg-soft); }
.side-nav a.active {
  color: var(--accent-soft);
  border-left-color: var(--gold);
  background: var(--bg-soft);
  font-weight: 600;
}

.theme-toggle {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: 500 12.5px var(--sans);
  color: var(--muted-text);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.theme-toggle:hover { border-color: var(--gold); color: var(--text); }

.side-foot { font-size: 12px; color: var(--muted-text); }

/* ------------------------------------------------------------ section head */

.section-head { margin-bottom: 26px; }
.section-head .kicker {
  font: 600 11.5px var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold-deep);
}
.section-head h2 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 27px;
  letter-spacing: -0.01em;
  margin-top: 2px;
  color: var(--text);
}
.section-head h2::after {
  content: "";
  display: block;
  width: 44px;
  height: 3px;
  margin-top: 10px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--gold), var(--accent));
}
.section-head .subnote { margin-top: 10px; font-size: 13.5px; color: var(--muted-text); }

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

.lede p { margin-bottom: 14px; font-size: 16px; color: var(--text-soft); }
.lede p:last-child { margin-bottom: 0; }
.lede a { font-weight: 500; }

.interests {
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.interest-chip {
  font: 500 12.5px var(--sans);
  color: var(--accent-soft);
  background: var(--blue-tint);
  padding: 5px 12px;
  border-radius: 999px;
}

/* -------------------------------------------------------------------- news */

.news-list { list-style: none; display: flex; flex-direction: column; gap: 13px; }
.news-list li {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 16px;
  align-items: baseline;
}
.news-date {
  font: 600 12px var(--mono);
  letter-spacing: 0.03em;
  color: var(--gold-deep);
  white-space: nowrap;
}
.news-body { font-size: 14.5px; color: var(--text-soft); }
.news-body b { color: var(--text); }

details.more-news > summary,
details.workshops > summary {
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: 500 13px var(--sans);
  color: var(--accent-soft);
  margin-top: 14px;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-elev);
  user-select: none;
}
details.more-news > summary:hover,
details.workshops > summary:hover { border-color: var(--gold); }
details.more-news > summary::-webkit-details-marker,
details.workshops > summary::-webkit-details-marker { display: none; }
details.more-news > summary::after { content: "↓"; font-size: 11px; }
details.more-news[open] > summary::after { content: "↑"; }
details.more-news[open] > summary { margin-bottom: 13px; }

/* --------------------------------------------------------------- spotlight */

.feature-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--card-shadow);
}
.feature-card::before {
  content: "";
  display: block;
  height: 4px;
  background: linear-gradient(90deg, var(--accent) 0%, #2c6bab 45%, var(--gold) 100%);
}
.feature-media {
  display: block;
  width: 100%;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.feature-media img { width: 100%; display: block; }
.feature-body { padding: 26px 30px 28px; }
.feature-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.feature-body h3 {
  font-family: var(--serif);
  font-size: 23px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}
.feature-body h3 a { color: var(--text); }
.feature-body h3 a:hover { color: var(--accent-soft); text-decoration: none; }
.feature-role { font-size: 13px; color: var(--muted-text); margin-bottom: 12px; }
.feature-body p { font-size: 14.5px; color: var(--text-soft); margin-bottom: 10px; }
.feature-collab { font-size: 13px; color: var(--muted-text); margin-bottom: 16px; }
.feature-card + .feature-card { margin-top: 22px; }

/* side-by-side spotlight cards (media left, text right) */
.feature-card--row { display: grid; grid-template-columns: 330px minmax(0, 1fr); }
.feature-card--row::before { grid-column: 1 / -1; }
.feature-card--row .feature-media {
  border-bottom: none;
  border-right: 1px solid var(--line);
  background: var(--bg-elev);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}
.feature-card--row .feature-media video,
.feature-card--row .feature-media img { width: 100%; height: auto; display: block; border-radius: 10px; background: #0c1322; }
.feature-card--row .feature-body { padding: 20px 24px 22px; }
.feature-card--row .feature-body h3 { font-size: 19px; }
.feature-card--row .feature-body p { font-size: 14px; }
@media (max-width: 760px) {
  .feature-card--row { grid-template-columns: 1fr; }
  .feature-card--row .feature-media { border-right: none; border-bottom: 1px solid var(--line); }
}

/* ------------------------------------------------------------ chips/badges */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font: 600 11.5px var(--sans);
  letter-spacing: 0.02em;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.chip-venue { color: var(--accent-soft); background: var(--blue-tint); }
.chip-award { color: var(--gold-deep); background: var(--gold-tint); }
.chip-award::before { content: "★"; font-size: 10px; }
.chip-new { color: #fff; background: linear-gradient(100deg, var(--accent), #2c6bab); }
html[data-theme="dark"] .chip-new { color: #0c1322; background: linear-gradient(100deg, var(--gold), #ffd061); }

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-mini {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: 500 12.5px var(--sans);
  color: var(--accent-soft);
  background: var(--bg-elev);
  border: 1px solid var(--line-strong);
  padding: 5px 13px;
  border-radius: 999px;
  transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}
.btn-mini:hover {
  text-decoration: none;
  border-color: var(--gold);
  background: var(--gold-tint);
  transform: translateY(-1px);
}
.btn-mini.disabled {
  color: var(--muted-text);
  pointer-events: none;
  border-style: dashed;
  background: transparent;
}

/* ------------------------------------------------------ selected pub cards */

.pub-cards { display: flex; flex-direction: column; gap: 18px; }

.pub-card {
  display: grid;
  grid-template-columns: 216px 1fr;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--card-shadow);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.pub-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--card-shadow-hover);
  border-color: var(--line-strong);
}
.pub-thumb {
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}
.pub-thumb img { max-width: 100%; max-height: 168px; object-fit: contain; display: block; }
.pub-card-body { padding: 18px 22px 17px; min-width: 0; }
.pub-card-tags { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 8px; }
.pub-card-body h3 { font-size: 16.5px; font-weight: 600; line-height: 1.4; margin-bottom: 5px; }
.pub-card-body h3 a { color: var(--text); }
.pub-card-body h3 a:hover { color: var(--accent-soft); text-decoration: none; }
.pub-authors { font-size: 13px; color: var(--muted-text); margin-bottom: 11px; line-height: 1.55; }
.pub-authors b { color: var(--text-soft); font-weight: 600; }

/* ----------------------------------------------------------- full pub list */

.pub-group { margin-bottom: 26px; }
.pub-group-title {
  font: 600 12px var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-text);
  border-bottom: 1px solid var(--line);
  padding-bottom: 7px;
  margin-bottom: 14px;
}
.pub-rows { list-style: none; display: flex; flex-direction: column; gap: 15px; }
.pub-row { display: grid; grid-template-columns: 52px 1fr; gap: 14px; }
.pub-year { font: 600 12.5px var(--mono); color: var(--muted-text); padding-top: 2px; }
.pub-row-title { font-size: 14.5px; font-weight: 600; line-height: 1.45; }
.pub-row-title a { color: var(--text); }
.pub-row-title a:hover { color: var(--accent-soft); }
.pub-row-meta { font-size: 13px; color: var(--muted-text); margin-top: 2px; line-height: 1.55; }
.pub-row-meta b { color: var(--text-soft); font-weight: 600; }
.pub-row-links { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; }
.pub-row-links .btn-mini { padding: 2.5px 10px; font-size: 11.5px; }
.pub-row .chip { font-size: 10.5px; padding: 2px 8px; margin-left: 4px; }

details.workshops { margin-top: 6px; }
details.workshops[open] > summary { margin-bottom: 16px; }
details.workshops > summary::after { content: "↓"; font-size: 11px; }
details.workshops[open] > summary::after { content: "↑"; }

/* ------------------------------------------------------------------ awards */

.award-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.award-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  box-shadow: var(--card-shadow);
}
.award-icon { font-size: 22px; line-height: 1.2; flex: none; }
.award-card h3 { font-size: 14.5px; font-weight: 600; line-height: 1.4; }
.award-card p { font-size: 12.5px; color: var(--muted-text); margin-top: 3px; }

/* ----------------------------------------------- experience / talks / etc. */

.xp-list, .talk-list { list-style: none; display: flex; flex-direction: column; gap: 16px; }
.xp-item { display: grid; grid-template-columns: 1fr auto; gap: 18px; align-items: baseline; }
.xp-what { font-size: 14.5px; }
.xp-what b { font-weight: 600; }
.xp-what .xp-sub { display: block; font-size: 13px; color: var(--muted-text); margin-top: 1px; }
.xp-when { font: 500 12px var(--mono); color: var(--muted-text); white-space: nowrap; }

.edu-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.edu-card { font-size: 13px; color: var(--muted-text); }
.edu-card b { display: block; font-size: 13.5px; color: var(--text); font-weight: 600; }

.talk-item { display: grid; grid-template-columns: 74px 1fr; gap: 16px; align-items: baseline; }
.talk-when { font: 600 12px var(--mono); color: var(--gold-deep); white-space: nowrap; }
.talk-what { font-size: 14.5px; color: var(--text-soft); }
.talk-what b { color: var(--text); font-weight: 600; }

/* --------------------------------------------------------- teaching/service */

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 28px;
}
.two-col h3 {
  font: 600 12px var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-text);
  border-bottom: 1px solid var(--line);
  padding-bottom: 7px;
  margin-bottom: 12px;
}
.simple-list { list-style: none; display: flex; flex-direction: column; gap: 10px; font-size: 14px; color: var(--text-soft); }
.simple-list b { color: var(--text); font-weight: 600; }
.simple-list .sub { font-size: 12.5px; color: var(--muted-text); }

/* ------------------------------------------------------------------ footer */

footer {
  border-top: 1px solid var(--line);
  padding: 22px 0 4px;
  font-size: 12.5px;
  color: var(--muted-text);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
footer a { color: var(--muted-text); }
footer a:hover { color: var(--accent-soft); }

/* ------------------------------------------------------------------ reveal */

.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.55s ease, transform 0.55s ease;
}
.reveal.in { opacity: 1; transform: none; }

/* -------------------------------------------------------------- responsive */

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; gap: 40px; padding: 36px 20px 32px; }
  .sidebar-inner { position: static; }
  .side-nav { display: none; }
  .portrait { width: 148px; height: 148px; }
  .award-grid, .two-col { grid-template-columns: 1fr; }
  .edu-strip { grid-template-columns: 1fr; gap: 14px; }
  section { margin-bottom: 56px; }
}

@media (max-width: 620px) {
  body { font-size: 15px; }
  .pub-card { grid-template-columns: 1fr; }
  .pub-thumb { border-right: none; border-bottom: 1px solid var(--line); padding: 14px; }
  .pub-thumb img { max-height: 150px; }
  .news-list li { grid-template-columns: 1fr; gap: 1px; }
  .talk-item { grid-template-columns: 1fr; gap: 1px; }
  .xp-item { grid-template-columns: 1fr; gap: 2px; }
  .feature-body { padding: 20px 20px 22px; }
  .identity h1 { font-size: 26px; }
}

/* ------------------------------------------------------------------- print */

@media print {
  .side-nav, .theme-toggle, details.more-news > summary, details.workshops > summary { display: none; }
  .layout { grid-template-columns: 1fr; padding: 0; }
  body { background: #fff; }
  .reveal { opacity: 1; transform: none; }
}
