/* ================================================================== */
/*  THEME TOKENS                                                       */
/* ================================================================== */

:root,
[data-theme="light"] {
    --bg:              #fafaf7;
    --bg-soft:         #f1f0eb;
    --surface:         #ffffff;
    --surface-2:       #f5f4ef;
    --text:            #0d0d0d;
    --text-soft:       #4b4b4b;
    --text-mute:       #7a7a7a;
    --border:          #e6e3dc;
    --border-strong:   #cfcbc0;
    --accent:          #ff2b2b;   /* JHU red, electrified */
    --accent-soft:     #ff4d4d;
    --accent-faint:    rgba(255, 43, 43, 0.10);
    --cyan:            #0ea5b7;
    --grid-line:       rgba(0, 0, 0, 0.04);
    --orb-1:           rgba(255, 43, 43, 0.10);
    --orb-2:           rgba(14, 165, 183, 0.08);
    --shadow-card:     0 1px 0 rgba(0,0,0,0.02), 0 6px 22px rgba(0,0,0,0.04);
    --shadow-glow:     0 0 0 1px rgba(255, 43, 43, 0.10), 0 12px 30px rgba(255, 43, 43, 0.10);
    color-scheme: light;
}

[data-theme="dark"] {
    --bg:              #0a0b0d;
    --bg-soft:         #0e0f12;
    --surface:         #111317;
    --surface-2:       #15181d;
    --text:            #f1efe9;
    --text-soft:       #c2c0b9;
    --text-mute:       #7e7c75;
    --border:          #23262d;
    --border-strong:   #2c3038;
    --accent:          #ff4d4d;
    --accent-soft:     #ff7070;
    --accent-faint:    rgba(255, 77, 77, 0.16);
    --cyan:            #4cc9f0;
    --grid-line:       rgba(255, 255, 255, 0.04);
    --orb-1:           rgba(255, 77, 77, 0.16);
    --orb-2:           rgba(76, 201, 240, 0.10);
    --shadow-card:     0 1px 0 rgba(0,0,0,0.4), 0 8px 28px rgba(0,0,0,0.35);
    --shadow-glow:     0 0 0 1px rgba(255, 77, 77, 0.25), 0 14px 36px rgba(255, 77, 77, 0.18);
    color-scheme: dark;
}

/* ================================================================== */
/*  BASE                                                               */
/* ================================================================== */

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.62;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
    transition: background 0.35s ease, color 0.35s ease;
}

body {
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

a {
    color: var(--text);
    text-decoration: none;
    border-bottom: 1px solid var(--accent);
    padding-bottom: 0;
    transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

a:hover {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: var(--accent-faint);
}

::selection {
    background: var(--accent);
    color: #fff;
}

/* ================================================================== */
/*  AMBIENT BACKGROUND — dot grid + orbs                              */
/* ================================================================== */

.bg-grid {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background-image:
        radial-gradient(var(--grid-line) 1px, transparent 1px);
    background-size: 24px 24px;
    mask-image: radial-gradient(ellipse at center, rgba(0,0,0,1) 35%, transparent 85%);
    -webkit-mask-image: radial-gradient(ellipse at center, rgba(0,0,0,1) 35%, transparent 85%);
}

.bg-orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    pointer-events: none;
    z-index: 0;
    opacity: 1;
    animation: orb-drift 22s ease-in-out infinite alternate;
}

.bg-orb-1 {
    width: 540px;
    height: 540px;
    background: var(--orb-1);
    top: -180px;
    left: -120px;
}

.bg-orb-2 {
    width: 460px;
    height: 460px;
    background: var(--orb-2);
    bottom: -160px;
    right: -120px;
    animation-delay: -8s;
}

@keyframes orb-drift {
    0%   { transform: translate(0, 0) scale(1); }
    100% { transform: translate(40px, 60px) scale(1.08); }
}

@media (prefers-reduced-motion: reduce) {
    .bg-orb { animation: none; }
}

/* ================================================================== */
/*  LAYOUT                                                             */
/* ================================================================== */

.layout {
    position: relative;
    z-index: 1;
    max-width: 1180px;
    margin: 0 auto;
    padding: 56px 36px 80px;
    display: grid;
    grid-template-columns: 290px 1fr;
    gap: 64px;
    align-items: start;
}

/* ================================================================== */
/*  SIDEBAR                                                            */
/* ================================================================== */

.sidebar {
    position: sticky;
    top: 40px;
    align-self: start;
    max-height: calc(100vh - 64px);   /* never taller than the viewport... */
    overflow-y: auto;                  /* ...scroll within the sidebar so the CV stays reachable */
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }

.sidebar-inner {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.photo-wrap {
    position: relative;
    width: 180px;
    height: 180px;
    margin-bottom: 4px;
}

.photo {
    position: relative;
    z-index: 2;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    object-fit: cover;
    object-position: center;
    border: 1px solid var(--border-strong);
    box-shadow: 0 8px 30px rgba(0,0,0,0.10);
    display: block;
}

.photo-glow {
    position: absolute;
    inset: -10px;
    border-radius: 50%;
    background: conic-gradient(
        from 0deg,
        var(--accent) 0%,
        transparent 25%,
        var(--cyan) 50%,
        transparent 75%,
        var(--accent) 100%
    );
    filter: blur(14px);
    opacity: 0.50;
    z-index: 1;
    animation: glow-spin 14s linear infinite;
}

@keyframes glow-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .photo-glow { animation: none; }
}

/* --- Name block --- */

.name-block { display: flex; flex-direction: column; gap: 6px; }

.name {
    font-family: "Space Grotesk", "Inter", sans-serif;
    font-size: 1.85rem;
    font-weight: 600;
    line-height: 1.12;
    margin: 0;
    letter-spacing: -0.015em;
}

.name-cn {
    color: var(--text-mute);
    font-weight: 400;
    font-size: 0.85em;
}

.name-rule {
    height: 2px;
    width: 64px;
    margin: 4px 0 2px;
    background: linear-gradient(90deg, var(--accent) 0%, var(--cyan) 80%, transparent 100%);
    border-radius: 2px;
}

.tagline {
    font-family: "JetBrains Mono", monospace;
    font-size: 0.74rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--accent);
    margin: 0;
}

