/*
 * Academic personal-site layer for MkDocs Material 9.7.x.
 * Uses system fonts only and keeps the visual language restrained in both themes.
 */

:root {
  --site-font-sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC",
    Arial, sans-serif;
  --site-font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --site-radius-sm: 0.45rem;
  --site-radius-md: 0.8rem;
  --site-radius-lg: 1.15rem;
  --site-shadow-sm: 0 1px 2px rgb(15 23 42 / 0.05), 0 8px 24px rgb(15 23 42 / 0.05);
  --site-shadow-md: 0 18px 48px rgb(15 23 42 / 0.1);
  --site-content-width: 90rem;
  --site-reading-width: 54rem;
}

[data-md-color-scheme="default"] {
  --md-primary-fg-color: #183153;
  --md-primary-fg-color--light: #284a73;
  --md-primary-fg-color--dark: #10233d;
  --md-accent-fg-color: #2563a6;
  --md-default-bg-color: #f8fafc;
  --md-default-fg-color: #172033;
  --md-default-fg-color--light: #4b5870;
  --md-typeset-a-color: #1d5e9f;
  --site-surface: #ffffff;
  --site-surface-muted: #f1f5f9;
  --site-border: #dbe3ec;
  --site-hero-start: #edf4fb;
  --site-hero-end: #f8fafc;
  --site-card-hover: #f5f9fd;
  --site-table-stripe: #f7f9fc;
}

[data-md-color-scheme="slate"] {
  --md-primary-fg-color: #172a46;
  --md-primary-fg-color--light: #25466f;
  --md-primary-fg-color--dark: #0d1c31;
  --md-accent-fg-color: #7ab7e8;
  --md-default-bg-color: #0f1724;
  --md-default-fg-color: #e6edf5;
  --md-default-fg-color--light: #acb8c8;
  --md-typeset-a-color: #8ac5f4;
  --site-surface: #151f2e;
  --site-surface-muted: #1a2637;
  --site-border: #2d3c51;
  --site-hero-start: #17263a;
  --site-hero-end: #111a28;
  --site-card-hover: #1b2a3e;
  --site-table-stripe: #182536;
  --site-shadow-sm: 0 1px 2px rgb(0 0 0 / 0.18), 0 10px 28px rgb(0 0 0 / 0.16);
  --site-shadow-md: 0 20px 52px rgb(0 0 0 / 0.28);
}

html {
  scroll-behavior: smooth;
}

body,
input {
  font-family: var(--site-font-sans);
}

code,
kbd,
pre {
  font-family: var(--site-font-mono);
}

.md-grid {
  max-width: var(--site-content-width);
}

.md-header {
  box-shadow: 0 1px 0 rgb(255 255 255 / 0.08), 0 6px 24px rgb(0 0 0 / 0.12);
}

.md-header__title {
  font-weight: 650;
  letter-spacing: -0.015em;
}

.md-tabs {
  border-bottom: 1px solid rgb(255 255 255 / 0.1);
}

.md-tabs__link {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.015em;
  opacity: 0.78;
}

.md-tabs__link--active,
.md-tabs__link:hover {
  opacity: 1;
}

.md-search__form {
  border-radius: 0.55rem;
}

.md-search-result__meta {
  font-size: 0.67rem;
}

.md-content__inner {
  padding-bottom: 2rem;
}

.md-typeset {
  font-size: 0.78rem;
  line-height: 1.78;
  text-rendering: optimizeLegibility;
}

.md-typeset > :not(.profile-hero, .resume-panel, .home-nav-grid, .page-language-switch, .md-typeset__scrollwrap) {
  max-width: var(--site-reading-width);
}

.md-typeset h1,
.md-typeset h2,
.md-typeset h3,
.md-typeset h4 {
  color: var(--md-default-fg-color);
  font-weight: 650;
  letter-spacing: -0.025em;
  scroll-margin-top: 6.5rem;
}

.md-typeset h1 {
  margin-bottom: 1.1rem;
  font-size: clamp(1.8rem, 4vw, 2.5rem);
}

.md-typeset h2 {
  margin-top: 2.7rem;
  padding-bottom: 0.42rem;
  border-bottom: 1px solid var(--site-border);
  font-size: clamp(1.24rem, 2.5vw, 1.52rem);
}

.md-typeset h3 {
  margin-top: 2rem;
  font-size: 1.03rem;
}

