/* Haochun Ma · academic homepage
 * Editorial layout: a label column on the left carries section names (and the
 * portrait on the home page); the reading column on the right carries content.
 * Type: Source Serif Pro for reading, Source Sans Pro for labels and controls.
 * Both are unmodified OFL fonts from TeX Live, wrapped as WOFF.
 */
@import url("tokens.css");

@font-face {
  font-family: "Source Serif Pro";
  src: url("assets/fonts/SourceSerifPro-Regular.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Source Serif Pro";
  src: url("assets/fonts/SourceSerifPro-RegularIt.woff") format("woff");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Source Serif Pro";
  src: url("assets/fonts/SourceSerifPro-Semibold.woff") format("woff");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Source Sans Pro";
  src: url("assets/fonts/SourceSansPro-Regular.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Source Sans Pro";
  src: url("assets/fonts/SourceSansPro-Semibold.woff") format("woff");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  overflow-x: clip;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: var(--fs-body);
  line-height: 1.65;
  font-kerning: normal;
  font-variant-ligatures: common-ligatures;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--selection); }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-weight: 600; overflow-wrap: break-word; }
h1, h2 { text-wrap: balance; }
h3, p { text-wrap: pretty; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { color: var(--accent-deep); }
a:focus-visible, summary:focus-visible, main:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}
main:focus { outline: none; }
em, i { font-style: italic; }
img { max-width: 100%; height: auto; }
.icon { width: 0.875em; height: 0.875em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.skip-link {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 10;
  padding: 0.5rem 0.875rem;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: var(--fs-ui);
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.wrap {
  width: 100%;
  max-width: calc(var(--wrap) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* ---------- Header ---------- */
.site-header {
  border-top: 3px solid var(--accent);
  border-bottom: 1px solid var(--rule);
}
.header-inner {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 1rem 2rem;
  min-height: 4.75rem;
}
.wordmark {
  display: inline-flex;
  align-items: center;
  font-family: var(--serif);
  font-size: 1.3125rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.wordmark:hover { color: var(--accent); }
.site-nav ul {
  display: flex;
  height: 100%;
  gap: 2.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.site-nav a {
  position: relative;
  display: flex;
  align-items: center;
  height: 100%;
  min-height: 44px;
  font-family: var(--sans);
  font-size: 1rem;
  letter-spacing: 0.01em;
  color: var(--ink-2);
  text-decoration: none;
}
.site-nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.2s ease;
}
.site-nav a:hover { color: var(--ink); }
.site-nav a:hover::after { transform: scaleX(1); opacity: 0.35; }
.site-nav a[aria-current="page"] { color: var(--accent); font-weight: 600; }
.site-nav a[aria-current="page"]::after { transform: scaleX(1); opacity: 1; }

/* ---------- Grid shared by hero and sections ---------- */
main { display: block; padding-top: 4.5rem; }
.hero, .section, .page-head {
  display: grid;
  grid-template-columns: var(--col-label) minmax(0, 1fr);
  column-gap: var(--col-gap);
}

/* ---------- Home hero ---------- */
.hero {
  grid-template-areas:
    "photo badge"
    "photo head"
    "photo body";
  grid-template-rows: auto auto 1fr;
}
.portrait {
  grid-area: photo;
  margin: 0;
}
.portrait img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: 2px;
  background: #2f3031;
  box-shadow: 0 1px 2px rgba(28, 26, 25, 0.08), 0 12px 32px -12px rgba(28, 26, 25, 0.28);
}
.badge {
  grid-area: badge;
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3125rem 0.75rem 0.3125rem 0.625rem;
  border-radius: 999px;
  background: var(--accent-tint);
  color: var(--accent);
  font-family: var(--sans);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.3;
}
.badge::before {
  content: "";
  width: 0.4375rem;
  height: 0.4375rem;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.hero-head { grid-area: head; margin-top: 1.125rem; }
.name {
  font-family: var(--serif);
  font-size: var(--fs-name);
  font-weight: 400;
  line-height: 1.04;
  letter-spacing: -0.02em;
}
.role {
  margin-top: 0.75rem;
  font-family: var(--sans);
  font-size: 1.125rem;
  line-height: 1.45;
  color: var(--ink-2);
}
.role .sep { color: var(--rule-strong); padding-inline: 0.375rem; }
.hero-body { grid-area: body; margin-top: 1.75rem; }
.hero-body p { max-width: var(--measure); }
.hero-body p + p { margin-top: 1rem; }
.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.75rem;
  margin-top: 2rem;
}
.button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0 1.25rem;
  border-radius: 3px;
  background: var(--accent);
  color: #fff;
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-decoration: none;
  transition: background-color 0.15s ease;
}
.button:hover { background: var(--accent-deep); color: #fff; }
.contact-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  font-family: var(--sans);
  font-size: 1.0625rem;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--rule-strong);
}
.contact-link .icon { color: var(--muted); width: 1em; height: 1em; }
.contact-link:hover { color: var(--accent); text-decoration-color: currentColor; }

/* ---------- Page heading (Research, Teaching) ---------- */
.page-head h1 {
  grid-column: 2;
  font-size: var(--fs-h1);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.015em;
}
.page-head .lede {
  grid-column: 2;
  margin-top: 0.875rem;
  font-family: var(--sans);
  font-size: 1.125rem;
  color: var(--ink-2);
}

/* ---------- Sections ---------- */
.section {
  position: relative;
  margin-top: var(--section-gap);
  padding-top: 1.75rem;
  border-top: 1px solid var(--rule);
}
.section::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 0;
  width: 2rem;
  height: 2px;
  background: var(--accent);
}
.section-label {
  font-family: var(--sans);
  font-size: var(--fs-label);
  font-weight: 600;
  letter-spacing: 0.14em;
  line-height: 1.6;
  text-transform: uppercase;
  color: var(--accent);
  padding-top: 0.25rem;
}
.section-body { min-width: 0; }
.page-head + .section { margin-top: 3.5rem; }

/* ---------- Papers ---------- */
.paper + .paper { margin-top: 2.75rem; }
.paper-title {
  font-size: var(--fs-paper);
  line-height: 1.36;
  letter-spacing: -0.005em;
  max-width: 46rem;
}
.paper-title a {
  color: var(--ink);
  text-decoration-line: underline;
  text-decoration-color: var(--accent-line);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}
.paper-title a:hover { color: var(--accent); text-decoration-color: currentColor; }
.byline {
  margin-top: 0.5rem;
  font-size: var(--fs-meta);
  color: var(--ink-2);
}
.byline a {
  color: inherit;
  text-decoration-color: var(--rule-strong);
}
.byline a:hover { color: var(--accent); text-decoration-color: currentColor; }
.venue {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.625rem;
  margin-top: 0.5rem;
  font-size: var(--fs-meta);
  color: var(--ink-2);
}
.tag {
  display: inline-block;
  padding: 0.1875rem 0.5rem 0.125rem;
  border-radius: 3px;
  background: var(--accent-tint);
  color: var(--accent);
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  line-height: 1.5;
  text-transform: uppercase;
}
.paper .summary {
  margin-top: 1.125rem;
  max-width: var(--measure);
}

.paper-actions {
  position: relative;
  margin-top: 0.5rem;
  font-family: var(--sans);
  font-size: var(--fs-ui);
}
.paper-actions.row { display: flex; flex-wrap: wrap; gap: 0 1.75rem; }
.action {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  min-height: 44px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--accent);
  text-decoration: none;
}
.action:hover { color: var(--accent-deep); text-decoration: underline; }
.action.quiet { color: var(--ink-2); font-weight: 400; }
.action.quiet:hover { color: var(--accent); }