.institution {
    margin: 0;
    color: var(--text-soft);
    font-size: 0.92rem;
    font-weight: 500;
}

/* --- Affiliation block --- */

.affil-block {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px 14px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 4px;
    box-shadow: var(--shadow-card);
}

.affil-line {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-soft);
    display: flex;
    align-items: baseline;
    gap: 10px;
    line-height: 1.4;
}

.mono-mini {
    font-family: "JetBrains Mono", monospace;
    font-size: 0.62rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--text-mute);
    flex-shrink: 0;
    padding: 2px 6px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--bg-soft);
}

/* --- Contact block --- */

.contact-block {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.contact-item {
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding: 8px 10px;
    border: none;
    border-radius: 4px;
    background: transparent;
    transition: background 0.15s ease;
    margin-left: -10px;
}

.contact-item:hover {
    background: var(--accent-faint);
    color: var(--text);
    border: none;
}

.contact-key {
    font-family: "JetBrains Mono", monospace;
    font-size: 0.68rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--text-mute);
    width: 56px;
    flex-shrink: 0;
}

.contact-val {
    font-size: 0.9rem;
    color: var(--text);
    font-weight: 500;
}

.contact-item:hover .contact-val { color: var(--accent); }

/* --- CV button --- */

.cv-button {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 14px 18px;
    border: 1px solid var(--accent);
    border-radius: 4px;
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.15s ease;
    box-shadow: 0 6px 20px rgba(255, 43, 43, 0.18);
}

.cv-button:hover {
    transform: translateY(-2px);
    color: #fff;
    border: 1px solid var(--accent);
    box-shadow: 0 10px 30px rgba(255, 43, 43, 0.28);
    background: var(--accent-soft);
}

.cv-button-label {
    font-family: "Space Grotesk", "Inter", sans-serif;
    font-weight: 600;
    font-size: 0.98rem;
    letter-spacing: 0.01em;
}

.cv-button-meta {
    font-family: "JetBrains Mono", monospace;
    font-size: 0.7rem;
    opacity: 0.78;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

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

.sidebar-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--surface);
    color: var(--text-soft);
    font-family: "JetBrains Mono", monospace;
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.theme-toggle:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.theme-icon { font-size: 0.9rem; line-height: 1; }

.loc {
    margin: 0;
    font-family: "JetBrains Mono", monospace;
    font-size: 0.7rem;
    color: var(--text-mute);
    letter-spacing: 0.06em;
}

/* ================================================================== */
/*  MAIN                                                               */
/* ================================================================== */

.main {
    min-width: 0;
}

/* --- Section primitives --- */

.section {
    margin-bottom: 64px;
    scroll-margin-top: 24px;
}

