/* =========================================================
   Tuo Shi — personal homepage (redesign)
   ========================================================= */

:root {
    --ink:        #1f2733;
    --muted:      #5b6675;
    --muted-2:    #8a93a0;
    --primary:    #2d3e50;   /* dark academic blue   */
    --primary-2:  #303d5f;
    --accent:     #3d92c9;   /* link / highlight blue */
    --accent-soft:#b0cadb;
    --line:       #e3e8ee;
    --bg:         #ffffff;
    --bg-soft:    #f6f8fb;
    --bg-blue:    #eaf0f8;   /* light navy-tinted panel fill */
    --line-blue:  #b6c4d6;   /* navy-tinted hairline       */
    --radius:     8px;
    --r-chip:     4px;
    --shadow:     0 1px 2px rgba(31, 39, 51, 0.05);
    --shadow-sm:  0 1px 2px rgba(31, 39, 51, 0.05);

    /* type system (after RealZST.github.io) */
    --font-sans:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    --font-serif: 'Source Serif 4', Georgia, ui-serif, serif;
    --font-mono:  'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    /* Latin in Inter, CJK in a clean sans (黑体) — used on Chinese pages */
    --font-cjk:   'Inter', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans SC', -apple-system, sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    color: var(--ink);
    background: var(--bg);
    font-size: 16px;
    line-height: 1.7;
    font-family: var(--font-sans);
    font-feature-settings: 'kern', 'liga';
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* sticky footer: keep .footer at the bottom even on short pages */
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
body > main { flex: 1 0 auto; }
body > .footer { flex-shrink: 0; }

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

.wrap {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ---------- top link bar ---------- */
.topbar {
    background: var(--bg);
    color: var(--ink);
    border-bottom: 1px solid var(--line);
    font-family: var(--font-mono);
    font-size: 0.72rem;
}
.topbar .wrap {
    display: flex;
    align-items: center;
    gap: 24px;
    height: 48px;
    justify-content: flex-end;
}
.topbar .brand {
    margin-right: auto;
    font-family: var(--font-serif);
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: -0.01em;
    color: var(--ink);
}
.topbar a {
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border: none;
    padding: 0;
    transition: color 0.18s;
}
.topbar a:hover {
    color: var(--accent);
    background: none;
    text-decoration: none;
}

/* ---------- header : photo + identity ---------- */
.hero { padding: 44px 0 0; }

.hero-grid {
    display: grid;
    grid-template-columns: 220px 1fr auto;
    gap: 34px;
    align-items: start;
}

/* right column: external links, stacked */
.hero-links {
    margin-top: 58px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.hero-links a {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: var(--muted);
    white-space: nowrap;
    transition: color 0.18s;
}
.hero-links a:hover { color: var(--accent); text-decoration: none; }
.hero-links .li-ico {
    width: 17px;
    height: 17px;
    flex: 0 0 auto;
}

/* left column: photo */
.hero-photo {
    width: 100%;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    display: block;
    aspect-ratio: 1 / 1;
    object-fit: cover;
}

/* right column: name + identity tags */
.hero-name {
    font-family: var(--font-serif);
    font-size: 2.6rem;
    font-weight: 600;
    line-height: 1.02;
    margin: 0 0 18px;
    letter-spacing: -0.02em;
}
.hero-right .role {
    font-family: var(--font-mono);
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--primary);
    font-weight: 600;
    margin: 0 0 4px;
}
.hero-right .affil {
    font-family: var(--font-mono);
    font-size: 0.92rem;
    line-height: 1.5;
    color: var(--muted);
    margin: 0 0 11px;
}
.hero-right .contact-line {
    font-family: var(--font-mono);
    font-size: 0.92rem;
    line-height: 1.5;
    color: var(--muted);
    margin: 0 0 3px;
}
.hero-right .contact-line:last-child { margin-bottom: 0; }
.hero-right .m-label { color: var(--muted-2); margin-right: 4px; }

/* about (intro bio) */
.intro p { margin: 0 0 16px; text-align: justify; }
.intro p:last-child { margin-bottom: 0; }
.intro b { color: var(--primary); }
.intro .uni-logo {
    height: 1.3em;
    width: auto;
    vertical-align: -0.32em;
    margin: 0 0.18em;
    border-radius: 2px;
}

.news {
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    background: var(--bg-blue);
    padding: 14px 18px;
}
.news h3 {
    margin: 0 0 6px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-weight: 600;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
}
.news h3::before {
    content: "";
    width: 5px; height: 5px;
    border-radius: 50%;
    background: var(--primary);
}
.news ul { margin: 0; padding-left: 0; list-style: none; }
.news li {
    display: flex;
    gap: 14px;
    padding: 3px 0;
    font-size: 0.95rem;
}
.news .date {
    flex: 0 0 84px;
    font-family: var(--font-mono);
    color: var(--muted);
    font-weight: 500;
    font-size: 0.78rem;
    padding-top: 2px;
}

/* ---------- section divider + heading ---------- */
.divider {
    border: none;
    border-top: 1px solid var(--line);
    margin: 44px 0 0;
}
.section { padding: 26px 0; }
.section-title {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--primary);
    margin: 0 0 22px;
    padding-bottom: 9px;
    border-bottom: 1px solid var(--line);
}

/* ---------- research interests ---------- */
.research-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 20px;
}
.research-tags .rtag {
    font-family: var(--font-mono);
    font-size: 0.74rem;
    letter-spacing: 0.02em;
    color: var(--primary);
    background: var(--bg-blue);
    border: 1px solid var(--line-blue);
    border-radius: var(--r-chip);
    padding: 4px 11px;
}