.md-typeset h4 {
  margin-top: 1.6rem;
  font-size: 0.88rem;
}

.md-typeset h2 .headerlink,
.md-typeset h3 .headerlink,
.md-typeset h4 .headerlink {
  opacity: 0;
  transition: opacity 160ms ease;
}

.md-typeset h2:hover .headerlink,
.md-typeset h3:hover .headerlink,
.md-typeset h4:hover .headerlink,
.md-typeset .headerlink:focus {
  opacity: 0.55;
}

.md-typeset a {
  text-decoration-thickness: 0.06em;
  text-underline-offset: 0.16em;
}

.md-typeset a:hover {
  text-decoration: underline;
}

.md-typeset hr {
  margin-block: 2rem;
  border-bottom-color: var(--site-border);
}

.md-typeset blockquote {
  border-left: 0.18rem solid var(--md-accent-fg-color);
  color: var(--md-default-fg-color--light);
}

/* Compact in-page anchor navigation for long academic pages. */
.page-jump-links {
  display: flex;
  max-width: var(--site-reading-width);
  margin: 0.15rem 0 1.35rem;
  padding: 0.42rem;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid var(--site-border);
  border-radius: 0.8rem;
  background: color-mix(in srgb, var(--site-surface) 94%, transparent);
  box-shadow: var(--site-shadow-sm);
}

.md-typeset .page-jump-links a {
  display: inline-flex;
  min-height: 1.75rem;
  align-items: center;
  justify-content: center;
  padding: 0.28rem 0.66rem;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--site-surface-muted);
  color: var(--md-default-fg-color--light);
  font-size: 0.64rem;
  font-weight: 680;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, transform 150ms ease;
}

.md-typeset .page-jump-links a:hover,
.md-typeset .page-jump-links a:focus-visible {
  border-color: color-mix(in srgb, var(--md-accent-fg-color) 45%, var(--site-border));
  background: var(--site-card-hover);
  color: var(--md-typeset-a-color);
  text-decoration: none;
  transform: translateY(-1px);
}

.md-typeset :is(h2, h3, h4):target {
  border-radius: var(--site-radius-sm);
  outline: 0.18rem solid color-mix(in srgb, var(--md-accent-fg-color) 20%, transparent);
  outline-offset: 0.32rem;
}

/* Bilingual switcher embedded on profile pages. */
.page-language-switch {
  display: flex;
  width: fit-content;
  margin: -0.65rem 0 1.1rem auto;
  padding: 0.2rem;
  gap: 0.15rem;
  border: 1px solid var(--site-border);
  border-radius: 999px;
  background: var(--site-surface);
  box-shadow: var(--site-shadow-sm);
  font-size: 0.68rem;
  line-height: 1;
}

.page-language-switch a,
.page-language-switch span {
  display: inline-flex;
  min-height: 1.8rem;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.72rem;
  border-radius: 999px;
  color: var(--md-default-fg-color--light);
  font-weight: 650;
  text-decoration: none;
}

.page-language-switch span {
  background: var(--md-primary-fg-color);
  color: #fff;
}

.page-language-switch a:hover {
  background: var(--site-surface-muted);
  color: var(--md-typeset-a-color);
  text-decoration: none;
}

/* Profile hero: works with the existing semantic HTML without changing page content. */
.profile-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(10rem, 13rem) minmax(0, 1fr);
  align-items: center;
  margin: 0 0 1.5rem;
  padding: clamp(1.25rem, 3.2vw, 2.3rem);
  gap: clamp(1.35rem, 4vw, 2.8rem);
  overflow: hidden;
  border: 1px solid var(--site-border);
  border-radius: var(--site-radius-lg);
  background:
    radial-gradient(circle at 88% 8%, color-mix(in srgb, var(--md-accent-fg-color) 14%, transparent), transparent 33%),
    linear-gradient(135deg, var(--site-hero-start), var(--site-hero-end));
  box-shadow: var(--site-shadow-md);
}

.profile-hero::after {
  position: absolute;
  right: -4rem;
  bottom: -5rem;
  width: 13rem;
  height: 13rem;
  border: 1px solid color-mix(in srgb, var(--md-accent-fg-color) 25%, transparent);
  border-radius: 50%;
  content: "";
  pointer-events: none;
}

.profile-portrait {
  position: relative;
  z-index: 1;
}

