/* ==========================================================================
   tommyshen.me — Tongle Shen
   Plain CSS, one file. The complete light palette lives in custom properties
   on bare :root; the dark theme only re-declares those same tokens.
   Layout adapted from the homepage of Nicklas Hansen (nicklashansen.com).
   ========================================================================== */

/* Light is the default theme. Dark applies only when the visitor toggles it,
   which stamps data-theme="dark" on <html> and persists in localStorage. */
:root {
    color-scheme: light;

    /* surfaces + ink */
    --bg:            #fdfdfd;
    --bg-elev:       #f5f6f8;
    --text:          #2c3c4c;
    --text-muted:    #656f7a;
    --heading:       #334455;
    --rule:          #e0e0e0;

    /* links */
    --link:           #2471a3;
    --link-hover:     #a35a00;
    --link-underline: rgba(36, 113, 163, 0.32);
    --btn-hover-bg:   rgba(44, 60, 76, 0.07);

    /* highlighted publication card */
    --hl-a:          #f1e9fb;
    --hl-b:          #e4d6f4;
    --hl-edge:       #ddd0f0;
    --hl-text:       #3a2f4d;
    --hl-muted:      #5f5375;
    --hl-link:       #75409c;
    --hl-link-hover: #5c2f7d;
    --hl-underline:  rgba(117, 64, 156, 0.34);
    --hl-btn-bg:     rgba(117, 64, 156, 0.10);
    --pill-bg:       #75409c;
    --pill-bg-hover: #9150be;
    --pill-fg:       #ffffff;

    /* figure plate behind publication thumbnails */
    --fig-plate:     #ffffff;

    /* small pill (awards, status) */

    /* chrome */
    --nav-bg:        rgba(253, 253, 253, 0.86);
    --icon:          #2c3c4c;
    --icon-hover:    #1e2a36;
    --focus:         #2471a3;

    /* type */
    --sans: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Helvetica, Arial, sans-serif;

    --fs-h1:    2.4em;
    --fs-h2:    1.5em;
    --fs-h3:    1.0667em;
    --fs-lead:  1.0667em;
    --fs-meta:  0.9333em;
    --fs-small: 0.8667em;
}


:root[data-theme="dark"] {
    color-scheme: dark;
    --bg:            #101418;
    --bg-elev:       #171c22;
    --text:          #c9d3dd;
    --text-muted:    #98a4b1;
    --heading:       #e2e9f0;
    --rule:          #252d35;
    --link:           #6fb4e8;
    --link-hover:     #f4a94a;
    --link-underline: rgba(111, 180, 232, 0.34);
    --btn-hover-bg:   rgba(201, 211, 221, 0.10);
    --hl-a:          #2b2340;
    --hl-b:          #221c31;
    --hl-edge:       #3a3054;
    --hl-text:       #ded8ea;
    --hl-muted:      #b0a6c6;
    --hl-link:       #c9a6ee;
    --hl-link-hover: #ddc6fb;
    --hl-underline:  rgba(201, 166, 238, 0.36);
    --hl-btn-bg:     rgba(201, 166, 238, 0.13);
    --pill-bg:       #8a5fc0;
    --pill-bg-hover: #7549ae;
    --pill-fg:       #ffffff;
    --fig-plate:     #ffffff;
    --nav-bg:        rgba(16, 20, 24, 0.86);
    --icon:          #c9d3dd;
    --icon-hover:    #eaf1f7;
    --focus:         #6fb4e8;
}

/* --------------------------------------------------------------- base ---- */

*, *::before, *::after { box-sizing: border-box; }

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

body {
    margin: 0;
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    font-size: 15px;
    line-height: 1.6;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-wrap: break-word;
}

h1, h2, h3 {
    color: var(--heading);
    font-weight: 600;
    margin: 0;
    text-wrap: balance;
}

h1 { font-size: var(--fs-h1); line-height: 1.08; letter-spacing: -0.026em; }