.research-grid {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 44px;
    align-items: start;
}
.research-text p { margin: 0 0 16px; text-align: justify; }
.research-text b { color: var(--primary); }

.dir-lead { margin: 4px 0 12px; }
.dir-list { list-style: none; margin: 0; padding: 0; }
.dir-list li {
    position: relative;
    padding: 0 0 13px 20px;
}
.dir-list li:last-child { padding-bottom: 0; }
.dir-list li::before {
    content: "";
    position: absolute;
    left: 2px; top: 8px;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--primary);
}
.dir-title { display: block; font-weight: 600; color: var(--primary); }
.dir-sub { display: block; margin-top: 2px; font-size: 0.9rem; color: var(--muted); }

/* ----- scale-up stack (small → large) ----- */
.scale-stack {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px 14px;
    align-items: stretch;
}
.scale-axis {
    grid-column: 1;
    grid-row: 1;
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
}
.axis-label {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    color: var(--primary);
    letter-spacing: 0.12em;
    white-space: nowrap;
}
.axis-line {
    position: relative;
    width: 12px;
    align-self: stretch;
}
.axis-line::before {           /* shaft */
    content: "";
    position: absolute;
    left: 50%;
    top: 7px;
    bottom: 0;
    width: 2px;
    background: var(--primary);
    transform: translateX(-50%);
}
.axis-line::after {            /* sharp chevron arrowhead */
    content: "";
    position: absolute;
    left: 50%;
    top: 1px;
    width: 8px;
    height: 8px;
    border-top: 2px solid var(--primary);
    border-right: 2px solid var(--primary);
    transform: translateX(-50%) rotate(-45deg);
}

/* shared-border stacked layers (after RealZST research diagram) */
.scale-blocks {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--primary);
    border-radius: 0;
    overflow: hidden;
    background: #fff;
}
.scale-block {
    text-align: left;
    font: inherit;
    background: #fff;
    border: none;
    border-bottom: 1px solid var(--line-blue);
    border-radius: 0;
    padding: 13px 16px;
    cursor: pointer;
    transition: background 0.16s ease;
}
.scale-block:last-child { border-bottom: none; }
.scale-block .sb-title {
    font-family: var(--font-serif);
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--primary);
}
.scale-block .sb-ex {
    margin-top: 3px;
    font-family: var(--font-mono);
    font-size: 0.74rem;
    letter-spacing: 0.01em;
    color: var(--muted);
}
.scale-block:hover,
.scale-block:focus-visible {
    background: rgba(45, 62, 80, 0.07);
    outline: none;
}

/* ----- detail panel (same width as the blocks; revealed on hover) ----- */
.scale-detail {
    grid-column: 2;
    grid-row: 2;
    margin-top: 6px;
    min-height: 92px;
    display: flex;
    align-items: center;
    border: 1px solid var(--primary);
    border-radius: 0;
    background: var(--bg-blue);
    padding: 12px 16px;
    font-size: 0.92rem;
    line-height: 1.5;
}
.scale-pane { display: none; margin: 0; }
.scale-pane.active { display: block; animation: fade 0.25s ease; }
.scale-pane b { color: var(--primary); }
.scale-pane .hint { color: var(--muted); font-style: italic; }
.scale-pane .goal {
    display: block;
    margin-top: 8px;
    color: var(--primary);
}
.scale-pane .goal .glabel {
    font-family: var(--font-mono);
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
    color: var(--primary);
}
.scale-pane .goal u { text-decoration: none; }

/* ---------- section rail : table of contents ----------
   wide screens  -> vertical dashes in the right margin, name on hover
   narrow screens-> horizontal sticky bar at the top, names always visible  */
