/* Self-hosted fonts (IBM Plex families + Noto Serif SC glyph subset for the name) */
@font-face {
    font-family: 'IBM Plex Mono';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('fonts/plex-mono-500.woff2') format('woff2');
}
@font-face {
    font-family: 'IBM Plex Mono';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('fonts/plex-mono-600.woff2') format('woff2');
}
@font-face {
    font-family: 'IBM Plex Sans';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('fonts/plex-sans-400.woff2') format('woff2');
}
@font-face {
    font-family: 'IBM Plex Sans';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('fonts/plex-sans-500.woff2') format('woff2');
}
@font-face {
    font-family: 'IBM Plex Sans';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('fonts/plex-sans-600.woff2') format('woff2');
}
@font-face {
    font-family: 'IBM Plex Sans';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('fonts/plex-sans-700.woff2') format('woff2');
}
@font-face {
    font-family: 'IBM Plex Serif';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('fonts/plex-serif-500.woff2') format('woff2');
}
@font-face {
    font-family: 'IBM Plex Serif';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('fonts/plex-serif-600.woff2') format('woff2');
}
@font-face {
    font-family: 'IBM Plex Serif';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('fonts/plex-serif-700.woff2') format('woff2');
}
@font-face {
    font-family: 'Noto Serif SC';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('fonts/noto-serif-sc-600-subset.woff2') format('woff2');
}

:root {
    --surface-strong: #ffffff;
    --surface-muted: #eceff3;
    --text: #14181d;
    --text-muted: #424c55;
    --text-soft: #687079;
    --accent: #285c8f;
    --accent-strong: #1d4a76;
    --accent-soft: rgba(40, 92, 143, 0.1);
    --line: rgba(20, 24, 29, 0.1);
    --shadow-soft: 0 14px 36px rgba(30, 35, 40, 0.07);
    --max-width: 1140px;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'IBM Plex Sans', sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(40, 92, 143, 0.05), transparent 36%),
        linear-gradient(180deg, #fbfcfd 0%, #f4f6f8 52%, #fbfcfd 100%);
    line-height: 1.6;
    overflow-x: hidden;
}

a {
    color: inherit;
}

img {
    max-width: 100%;
    display: block;
}

.container {
    width: min(var(--max-width), calc(100% - 48px));
    margin: 0 auto;
}

main {
    position: relative;
    z-index: 1;
}

section {
    padding: 36px 0;
    position: relative;
}

section[id] {
    scroll-margin-top: 84px;
}

main > section:not(.hero) {
    content-visibility: auto;
    contain-intrinsic-size: 700px;
}

/* Navigation */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    background: rgba(251, 252, 253, 0.72);
    border-bottom: 1px solid var(--accent-soft);
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.navbar.scrolled {
    background: rgba(252, 253, 254, 0.92);
    border-color: rgba(40, 92, 143, 0.28);
    box-shadow: 0 8px 18px rgba(20, 24, 29, 0.05);
}

.nav-container {
    width: min(var(--max-width), calc(100% - 48px));
    margin: 0 auto;
    height: 68px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.nav-logo {
    font-family: 'IBM Plex Serif', serif;
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.03em;
    text-decoration: none;
    transition: transform 0.1s ease;
}

.nav-logo:active {
    transform: scale(0.97);
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 1.35rem;
}

.nav-link {
    font-family: 'IBM Plex Serif', serif;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    transition: color 0.2s ease, transform 0.1s ease;
}

.nav-link:hover,
.nav-link:focus-visible {
    color: var(--text);
}

/* Very subtle press feedback on click */
.nav-link:active {
    transform: scale(0.96);
}

.hamburger {
    appearance: none;
    display: none;
    width: 44px;
    height: 44px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.6);
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    cursor: pointer;
}

.bar {
    width: 18px;
    height: 2px;
    background: var(--text);
    border-radius: 999px;
    transition: transform 0.25s ease, opacity 0.25s ease;
}

.hamburger.active .bar:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.hamburger.active .bar:nth-child(2) {
    opacity: 0;
}

.hamburger.active .bar:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

/* Hero (compact text-only header) */
.hero {
    padding: 140px 0 32px;
    background: transparent;
}

