/* ===== Reset & Base ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    color-scheme: light dark;
    --bg: #ffffff;
    --surface: #ffffff;
    --text: #1a1a2e;
    --text-secondary: #555;
    --accent: #4f46e5;
    --accent-hover: #4338ca;
    --accent-light: #eef2ff;
    --border: #e5e7eb;
    --border-hover: #cbd0dc;
    --nav-bg: #ffffff;
    --btn-bg: #ffffff;
    --footer-bg: #fafbfc;
    --footer-text: #6b7280;
    --radius: 14px;
    --max-width: 1120px;
}

html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    * { transition: none !important; }
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    font-size: 15px;
    overflow-x: hidden;
}

/* Offset anchor jumps so headings clear the sticky nav */
section,
.hero,
.site-footer {
    scroll-margin-top: 68px;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* Keyboard focus visibility */
a:focus-visible,
button:focus-visible,
.btn:focus-visible,
.nav-toggle:focus-visible,
.footer-link:focus-visible,
.pub-links a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ===== Nav ===== */
nav {
    position: sticky;
    top: 0;
    background: var(--nav-bg);
    border-bottom: 1px solid var(--border);
    z-index: 100;
}

.nav-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.nav-name {
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
}

.nav-name:hover {
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: 19px;
    font-size: 14px;
}

.nav-links a {
    color: var(--text-secondary);
    font-weight: 400;
    padding: 4px 0;
    position: relative;
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent);
    transition: width 0.3s;
}

.nav-links a:hover {
    color: var(--accent);
    text-decoration: none;
}

.nav-links a:hover::after {
    width: 100%;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}

.nav-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
}

/* ===== Main ===== */
main {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 24px;
}

/* ===== Hero ===== */
.hero {
    padding: 60px 0 40px;
}

.hero-content {
    display: flex;
    gap: 40px;
    align-items: flex-start;
}

.hero-photo {
    flex-shrink: 0;
}

.hero-text {
    flex: 1;
    min-width: 0;
}

.hero-photo img {
    width: 170px;
    height: 170px;
    border-radius: 50%;
    object-fit: cover;
    object-position: center top;
    border: 1px solid var(--border);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

.hero h1,
.name {
    font-size: 30px;
    font-weight: 700;
    margin-bottom: 6px;
    line-height: 1.25;
    letter-spacing: -0.5px;
    color: var(--text);
}

.name-zh {
    font-weight: 400;
    color: var(--text-secondary);
    font-size: 22px;
    margin-left: 3px;
}

.hero-tagline {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    font-weight: 400;
}

.bio {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    line-height: 1.75;
}

.bio:last-of-type {
    margin-bottom: 20px;
}

.hero-links {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 20px;
    border-radius: 24px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.25s;
}

.btn-primary {
    background: var(--accent);
    color: #fff !important;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}

.btn-primary:hover {
    background: var(--accent-hover);
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.22);
}

.btn-outline {
    background: var(--btn-bg);
    color: var(--text) !important;
    border: 1px solid var(--border);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.btn-outline:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent) !important;
    text-decoration: none;
}

/* ===== Sections ===== */
.section {
    padding: 48px 0;
    border-top: 1px solid var(--border);
}