.section-head {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 22px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.section-num {
    font-family: "JetBrains Mono", monospace;
    font-size: 0.86rem;
    font-weight: 500;
    color: var(--accent);
    letter-spacing: 0.08em;
}

.section-title {
    font-family: "Space Grotesk", "Inter", sans-serif;
    font-weight: 600;
    font-size: 1.35rem;
    letter-spacing: -0.01em;
    margin: 0;
    color: var(--text);
}

.prose p { margin: 0 0 14px 0; }
.prose p:last-child { margin-bottom: 0; }

.prose-mini {
    font-family: "JetBrains Mono", monospace;
    font-size: 0.74rem;
    color: var(--text-mute);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin: -8px 0 18px 0;
}

.prose-mini .mono-mini {
    border: none;
    padding: 0;
    background: transparent;
}

/* ================================================================== */
/*  NEWS                                                               */
/* ================================================================== */

.news-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
}

.news-item {
    display: grid;
    grid-template-columns: 92px 1fr;
    gap: 18px;
    padding: 12px 0;
    border-bottom: 1px dashed var(--border);
    align-items: baseline;
}

.news-item:last-child { border-bottom: none; }

.news-date {
    font-family: "JetBrains Mono", monospace;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--accent);
    letter-spacing: 0.04em;
}

.news-text {
    font-size: 0.96rem;
    color: var(--text);
    line-height: 1.55;
}

/* ================================================================== */
/*  ABOUT — name note                                                 */
/* ================================================================== */

.name-note {
    margin-top: 18px;
    padding: 14px 18px;
    border-left: 2px solid var(--accent);
    background: var(--accent-faint);
    border-radius: 0 4px 4px 0;
    font-family: "Space Grotesk", "Inter", sans-serif;
    font-size: 0.96rem;
    color: var(--text-soft);
    line-height: 1.55;
}

.name-note em { color: var(--text); font-style: italic; }

/* ================================================================== */
/*  RESEARCH INTERESTS                                                 */
/* ================================================================== */