.hero-container {
    width: min(var(--max-width), calc(100% - 48px));
    margin: 0 auto;
}

.hero-content {
    max-width: 860px;
}

.hero-title {
    font-family: 'IBM Plex Serif', serif;
    font-size: clamp(2.1rem, 3vw, 2.6rem);
    line-height: 1;
    letter-spacing: -0.04em;
    margin-bottom: 16px;
    white-space: nowrap;
}

.hero-title-cn {
    font-family: 'Noto Serif SC', 'Source Han Serif SC', 'Songti SC', serif;
    font-size: 0.92em;
    font-weight: 600;
    letter-spacing: -0.03em;
    color: inherit;
}

.hero-subtitle {
    font-size: 1.05rem;
    color: var(--text-soft);
    margin-bottom: 14px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.hero-description {
    max-width: 78ch;
    font-size: 1.02rem;
    color: var(--text-muted);
    margin-bottom: 0;
}

/* Shared headings */
.section-title {
    font-family: 'IBM Plex Serif', serif;
    font-size: clamp(1.7rem, 2.6vw, 2.05rem);
    line-height: 1.1;
    letter-spacing: -0.03em;
    margin-bottom: 22px;
}

.section-title::after {
    content: '';
    display: block;
    width: 56px;
    height: 2px;
    margin-top: 12px;
    background: linear-gradient(90deg, var(--accent), transparent);
}

/* Indent section body content relative to its title.
   Sections tagged .flush (Experience, Publications) stay flush. */
.page-home main section:not(.flush) .container > *:not(.section-title) {
    margin-left: 8px;
}

/* Section background tints */
.experience,
.publications {
    background: rgba(255, 255, 255, 0.5);
}

.contact {
    background: transparent;
}

/* Body copy colors */
.timeline-description,
.publication-venue-full,
.contact-item p {
    color: var(--text-muted);
}

.contact-item a {
    color: var(--accent);
    text-decoration: none;
}

.contact-item a:hover {
    text-decoration: underline;
}

/* Experience timeline (flat) */
.timeline {
    position: relative;
    display: grid;
    gap: 10px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 23px;
    top: 18px;
    bottom: 34px;
    width: 1px;
    background: linear-gradient(180deg, rgba(40, 92, 143, 0.26), rgba(40, 92, 143, 0.04));
}

.timeline-item {
    position: relative;
    padding-left: 60px;
}

.timeline-marker {
    position: absolute;
    left: 14px;
    top: 18px;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    background: var(--surface-strong);
    border: 4.5px solid var(--accent);
    box-shadow: 0 0 0 4px rgba(40, 92, 143, 0.08);
    transform: translateY(-50%);
}

.timeline-content {
    padding: 2px 0 14px;
    border-bottom: 1px solid var(--line);
}

.timeline-item:last-child .timeline-content {
    padding-bottom: 2px;
    border-bottom: 0;
}

.timeline-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.timeline-header h3 {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-size: 1.1rem;
    line-height: 1.3;
    transition: color 0.2s ease;
}

.timeline-item:hover .timeline-header h3 {
    color: var(--accent-strong);
}

.company-logo {
    width: 1.85rem;
    height: 1.85rem;
    border-radius: 0.55rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 1.85rem;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--line);
    overflow: hidden;
}

.company-logo img {
    width: 78%;
    height: 78%;
    object-fit: contain;
    display: block;
}

.timeline-date {
    flex-shrink: 0;
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
    color: var(--text-soft);
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0;
    white-space: nowrap;
}

.timeline-location {
    color: var(--text-soft);
    margin: 5px 0 7px;
    font-size: 0.95rem;
}

.timeline-description {
    display: grid;
    gap: 0.4rem;
    max-width: 56rem;
    color: var(--text-muted);
    line-height: 1.55;
}

.timeline-description p {
    margin: 0;
}

/* Stacked roles: same company, multiple titles (e.g. an intern who converted
   to full-time) shown as one entry with a sub-timeline of roles instead of a
   duplicated company block. */
.timeline-roles {
    position: relative;
    display: grid;
    gap: 14px;
    margin-top: 4px;
    padding-left: 20px;
}

.timeline-roles::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 8px;
    bottom: 8px;
    width: 1px;
    background: var(--line);
}