.section h2 {
    font-size: 21px;
    font-weight: 700;
    margin-bottom: 28px;
    letter-spacing: -0.3px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.section h2::before {
    content: '';
    flex-shrink: 0;
    width: 4px;
    height: 20px;
    background: var(--accent);
    border-radius: 2px;
}

/* ===== Education with Logo Badges ===== */
.edu-item {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 16px;
    padding: 20px 24px;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    transition: all 0.3s;
}

.edu-item:hover {
    border-color: var(--border-hover);
}

.edu-item:last-child {
    margin-bottom: 0;
}

.edu-logo-wrap,
.org-logo-wrap {
    width: 88px;
    min-height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    background: #fff;
}

.edu-logo-nycu .edu-logo-img {
    width: 72px;
    height: 72px;
}

.edu-logo-fhsh .edu-logo-img {
    width: 48px;
    height: 48px;
}

.edu-logo-img,
.org-logo-img {
    object-fit: contain;
}

.edu-content {
    flex: 1;
}

/* Experience / publication logo slots are wider than the education ones */
.org-logo-wrap {
    width: 72px;
    min-height: 56px;
}

.exp-item-logo {
    display: flex;
    align-items: flex-start;
    gap: 20px;
}

.exp-logo-content {
    flex: 1;
    min-width: 0;
}

.org-logo-iis .org-logo-img {
    width: 56px;
    height: 56px;
}

.org-logo-eneural .org-logo-img {
    width: 72px;
    height: 42px;
}

.org-logo-basiclab .org-logo-img {
    width: 72px;
    height: 53px;
}

.org-logo-nics .org-logo-img {
    width: 49px;
    height: 56px;
}

.org-logo-acl .org-logo-img {
    width: 72px;
    height: 49px;
}

.org-logo-fhsh .org-logo-img {
    width: 54px;
    height: 56px;
}

.pub-item-logo {
    display: flex;
    align-items: flex-start;
    gap: 20px;
}

.pub-logo-content {
    flex: 1;
    min-width: 0;
}

/* ===== Interests Grid (Colorful) ===== */
.interests-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.interest-card {
    position: relative;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color 0.2s;
    border: 1px solid var(--border);
}

.interest-card:hover {
    border-color: var(--border-hover);
}

.card-accent {
    height: 3px;
}

.card-nlp .card-accent      { background: #8b5cf6; }
.card-vla .card-accent      { background: #10b981; }
.card-security .card-accent { background: #ef4444; }
.card-cv .card-accent       { background: #3b82f6; }

.card-body {
    padding: 20px 22px;
}

.interest-card h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 6px;
}

.interest-card p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.65;
}

/* ===== Publications ===== */
.pub-item {
    padding: 20px 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.2s;
}

.pub-item:hover {
    border-color: var(--border-hover);
}

.pub-item + .pub-item {
    margin-top: 14px;
}

.pub-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.pub-badge {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #fff;
    background: var(--accent);
    padding: 2px 8px;
    border-radius: 6px;
}

.pub-venue {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
}

.pub-title {
    font-size: 15.5px;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 5px;
}

.pub-authors {
    font-size: 13.5px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.pub-summary {
    font-size: 13.5px;
    color: var(--text-secondary);
    line-height: 1.65;
}

.pub-links {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.pub-links a {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--accent);
    border: 1px solid var(--border);
    padding: 3px 12px;
    border-radius: 6px;
    transition: all 0.2s;
}

.pub-links a:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    text-decoration: none;
}

/* ===== Timeline & Experience ===== */
.timeline {
    position: relative;
    padding-left: 28px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 6px;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background: var(--border);
    border-radius: 2px;
}

.timeline-item {
    position: relative;
    margin-bottom: 20px;
}

.timeline-item:last-child {
    margin-bottom: 0;
}

.timeline-dot {
    position: absolute;
    left: -28px;
    top: 24px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    border: 3px solid var(--bg);
    box-shadow: 0 0 0 2px var(--accent);
    z-index: 1;
}

.exp-item {
    padding: 20px 24px;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    transition: all 0.3s;
}

.exp-item:hover {
    border-color: var(--border-hover);
}

.exp-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
    gap: 16px;
}

.exp-header h3 {
    font-size: 15px;
    font-weight: 600;
}

.exp-role {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.exp-date {
    font-size: 13px;
    color: var(--accent);
    white-space: nowrap;
    flex-shrink: 0;
    font-weight: 500;
}

.exp-item ul,
.edu-content ul {
    padding-left: 20px;
    margin-top: 4px;
}

.exp-item li,
.edu-content li {
    font-size: 13.5px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    line-height: 1.65;
}

/* ===== Awards ===== */
.awards-group {
    margin-bottom: 24px;
}

.awards-group:last-child {
    margin-bottom: 0;
}

.awards-category {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--accent);
    margin-bottom: 12px;
}

.award-item {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 12px;
    padding: 18px 22px;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    transition: all 0.3s;
}

.award-item:hover {
    border-color: var(--border-hover);
}

.award-content {
    flex: 1;
}

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

.award-name {
    font-weight: 600;
    font-size: 14.5px;
}

.award-date {
    font-size: 13px;
    color: var(--accent);
    white-space: nowrap;
    flex-shrink: 0;
    font-weight: 500;
}

.award-item p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
    line-height: 1.65;
}

/* ===== Activities Grid ===== */
.activities-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

.activity-card {
    padding: 20px 22px;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    transition: all 0.3s;
}

.activity-card:hover {
    border-color: var(--border-hover);
}

.activity-card h3 {
    font-size: 14.5px;
    font-weight: 600;
    margin-bottom: 4px;
}

.activity-card .exp-role {
    margin-bottom: 6px;
}

.activity-details {
    padding-left: 20px;
    margin: 6px 0;
}

.activity-details li {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.65;
    margin-bottom: 2px;
}

.activity-card .exp-date {
    display: inline-block;
    color: var(--accent);
    font-size: 12.5px;
    font-weight: 500;
}

/* ===== Footer / Contact ===== */
.site-footer {
    background: var(--footer-bg);
    color: var(--text);
    border-top: 1px solid var(--border);
    padding: 3.5rem 2rem 1.5rem;
    margin-top: 3rem;
}

.footer-content {
    max-width: var(--max-width);
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    align-items: start;
}

.footer-main h2 {
    font-size: 22px;
    color: var(--text);
    margin-bottom: 12px;
}

.footer-main p {
    line-height: 1.7;
    color: var(--text-secondary);
    font-size: 14px;
}

.footer-links {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.footer-link {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--accent) !important;
    text-decoration: none;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 14px;
    transition: background 0.2s;
}

.footer-link:hover {
    color: var(--accent-hover) !important;
    background: var(--accent-light);
    text-decoration: none;
}

.footer-link svg {
    flex-shrink: 0;
    opacity: 0.9;
}

.footer-bottom {
    max-width: var(--max-width);
    margin: 2.5rem auto 0;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 13px;
    color: var(--footer-text);
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
    .nav-links {
        display: none;
    }

    .nav-links.open {
        display: flex;
        flex-direction: column;
        gap: 16px;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--nav-bg);
        border-bottom: 1px solid var(--border);
        box-shadow: 0 8px 16px rgba(0, 0, 0, 0.06);
        padding: 18px 24px;
        z-index: 100;
    }

    .nav-toggle {
        display: flex;
    }

    .hero-content {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .hero-photo img {
        width: 140px;
        height: 140px;
    }

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

    .hero h1 {
        font-size: 22px;
    }

    .interests-grid,
    .activities-grid {
        grid-template-columns: 1fr;
    }

    .exp-header {
        flex-direction: column;
        gap: 4px;
    }

    .award-header {
        flex-direction: column;
        gap: 4px;
    }

    .edu-item {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .exp-item-logo,
    .pub-item-logo {
        flex-direction: column;
        align-items: flex-start;
        gap: 14px;
    }

    .footer-content {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .timeline {
        padding-left: 24px;
    }

    .timeline-dot {
        left: -24px;
        width: 12px;
        height: 12px;
    }
}

/* ===== Dark Mode (follows the visitor's OS setting) ===== */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0e1015;
        --surface: #171a22;
        --text: #e7e8ec;
        --text-secondary: #a1a6b4;
        --accent: #8b8df2;
        --accent-hover: #a5a7f7;
        --accent-light: #1f2038;
        --border: #282c38;
        --border-hover: #3a3f4f;
        --nav-bg: #12141b;
        --btn-bg: #1c1f28;
        --footer-bg: #12141b;
        --footer-text: #8b91a1;
    }

    /* Logo tiles keep a light ground: the marks themselves are drawn for one */
    .edu-logo-wrap,
    .org-logo-wrap {
        background: #f3f4f6;
    }

    .hero-photo img {
        border-color: var(--border);
    }
}

/* ===== Print (CV sites get printed and saved to PDF) ===== */
@media print {
    /* @media print does not cancel prefers-color-scheme, so force the light
       palette back or a dark-mode visitor prints a black page. */
    :root {
        --bg: #ffffff;
        --surface: #ffffff;
        --text: #000000;
        --text-secondary: #333333;
        --accent: #000000;
        --accent-light: #ffffff;
        --border: #cccccc;
        --border-hover: #cccccc;
        --nav-bg: #ffffff;
        --btn-bg: #ffffff;
        --footer-bg: #ffffff;
        --footer-text: #333333;
    }

    nav,
    .nav-toggle,
    .hero-links,
    .timeline-dot {
        display: none;
    }

    body {
        font-size: 10.5pt;
        line-height: 1.5;
    }

    main {
        max-width: none;
        padding: 0;
    }

    .timeline {
        padding-left: 0;
    }

    .timeline::before {
        display: none;
    }

    .edu-item,
    .exp-item,
    .award-item,
    .pub-item,
    .interest-card,
    .activity-card {
        box-shadow: none;
        break-inside: avoid;
        page-break-inside: avoid;
    }

    h2 {
        break-after: avoid;
        page-break-after: avoid;
    }

    a {
        text-decoration: underline;
    }

    /* Links are dead on paper: spell out the destination for the ones a
       reader would actually want to follow. */
    .footer-link[href^="http"]::after,
    .award-name a[href^="http"]::after {
        content: " (" attr(href) ")";
        font-size: 8.5pt;
        font-weight: 400;
        word-break: break-all;
    }

    .section,
    .site-footer {
        break-before: auto;
    }
}