h2 {
    font-size: var(--fs-h2);
    line-height: 1.22;
    letter-spacing: -0.014em;
    margin: 48px 0 12px;
}

h3 { font-size: var(--fs-h3); line-height: 1.35; letter-spacing: -0.008em; }

p { margin: 0 0 1rem; }
p:last-child { margin-bottom: 0; }

img { max-width: 100%; }
ul { margin: 0; padding: 0; }

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

.italic { font-style: italic; }
.bold   { font-weight: 600; }
.noselect { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }

/* the inline swatch reuses the card's own gradient stop, so they cannot drift */
/* --------------------------------------------------------------- links --- */

a {
    color: var(--link);
    text-decoration: none;
    text-underline-offset: 0.18em;
    text-decoration-thickness: 1px;
    transition: color 0.18s ease, text-decoration-color 0.18s ease, background-color 0.18s ease;
}

a:hover { color: var(--link-hover); }

/* prose links reveal a hairline rule on hover */
.intro > p a, .venue a, .project-meta a, .footer-content a {
    text-decoration: underline;
    text-decoration-color: var(--link-underline);
}
.intro > p a:hover, .venue a:hover,
.project-meta a:hover, .footer-content a:hover { text-decoration-color: currentColor; }

:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 3px;
    border-radius: 3px;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 200;
    background: var(--bg);
    color: var(--link);
    padding: 10px 16px;
    border: 1px solid var(--rule);
    border-radius: 0 0 6px 0;
}
.skip-link:focus, .skip-link:focus-visible { left: 0; }

/* ------------------------------------------------------------- layout ---- */

.content {
    max-width: 860px;
    margin: 48px auto 0;
    padding-left: 16px;
    padding-right: 16px;
}

main.content {
    margin-top: 48px;
    padding-bottom: 64px;
}



/* a tighter gap between the two intro paragraphs than the 1rem default */
.intro p { margin-bottom: 0.55rem; }
.intro p:last-child { margin-bottom: 0; }

/* ------------------------------------------------------------- header ---- */

.header { width: 100%; padding-top: 24px; }

.header-div {
    display: flex;
    align-items: flex-start;
    padding-bottom: 22px;
    border-bottom: 1px solid var(--rule);
}

.header-profile-picture {
    width: 150px;
    height: auto;          /* 4:5 portrait, shown whole rather than cropped */
    flex-shrink: 0;
    margin-right: 24px;
    border-radius: 6px;
    background-color: var(--bg-elev);
}

.header-text { min-width: 0; padding-top: 6px; }

.header-subtitle { margin: 0.35rem 0 0; font-size: var(--fs-lead); color: var(--text); }
.header-emails {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
    margin: 0.45rem 0 0;
    font-size: var(--fs-meta);
}
.email-link { display: inline-flex; align-items: center; gap: 0.38rem; }
.email-link svg { width: 15px; height: 15px; flex-shrink: 0; opacity: 0.7; }
.email-link:hover svg, .email-link:focus-visible svg { opacity: 1; }
.email-sep { color: var(--text-muted); opacity: 0.5; }

.header-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px;
    margin: 0.6rem 0 0 -8px;
}

.header-links-sep {
    flex: 0 0 1px;
    width: 1px;
    height: 18px;
    margin: 0 6px;
    background: var(--rule);
}

/* icon buttons (social links + theme toggle) */
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--icon);
    opacity: 0.56;
    cursor: pointer;
    transition: opacity 0.18s ease, background-color 0.18s ease, transform 0.18s ease, color 0.18s ease;
}
.icon-btn:hover { opacity: 1; color: var(--icon-hover); background: var(--btn-hover-bg); transform: translateY(-1px); }
.icon-btn:focus-visible { opacity: 1; }
.icon-btn svg { width: 18px; height: 18px; display: block; fill: currentColor; }

/* the icon shows the action, driven by theme state in CSS so it is correct
   even before (or without) the toggle script */