.profile-portrait img {
  display: block;
  width: min(100%, 12rem);
  aspect-ratio: 4 / 5;
  margin: 0 auto;
  border: 0.28rem solid color-mix(in srgb, var(--site-surface) 82%, transparent);
  border-radius: 1rem;
  object-fit: cover;
  box-shadow: 0 16px 38px rgb(15 23 42 / 0.2);
}

.profile-summary {
  position: relative;
  z-index: 1;
  min-width: 0;
}

.profile-summary > :first-child {
  margin-top: 0;
}

.profile-summary p {
  max-width: 45rem;
  margin: 0.45rem 0;
}

.profile-kicker {
  color: var(--md-typeset-a-color);
  font-size: 0.69rem;
  font-weight: 750;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.profile-role {
  font-size: clamp(0.94rem, 2vw, 1.15rem);
  font-weight: 650;
  line-height: 1.5;
}

.profile-actions {
  display: flex;
  flex-wrap: wrap;
  margin-top: 1.15rem;
  gap: 0.55rem;
}

.md-typeset .profile-button {
  display: inline-flex;
  min-height: 2.25rem;
  align-items: center;
  justify-content: center;
  padding: 0.48rem 0.86rem;
  border: 1px solid var(--site-border);
  border-radius: 0.55rem;
  background: var(--site-surface);
  color: var(--md-default-fg-color);
  font-size: 0.7rem;
  font-weight: 700;
  text-decoration: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.md-typeset .profile-button:hover {
  border-color: var(--md-accent-fg-color);
  box-shadow: var(--site-shadow-sm);
  text-decoration: none;
  transform: translateY(-1px);
}

.md-typeset .profile-button--primary {
  border-color: var(--md-primary-fg-color);
  background: var(--md-primary-fg-color);
  color: #fff;
}

/* Compact bilingual CV access panel. */
.resume-panel {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  margin: 0 0 1.35rem;
  padding: 0.9rem;
  gap: 0.85rem;
  overflow: hidden;
  border: 1px solid var(--site-border);
  border-radius: var(--site-radius-md);
  background:
    linear-gradient(110deg, color-mix(in srgb, var(--md-primary-fg-color) 8%, var(--site-surface)), var(--site-surface) 48%);
  box-shadow: var(--site-shadow-sm);
}

.resume-panel::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0.2rem;
  background: linear-gradient(180deg, var(--md-primary-fg-color), var(--md-accent-fg-color));
  content: "";
}

.resume-panel__intro {
  padding: 0.25rem 0.55rem;
}

.resume-panel__intro p {
  margin: 0;
}

.resume-panel__eyebrow {
  color: var(--md-typeset-a-color);
  font-size: 0.6rem;
  font-weight: 760;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.resume-panel__title {
  margin-top: 0.2rem !important;
  color: var(--md-default-fg-color);
  font-size: 0.88rem;
  font-weight: 720;
  line-height: 1.35;
}

.resume-panel__description {
  margin-top: 0.28rem !important;
  color: var(--md-default-fg-color--light);
  font-size: 0.63rem;
  line-height: 1.5;
}

.resume-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.resume-option {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  padding: 0.72rem;
  gap: 0.65rem;
  border: 1px solid color-mix(in srgb, var(--site-border) 88%, var(--md-accent-fg-color));
  border-radius: 0.7rem;
  background: color-mix(in srgb, var(--site-surface) 94%, transparent);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.resume-option:hover {
  border-color: color-mix(in srgb, var(--md-accent-fg-color) 52%, var(--site-border));
  box-shadow: var(--site-shadow-sm);
  transform: translateY(-1px);
}

.resume-option__meta {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.resume-option__meta span {
  color: var(--md-typeset-a-color);
  font-size: 0.57rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  line-height: 1.2;
  text-transform: uppercase;
}

.resume-option__meta strong {
  margin-top: 0.17rem;
  color: var(--md-default-fg-color);
  font-size: 0.76rem;
  line-height: 1.3;
}

.resume-option__meta small {
  margin-top: 0.12rem;
  color: var(--md-default-fg-color--light);
  font-size: 0.58rem;
  line-height: 1.3;
}

.resume-option__actions {
  display: flex;
  flex-shrink: 0;
  gap: 0.32rem;
}

.md-typeset .resume-link {
  display: inline-flex;
  min-height: 1.9rem;
  align-items: center;
  justify-content: center;
  padding: 0.34rem 0.56rem;
  border: 1px solid var(--site-border);
  border-radius: 0.48rem;
  background: var(--site-surface);
  color: var(--md-default-fg-color);
  font-size: 0.6rem;
  font-weight: 700;
  line-height: 1.15;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color 150ms ease, background-color 150ms ease, color 150ms ease;
}

.md-typeset .resume-link:hover,
.md-typeset .resume-link:focus-visible {
  border-color: var(--md-accent-fg-color);
  color: var(--md-typeset-a-color);
  text-decoration: none;
}

.md-typeset .resume-link--primary {
  border-color: var(--md-primary-fg-color);
  background: var(--md-primary-fg-color);
  color: #fff;
}

.md-typeset .resume-link--primary:hover,
.md-typeset .resume-link--primary:focus-visible {
  border-color: var(--md-accent-fg-color);
  background: var(--md-accent-fg-color);
  color: #fff;
}

/* Homepage navigation cards. */
.home-nav-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 1.35rem 0 2.5rem;
  gap: 0.8rem;
}

.md-typeset .home-nav-grid > a {
  display: flex;
  min-height: 8.2rem;
  flex-direction: column;
  padding: 1.05rem 1.1rem;
  border: 1px solid var(--site-border);
  border-radius: var(--site-radius-md);
  background: var(--site-surface);
  box-shadow: var(--site-shadow-sm);
  color: var(--md-default-fg-color);
  text-decoration: none;
  transition: background-color 160ms ease, border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.md-typeset .home-nav-grid > a:hover {
  border-color: color-mix(in srgb, var(--md-accent-fg-color) 60%, var(--site-border));
  background: var(--site-card-hover);
  box-shadow: var(--site-shadow-md);
  text-decoration: none;
  transform: translateY(-2px);
}

.home-nav-grid span {
  color: var(--md-typeset-a-color);
  font-size: 0.62rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.home-nav-grid strong {
  margin: 0.35rem 0 0.42rem;
  font-size: 0.9rem;
  line-height: 1.35;
}

.home-nav-grid small {
  margin-top: auto;
  color: var(--md-default-fg-color--light);
  font-size: 0.66rem;
  line-height: 1.55;
}

/* Long research, publication, and award tables. */
.md-typeset__scrollwrap {
  max-width: 100%;
  margin: 1.1rem 0;
  overflow-x: auto;
  border: 1px solid var(--site-border);
  border-radius: var(--site-radius-md);
  background: var(--site-surface);
  box-shadow: var(--site-shadow-sm);
  scrollbar-color: var(--site-border) transparent;
}

.md-typeset__table {
  display: table;
  width: 100%;
  margin: 0;
  padding: 0;
}

.md-typeset table:not([class]) {
  display: table;
  width: 100%;
  margin: 0;
  border-collapse: separate;
  border-spacing: 0;
  border: 0;
  font-size: 0.68rem;
  line-height: 1.55;
}

.md-typeset table:not([class]) th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 0.72rem 0.78rem;
  border-bottom: 1px solid var(--site-border);
  background: var(--site-surface-muted);
  color: var(--md-default-fg-color);
  font-weight: 720;
  white-space: nowrap;
}

.md-typeset table:not([class]) td {
  padding: 0.64rem 0.78rem;
  border-top: 0;
  border-bottom: 1px solid var(--site-border);
  vertical-align: top;
}

.md-typeset table:not([class]) tbody tr:nth-child(even) {
  background: var(--site-table-stripe);
}

.md-typeset table:not([class]) tbody tr:hover {
  background: var(--site-card-hover);
}

.md-typeset table:not([class]) tbody tr:last-child td {
  border-bottom: 0;
}

.md-typeset table:not([class]) td:first-child,
.md-typeset table:not([class]) th:first-child {
  padding-left: 0.95rem;
}

.md-typeset table:not([class]) td:last-child,
.md-typeset table:not([class]) th:last-child {
  padding-right: 0.95rem;
}

/* Navigation and table-of-contents rhythm. */
.md-nav__title {
  font-weight: 700;
}

.md-nav__link {
  line-height: 1.45;
}

.md-nav__link--active {
  font-weight: 680;
}

.md-sidebar--secondary .md-nav__link {
  font-size: 0.66rem;
}

.md-top {
  border: 1px solid var(--site-border);
  border-radius: 999px;
  background: var(--site-surface);
  color: var(--md-default-fg-color);
  box-shadow: var(--site-shadow-md);
}

/* Tablet and mobile layout. */
@media screen and (max-width: 76.234375em) {
  .md-typeset > :not(.profile-hero, .resume-panel, .home-nav-grid, .page-language-switch, .md-typeset__scrollwrap) {
    max-width: none;
  }

}

@media screen and (max-width: 60em) {
  .home-nav-grid {
    grid-template-columns: 1fr;
  }

  .md-typeset .home-nav-grid > a {
    min-height: 0;
  }
}

@media screen and (max-width: 44em) {
  .md-typeset {
    font-size: 0.75rem;
    line-height: 1.72;
  }

  .md-typeset h1 {
    font-size: 1.75rem;
  }

  .page-language-switch {
    margin-top: -0.45rem;
  }

  .profile-hero {
    grid-template-columns: 1fr;
    padding: 1.15rem;
    text-align: left;
  }

  .profile-portrait img {
    width: 8.6rem;
    aspect-ratio: 1;
    border-radius: 50%;
  }

  .profile-kicker {
    letter-spacing: 0.055em;
  }

  .profile-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .profile-actions .profile-button--primary {
    grid-column: 1 / -1;
  }

  .resume-panel {
    padding: 0.78rem;
  }

  .resume-options {
    grid-template-columns: 1fr;
  }

  .resume-option {
    align-items: stretch;
  }

  .resume-option__actions {
    align-items: center;
  }

  .page-jump-links {
    margin-right: -0.2rem;
    margin-left: -0.2rem;
    padding: 0.35rem;
    gap: 0.28rem;
  }

  .md-typeset .page-jump-links a {
    min-height: 1.65rem;
    padding: 0.25rem 0.56rem;
    font-size: 0.61rem;
    white-space: normal;
    text-align: center;
  }

  .md-typeset__scrollwrap {
    margin-right: -0.8rem;
    margin-left: -0.8rem;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }

  .md-typeset table:not([class]) {
    font-size: 0.64rem;
  }

  .md-typeset table:not([class]) th,
  .md-typeset table:not([class]) td {
    min-width: 7.5rem;
    padding: 0.58rem 0.65rem;
  }
}

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

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

/* Clean, readable print output for CV and research-history pages. */
@media print {
  :root {
    --md-default-bg-color: #fff;
    --md-default-fg-color: #111827;
    --md-default-fg-color--light: #374151;
    --site-surface: #fff;
    --site-surface-muted: #f3f4f6;
    --site-border: #cbd5e1;
  }

  @page {
    margin: 14mm 13mm;
  }

  body {
    background: #fff !important;
    color: #111827 !important;
  }

  .md-header,
  .md-tabs,
  .md-sidebar,
  .md-footer,
  .md-top,
  .md-search,
  .page-language-switch,
  .page-jump-links,
  .profile-actions,
  .resume-panel,
  .home-nav-grid,
  .headerlink {
    display: none !important;
  }

  .md-main,
  .md-main__inner,
  .md-content,
  .md-content__inner {
    display: block !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .md-typeset {
    font-size: 9.5pt;
    line-height: 1.5;
  }

  .md-typeset h1,
  .md-typeset h2,
  .md-typeset h3,
  .md-typeset h4 {
    break-after: avoid;
    color: #111827 !important;
  }

  .profile-hero {
    grid-template-columns: 32mm 1fr;
    padding: 6mm;
    border: 1px solid #cbd5e1;
    background: #fff !important;
    box-shadow: none;
    break-inside: avoid;
  }

  .profile-portrait img {
    width: 28mm;
    border: 0;
    border-radius: 3mm;
    box-shadow: none;
  }

  .md-typeset__scrollwrap {
    overflow: visible;
    border: 0;
    box-shadow: none;
  }

  .md-typeset table:not([class]) {
    width: 100%;
    font-size: 7.5pt;
  }

  .md-typeset table:not([class]) th {
    position: static;
    background: #f3f4f6 !important;
  }

  .md-typeset table:not([class]) tr,
  .md-typeset table:not([class]) img,
  .md-typeset pre,
  .md-typeset blockquote {
    break-inside: avoid;
  }

  .md-typeset a {
    color: #111827 !important;
    text-decoration: none;
  }
}