/* Abstract toggle. When a paper also has a PDF link, the link sits on the
   summary's row: the summary has a fixed width and the link is placed after it. */
.abstract > summary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  width: 5.5rem;
  cursor: pointer;
  list-style: none;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--accent);
  user-select: none;
}
.abstract > summary::-webkit-details-marker { display: none; }
.abstract > summary::before {
  content: "";
  flex: none;
  width: 0.4rem;
  height: 0.4rem;
  margin-right: 0.125rem;
  border-right: 1.6px solid currentColor;
  border-bottom: 1.6px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.2s ease;
}
.abstract[open] > summary::before { transform: translateY(-0.125rem) rotate(45deg); }
.abstract > summary:hover { color: var(--accent-deep); text-decoration: underline; text-underline-offset: 0.2em; }
.paper-actions > .abstract + .action { position: absolute; top: 0; left: 6.75rem; }
.abstract-body {
  margin: 0.375rem 0 0.25rem;
  padding-left: 1.125rem;
  border-left: 2px solid var(--rule);
  max-width: calc(var(--measure) + 1.25rem);
  font-family: var(--serif);
  font-size: var(--fs-meta);
  line-height: 1.68;
  color: var(--ink-2);
}

/* ---------- References ---------- */
.refs {
  display: grid;
  max-width: 50rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.75rem 2.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.ref-name { font-size: var(--fs-meta); font-weight: 600; line-height: 1.4; }
.ref-name a { color: var(--ink); text-decoration-color: var(--accent-line); }
.ref-name a:hover { color: var(--accent); text-decoration-color: currentColor; }
.ref-role {
  margin-top: 0.3125rem;
  font-family: var(--sans);
  font-size: var(--fs-ui);
  line-height: 1.45;
  color: var(--muted);
}
.ref-email {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-family: var(--sans);
  font-size: var(--fs-ui);
  color: var(--ink-2);
  text-decoration-color: var(--rule-strong);
  overflow-wrap: anywhere;
}
.ref-email:hover { color: var(--accent); text-decoration-color: currentColor; }

/* ---------- Dated lists (Education, Teaching) ---------- */
.entries { margin: 0; padding: 0; list-style: none; max-width: 46rem; }
.entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.25rem 2rem;
  align-items: baseline;
}
.entry + .entry { margin-top: 1.125rem; }
.entries.spaced .entry + .entry { margin-top: 1.75rem; }
.entry-title { font-size: var(--fs-body); font-weight: 600; line-height: 1.45; }
.entry-title .code {
  font-family: var(--sans);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-right: 0.5rem;
}
.entry-meta { margin-top: 0.125rem; font-size: var(--fs-meta); color: var(--ink-2); }
.entry-note {
  display: inline-flex;
  margin-top: 0.5rem;
}
.years {
  font-family: var(--sans);
  font-size: var(--fs-ui);
  color: var(--muted);
  font-variant-numeric: lining-nums tabular-nums;
  white-space: nowrap;
}