.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-sun  { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* --------------------------------------------------------- sticky nav ---- */

.sticky-nav {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 100;
    background: var(--nav-bg);
    backdrop-filter: blur(12px) saturate(120%);
    -webkit-backdrop-filter: blur(12px) saturate(120%);
    border-bottom: 1px solid var(--rule);
    transform: translateY(-100%);
    /* hidden for the keyboard as well as the eye: a fixed off-screen element
       cannot be scrolled into view, so a focus ring on it would be invisible */
    visibility: hidden;
    pointer-events: none;
    transition: transform 0.3s ease, visibility 0s linear 0.3s;
    font-size: 14px;
}
.sticky-nav.visible {
    transform: translateY(0);
    visibility: visible;
    pointer-events: auto;
    transition: transform 0.3s ease, visibility 0s;
}

.sticky-nav-content {
    max-width: 860px;
    margin: 0 auto;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.sticky-nav-name {
    color: var(--heading);
    font-weight: 600;
    font-size: 16px;
    letter-spacing: -0.012em;
}
.sticky-nav-name:hover { color: var(--link-hover); }

.sticky-nav-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 6px 16px;
}
.sticky-nav-links .icon-btn { width: 28px; height: 28px; }
.sticky-nav-links .icon-btn svg { width: 16px; height: 16px; }

/* -------------------------------------------------- research interests ---- */

/* ul is reset globally, so the markers and indent are restored here */
.interest-list { list-style: disc; padding-left: 1.1rem; }
.interest-list > li { margin-bottom: 0.9rem; }
.interest-list > li:last-child { margin-bottom: 0; }
.interest-list > li::marker { color: var(--text-muted); }

.interest-area {
    color: var(--heading);
    font-size: var(--fs-h3);
    line-height: 1.4;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
}

.interest-list ul { list-style: circle; padding-left: 1.15rem; margin-top: 0.3rem; }
.interest-list ul li { margin-bottom: 0.22rem; color: var(--text-muted); line-height: 1.55; }
.interest-list ul li:last-child { margin-bottom: 0; }

/* ------------------------------------------------------- publications ---- */

.row { display: flex; align-items: flex-start; }

.publication {
    margin: 0 -10px 32px;
    padding: 10px;
    border-radius: 8px;
}
.publication:last-child { margin-bottom: 0; }

.row-media {
    display: block;
    flex-shrink: 0;
    width: 170px;
    height: 170px;
    border-radius: 6px;
    overflow: hidden;
    /* every thumbnail gets the plate, so the box edge (not the letterboxed
       image content) is what lines up with the title on all papers */
    background-color: var(--fig-plate);
}
.row-media img { width: 100%; height: 100%; display: block; object-fit: contain; }

/* project thumbnails sit smaller than the publication ones */
.project .row-media { width: 120px; height: 120px; }

.row-text { margin-left: 20px; min-width: 0; }

.publication-title {
    margin: 0 0 0.2rem;
    font-size: var(--fs-h3);
}
.publication-title a {
    color: var(--link);
    text-decoration: underline;
    text-decoration-color: transparent;
}
.publication-title a:hover { color: var(--link-hover); text-decoration-color: currentColor; }

.authors, .venue, .links {
    margin: 0;
    font-size: var(--fs-meta);
    line-height: 1.55;
}
.authors { color: var(--text); }
.venue   { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.me      { font-weight: 600; }


.links { margin-top: 0.5rem; }
.links .sep { color: var(--text-muted); margin: 0 1px; }

.btn {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 5px;
    font-size: var(--fs-meta);
}
.btn:hover { background: var(--btn-hover-bg); }

/* not a link: a pending artefact, styled like .btn but inert */
.btn-muted {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 5px;
    font-size: var(--fs-meta);
    color: var(--text-muted);
    font-style: italic;
}
.publication.highlight .btn-muted { color: var(--hl-muted); }

.btn-feature {
    background: var(--pill-bg);
    color: var(--pill-fg);
    border-radius: 999px;
    padding: 1px 11px;
}
.btn-feature:hover { background: var(--pill-bg-hover); color: var(--pill-fg); }

/* highlighted card */
.publication.highlight {
    background: linear-gradient(135deg, var(--hl-a), var(--hl-b));
    border: 1px solid var(--hl-edge);
    border-radius: 10px;
    padding: 16px;
    color: var(--hl-text);
}
.publication.highlight .authors,
.publication.highlight .venue { color: var(--hl-muted); }
.publication.highlight .links .sep { color: var(--hl-muted); }
.publication.highlight a:not(.btn-feature) { color: var(--hl-link); }
.publication.highlight a:not(.btn-feature):hover { color: var(--hl-link-hover); }
.publication.highlight .publication-title a:hover { text-decoration-color: var(--hl-underline); }
.publication.highlight .btn:not(.btn-feature):hover { background: var(--hl-btn-bg); }



/* ----------------------------------------------------------- projects ---- */

.projects { list-style: none; }

.project { margin-top: 22px; }
.project-title { margin-bottom: 0.15rem; }

.project-meta {
    margin: 0;
    font-variant-numeric: tabular-nums;
    font-size: var(--fs-small);
    color: var(--text-muted);
}

/* CV-style bullets; ul is reset globally so markers are restored here */
.project-points {
    list-style: disc;
    padding-left: 1.1rem;
    margin: 0.35rem 0 0;
    font-size: var(--fs-meta);
    line-height: 1.55;
    color: var(--text-muted);
}
.project-points li { margin-bottom: 0.15rem; }
.project-points li:last-child { margin-bottom: 0; }
.project-points li::marker { color: var(--text-muted); }
.project .authors { margin-top: 0.1rem; }
.project .links { margin-top: 0.45rem; }
.project .btn:first-child { margin-left: -7px; }

/* ------------------------------------------------------------ contact ---- */


/* ------------------------------------------------------------- footer ---- */

.footer {
    max-width: 860px;
    margin: 0 auto;
    padding-left: 16px;
    padding-right: 16px;
    border-top: 1px solid var(--rule);
}

.footer-content {
    color: var(--text-muted);
    font-size: var(--fs-small);
    padding: 14px 0 22px;
}
.footer-content a { color: var(--text-muted); }
.footer-content a:hover { color: var(--text); }

/* -------------------------------------------------------- responsive ----- */

@media only screen and (max-width: 1150px) {
    body { font-size: 18px; }
    .header-div { flex-direction: column; align-items: center; text-align: center; }
    .header-profile-picture { width: 170px; height: auto; margin: 0 auto 14px; }
    .header-text { padding-top: 0; }
    .header-links { justify-content: center; margin-left: 0; }
}

@media only screen and (max-width: 1000px) {
    .publication { margin-bottom: 42px; }
    .publication.row, .project.row { flex-direction: column; align-items: center; }
    .publication .row-media, .project .row-media { width: 100%; max-width: 320px; height: 260px; margin-bottom: 14px; }
    .publication .row-text, .project .row-text { width: 100%; margin-left: 0; }
}

@media only screen and (max-width: 680px) {
    :root { --fs-h1: 2.1em; --fs-h2: 1.35em; }
    .sticky-nav-links { gap: 6px 12px; font-size: 13px; }
    .sticky-nav-name { font-size: 15px; }
    .publication { margin-left: 0; margin-right: 0; }
    .publication.highlight { padding: 14px; }
}

@media only screen and (max-width: 420px) {
    :root { --fs-h1: 2em; }
    .sticky-nav { font-size: 12px; }
    .sticky-nav-links { gap: 6px 10px; }
    .sticky-nav-name { font-size: 13px; }
    .publication .row-media, .project .row-media { height: 210px; }
}

/* ----------------------------------------------------- reduced motion ---- */

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .sticky-nav { transition: none; }
    .icon-btn:hover { transform: none; }
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}

/* ------------------------------------------------------------- print ----- */

@media print {
    .sticky-nav, .skip-link, .icon-btn { display: none !important; }
    body { font-size: 11pt; }
    a { color: inherit; }
}