.interest-grid {
    list-style: none;
    padding: 0;
    margin: 20px 0 0 0;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.interest-card {
    position: relative;
    padding: 16px 16px 16px 18px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 4px;
    transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.interest-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.interest-num {
    display: block;
    font-family: "JetBrains Mono", monospace;
    font-size: 0.68rem;
    color: var(--text-mute);
    letter-spacing: 0.12em;
    margin-bottom: 6px;
}

.interest-card p {
    margin: 0;
    font-size: 0.92rem;
    line-height: 1.5;
    color: var(--text);
}

/* ================================================================== */
/*  PUBLICATIONS                                                       */
/* ================================================================== */

.pub-card {
    display: grid;
    grid-template-columns: 124px 1fr;
    gap: 22px;
    padding: 18px;
    margin-bottom: 14px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 4px;
    transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.pub-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.pub-thumb {
    width: 124px;
    height: 96px;
    border-radius: 3px;
    overflow: hidden;
    background: var(--surface-2);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
}

.pub-thumb svg {
    width: 100%;
    height: 100%;
    display: block;
}

.pub-body { min-width: 0; }

.pub-venue-tag {
    display: inline-block;
    font-family: "JetBrains Mono", monospace;
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
    margin-bottom: 6px;
    padding: 3px 7px;
    border: 1px solid var(--accent);
    border-radius: 3px;
    background: var(--accent-faint);
}

.venue-sep { color: var(--text-mute); margin: 0 4px; }

.pub-title {
    font-family: "Space Grotesk", "Inter", sans-serif;
    font-size: 1.02rem;
    font-weight: 600;
    line-height: 1.35;
    margin: 0 0 6px 0;
    color: var(--text);
    letter-spacing: -0.005em;
}

.pub-authors {
    margin: 0 0 8px 0;
    color: var(--text-soft);
    font-size: 0.9rem;
    line-height: 1.5;
}

.pub-links { margin: 0; font-size: 0.86rem; }
.link-sep { color: var(--text-mute); margin: 0 6px; }

.muted {
    color: var(--text-mute);
    font-style: italic;
    font-size: 0.85rem;
}

/* ================================================================== */
/*  ENTRIES — education / experience / teaching                       */
/* ================================================================== */

.entry {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 22px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.entry:last-child { border-bottom: none; }

.entry-date {
    font-family: "JetBrains Mono", monospace;
    font-size: 0.78rem;
    color: var(--text-mute);
    letter-spacing: 0.04em;
    padding-top: 3px;
}

.entry-body { min-width: 0; }

.entry-title {
    margin: 0 0 4px 0;
    font-family: "Space Grotesk", "Inter", sans-serif;
    font-weight: 600;
    font-size: 0.98rem;
    color: var(--text);
}

.entry-sub {
    margin: 0 0 6px 0;
    color: var(--text-soft);
    font-size: 0.9rem;
    line-height: 1.5;
}

.entry-detail {
    margin: 6px 0 0 0;
    font-size: 0.92rem;
    color: var(--text);
    line-height: 1.55;
}

/* ================================================================== */
/*  SKILLS                                                             */
/* ================================================================== */

.skill-grid {
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.skill-row {
    display: grid;
    grid-template-columns: 130px 1fr;
    gap: 22px;
    padding: 10px 0;
    border-bottom: 1px dashed var(--border);
}

.skill-row:last-child { border-bottom: none; }

.skill-row dt {
    font-family: "JetBrains Mono", monospace;
    font-size: 0.74rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
}

.skill-row dd {
    margin: 0;
    font-size: 0.94rem;
    color: var(--text);
}

/* ================================================================== */
/*  FOOTER                                                             */
/* ================================================================== */

.footer {
    margin-top: 64px;
    padding-top: 22px;
    border-top: 1px solid var(--border);
    color: var(--text-mute);
    font-size: 0.86rem;
}

.footer-line { margin: 0 0 6px 0; }
.footer-meta {
    margin: 0;
    font-family: "JetBrains Mono", monospace;
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    color: var(--text-mute);
}
.footer-sep { color: var(--text-mute); }

/* ================================================================== */
/*  RESPONSIVE                                                         */
/* ================================================================== */

@media (max-width: 960px) {
    .layout {
        grid-template-columns: 1fr;
        gap: 48px;
        padding: 36px 24px 64px;
    }

    .sidebar {
        position: relative;
        top: 0;
    }

    .sidebar-inner {
        display: grid;
        grid-template-columns: 160px 1fr;
        gap: 20px 28px;
        align-items: start;
    }

    .photo-wrap { width: 160px; height: 160px; grid-row: span 4; }
    .photo { width: 160px; height: 160px; }

    .name-block { grid-column: 2; }
    .affil-block { grid-column: 2; }
    .contact-block { grid-column: 2; }
    .cv-button { grid-column: 2; }
    .sidebar-foot {
        grid-column: 1 / -1;
        padding-top: 12px;
    }
}

@media (max-width: 640px) {
    .layout { padding: 28px 20px 56px; }

    .sidebar-inner {
        grid-template-columns: 1fr;
        text-align: left;
    }

    .photo-wrap {
        width: 140px;
        height: 140px;
        grid-row: auto;
    }
    .photo { width: 140px; height: 140px; }

    .name-block, .affil-block, .contact-block, .cv-button {
        grid-column: 1;
    }

    .name { font-size: 1.65rem; }

    .interest-grid {
        grid-template-columns: 1fr;
    }

    .pub-card {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .pub-thumb {
        width: 100%;
        height: 110px;
    }

    .entry {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .entry-date { padding-top: 0; }

    .news-item {
        grid-template-columns: 80px 1fr;
        gap: 12px;
    }

    .skill-row {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .footer-line { line-height: 1.7; }
}

/* --- Section directory (site guide) + availability note --- */
.site-nav {
    display: flex; flex-direction: column; gap: 1px;
    padding: 12px 14px; border: 1px solid var(--border);
    background: var(--surface); border-radius: 4px; box-shadow: var(--shadow-card);
}
.site-nav-title {
    font-family: "JetBrains Mono", monospace; font-size: 0.62rem; font-weight: 500;
    text-transform: uppercase; letter-spacing: 0.14em; color: var(--text-mute); margin: 0 0 6px;
}
.site-nav a {
    display: flex; align-items: baseline; gap: 10px;
    font-size: 0.82rem; color: var(--text-soft); text-decoration: none;
    padding: 3px 4px; border-radius: 3px; transition: color 0.15s ease, background 0.15s ease;
}
.site-nav a:hover { color: var(--accent); background: var(--accent-faint); }
.site-nav a .n {
    font-family: "JetBrains Mono", monospace; font-size: 0.68rem;
    color: var(--text-mute); flex-shrink: 0; width: 1.5em;
}
.availability {
    margin: 20px 0 6px; padding: 12px 16px;
    border: 1px solid var(--border); border-left: 3px solid var(--accent);
    background: var(--accent-faint); border-radius: 4px;
    font-size: 0.9rem; color: var(--text-soft); line-height: 1.55;
}
.availability strong { color: var(--text); }