.rail {
    position: fixed;
    z-index: 50;
    display: flex;
}
.rail-item { display: flex; text-decoration: none; }
.rail-item:hover { text-decoration: none; }
.rail-label {
    font-family: var(--font-mono);
    font-size: 0.66rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    white-space: nowrap;
}

/* ---- narrow: sticky top bar ---- */
@media (max-width: 1239px) {
    body { padding-top: 43px; }
    .rail {
        top: 0;
        left: 0;
        right: 0;
        flex-direction: row;
        padding: 0 14px;
        background: rgba(255, 255, 255, 0.93);
        -webkit-backdrop-filter: saturate(180%) blur(8px);
        backdrop-filter: saturate(180%) blur(8px);
        border-bottom: 1px solid var(--line);
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scrollbar-width: none;
    }
    .rail::-webkit-scrollbar { display: none; }
    .rail-dash { display: none; }
    .rail-label {
        padding: 12px 10px;
        color: var(--muted);
        border-bottom: 2px solid transparent;
        transition: color 0.18s ease, border-color 0.18s ease;
    }
    .rail-item.active .rail-label {
        color: var(--primary);
        border-bottom-color: var(--primary);
    }
    /* keep an anchored heading clear of the bar */
    .section { scroll-margin-top: 52px; }
}

/* ---- wide: vertical dashes in the right margin ---- */
@media (min-width: 1240px) {
    .rail {
        right: 26px;
        top: 50%;
        transform: translateY(-50%);
        flex-direction: column;
        align-items: flex-end;
        gap: 13px;
    }
    .rail-item {
        align-items: center;
        justify-content: flex-end;
        gap: 10px;
        padding: 3px 0;
    }
    .rail-dash {
        width: 11px;
        height: 3px;
        border-radius: 2px;
        background: var(--line-blue);
        transition: width 0.22s ease, background-color 0.22s ease;
    }
    .rail-label {
        color: var(--primary);
        /* a real chip, so the label reads as an overlay instead of loose text
           floating on top of the column underneath */
        background: var(--bg);
        border: 1px solid var(--line);
        border-radius: var(--r-chip);
        box-shadow: var(--shadow-sm);
        padding: 2px 8px;
        opacity: 0;
        transform: translateX(4px);
        transition: opacity 0.18s ease, transform 0.18s ease;
        pointer-events: none;
    }
    /* only the item under the cursor names itself */
    .rail-item:hover .rail-label,
    .rail-item:focus-visible .rail-label {
        opacity: 1;
        transform: none;
    }
    .rail-item:hover .rail-dash,
    .rail-item:focus-visible .rail-dash {
        width: 22px;
        background: var(--accent);
    }
    /* current section: dash only — a pinned label would sit on the text forever */
    .rail-item.active .rail-dash {
        width: 22px;
        background: var(--primary);
    }
}

@media (prefers-reduced-motion: reduce) {
    .rail-dash, .rail-label { transition: none; }
}

/* ---------- flat modules (publications / projects / teaching / services) ---------- */
.module h3 {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--primary);
    margin: 26px 0 13px;
    padding-bottom: 7px;
    border-bottom: 1px solid var(--line);
}
.module > h3:first-of-type { margin-top: 0; }

/* publication / generic lists */
.pub-list, .plain-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.pub-list li {
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
    line-height: 1.55;
}
.pub-list li:last-child { border-bottom: none; }
.pub-list li > a {
    font-family: var(--font-serif);
    font-weight: 600;
    color: var(--ink);
}
.pub-list li > a:hover { color: var(--accent); }
.pub-list .venue {
    font-family: var(--font-serif);
    font-style: italic;
    color: var(--muted);
    font-size: 0.9rem;
}
.pub-list .venue .ccf { color: var(--accent); font-style: italic; }
.pub-list .authors {
    font-family: var(--font-mono);
    color: var(--muted);
    font-size: 0.78rem;
    letter-spacing: 0.01em;
}
.pub-list b { color: var(--ink); }

.plain-list li {
    position: relative;
    padding: 8px 0 8px 22px;
    border-bottom: 1px dashed var(--line);
}
.plain-list li:last-child { border-bottom: none; }
.plain-list li::before {
    content: "";
    position: absolute;
    left: 2px; top: 18px;
    width: 5px; height: 5px;
    border-radius: 50%;
    background: var(--primary);
}
.plain-list i { color: var(--muted); }

.conference-tag {
    display: inline-block;
    min-width: 86px;
    padding: 2px 8px;
    margin-right: 10px;
    background: var(--primary);
    color: #fff;
    border: 1px solid var(--primary);
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-align: center;
    border-radius: var(--r-chip);
    vertical-align: middle;
}