.timeline-role {
    position: relative;
}

.timeline-role::before {
    content: '';
    position: absolute;
    left: -20px;
    top: 8px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--surface-strong);
    border: 2px solid var(--accent);
}

.timeline-role:not(:first-child)::before {
    border-color: var(--text-soft);
    opacity: 0.5;
}

.timeline-role-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.timeline-role-title {
    font-weight: 700;
    font-size: 0.98rem;
    color: var(--text);
}

.timeline-role:not(:first-child) .timeline-role-title {
    font-weight: 600;
    color: var(--text-muted);
}

.timeline-role .timeline-description {
    margin-top: 4px;
    font-size: 0.96rem;
}

/* Open source software (flat list) */
.software-grid {
    display: grid;
    gap: 12px;
}

.software-card {
    padding: 0 0 12px;
    border-bottom: 1px solid var(--line);
}

.software-card:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.software-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 0.3rem;
}

.software-header h3 {
    font-size: 1.1rem;
    line-height: 1.3;
}

.software-card p {
    color: var(--text-muted);
}

.software-github {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    border-radius: 8px;
    border: 1px solid var(--line);
    color: var(--text-soft);
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.software-github svg {
    width: 18px;
    height: 18px;
}

.software-github:hover,
.software-github:focus-visible {
    background: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
}

/* Publications (grouped flat) */
.publication-groups {
    display: grid;
    gap: 22px;
}

.publication-group-title {
    margin-bottom: 12px;
    padding: 2px 0 2px 12px;
    border-left: 3px solid var(--accent);
    color: var(--accent-strong);
    font-size: 1.08rem;
    font-weight: 800;
    line-height: 1.3;
}

.publications-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.publication-group .publications-grid {
    padding-left: 0.85rem;
}

.publication-card {
    display: grid;
    gap: 3px;
    padding: 0 0 12px;
    border-bottom: 1px solid var(--line);
}

.publication-card:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.publication-title {
    font-size: 1.1rem;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.publication-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
}

/* Wide screens: title takes the remaining width and wraps internally while the
   abbr stays pinned top-right, baseline-aligned to the title's first line. */
.publication-header .publication-title {
    flex: 1;
    min-width: 0;
}

.publication-header .venue-abbr {
    flex-shrink: 0;
}

/* Tablet-portrait and phones: don't squeeze the abbr beside a wrapping title —
   let the title use the full width and drop the abbr onto its own line below
   (left-aligned), same as the phone layout. */
@media (max-width: 900px) {
    .publication-header {
        display: block;
    }

    .publication-header .venue-abbr {
        display: inline-block;
        margin-top: 2px;
    }
}

.publication-authors {
    margin: 0;
    color: var(--text-soft);
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.publication-authors strong {
    color: var(--text-muted);
    font-weight: 800;
}

.publication-venue-full {
    margin: 0;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.venue-abbr {
    color: var(--accent);
    font-weight: 800;
    white-space: nowrap;
}

.publications-footer {
    margin-top: 16px;
    display: flex;
    justify-content: flex-start;
}

/* "View all publications" — a borderless accent link (no button box), so it
   reads as clickable without competing with the minimal page. */
.view-all-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--accent);
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    text-decoration: none;
    transition: color 0.2s ease;
}

.view-all-link svg {
    width: 15px;
    height: 15px;
    transition: transform 0.2s ease;
}

.view-all-link:hover,
.view-all-link:focus-visible {
    color: var(--accent-strong);
}

.view-all-link:hover svg,
.view-all-link:focus-visible svg {
    transform: translateX(3px);
}

/* Reverse the arrow slide for the back-pointing variant ("Back to Home"). */
.view-all-link.back:hover svg,
.view-all-link.back:focus-visible svg {
    transform: translateX(-3px);
}

/* Contact (flat) */
.contact-content {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(260px, 0.9fr);
    gap: 32px;
    align-items: start;
}

.contact-info {
    display: grid;
    gap: 12px;
    padding: 0;
}

.contact-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.contact-item svg {
    color: var(--accent);
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin-top: 2px;
}

.contact-item h3 {
    font-size: 0.98rem;
    margin-bottom: 2px;
}

.social-links {
    display: grid;
    gap: 0;
}

.social-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 0;
    text-decoration: none;
    color: var(--text-muted);
    border-bottom: 1px solid var(--line);
    transition: color 0.2s ease;
}

