/* ==========================================================================
   Dongming Jiang — academic homepage
   Palette and type scale follow the CV (cv/cv.tex).
   ========================================================================== */

:root {
  /* CV palette */
  --navy: #1F3864;
  --blue: #2A6EBB;
  --ink: #172033;
  --muted: #667085;
  --line: #E5EAF0;
  --surface: #F6F8FB;
  --background: #FFFFFF;

  /* Derived */
  --navy-soft: rgba(31, 56, 100, 0.08);
  --blue-soft: rgba(42, 110, 187, 0.10);
  --focus: #0B57D0;

  --sidebar-w: 292px;
  --main-w: 900px;
  --gutter: 16px;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia,
    "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 24px;
}

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

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

a {
  color: var(--blue);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}

a:hover { color: var(--navy); text-decoration-thickness: 2px; }

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

/* ---------- Skip link ---------- */

.skip-link {
  position: absolute;
  left: 8px;
  top: -64px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--navy);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: top 120ms ease-in;
}

.skip-link:focus { top: 8px; color: #fff; }

/* ---------- Page frame ---------- */

.layout {
  display: block;
  max-width: calc(var(--sidebar-w) + var(--main-w) + 120px);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* ---------- Sidebar ---------- */

.sidebar {
  padding: 32px 0 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 32px;
}

.profile-head {
  display: flex;
  align-items: center;
  gap: 16px;
}

.monogram {
  position: relative;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 120px;
  height: 120px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--navy);
  color: #fff;
  font-family: var(--font-serif);
  font-size: 46px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* Initials sit underneath the portrait. If profile.jpg fails to load the
   (alt="") image collapses to nothing and the monogram shows through. */
.monogram-initials {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.monogram-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 28%;
}

.profile-name {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.75rem;
  line-height: 1.2;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.01em;
}

.profile-role {
  margin: 10px 0 0;
  font-size: 0.975rem;
  line-height: 1.45;
  color: var(--ink);
}

.profile-org {
  margin: 2px 0 0;
  font-size: 0.975rem;
  color: var(--muted);
}

.profile-focus {
  margin: 12px 0 0;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--blue);
}

/* Contact list */

.contact {
  list-style: none;
  margin: 20px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  font-size: 0.9rem;
}

.contact li {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.contact a { color: var(--blue); font-weight: 500; }

.contact .icon {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  color: var(--muted);
}

/* Navigation */

.site-nav { margin-top: 22px; }

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

.nav-list a {
  display: block;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--background);
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
}

.nav-list a:hover {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: var(--navy);
}

.nav-list a[aria-current="true"] {
  border-color: var(--navy);
  background: var(--navy);
  color: #fff;
}

/* ---------- Main column ---------- */

.main { padding-bottom: 8px; }

.section { margin: 0 0 44px; scroll-margin-top: 24px; }

.section-title {
  margin: 0 0 18px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--navy);
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.005em;
}

.section-title .count {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0;
}

.lede { margin: 0 0 14px; font-size: 1.02rem; }

.interests {
  margin: 0;
  padding: 12px 16px;
  border-left: 3px solid var(--blue);
  background: var(--surface);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.925rem;
  font-weight: 500;
  color: var(--navy);
}

/* ---------- Project cards ---------- */

.cards {
  display: grid;
  gap: 18px;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--background);
  padding: 20px 22px;
}

.card--lead { border-color: rgba(31, 56, 100, 0.28); }

.card[hidden] { display: none; }

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 12px;
  margin-bottom: 8px;
}

.card-title {
  margin: 0;
  font-size: 1.06rem;
  font-weight: 650;
  line-height: 1.4;
  color: var(--navy);
}

.card-desc { margin: 0 0 12px; font-size: 0.95rem; color: var(--ink); }

.card-result {
  margin: 0 0 14px;
  padding: 10px 14px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  color: var(--muted);
}

.card-result strong { color: var(--navy); font-weight: 600; }

.card-figure { margin: 0 0 14px; }

.card-figure img {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.card-figure figcaption {
  margin-top: 8px;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--muted);
}

/* Status badges */

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge--accepted { background: var(--navy); color: #fff; }

.badge--preprint {
  background: var(--surface);
  color: var(--navy);
  border: 1px solid var(--line);
}

/* Link buttons */

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--navy);
  font-size: 0.825rem;
  font-weight: 600;
  text-decoration: none;
  line-height: 1.5;
}

.btn:hover {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: var(--navy);
  text-decoration: underline;
}

.btn .icon { width: 13px; height: 13px; flex: 0 0 auto; }

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

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

.news li {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 4px 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.935rem;
}

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

.news time,
.news .date {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
  padding-top: 3px;
  text-transform: uppercase;
}

/* Compact scrollable panel. Keyboard-focusable so it can be scrolled without
   a pointer; newest items stay at the top. */
.news-scroll {
  max-height: 322px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--background);
  scrollbar-width: thin;
  scrollbar-color: #C8D2E0 transparent;
}

.news-scroll::-webkit-scrollbar { width: 8px; }
.news-scroll::-webkit-scrollbar-track { background: transparent; }

.news-scroll::-webkit-scrollbar-thumb {
  background: #C8D2E0;
  border-radius: 999px;
  border: 2px solid var(--background);
}

.news-scroll::-webkit-scrollbar-thumb:hover { background: var(--muted); }

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

.pub-note {
  margin: 0 0 18px;
  font-size: 0.83rem;
  color: var(--muted);
}

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

.pub {
  display: grid;
  grid-template-columns: 104px 1fr;
  gap: 6px 18px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

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

.pub-venue {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--blue);
  padding-top: 3px;
}

.pub-venue .status {
  display: block;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0;
  margin-top: 2px;
}