.muted-link {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
}

/* ---------- footer ---------- */
.footer {
    background: var(--bg-soft);
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.74rem;
    letter-spacing: 0.02em;
    text-align: center;
    padding: 22px 0;
    margin-top: 30px;
}

/* ---------- blog (index + article pages) ---------- */
.blog-index { max-width: 800px; }   /* match .article width */
.blog-head { padding: 44px 0 4px; }
.back-link {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.74rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted-2);
    margin-bottom: 26px;
}
.back-link:hover { color: var(--accent); text-decoration: none; }
.blog-title {
    font-family: var(--font-serif);
    font-size: 2rem;
    font-weight: 600;
    color: var(--ink);
    margin: 0 0 8px;
}
.blog-lead {
    color: var(--muted);
    margin: 0;
    max-width: 60ch;
}

.post-list {
    list-style: none;
    margin: 22px 0 0;
    padding: 0;
    border-top: 1px solid var(--line);
}
.post-item {
    padding: 22px 0;
    border-bottom: 1px solid var(--line);
}
.post-date {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted-2);
    margin-bottom: 6px;
}
.post-title {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--ink);
}
.post-title:hover { color: var(--accent); text-decoration: none; }
.post-summary {
    color: var(--muted);
    margin: 7px 0 0;
    font-size: 0.95rem;
}
.post-draft { color: var(--muted-2); font-style: italic; }

/* article / index header row: back-link + language toggle */
.article-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
    margin-bottom: 28px;
}
.article-top .back-link { margin-bottom: 0; }
.lang-switch {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    white-space: nowrap;
}
.lang-switch a { color: var(--muted-2); }
.lang-switch a:hover { color: var(--accent); text-decoration: none; }
.lang-switch .lang-current { color: var(--ink); font-weight: 600; }
.lang-sep { color: var(--line-blue); margin: 0 7px; }

.article { max-width: 800px; padding: 44px 0 0; }
.article-title {
    font-family: var(--font-serif);
    font-size: 2.05rem;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.01em;
    color: var(--ink);
    margin: 0 0 12px;
    text-wrap: balance;
}
.article-meta {
    font-family: var(--font-mono);
    font-size: 0.74rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted-2);
    margin: 0 0 34px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--line);
}
.article-body {
    color: var(--ink);
    font-size: 1.05rem;
    line-height: 1.85;
}
.article-body > p:first-child { font-size: 1.12rem; }
.article-body p { margin: 0 0 22px; text-wrap: pretty; }
.article-body h2 {
    font-family: var(--font-serif);
    font-size: 1.35rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--primary);
    margin: 46px 0 16px;
    text-wrap: balance;
}
.article-body a { color: var(--accent); }
.article-body a:hover { text-decoration: underline; }
.article-body b { font-weight: 600; }              /* 纯加粗，不改颜色 */
.article-body .hl { color: #234e9c; }               /* 深蓝（换色强调）*/
.article-body blockquote {
    margin: 24px 0;
    padding: 4px 0 4px 20px;
    border-left: 3px solid var(--line-blue);
    color: var(--muted);
    font-style: italic;
}
.article-body code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: var(--bg-blue);
    padding: 1px 5px;
    border-radius: var(--r-chip);
}
.article-body .hk-logo {
    height: 1.55em;
    width: auto;
    vertical-align: -0.44em;
    margin: 0 0.15em;
}

/* Chinese pages: title + headings + body in a clean sans (黑体) */
html[lang="zh-CN"] .article-title,
html[lang="zh-CN"] .article-body h2 {
    font-family: var(--font-cjk);
    letter-spacing: 0;
}
html[lang="zh-CN"] .article-title { font-weight: 600; }
html[lang="zh-CN"] .article-body { font-family: var(--font-cjk); }

/* ---------- responsive ---------- */
@media (max-width: 820px) {
    .hero-grid { grid-template-columns: 1fr; gap: 24px; }
    .hero-photo { max-width: 220px; }
    .hero-links { margin-top: 0; flex-direction: row; flex-wrap: wrap; align-items: flex-start; gap: 18px; }
    .research-grid { grid-template-columns: 1fr; gap: 28px; }
    .hero-name { font-size: 2rem; }
}
@media (max-width: 600px) {
    .hero-name { font-size: 1.9rem; }
}
@media (max-width: 520px) {
    .topbar .wrap { justify-content: center; flex-wrap: wrap; height: auto; padding: 10px 24px; }
    .topbar .label { margin-right: 0; width: 100%; text-align: center; }
}