/* ---------- Footer ---------- */
.site-footer { margin-top: 6rem; border-top: 1px solid var(--rule); }
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 2rem;
  padding-block: 1.75rem 2.75rem;
  font-family: var(--sans);
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--muted);
}
.footer-inner a { color: inherit; text-decoration-color: var(--rule-strong); }
.footer-inner a:hover { color: var(--accent); }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  :root { --col-label: 12.5rem; --col-gap: 2.75rem; --gutter: 2rem; }
}
@media (max-width: 860px) {
  :root { --col-label: 10rem; --col-gap: 2rem; }
  .refs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  :root {
    --gutter: 1.25rem;
    --fs-body: 1.0625rem;
    --fs-meta: 1rem;
    --fs-paper: 1.1875rem;
    --section-gap: 3rem;
  }
  .header-inner { flex-direction: column; align-items: flex-start; gap: 0; min-height: 0; padding-top: 0.875rem; }
  .wordmark { font-size: 1.1875rem; min-height: 2rem; }
  .site-nav { width: 100%; }
  .site-nav ul { gap: 1.5rem; }
  .site-nav a { font-size: 0.9375rem; }
  main { padding-top: 2.25rem; }

  .hero {
    grid-template-columns: 6.75rem minmax(0, 1fr);
    column-gap: 1.25rem;
    grid-template-areas:
      "photo head"
      "badge badge"
      "body body";
    grid-template-rows: auto auto auto;
  }
  .hero-head { margin-top: 0; align-self: center; }
  .name { font-size: 2.125rem; line-height: 1.08; }
  .role { font-size: 0.9375rem; margin-top: 0.5rem; }
  .role .sep { display: none; }
  .role .inst { display: block; }
  .badge { margin-top: 1.5rem; font-size: 0.8125rem; }
  .hero-body { margin-top: 1.125rem; }
  .actions { gap: 0.25rem 1.5rem; margin-top: 1.5rem; }

  .section, .page-head { grid-template-columns: minmax(0, 1fr); }
  .page-head h1, .page-head .lede { grid-column: 1; }
  .section { padding-top: 1.25rem; }
  .section-label { margin-bottom: 1rem; padding-top: 0; }
  .page-head + .section { margin-top: 2.5rem; }
  .refs { grid-template-columns: minmax(0, 1fr); gap: 1.25rem; }
  .paper + .paper { margin-top: 2.25rem; }
  .site-footer { margin-top: 4rem; }
}
@media (max-width: 360px) {
  .site-nav ul { gap: 1.125rem; }
  .hero { grid-template-columns: 5.75rem minmax(0, 1fr); column-gap: 1rem; }
  .name { font-size: 1.875rem; }
  .entry { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
@media print {
  .site-header, .skip-link, .paper-actions, .actions .button { display: none; }
  .site-footer { margin-top: 2rem; }
  .section { break-inside: avoid; }
  .abstract-body { display: block; }
  .portrait img { box-shadow: none; }
}

/* Academic refinement · 14 October 2026
 * Preserve the portrait, typefaces, page structure and research content.
 * Use prose for status, text links for resources and stacked section headings.
 * Hallmark · pre-emit critique: P5 H4 E4 S5 R5 V4.
 */
html { overflow-x: clip; scrollbar-gutter: stable; }
h1, h2, h3 { min-width: 0; overflow-wrap: anywhere; }
.site-header { border-top: 0; }
.site-nav a {
  font-family: var(--serif);
  font-size: var(--fs-body);
  letter-spacing: 0;
  white-space: nowrap;
}
.site-nav a::after { content: none; }
.site-nav a:hover, .site-nav a[aria-current="page"] { text-decoration: underline; }
.site-nav a[aria-current="page"] { font-weight: 400; }
.hero {
  grid-template-areas: "photo head" "photo body";
  grid-template-rows: auto 1fr;
}
.hero-head { margin-top: 0; }
.portrait img { border-radius: 0; box-shadow: none; }
.role { font-family: var(--serif); }
.market-note { color: var(--ink); }
.actions { margin-top: 1.25rem; }
.actions .icon, .paper-actions .icon { display: none; }
.cv-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: var(--fs-body);
  white-space: nowrap;
}
.contact-link { font-family: var(--serif); font-size: var(--fs-body); }
.section { padding-top: 0; border-top: 0; }
.section::before { content: none; }
.section-label {
  grid-column: 2;
  padding-top: 1.25rem;
  margin-bottom: 1.25rem;
  border-top: 1px solid var(--rule);
  font-family: var(--serif);
  font-size: 1.375rem;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.35;
  text-transform: none;
  color: var(--ink);
}
.section-body { grid-column: 2; }
/* Research and Teaching use a shared single column without a profile sidebar.
 * Titles use the full content width; prose keeps a comfortable reading measure.
 * Hallmark · pre-emit critique: P5 H5 E4 S5 R5 V4.
 */
.content-page {
  --fs-meta: var(--fs-body);
  --fs-ui: var(--fs-body);
}
.research-page, .teaching-page { --measure: 56rem; }
:is(.research-page, .teaching-page) > .section { grid-template-columns: minmax(0, 1fr); }
:is(.research-page, .teaching-page) .section-label,
:is(.research-page, .teaching-page) .section-body { grid-column: 1; }
:is(.research-page, .teaching-page) .paper-title { max-width: none; }
:is(.research-page, .teaching-page) > .section:first-of-type { margin-top: 0; }
:is(.research-page, .teaching-page) > .section:first-of-type > .section-label { padding-top: 0; border-top: 0; }
.teaching-page .entries { max-width: none; }
.teaching-intro { margin-bottom: 2rem; }
.teaching-course + .teaching-course { margin-top: 2.75rem; }
.course-meta { margin-top: 0.5rem; font-size: var(--fs-meta); color: var(--ink-2); }
.course-description { max-width: var(--measure); margin-top: 0.875rem; }
.paper-title { font-weight: 400; }
.paper-title a { color: var(--accent); text-decoration: none; transition: none; }
.paper-title a:hover { text-decoration: underline; }
.byline a:hover { color: inherit; text-decoration: underline; }
.venue { display: block; color: var(--ink); }
.status { color: var(--accent); font-weight: 400; }
.teaching-distinction { font-size: var(--fs-meta); font-style: italic; color: var(--ink-2); }
.paper-actions { font-family: var(--serif); font-size: var(--fs-meta); }
.paper-actions.row { align-items: center; }
.action { font-weight: 400; letter-spacing: 0; text-decoration: underline; white-space: nowrap; }
.abstract > summary { font-weight: 400; letter-spacing: 0; }
.abstract > summary::before { transition: none; }
.abstract-body {
  padding-left: 0;
  border-left: 0;
  max-width: var(--measure);
  font-size: var(--fs-body);
  color: var(--ink);
}
.ref-role, .ref-email, .years, .entry-title .code, .footer-inner { font-family: var(--serif); }
.entry-title .code { font-size: var(--fs-meta); font-weight: 400; letter-spacing: 0; }
a:active, summary:active { text-decoration: underline; }

@media (max-width: 720px) {
  .hero { grid-template-areas: "photo head" "body body"; grid-template-rows: auto auto; }
  .section-label, .section-body { grid-column: 1; }
  .section-label { font-size: 1.25rem; }
  .hero-body { margin-top: 1.5rem; }
}

/* Home identity column · 14 October 2026
 * Hallmark · component: academic profile · existing Cardinal / Source Serif Pro
 * Pre-emit critique: P5 H5 E4 S5 R5 V4.
 */
.hero--profile {
  --fs-profile-name: 1.875rem;
  --fs-profile-meta: 1rem;
  --profile-caption-gap: 1.125rem;
  --profile-mobile-width: 12.5rem;
  grid-template-areas: "profile body";
  grid-template-rows: auto;
  align-items: start;
}
.hero--profile .profile { grid-area: profile; min-width: 0; }
.hero--profile .hero-head {
  margin-top: var(--profile-caption-gap);
  text-align: left;
}
.hero--profile .name {
  font-size: var(--fs-profile-name);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  text-wrap: wrap;
}
.hero--profile .role {
  margin-top: 0.375rem;
  font-size: var(--fs-profile-meta);
  line-height: 1.5;
  text-wrap: wrap;
}
.hero--profile .role span { display: block; }
.hero--profile .hero-body { margin-top: 0; min-width: 0; }

@media (min-width: 721px) and (max-width: 860px) {
  .hero--profile { --fs-profile-name: 1.625rem; }
}

@media (max-width: 720px) {
  .hero--profile {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "profile" "body";
    grid-template-rows: auto auto;
    row-gap: 2rem;
  }
  .hero--profile .profile { width: 100%; max-width: var(--profile-mobile-width); }
}