.social-link:last-child {
    border-bottom: 0;
}

.social-link:hover {
    color: var(--text);
}

.social-link svg {
    color: var(--accent);
    width: 19px;
    height: 19px;
    flex-shrink: 0;
}

.social-link:hover svg {
    color: var(--accent-strong);
}

/* Footer */
.footer {
    padding: 28px 0 40px;
    color: var(--text-soft);
    text-align: center;
    position: relative;
    z-index: 1;
}

/* All-publications page */
.page-publications .publications {
    padding-top: 112px;
    min-height: calc(100vh - 120px);
}

.page-publications .publications-grid {
    gap: 12px;
}

/* Responsive */
@media (max-width: 960px) {
    section {
        padding: 32px 0;
    }

    .hero {
        padding-top: 120px;
        padding-bottom: 24px;
    }

    .contact-content {
        grid-template-columns: 1fr;
    }

    .nav-menu {
        gap: 1rem;
        flex-wrap: wrap;
        justify-content: flex-end;
    }
}

@media (max-width: 780px) {
    .container,
    .nav-container,
    .hero-container {
        width: min(var(--max-width), calc(100% - 32px));
    }

    .hamburger {
        display: flex;
    }

    .nav-menu {
        position: fixed;
        top: 74px;
        right: 16px;
        left: auto;
        width: max-content;
        min-width: 190px;
        max-width: calc(100% - 32px);
        display: grid;
        grid-template-columns: 1fr;
        justify-content: stretch;
        gap: 4px;
        padding: 10px;
        border-radius: 16px;
        background: rgba(252, 253, 254, 0.97);
        border: 1px solid var(--line);
        box-shadow: var(--shadow-soft);
        transform: translateY(-10px);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
    }

    .nav-menu.active {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: translateY(0);
    }

    .nav-link {
        padding: 10px 12px;
        border-radius: 12px;
    }

    .nav-link:hover,
    .nav-link:focus-visible {
        background: var(--surface-muted);
    }

    .timeline::before {
        left: 19px;
    }

    .timeline-item {
        padding-left: 46px;
    }

    .timeline-marker {
        left: 10px;
    }

    .timeline-date {
        width: 100%;
        margin-top: 2px;
    }
}

@media (max-width: 640px) {
    section {
        padding: 26px 0;
    }

    .hero {
        padding: 104px 0 20px;
    }

    .hero-title {
        font-size: clamp(1.9rem, 8vw, 2.3rem);
        white-space: normal;
        line-height: 1.06;
    }

    .hero-subtitle,
    .hero-description {
        font-size: 1rem;
    }

    .timeline-header {
        gap: 8px;
    }

    .timeline-header h3,
    .publication-title {
        font-size: 1.04rem;
    }

    .timeline-role-title {
        font-size: 0.92rem;
    }

    .publication-group-title {
        font-size: 1.04rem;
    }
}

@media (max-width: 480px) {
    .nav-container {
        height: 62px;
    }

    .nav-menu {
        top: 68px;
        right: 12px;
        left: auto;
    }

    section {
        padding: 22px 0;
    }

    .hero {
        padding: 92px 0 16px;
    }

    .hero-title {
        font-size: clamp(1.75rem, 9vw, 2.1rem);
    }

    .hero-title-cn {
        font-size: 0.86em;
    }

    .section-title {
        font-size: clamp(1.55rem, 7vw, 1.9rem);
        margin-bottom: 18px;
    }

    .section-title::after {
        margin-top: 10px;
        width: 44px;
    }

    .timeline-item {
        padding-left: 38px;
    }

    .timeline::before {
        left: 15px;
    }

    .timeline-marker {
        left: 7px;
        width: 15px;
        height: 15px;
        border-width: 4px;
    }

    .timeline-roles {
        padding-left: 16px;
    }

    .timeline-role::before {
        left: -16px;
    }

    .publication-group .publications-grid {
        padding-left: 0.5rem;
    }
}

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

    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}