.pub-title {
  margin: 0 0 4px;
  font-size: 1rem;
  font-weight: 650;
  line-height: 1.42;
  color: var(--navy);
}

.pub-authors {
  margin: 0 0 3px;
  font-size: 0.885rem;
  color: var(--ink);
}

.pub-authors strong { font-weight: 700; color: var(--navy); }

.pub-meta {
  margin: 0 0 10px;
  font-size: 0.85rem;
  font-style: italic;
  color: var(--muted);
}

.pub .links { margin-top: 2px; }

.subsection-title {
  margin: 34px 0 12px;
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--navy);
}

.subsection-title:first-of-type { margin-top: 0; }

/* ---------- Experience / education ---------- */

.entry { padding: 0 0 22px; }
.entry:last-child { padding-bottom: 0; }

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

.entry-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
  color: var(--navy);
}

.entry-date {
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
  white-space: nowrap;
}

.entry-sub {
  margin: 2px 0 0;
  font-size: 0.9rem;
  font-style: italic;
  color: var(--muted);
}

.entry ul {
  margin: 10px 0 0;
  padding-left: 20px;
  font-size: 0.93rem;
}

.entry li { margin-bottom: 6px; }
.entry li::marker { color: var(--blue); }

/* ---------- Service ---------- */

.service-label {
  margin: 0 0 8px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink);
}

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

.tags li {
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 0.8rem;
  color: var(--ink);
}

.skills {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
  font-family: var(--font-mono);
  line-height: 1.9;
}

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

.site-footer {
  margin-top: 8px;
  padding: 20px 0 40px;
  border-top: 1px solid var(--line);
  font-size: 0.82rem;
  color: var(--muted);
}

.site-footer p { margin: 0 0 4px; }

/* ---------- Standalone pages (publications, 404) ---------- */

.page-header {
  padding: 28px 0 20px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 32px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
}

.back-link:hover { text-decoration: underline; }

.page-title {
  margin: 14px 0 6px;
  font-family: var(--font-serif);
  font-size: 2rem;
  line-height: 1.2;
  font-weight: 700;
  color: var(--navy);
}

.page-sub { margin: 0; font-size: 0.95rem; color: var(--muted); }

.narrow { max-width: var(--main-w); margin: 0 auto; }

.notfound {
  max-width: 560px;
  margin: 0 auto;
  padding: 80px var(--gutter) 100px;
  text-align: center;
}

.notfound .code {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 4rem;
  font-weight: 700;
  color: var(--navy);
  line-height: 1;
}

.notfound h1 {
  margin: 14px 0 10px;
  font-size: 1.4rem;
  color: var(--ink);
}

.notfound p { margin: 0 0 22px; color: var(--muted); }

.notfound .links { justify-content: center; }

/* ==========================================================================
   Responsive
   ========================================================================== */

/* Tablet and up: wider contact rows, roomier cards */
@media (min-width: 600px) {
  :root { --gutter: 28px; }
  .cards { gap: 20px; }

  .monogram {
    width: 140px;
    height: 140px;
    font-size: 54px;
  }
}

/* Desktop: sticky sidebar + centred main column */
@media (min-width: 1024px) {
  :root { --gutter: 32px; }

  .layout {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    gap: 56px;
    align-items: start;
  }

  .sidebar {
    position: sticky;
    top: 0;
    max-height: 100vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 48px 0 32px;
    margin-bottom: 0;
    border-bottom: 0;
    border-right: 1px solid var(--line);
    padding-right: 28px;
  }

  .profile-head { display: block; }

  .monogram {
    width: 200px;
    height: 200px;
    font-size: 76px;
    margin-bottom: 22px;
  }

  .profile-name {
    font-size: 1.7rem;
    text-wrap: balance;
  }

  .contact {
    display: block;
    margin-top: 22px;
  }

  .contact li { padding: 4px 0; }

  .nav-list { display: block; }

  .nav-list li + li { margin-top: 2px; }

  .nav-list a {
    border: 0;
    border-left: 2px solid transparent;
    border-radius: 0;
    padding: 5px 0 5px 12px;
    color: var(--muted);
  }

  .nav-list a:hover {
    background: transparent;
    border-left-color: var(--blue);
    color: var(--navy);
  }

  .nav-list a[aria-current="true"] {
    background: transparent;
    border-left-color: var(--navy);
    color: var(--navy);
    font-weight: 650;
  }

  .main { padding: 48px 0 0; max-width: var(--main-w); }

  .section { margin-bottom: 56px; }

  html { scroll-padding-top: 32px; }

  .section { scroll-margin-top: 32px; }

  .page-header { padding-top: 40px; }
}

/* Small phones: stack the label columns */
@media (max-width: 460px) {
  .news li,
  .pub { grid-template-columns: 1fr; }

  .news time,
  .news .date,
  .pub-venue { padding-top: 0; }

  .pub-venue .status { display: inline; margin-left: 6px; }

  .card { padding: 18px 16px; }

  .profile-name { font-size: 1.5rem; }
}

/* ---------- Motion ---------- */

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

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Print ---------- */

@media print {
  :root { --gutter: 0; }

  .site-nav,
  .skip-link,
  .back-link,
  .links { display: none !important; }

  body { font-size: 11pt; line-height: 1.45; color: #000; }

  .layout { display: block; max-width: none; }

  .sidebar {
    position: static;
    max-height: none;
    border: 0;
    padding: 0 0 16px;
  }

  .card,
  .interests,
  .card-result { border: 1px solid #ccc; background: #fff; }

  .section { page-break-inside: avoid; margin-bottom: 20px; }

  .news-scroll {
    max-height: none;
    overflow: visible;
    border: 0;
    padding: 0;
  }

  a { color: #000; text-decoration: none; }
}
