/* ============================================
   ACADEMIC WEBSITE - STYLES
   A refined, scholarly aesthetic with warmth
   ============================================ */

@font-face {
    font-family: 'Merriweather';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('Asset/fonts/merriweather-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'Merriweather';
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: url('Asset/fonts/merriweather-latin-italic.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* CSS Variables */
:root {
    /* Color palette - Academic Professional with Northwestern accent (Light Mode) */
    --color-bg: #fafafa;
    --color-bg-alt: #f5f5f5;
    --color-surface: #ffffff;
    --color-text: #1a1a1a;
    --color-text-muted: #555555;
    --color-text-light: #888888;
    --color-accent: #4E2A84;
    --color-accent-hover: #3d2069;
    --color-accent-light: #e8e0f0;
    --color-border: #e0e0e0;
    --color-border-light: #eeeeee;
    --color-on-accent: #ffffff;
    
    /* Component-specific tokens (consolidated for dark mode) */
    --nav-bg: rgba(250, 250, 250, 0.95);
    --nav-bg-safari: rgba(250, 250, 250, 0.98);
    --nav-menu-overlay-bg: rgba(250, 250, 250, 0.68);
    --hero-text-scrim: rgba(250, 250, 250, 0.92);
    --spotlight-gradient: rgba(78, 42, 132, 0.12);
    --spotlight-blend: multiply;
    --pub-hover-shadow: 0 15px 35px rgba(0, 0, 0, 0.1), 0 5px 15px rgba(0,0,0,0.05);
    --pub-hover-border: rgba(78, 42, 132, 0.3);
    --tag-uchicago-bg: rgba(128, 0, 0, 0.1);
    --tag-uchicago-color: #800000;
    --tag-uchicago-border: rgba(128, 0, 0, 0.3);
    --tag-northwestern-bg: rgba(78, 42, 132, 0.1);
    --tag-northwestern-color: #4E2A84;
    --tag-northwestern-border: rgba(78, 42, 132, 0.3);
    --tag-upenn-bg: rgba(1, 31, 91, 0.1);
    --tag-upenn-color: #011F5B;
    --tag-upenn-border: rgba(1, 31, 91, 0.3);
    
    /* Typography: Merriweather on EN; Noto loads via styles-zh-fonts.css on /zh/ only */
    --font-serif: 'Merriweather', "PingFang SC", "Hiragino Sans GB", -apple-system, BlinkMacSystemFont, "SF Pro SC", "SF Pro Text", "Helvetica Neue", "Segoe UI", "Microsoft YaHei UI", serif;
    
    /* Body: native Apple stack first so Chinese matches macOS/iOS system typography */
    --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro SC", "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Helvetica Neue", "Segoe UI", "Microsoft YaHei UI", sans-serif;
    
    /* Spacing - more compact */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2.5rem;
    --space-2xl: 4rem;
    --space-3xl: 6rem;
    
    /* Layout: fluid cap so wide windows (e.g. Safari on large displays) use more horizontal space */
    --max-width: min(92vw, 1320px);
    --content-width: 800px;
    --border-radius: 4px; /* Sharper corners for academic look */
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 400ms ease;
    --lang-transition-duration: 380ms;
    --lang-transition-ease: cubic-bezier(0.4, 0, 0.2, 1);
    --theme-transition-duration: 0.65s;
    --theme-transition-ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode Variables - shared mixin via CSS custom properties */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]),
    [data-theme="dark"] {
        --color-bg: #121212;
        --color-bg-alt: #1a1a1a;
        --color-surface: #242424;
        --color-text: #e4e4e4;
        --color-text-muted: #a0a0a0;
        --color-text-light: #707070;
        --color-accent: #b39ddb;
        --color-accent-hover: #d1c4e9;
        --color-accent-light: #3d2069;
        --color-border: #333333;
        --color-border-light: #2a2a2a;
        --color-on-accent: #121212;
        --nav-bg: rgba(18, 18, 18, 0.95);
        --nav-bg-safari: rgba(18, 18, 18, 0.98);
        --nav-menu-overlay-bg: rgba(18, 18, 18, 0.75);
        --hero-text-scrim: rgba(18, 18, 18, 0.82);
        --spotlight-gradient: rgba(179, 157, 219, 0.15);
        --spotlight-blend: normal;
        --pub-hover-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
        --pub-hover-border: rgba(179, 157, 219, 0.3);
        --tag-uchicago-bg: rgba(128, 0, 0, 0.2);
        --tag-uchicago-color: #e07070;
        --tag-uchicago-border: rgba(128, 0, 0, 0.4);
        --tag-northwestern-bg: rgba(78, 42, 132, 0.2);
        --tag-northwestern-color: #a888d0;
        --tag-northwestern-border: rgba(78, 42, 132, 0.4);
        --tag-upenn-bg: rgba(1, 31, 91, 0.2);
        --tag-upenn-color: #7090c0;
        --tag-upenn-border: rgba(1, 31, 91, 0.4);
    }
}

/* Manual dark mode override (when system is light but user prefers dark) */
@media (prefers-color-scheme: light) {
    [data-theme="dark"] {
        --color-bg: #121212;
        --color-bg-alt: #1a1a1a;
        --color-surface: #242424;
        --color-text: #e4e4e4;
        --color-text-muted: #a0a0a0;
        --color-text-light: #707070;
        --color-accent: #b39ddb;
        --color-accent-hover: #d1c4e9;
        --color-accent-light: #3d2069;
        --color-border: #333333;
        --color-border-light: #2a2a2a;
        --color-on-accent: #121212;
        --nav-bg: rgba(18, 18, 18, 0.95);
        --nav-bg-safari: rgba(18, 18, 18, 0.98);
        --nav-menu-overlay-bg: rgba(18, 18, 18, 0.75);
        --hero-text-scrim: rgba(18, 18, 18, 0.82);
        --spotlight-gradient: rgba(179, 157, 219, 0.15);
        --spotlight-blend: normal;
        --pub-hover-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
        --pub-hover-border: rgba(179, 157, 219, 0.3);
        --tag-uchicago-bg: rgba(128, 0, 0, 0.2);
        --tag-uchicago-color: #e07070;
        --tag-uchicago-border: rgba(128, 0, 0, 0.4);
        --tag-northwestern-bg: rgba(78, 42, 132, 0.2);
        --tag-northwestern-color: #a888d0;
        --tag-northwestern-border: rgba(78, 42, 132, 0.4);
        --tag-upenn-bg: rgba(1, 31, 91, 0.2);
        --tag-upenn-color: #7090c0;
        --tag-upenn-border: rgba(1, 31, 91, 0.4);
    }
}

/* Scroll Lock for Mobile Menu */
body.no-scroll {
    overflow: hidden;
}

/* Block interaction while menu is open; content stays visible through the nav overlay */
body.no-scroll main,
body.no-scroll header,
body.no-scroll footer,
body.no-scroll #particle-canvas {
    pointer-events: none;
    user-select: none;
}

main, header, footer, #particle-canvas {
    transition: opacity 0.3s ease;
}

/* Skip Link for Accessibility */
.skip-link {
    position: absolute;
    top: -100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--color-accent);
    color: var(--color-on-accent);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--border-radius);
    z-index: 10000;
    font-weight: 500;
    text-decoration: none;
    transition: top var(--transition-fast);
}

.skip-link:focus {
    top: var(--space-md);
    color: var(--color-on-accent);
}

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

html {
    scroll-behavior: smooth;
    scroll-padding-top: var(--nav-scroll-offset, 5.5rem);
    font-size: 16px;
    scrollbar-gutter: stable;
}

body {
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.7;
    color: var(--color-text);
    background-color: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   THEME & LANGUAGE TRANSITION ANIMATIONS
   ============================================ */

/* Theme transition - smooth color changes */
html.theme-transition,
html.theme-transition *,
html.theme-transition *::before,
html.theme-transition *::after {
    transition:
        background-color var(--theme-transition-duration) var(--theme-transition-ease),
        background var(--theme-transition-duration) var(--theme-transition-ease),
        border-color var(--theme-transition-duration) var(--theme-transition-ease),
        color var(--theme-transition-duration) var(--theme-transition-ease),
        fill var(--theme-transition-duration) var(--theme-transition-ease),
        stroke var(--theme-transition-duration) var(--theme-transition-ease),
        box-shadow var(--theme-transition-duration) var(--theme-transition-ease),
        outline-color var(--theme-transition-duration) var(--theme-transition-ease),
        text-decoration-color var(--theme-transition-duration) var(--theme-transition-ease) !important;
}

@supports (view-transition-name: none) {
    html.theme-view-transition::view-transition-old(root),
    html.theme-view-transition::view-transition-new(root) {
        animation-duration: var(--theme-transition-duration);
        animation-timing-function: var(--theme-transition-ease);
    }

    html.theme-view-transition::view-transition-old(root) {
        z-index: 1;
    }

    html.theme-view-transition::view-transition-new(root) {
        z-index: 2;
        animation: theme-circle-reveal var(--theme-transition-duration) var(--theme-transition-ease) both;
    }

    @keyframes theme-circle-reveal {
        from {
            clip-path: circle(0 at var(--theme-origin-x, 50vw) var(--theme-origin-y, 2rem));
        }
        to {
            clip-path: circle(var(--theme-reveal-radius, 150vmax) at var(--theme-origin-x, 50vw) var(--theme-origin-y, 2rem));
        }
    }
}

@media (prefers-reduced-motion: reduce) {
    html.theme-transition,
    html.theme-transition *,
    html.theme-transition *::before,
    html.theme-transition *::after {
        transition-duration: 0.01ms !important;
    }

    html.theme-view-transition::view-transition-old(root),
    html.theme-view-transition::view-transition-new(root) {
        animation: none !important;
    }
}

/* Language transition - opacity-only (avoids scroll jank from transform) */
html.lang-switching {
    scroll-behavior: auto !important;
}

/* Hide page until scroll position is restored (prevents visible scroll jump) */
html.lang-scroll-lock {
    overflow: hidden;
    background-color: var(--color-bg);
}

html.lang-scroll-lock body {
    visibility: hidden;
}

html.lang-switching .hero-text,
html.lang-switching main,
html.lang-switching .footer-inner,
html.lang-switching .nav-links {
    transition: opacity var(--lang-transition-duration) var(--lang-transition-ease);
    will-change: opacity;
}

html.lang-switching.lang-fade-out .hero-text,
html.lang-switching.lang-fade-out main,
html.lang-switching.lang-fade-out .footer-inner,
html.lang-switching.lang-fade-out .nav-links {
    opacity: 0;
    pointer-events: none;
}

html.lang-switching.lang-fade-in .hero-text,
html.lang-switching.lang-fade-in main,
html.lang-switching.lang-fade-in .footer-inner,
html.lang-switching.lang-fade-in .nav-links {
    opacity: 1;
}

html.lang-switching .hero-greeting,
html.lang-switching .hero-identity,
html.lang-switching .hero-title,
html.lang-switching .hero-affiliation,
html.lang-switching .hero-interests,
html.lang-switching .hero-links {
    transition:
        margin var(--lang-transition-duration) var(--lang-transition-ease),
        font-size var(--lang-transition-duration) var(--lang-transition-ease),
        line-height var(--lang-transition-duration) var(--lang-transition-ease),
        letter-spacing var(--lang-transition-duration) var(--lang-transition-ease);
}

html.lang-switching .lang-toggle {
    pointer-events: none;
    opacity: 0.65;
}

@media (prefers-reduced-motion: reduce) {
    html.lang-switching .hero-text,
    html.lang-switching main,
    html.lang-switching .footer-inner,
    html.lang-switching .nav-links,
    html.lang-switching .hero-greeting,
    html.lang-switching .hero-identity,
    html.lang-switching .hero-title,
    html.lang-switching .hero-affiliation,
    html.lang-switching .hero-interests,
    html.lang-switching .hero-links {
        transition: none !important;
    }
}

/* Particle canvas background */
#particle-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    /* GPU acceleration for smoother animation */
    will-change: contents;
    transform: translateZ(0);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-serif);
    font-weight: 700; /* Bolder for NU style */
    line-height: 1.25;
    letter-spacing: -0.02em; /* Tighter tracking looks more professional */
    color: var(--color-text); /* Keep headers dark/neutral */
}

h1 { font-size: clamp(2.2rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.75rem, 3vw, 2.25rem); }
h3 { font-size: clamp(1.2rem, 2vw, 1.5rem); }

p {
    margin-bottom: 1em;
}

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

a {
    color: var(--color-accent);
    text-decoration: none;
    transition: color var(--transition-fast);
    /* Keep each link label on one line; the whole link may move to the next line. */
    display: inline-block;
    max-width: 100%;
    white-space: nowrap;
    vertical-align: baseline;
}

/* Long title links: still avoid mid-phrase breaks; allow wrapping only when unavoidable. */
a.course-title-link {
    white-space: normal;
}

/* Whole-card links (Teaching & Service): must wrap body text, not inherit phrase-link nowrap. */
a.course-item,
a.course-item--has-link {
    display: flex;
    white-space: normal;
    max-width: none;
}

@media (hover: hover) and (pointer: fine) {
    a:hover {
        color: var(--color-accent-hover);
    }
}

strong {
    font-weight: 600;
}

/* Selection */
::selection {
    background-color: var(--color-accent-light);
    color: var(--color-text);
}

/* Custom Focus Ring for Accessibility */
*:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 4px;
    border-radius: 2px;
}

/* Make sure buttons/links get rounded focus rings if they are rounded */
.btn:focus-visible, .nav-link:focus-visible, .theme-toggle:focus-visible, .lang-toggle:focus-visible, .nav-toggle:focus-visible {
    border-radius: var(--border-radius);
}

.hero-image:focus-visible, .theme-toggle:focus-visible, .lang-toggle:focus-visible {
    border-radius: 50%;
}

/* ============================================
   NAVIGATION
   ============================================ */

.nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: transparent;
    border-bottom: 1px solid transparent;
    transition: background var(--transition-base), border-color var(--transition-base), backdrop-filter var(--transition-base), -webkit-backdrop-filter var(--transition-base);
    will-change: transform, background, backdrop-filter;
    transform: translateZ(0);
}

.nav.scrolled,
body.no-scroll .nav {
    background: var(--nav-bg);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border-bottom-color: var(--color-border-light);
}

@supports (-webkit-touch-callout: none) {
    .nav.scrolled,
    body.no-scroll .nav {
        background: var(--nav-bg-safari);
        -webkit-backdrop-filter: blur(4px);
        backdrop-filter: blur(4px);
    }
}

.nav-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--space-md) var(--space-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-links {
    display: flex;
    gap: var(--space-lg);
    margin-left: auto;
    margin-right: var(--space-lg);
    list-style: none;
}

.nav-links li {
    display: flex;
    align-items: center;
}

.nav-controls {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-shrink: 0;
}

.nav-logo {
    font-family: var(--font-serif); /* Uses Merriweather now */
    font-size: 1.5rem;
    font-weight: 900; /* Extra bold for logo presence */
    color: var(--color-text);
    letter-spacing: -0.05em; /* Tight tracking for logo style */
    display: inline-block;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), color 0.3s ease;
}

@media (hover: hover) and (pointer: fine) {
    .nav-logo:hover {
        color: var(--color-accent);
    }
}

.nav-link {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-muted);
    letter-spacing: 0.02em;
    position: relative;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 1px;
    background-color: var(--color-accent);
    transition: width var(--transition-base);
}

@media (hover: hover) and (pointer: fine) {
    .nav-link:hover {
        color: var(--color-text);
    }

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

/* Active Nav Link (ScrollSpy) */
.nav-link.active {
    color: var(--color-accent);
    font-weight: 600;
}

.nav-link.active::after {
    width: 100%;
    height: 3px; /* Thicker line for active state */
}

/* Theme Toggle Button */
.theme-toggle {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: none;
    border: 1px solid var(--color-border);
    border-radius: 50%;
    cursor: pointer;
    color: var(--color-text);
    transition:
        background-color var(--transition-base),
        border-color var(--transition-base),
        color var(--transition-base),
        transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

@media (hover: hover) and (pointer: fine) {
    .theme-toggle:hover {
        background-color: var(--color-bg-alt);
        border-color: var(--color-accent);
    }
}

.theme-toggle.is-switching {
    transform: scale(0.94);
}

/* Theme toggle icon animation */
.theme-toggle .sun-icon,
.theme-toggle .moon-icon {
    position: absolute;
    left: 50%;
    top: 50%;
    display: block;
    transition:
        opacity var(--theme-transition-duration) var(--theme-transition-ease),
        transform var(--theme-transition-duration) var(--theme-transition-ease);
}

.theme-toggle .sun-icon {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(-60deg) scale(0.55);
}

.theme-toggle .moon-icon {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(0deg) scale(1);
}

.theme-toggle.is-switching .sun-icon,
.theme-toggle.is-switching .moon-icon {
    transition-duration: calc(var(--theme-transition-duration) * 0.85);
}

/* Dark mode icon swap - consolidated */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-toggle .sun-icon,
    [data-theme="dark"] .theme-toggle .sun-icon {
        opacity: 1;
        transform: translate(-50%, -50%) rotate(0deg) scale(1);
    }
    :root:not([data-theme="light"]) .theme-toggle .moon-icon,
    [data-theme="dark"] .theme-toggle .moon-icon {
        opacity: 0;
        transform: translate(-50%, -50%) rotate(60deg) scale(0.55);
    }
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) .theme-toggle .sun-icon {
        opacity: 0;
        transform: translate(-50%, -50%) rotate(-60deg) scale(0.55);
    }
    :root:not([data-theme="dark"]) .theme-toggle .moon-icon {
        opacity: 1;
        transform: translate(-50%, -50%) rotate(0deg) scale(1);
    }
    [data-theme="dark"] .theme-toggle .sun-icon {
        opacity: 1;
        transform: translate(-50%, -50%) rotate(0deg) scale(1);
    }
    [data-theme="dark"] .theme-toggle .moon-icon {
        opacity: 0;
        transform: translate(-50%, -50%) rotate(60deg) scale(0.55);
    }
}

/* Language Toggle Button */
.lang-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: none;
    border: 1px solid var(--color-border);
    border-radius: 50%;
    cursor: pointer;
    color: var(--color-text);
    transition: all var(--transition-base);
    font-size: 0.875rem;
    font-weight: 600;
    overflow: hidden;
}

@media (hover: hover) and (pointer: fine) {
    .lang-toggle:hover {
        background-color: var(--color-bg-alt);
        border-color: var(--color-accent);
    }
}

/* Language toggle text animation */
.lang-toggle .lang-en,
.lang-toggle .lang-zh {
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.lang-toggle:active .lang-en,
.lang-toggle:active .lang-zh {
    transform: scale(0.8);
}

/* Default: show 中 (to switch to Chinese) */
.lang-toggle .lang-en {
    display: none;
}

.lang-toggle .lang-zh {
    display: block;
}

/* When Chinese is active, show EN (to switch to English) */
[data-lang="zh"] .lang-toggle .lang-en {
    display: block;
}

[data-lang="zh"] .lang-toggle .lang-zh {
    display: none;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
    padding: var(--space-xs);
    margin-right: -8px; /* Offset the extra padding so it aligns with right edge */
}

.nav-toggle span {
    width: 24px;
    height: 2px;
    background-color: var(--color-text);
    transition: var(--transition-fast);
}

.nav-toggle.active span:first-child {
    transform: rotate(45deg) translate(5px, 5px);
}

.nav-toggle.active span:last-child {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* ============================================
   HERO SECTION
   ============================================ */

.hero {
    min-height: auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: var(--space-3xl) var(--space-lg) var(--space-2xl);
    position: relative;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 50%;
    height: 100%;
    background: linear-gradient(135deg, transparent 0%, var(--color-bg-alt) 100%);
    opacity: 0.5;
    z-index: -1;
}

.hero-content {
    max-width: var(--max-width);
    margin: 0 auto;
    width: 100%;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: calc(var(--space-xl) + 1rem);
    align-items: center;
}

.hero-image-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px;
}

/* Decorative accent frame behind the portrait */
.hero-image-accent {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 1px solid var(--color-accent);
    opacity: 0.35;
    --accent-x: 14px;
    --accent-y: 14px;
    transform: translate(var(--accent-x), var(--accent-y)) scale(0.94);
    pointer-events: none;
    transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.4s ease, border-color 0.4s ease;
}

@media (hover: hover) and (pointer: fine) {
    .hero-image-wrapper:hover .hero-image-accent {
        opacity: 0.55;
    }

    .hero-image:hover {
        transform: translateY(-4px) scale(1.02);
        box-shadow:
            0 2px 4px rgba(0, 0, 0, 0.05),
            0 30px 60px -15px rgba(78, 42, 132, 0.35);
    }
}

.hero-image {
    width: 280px;
    height: 280px;
    border-radius: 50%;
    overflow: hidden;
    border: 1px solid var(--color-border);
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.04),
        0 20px 50px -20px rgba(78, 42, 132, 0.25);
    position: relative;
    background: linear-gradient(90deg, var(--color-bg-alt) 25%, var(--color-border-light) 37%, var(--color-bg-alt) 63%);
    background-size: 400% 100%;
    animation: skeleton-loading 1.4s ease infinite;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.4s ease;
    isolation: isolate;
}

/* Dark mode: soften accent and shadow */
[data-theme="dark"] .hero-image-accent {
    opacity: 0.5;
}

[data-theme="dark"] .hero-image {
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.3),
        0 20px 50px -20px rgba(179, 157, 219, 0.35);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .hero-image-accent {
        opacity: 0.5;
    }
    :root:not([data-theme="light"]) .hero-image {
        box-shadow:
            0 1px 2px rgba(0, 0, 0, 0.3),
            0 20px 50px -20px rgba(179, 157, 219, 0.35);
    }
}

.hero-image.loaded {
    animation: none;
    background: var(--color-bg-alt);
}

.hero-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Image Fade In */
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}

.hero-image img.loaded {
    opacity: 1;
}

.hero-image .profile-img {
    transition: opacity 0.4s ease-in-out;
}

.hero-text {
    max-width: 600px;
    position: relative;
    isolation: isolate;
}

.hero-text::before {
    content: '';
    position: absolute;
    inset: -1.1rem -1.4rem;
    z-index: -1;
    background: radial-gradient(ellipse at center, var(--hero-text-scrim) 0%, transparent 72%);
    pointer-events: none;
}

.hero-greeting {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-text-muted);
    margin-bottom: var(--space-sm);
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.hero-greeting::before {
    content: '';
    width: 28px;
    height: 1px;
    background-color: var(--color-accent);
    display: inline-block;
    flex-shrink: 0;
}

.hero-name {
    margin-bottom: var(--space-md);
    color: var(--color-text);
    display: inline-block;
    transition: all 0.4s ease;
    position: relative;
}

.hero-identity {
    margin-bottom: var(--space-sm);
}

.hero-alias {
    font-size: 0.5em;
    font-weight: 400;
}

.hero-title {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--color-accent);
    margin-bottom: var(--space-xs);
    letter-spacing: 0.002em;
}

.hero-affiliation {
    font-size: 0.9375rem;
    color: var(--color-text-muted);
    line-height: 1.65;
    margin-bottom: var(--space-md);
}

.hero-affiliation a {
    color: var(--color-text);
    text-decoration: none;
    border-bottom: 1px solid var(--color-border);
    transition: color 0.25s ease, border-color 0.25s ease;
}

@media (hover: hover) and (pointer: fine) {
    .hero-affiliation a:hover {
        color: var(--color-accent);
        border-bottom-color: var(--color-accent);
    }
}

/* English name inline after Chinese name */
.hero-name-en {
    display: none;
    font-weight: 400;
    color: var(--color-text-light);
}

[data-lang="zh"] .hero-name-en {
    display: inline;
    font-size: 0.38em;
    letter-spacing: 0.05em;
    vertical-align: baseline;
}

@media (max-width: 900px) {
    [data-lang="zh"] .hero-name-en {
        display: none !important;
    }
}

.hero-interests {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: var(--space-lg);
}

.hero-interests .interest-chip {
    position: relative;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--color-accent);
    line-height: 1.35;
}

.hero-interests .interest-chip:not(:last-child)::after {
    content: "";
    display: inline-block;
    width: 0.25rem;
    height: 0.25rem;
    margin-left: 0.45rem;
    border-radius: 50%;
    background-color: var(--color-accent-light);
    vertical-align: 0.12em;
}

@media (hover: hover) and (pointer: fine) {
    .hero-interests .interest-chip:hover {
        color: var(--color-text);
    }
}

[data-theme="dark"] .hero-interests .interest-chip {
    color: var(--color-accent);
}

[data-theme="dark"] .hero-interests .interest-chip:not(:last-child)::after {
    background-color: rgba(179, 157, 219, 0.38);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .hero-interests .interest-chip {
        color: var(--color-accent);
    }

    :root:not([data-theme="light"]) .hero-interests .interest-chip:not(:last-child)::after {
        background-color: rgba(179, 157, 219, 0.38);
    }
}

.hero-links {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    align-items: center;
}

.hero-social {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-left: 0.15rem;
}

.hero-social .btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-sm);
    line-height: 0;
}

.hero-social svg {
    width: 20px;
    height: 20px;
    display: block;
}

.orcid-icon__svg {
    color: currentColor;
    transform: scale(0.96);
    transform-origin: center;
}

.orcid-icon__mark {
    fill: currentColor;
}

.orcid-icon__letters {
    fill: var(--color-bg);
}

@media (hover: hover) and (pointer: fine) {
    .btn-icon:hover .orcid-icon__letters {
        fill: var(--color-bg-alt);
    }
}

.hero-social a.hero-social-xhs {
    display: none;
}

[data-lang="zh"] .hero-social {
    gap: 0.25rem;
}

[data-lang="zh"] .hero-social a.hero-social-xhs {
    display: inline-flex;
}

/* Slightly larger wordmark; size not transform keeps row alignment */
.hero-social-xhs svg {
    width: 42px;
    height: 42px;
    position: relative;
    top: 2px;
}

.footer-social a.footer-social-xhs {
    display: none;
}

[data-lang="zh"] .footer-social a.footer-social-xhs {
    display: inline-flex;
}

.footer-social-xhs svg {
    width: 36px;
    height: 36px;
    position: relative;
    top: -6px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--border-radius);
    transition: all var(--transition-fast);
    border: 1px solid transparent;
    text-transform: uppercase; /* Academic touch */
    letter-spacing: 0.05em;
    cursor: pointer;
}

.btn-primary {
    background-color: var(--color-accent);
    color: var(--color-on-accent);
    border-color: var(--color-accent);
}

@media (hover: hover) and (pointer: fine) {
    .btn-primary:hover {
        background-color: var(--color-accent-hover);
        border-color: var(--color-accent-hover);
        color: var(--color-on-accent);
        transform: translateY(-1px);
    }
}

.btn-primary:active {
    transform: translateY(2px) scale(0.92);
}

.btn-secondary {
    background-color: transparent;
    color: var(--color-text);
    border-color: var(--color-border);
}

@media (hover: hover) and (pointer: fine) {
    .btn-secondary:hover {
        background-color: var(--color-bg-alt);
        border-color: var(--color-text-light);
        color: var(--color-text);
    }
}

.btn-icon {
    padding: var(--space-sm);
    background-color: transparent;
    color: var(--color-text-muted);
    border-color: transparent;
}

@media (hover: hover) and (pointer: fine) {
    .btn-icon:hover {
        color: var(--color-accent);
        background-color: var(--color-bg-alt);
    }
}

.btn-icon:active {
    transform: scale(0.85);
}

/* Hero scroll indicator - hidden for compact layout */
/* ============================================
   SECTIONS
   ============================================ */

.section {
    padding: var(--space-2xl) var(--space-lg);
    content-visibility: auto;
    contain-intrinsic-size: 800px;
    scroll-margin-top: var(--nav-scroll-offset, 5.5rem);
}

.section-alt {
    background-color: var(--color-bg-alt);
}

.section-inner {
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
}

/* Responsive sizes - Base definition */
h2.section-title { 
    font-size: 2.5rem; 
    margin-bottom: calc(var(--space-lg) + 10px); /* Add extra buffer for scaling */
    position: relative;
    display: inline-block;
    scroll-margin-top: var(--nav-scroll-offset, 5.5rem);
    /* Use transform for buttery smooth GPU-accelerated animation */
    transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
    transform-origin: 0 50%; /* Grow from left center */
    will-change: transform; 
}

@media (max-width: 1024px) { h2.section-title { font-size: 2rem; } }
@media (max-width: 768px) { h2.section-title { font-size: 1.75rem; } }

/* Active State - High Specificity */
h2.section-title.active {
    transform: scale(1.1) translateZ(0); /* Reduced to 1.1 for subtle elegance */
}

/* Line animation - Keep it separate */
.section-title::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 0;
    width: 60px;
    height: 4px; /* Thicker line for better visual balance with Merriweather */
    background-color: var(--color-accent);
    transition: width 0.5s ease;
    border-radius: 2px;
}

.section-title.active::after {
    width: 100%;
}

.section-subtitle {
    margin-top: calc(var(--space-md) * -1);
    margin-bottom: var(--space-lg);
    color: var(--color-text-muted);
    font-size: 0.9375rem;
}

/* Publications: keep header compact but leave room for the active underline (::after) */
#publications h2.section-title {
    margin-bottom: calc(var(--space-sm) + 2px);
}

#publications h2.section-title::after {
    z-index: 1;
}

#publications .section-subtitle {
    margin-top: 2px;
    margin-bottom: var(--space-md);
}

/* ============================================
   ABOUT SECTION
   ============================================ */

.about-content {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--space-xl);
    align-items: start;
}

/* Sticky news column while scrolling through About (desktop) */
@media (min-width: 901px) {
    #about.section {
        content-visibility: visible;
    }

    .about-news {
        position: sticky;
        top: 5.25rem;
        align-self: start;
        z-index: 2;
    }
}

.about-text .lead {
    font-family: var(--font-serif);
    font-size: 1.375rem;
    font-weight: 500;
    line-height: 1.5;
    color: var(--color-text);
    margin-bottom: var(--space-lg);
}

/* Keep parentheses and adjacent inline links on one line (avoids "(" on one line, link on next). */
.phrase-nowrap {
    white-space: nowrap;
    display: inline-block;
    max-width: 100%;
    vertical-align: baseline;
}

.phrase-nowrap a {
    display: inline;
    white-space: inherit;
    max-width: none;
}

.about-text a {
    color: var(--color-accent);
    text-decoration: none;
    position: relative;
    transition: color 0.3s ease;
}

.about-text a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 1px;
    background-color: var(--color-accent);
    transition: width 0.3s ease;
}

@media (hover: hover) and (pointer: fine) {
    .about-text a:hover {
        color: var(--color-accent-hover);
    }

    .about-text a:hover::after {
        width: 100%;
    }
}

.about-news h3 {
    font-size: 1rem;
    font-family: var(--font-sans);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    margin-bottom: var(--space-md);
}

.about-news .news-list {
    list-style: none;
}

.about-news .news-list li {
    padding: var(--space-sm) var(--space-sm); /* Add horizontal padding */
    margin: 0 calc(var(--space-sm) * -1); /* Negative margin to align text but allow bg highlight */
    border-bottom: 1px solid var(--color-border-light);
    font-size: 0.9375rem;
    color: var(--color-text-muted);
    line-height: 1.6;
    transition: all 0.2s ease;
    border-radius: 4px;
    position: relative;
}

/* Hover effects only for mouse users */
@media (hover: hover) and (pointer: fine) {
    .about-news .news-list li:hover {
        background-color: var(--color-surface); /* Highlight bg */
        transform: translateX(4px);
        color: var(--color-text); /* Darken text */
        border-bottom-color: transparent; /* Hide border on hover for cleaner look */
        box-shadow: 0 2px 8px rgba(0,0,0,0.05); /* Slight lift */
    }

    /* Accent mark on hover */
    .about-news .news-list li::before {
        content: '';
        position: absolute;
        left: 0;
        top: 50%;
        transform: translateY(-50%) scaleY(0);
        width: 3px;
        height: 70%;
        background-color: var(--color-accent);
        border-radius: 2px;
        transition: transform 0.2s ease;
        opacity: 0;
    }

    .about-news .news-list li:hover::before {
        transform: translateY(-50%) scaleY(1);
        opacity: 1;
    }
}

.about-news .news-list li:last-child {
    border-bottom: none;
}

.about-news .news-date {
    font-weight: 600;
    color: var(--color-accent);
    margin-right: var(--space-sm);
}

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

.publications-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.pub-item {
    display: flex;
    flex-direction: column;
    padding: 1.25rem;
    background-color: var(--color-surface);
    border-radius: 8px;
    border: 1px solid var(--color-border-light);
    transition: all 0.3s ease;
    cursor: pointer;
}

.pub-main {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 1.5rem;
    align-items: start;
}

/* Hover effects only on desktop (including narrow windows with mouse) */
@media (hover: hover) and (pointer: fine) {
    .pub-item:hover {
        box-shadow: 0 12px 28px rgba(0, 0, 0, 0.08), 0 3px 10px rgba(0,0,0,0.04);
        transform: translateY(-2px);
        border-color: var(--pub-hover-border);
        z-index: 5;
    }
    
    .pub-item:active {
        transform: translateY(2px) scale(0.97);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
        transition: transform 0.05s cubic-bezier(0.4, 0.0, 0.2, 1), box-shadow 0.05s cubic-bezier(0.4, 0.0, 0.2, 1);
    }

    .pub-item:hover .pub-title {
        color: var(--color-accent);
    }
    
    /* Image zoom removed for stability and cleaner look */
    .pub-item:hover .pub-thumbnail img,
    .pub-item:hover .pub-thumbnail video {
        transform: none;
    }
    
    /* Ensure the container clips contents */
    .pub-thumbnail {
        overflow: hidden;
    }
    
    /* Apply smooth transition to container only */
    .pub-item {
        /* Slower, more natural easing - Increased duration from 0.4s to 0.6s */
        transition: all 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
    }
}

/* Publication abstract */
.pub-abstract {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.8s cubic-bezier(0.22, 1, 0.36, 1);
    font-size: 0.9375rem;
    line-height: 1.7;
    color: var(--color-text-muted);
    padding: 0;
    margin: 0;
    border-top: 1px solid transparent;
}

.pub-item.expanded .pub-abstract {
    max-height: none;
    padding-top: var(--space-md);
    margin-top: var(--space-md);
    border-top-color: var(--color-border-light);
}

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

.pub-abstract-toggle {
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
}

@media (hover: hover) and (pointer: fine) {
    .pub-abstract-toggle:hover {
        color: var(--color-accent);
        border-color: var(--color-accent);
        background-color: var(--color-accent-light);
    }
}

.pub-abstract-toggle::after {
    content: '';
    width: 0.42rem;
    height: 0.42rem;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg) translateY(-1px);
    transition: transform 0.25s ease;
}

.pub-item.expanded .pub-abstract-toggle {
    color: var(--color-accent);
    border-color: var(--color-accent);
}

.pub-item.expanded .pub-abstract-toggle::after {
    transform: rotate(225deg) translate(-1px, -1px);
}

.pub-thumbnail {
    border-radius: 6px;
    overflow: hidden;
    align-self: start;
    width: 240px;
    border: 1px solid var(--color-border-light);
    /* Skeleton Loading */
    background: linear-gradient(90deg, var(--color-bg-alt) 25%, var(--color-border-light) 37%, var(--color-bg-alt) 63%);
    background-size: 400% 100%;
    animation: skeleton-loading 1.4s ease infinite;
}

.pub-thumbnail.loaded {
    animation: none;
    background: var(--color-bg-alt);
}

.pub-thumbnail img {
    width: 100%;
    height: auto;
    object-fit: contain;
    display: block;
    /* Image Fade In */
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}

.pub-thumbnail img.loaded {
    opacity: 1;
}

.pub-content {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    position: relative;
}

/* Badge row above title */
.pub-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.1rem;
}

.pub-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 0.3rem 0.55rem;
    border-radius: 3px;
    line-height: 1;
    white-space: nowrap;
}

.pub-badge-venue {
    background-color: var(--color-accent-light);
    color: var(--color-accent);
    border: 1px solid transparent;
}

/* Venue-specific palettes */
.pub-badge-venue.badge-chi {
    background-color: rgba(78, 42, 132, 0.1);
    color: var(--color-accent);
}

.pub-badge-venue.badge-cvpr {
    background-color: rgba(28, 100, 180, 0.1);
    color: #1c64b4;
}

[data-theme="dark"] .pub-badge-venue.badge-cvpr {
    background-color: rgba(120, 170, 230, 0.14);
    color: #78aae6;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .pub-badge-venue.badge-cvpr {
        background-color: rgba(120, 170, 230, 0.14);
        color: #78aae6;
    }
}

.pub-badge-venue.badge-uist {
    background-color: rgba(20, 130, 100, 0.1);
    color: #128264;
}

.pub-badge-venue.badge-imwut {
    background-color: rgba(0, 96, 140, 0.1);
    color: #00608c;
}

[data-theme="dark"] .pub-badge-venue.badge-imwut {
    background-color: rgba(80, 180, 220, 0.14);
    color: #6ec4e8;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .pub-badge-venue.badge-imwut {
        background-color: rgba(80, 180, 220, 0.14);
        color: #6ec4e8;
    }
}

[data-theme="dark"] .pub-badge-venue.badge-uist {
    background-color: rgba(80, 200, 160, 0.14);
    color: #5ccaa1;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .pub-badge-venue.badge-uist {
        background-color: rgba(80, 200, 160, 0.14);
        color: #5ccaa1;
    }
}

.pub-badge-status {
    background-color: rgba(184, 134, 11, 0.12);
    color: #a8740a;
    position: relative;
}

.pub-badge-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: currentColor;
    display: inline-block;
}

[data-theme="dark"] .pub-badge-status {
    background-color: rgba(232, 180, 60, 0.18);
    color: #e8b43c;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .pub-badge-status {
        background-color: rgba(232, 180, 60, 0.18);
        color: #e8b43c;
    }
}

.pub-title {
    font-size: 1.15rem;
    font-weight: 600;
    font-family: var(--font-sans);
    line-height: 1.35;
    letter-spacing: -0.005em;
    margin-top: 0.1rem;
}

.pub-authors {
    font-size: 0.9375rem;
    color: var(--color-text-muted);
    line-height: 1.45;
    margin-bottom: -0.12rem;
}

.pub-authors strong {
    color: var(--color-text);
    font-weight: 600;
}

.pub-venue {
    font-size: 0.875rem;
    color: var(--color-text-light);
    font-style: italic;
    line-height: 1.4;
    margin-bottom: -0.05rem;
}

.pub-links {
    display: flex;
    gap: 0.45rem;
    margin-top: 0.28rem;
    flex-wrap: wrap;
    align-items: center;
}

.pub-link {
    font-size: 0.8125rem;
    font-weight: 500;
    padding: 0.35rem 0.75rem;
    border-radius: 4px;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    cursor: pointer;
    font-family: inherit;
    line-height: 1.2;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    letter-spacing: 0.01em;
}

/* Primary actions (PDF / Video) - filled purple */
.pub-link.primary {
    background-color: var(--color-accent);
    color: var(--color-on-accent);
    border-color: var(--color-accent);
}

@media (hover: hover) and (pointer: fine) {
    .pub-link.primary:hover {
        background-color: var(--color-accent-hover);
        border-color: var(--color-accent-hover);
        color: var(--color-on-accent);
        transform: translateY(-1px);
        box-shadow: 0 4px 12px -4px rgba(78, 42, 132, 0.5);
    }
}

.pub-link.primary:active {
    transform: translateY(0) scale(0.97);
    box-shadow: none;
}

.pub-link.media {
    background-color: var(--color-accent-light);
    color: var(--color-accent);
    border-color: transparent;
}

@media (hover: hover) and (pointer: fine) {
    .pub-link.media:hover {
        background-color: transparent;
        color: var(--color-accent);
        border-color: var(--color-accent);
        transform: translateY(-1px);
    }
}

.pub-link.media:active {
    transform: translateY(0) scale(0.97);
}

@media (hover: hover) and (pointer: fine) {
    [data-theme="dark"] .pub-link.primary:hover {
        box-shadow: 0 4px 12px -4px rgba(179, 157, 219, 0.5);
    }
}

@media (hover: hover) and (pointer: fine) and (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .pub-link.primary:hover {
        box-shadow: 0 4px 12px -4px rgba(179, 157, 219, 0.5);
    }
}

/* Secondary actions (DOI / BibTeX) - ghost style */
.pub-link.subtle {
    background-color: transparent;
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
}

@media (hover: hover) and (pointer: fine) {
    .pub-link.subtle:hover {
        color: var(--color-accent);
        border-color: var(--color-accent);
        background-color: transparent;
    }
}

.pub-link.subtle:active {
    transform: scale(0.97);
}

.pub-link svg {
    flex-shrink: 0;
}

[data-lang="zh"] .hero-greeting {
    text-transform: none;
    letter-spacing: 0.12em;
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--color-text-light);
    margin-bottom: 0.6rem;
}

[data-lang="zh"] .hero-greeting::before {
    width: 22px;
    opacity: 0.65;
}

[data-lang="zh"] .hero-identity {
    margin-bottom: 0.75rem;
}

[data-lang="zh"] .hero-name {
    display: block;
    font-family: "Noto Serif SC", var(--font-serif);
    font-size: clamp(2.25rem, 4.2vw, 3.25rem);
    font-weight: 700;
    letter-spacing: 0.08em;
    line-height: 1.25;
    margin-bottom: 0;
}

/* Hide English alias in Chinese mode — romanization is inline via .hero-name-en */
[data-lang="zh"] .hero-alias {
    display: none;
}

[data-lang="zh"] .hero-title {
    display: none;
}

@media (min-width: 901px) {
    [data-lang="zh"] .hero-text {
        max-width: min(40rem, 100%);
    }
}

[data-lang="zh"] .hero-affiliation {
    font-size: 1.0625rem;
    line-height: 1.65;
    margin-bottom: 1.1rem;
    color: var(--color-text-muted);
}

[data-lang="zh"] .hero-affiliation::first-line {
    font-weight: 600;
    color: var(--color-text);
}

/* Chinese interests: plain text with dot separators (no capsule chips) */
[data-lang="zh"] .hero-interests {
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-bottom: 1.25rem;
}

[data-lang="zh"] .hero-interests .interest-chip {
    font-size: 0.9375rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: none;
    padding: 0;
    border: none;
    border-radius: 0;
    background-color: transparent;
    color: var(--color-accent);
    transition: color var(--transition-fast);
}

[data-lang="zh"] .hero-interests .interest-chip:not(:last-child)::after {
    display: inline-block;
    width: 0.25rem;
    height: 0.25rem;
    margin-left: 0.45rem;
    border-radius: 50%;
    background-color: var(--color-accent-light);
    vertical-align: 0.12em;
}

@media (hover: hover) and (pointer: fine) {
    [data-lang="zh"] .hero-interests .interest-chip:hover {
        color: var(--color-text);
        background-color: transparent;
    }
}

[data-lang="zh"] .hero-links .btn {
    text-transform: none;
    letter-spacing: 0.03em;
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
}

[data-lang="zh"] .hero-links .btn-primary {
    box-shadow: 0 4px 14px -6px rgba(78, 42, 132, 0.35);
}

@media (max-width: 900px) {
    [data-lang="zh"] .hero-name {
        letter-spacing: 0.08em;
    }
}

[data-lang="zh"] .section-title {
    letter-spacing: -0.02em;
}

[data-lang="zh"] .pub-title {
    font-weight: 600;
    letter-spacing: 0;
    line-height: 1.42;
}

[data-lang="zh"] .pub-venue {
    font-style: normal;
}

/* ============================================
   PROJECTS SECTION
   ============================================ */

.projects-grid {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-md);
    align-items: start; /* Prevent cards in the same row from stretching */
}

/* One transition on both states so shadow eases on press and on release */
.project-card {
    transition:
        transform 0.22s cubic-bezier(0.33, 1, 0.68, 1),
        box-shadow 0.35s ease,
        border-color 0.3s ease;
}

.project-card {
    background-color: var(--color-surface);
    border-radius: var(--border-radius);
    overflow: visible;
    border: 1px solid var(--color-border-light);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Lift + press on the actually-clickable card (project-card has tap-to-expand). */
@media (hover: hover) and (pointer: fine) {
    .project-card:hover {
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.05);
        transform: translateY(-6px) scale(1.01);
        border-color: var(--color-accent-light);
        z-index: 10;
    }

    .project-card:active,
    .project-card:hover:active {
        transform: translateY(2px) scale(0.96);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    }
}

@media (hover: none) {
    .project-card:active {
        transform: translateY(2px) scale(0.96);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    }
}

.project-image {
    aspect-ratio: 16/10;
    overflow: hidden;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    position: relative;
    /* Skeleton Loading */
    background: linear-gradient(90deg, var(--color-bg-alt) 25%, var(--color-border-light) 37%, var(--color-bg-alt) 63%);
    background-size: 400% 100%;
    animation: skeleton-loading 1.4s ease infinite;
}

.project-image.loaded {
    animation: none;
    background: var(--color-bg-alt);
}

/* Subtle gloss overlay */
.project-image::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        to bottom,
        rgba(255,255,255,0) 0%,
        rgba(255,255,255,0.1) 50%,
        rgba(255,255,255,0) 100%
    );
    opacity: 0;
    transform: translateY(-100%);
    transition: transform 0.6s;
    pointer-events: none;
}

@media (hover: hover) and (pointer: fine) {
    .project-card:hover .project-image::after {
        transform: translateY(100%);
        transition: transform 0.6s;
        opacity: 0.3;
    }
}

.project-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Image fade-in + hover zoom + object-position shifts */
    opacity: 0;
    transition:
        opacity 0.5s ease-in-out,
        transform 0.7s cubic-bezier(0.19, 1, 0.22, 1),
        object-position 0.7s cubic-bezier(0.19, 1, 0.22, 1);
}

.project-image img.loaded {
    opacity: 1;
}

@media (hover: hover) and (pointer: fine) {
    .project-card:hover .project-image img.loaded {
        transform: scale(1.08);
    }

    /* Haptics: anchor desktop hover zoom toward the finger side */
    #research-haptics .project-image img.loaded {
        transform-origin: 22% 70%;
    }
}

.project-content {
    padding: var(--space-sm) var(--space-md);
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background: var(--color-surface);
    transition: background-color 0.3s ease;
}

@media (hover: hover) and (pointer: fine) {
    .project-card:hover .project-content {
        background: var(--color-bg);
    }
}

.project-title {
    font-size: 1rem;
    margin-bottom: var(--space-xs);
    transition: color 0.3s ease;
    
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.2;
}

.project-title a {
    color: inherit;
    text-decoration: none;
}

.project-title a:focus-visible {
    color: var(--color-accent);
}

@media (hover: hover) and (pointer: fine) {
    .project-title a:hover {
        color: var(--color-accent);
    }
}

@media (hover: hover) and (pointer: fine) {
    .project-card:hover .project-title {
        color: var(--color-accent);
    }
}

/* Description + tags: collapsed shows 2-line desc only; tags fully hidden */
.project-reveal {
    position: relative;
    overflow: hidden;
    transition: max-height 1s cubic-bezier(0.33, 1, 0.38, 1);
}

/* Fade at visible clip edge (moves with max-height animation, not full desc height) */
.project-reveal::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2.25em;
    background: linear-gradient(to bottom, transparent, var(--color-surface));
    pointer-events: none;
    z-index: 1;
    opacity: 1;
    transition: opacity 1s cubic-bezier(0.33, 1, 0.38, 1);
}

@media (hover: hover) and (pointer: fine) {
    .project-card:hover .project-reveal::after {
        background: linear-gradient(to bottom, transparent, var(--color-bg));
    }
}

.project-card.is-reveal-open:not(.is-reveal-closing) .project-reveal::after,
.project-card.expanded:not(.is-reveal-closing) .project-reveal::after {
    opacity: 0;
    transition: opacity 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.project-desc {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-bottom: 0;
    position: relative;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.project-card.is-reveal-open .project-desc {
    display: block;
    -webkit-line-clamp: unset;
    line-clamp: unset;
    overflow: visible;
}

/* Tech stack tags — never partially visible */
.project-tags {
    display: none;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: var(--space-md);
}

.project-card.is-reveal-open .project-tags {
    display: flex;
}

@media (prefers-reduced-motion: reduce) {
    @media (hover: hover) and (pointer: fine) {
        .project-card:hover .project-desc {
            display: block;
            -webkit-line-clamp: unset;
            line-clamp: unset;
            overflow: visible;
        }

        .project-card:hover .project-tags {
            display: flex;
        }

        .project-card:hover .project-reveal::after {
            opacity: 0;
        }
    }
}

.project-tags span {
    font-size: 0.7rem;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: 4px;
    background-color: var(--color-bg-alt);
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
    text-decoration: none;
    /* Prevent tags from squishing during animation */
    flex-shrink: 0;
}

/* University affiliation tags with school colors */
.project-tags .tag-uchicago {
    background-color: var(--tag-uchicago-bg);
    color: var(--tag-uchicago-color);
    border-color: var(--tag-uchicago-border);
}

.project-tags .tag-northwestern {
    background-color: var(--tag-northwestern-bg);
    color: var(--tag-northwestern-color);
    border-color: var(--tag-northwestern-border);
}

.project-tags .tag-upenn {
    background-color: var(--tag-upenn-bg);
    color: var(--tag-upenn-color);
    border-color: var(--tag-upenn-border);
}

/* Ensure content container adjusts naturally */
.project-content {
    display: flex;
    flex-direction: column;
    padding: var(--space-sm) var(--space-md);
    background: var(--color-surface);
    transition: background-color 0.3s ease;
    /* Removed height: 100% to prevent unnecessary whitespace */
}

/* ============================================
   TEACHING SECTION
   ============================================ */

.teaching-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.course-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: var(--space-md);
    background-color: var(--color-surface);
    border-radius: var(--border-radius);
    border: 1px solid var(--color-border-light);
    position: relative;
    overflow: hidden;
}

a.course-item--has-link {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition:
        transform 0.22s cubic-bezier(0.33, 1, 0.68, 1),
        box-shadow 0.35s ease,
        border-color 0.3s ease,
        background-color 0.3s ease;
}

a.course-item {
    text-decoration: none;
    color: inherit;
}

a.course-item--has-link:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.course-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0;
    transition: opacity 0.4s ease-in-out;
    z-index: 0;
}

.course-item .course-info,
.course-item .course-meta {
    position: relative;
    z-index: 1;
}

.course-item .course-info {
    flex: 1;
    min-width: 0;
}

.course-title,
.course-desc {
    white-space: normal;
    overflow-wrap: break-word;
}

/* Hover effects: fine pointer only */
@media (hover: hover) and (pointer: fine) {
    a.course-item--has-link {
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    }

    .course-item:hover::before {
        opacity: 0.15;
    }

    .course-item--has-link:hover {
        border-color: var(--color-accent-light);
        box-shadow: 0 16px 32px rgba(0, 0, 0, 0.09), 0 2px 6px rgba(0, 0, 0, 0.04);
        transform: translateY(-5px) scale(1.015);
        z-index: 2;
    }

    .course-item--has-link:hover:active {
        transform: translateY(-1px) scale(0.995);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    }

    .course-item:not(.course-item--has-link):hover {
        border-color: var(--color-accent-light);
    }

    .course-item:hover .course-title {
        font-weight: 700;
        color: var(--color-accent);
    }

    .course-item:hover .course-desc {
        color: var(--color-text);
    }

    .course-item:hover .course-term {
        color: var(--color-text-muted);
        font-weight: 500;
    }

    .course-item--has-link .course-meta {
        display: flex;
        align-items: center;
        gap: var(--space-sm);
        flex-shrink: 0;
    }

    .course-item--has-link .course-meta::after {
        content: '↗';
        flex-shrink: 0;
        font-size: 0.875rem;
        line-height: 1;
        color: var(--color-text-light);
        opacity: 0;
        transform: translate(-3px, 3px);
        transition:
            opacity 0.25s ease,
            transform 0.25s ease,
            color 0.25s ease;
        pointer-events: none;
    }

    .course-item--has-link:hover .course-meta::after,
    .course-item--has-link:focus-visible .course-meta::after {
        opacity: 1;
        transform: translate(0, 0);
        color: var(--color-accent);
    }

    [data-theme="dark"] .course-item--has-link:hover {
        box-shadow: 0 16px 32px rgba(0, 0, 0, 0.35), 0 2px 6px rgba(0, 0, 0, 0.2);
    }
}

@media (hover: hover) and (pointer: fine) and (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .course-item--has-link:hover {
        box-shadow: 0 16px 32px rgba(0, 0, 0, 0.35), 0 2px 6px rgba(0, 0, 0, 0.2);
    }
}

/* Individual course item backgrounds (suffix match: zh pages use same token without ../) */
.course-item[data-hover-image$="Asset/IMWUT.jpg"]::before {
    background-image: url('Asset/IMWUT.jpg');
    background-image: image-set(
        url('Asset/IMWUT.webp') type('image/webp'),
        url('Asset/IMWUT.jpg') type('image/jpeg')
    );
}

.course-item[data-hover-image$="Asset/upenn.png"]::before {
    background-image: url('Asset/upenn.png');
}

.course-item[data-hover-image$="Asset/fife-penn.png"]::before {
    background-image: url('Asset/fife-penn.png');
    background-image: image-set(
        url('Asset/fife-penn.webp') type('image/webp'),
        url('Asset/fife-penn.png') type('image/png')
    );
}

.course-item[data-hover-image$="Asset/ilo.png"]::before {
    background-image: url('Asset/ilo.png');
    background-image: image-set(
        url('Asset/ilo.webp') type('image/webp'),
        url('Asset/ilo.png') type('image/png')
    );
}



.course-title {
    font-size: 1.0625rem;
    font-family: var(--font-sans);
    font-weight: 600;
    margin-bottom: var(--space-xs);
}

/* Touch / coarse pointer: whole card is tappable; link hint beside term (no title overlap) */
@media (hover: none), (pointer: coarse) {
    a.course-item--has-link {
        box-shadow: none;
    }

    .course-item--has-link .course-meta {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: var(--space-sm);
        width: 100%;
        max-width: none;
    }

    .course-item--has-link .course-meta::after {
        content: '↗';
        flex-shrink: 0;
        font-size: 0.875rem;
        line-height: 1;
        color: var(--color-text-light);
        pointer-events: none;
    }

    .course-item--has-link .course-term {
        white-space: normal;
    }

    .course-item--has-link:active {
        background-color: var(--color-bg-alt);
        transform: scale(0.995);
    }
}

.course-desc {
    font-size: 0.9375rem;
    color: var(--color-text-muted);
    max-width: 600px;
}

.course-term {
    font-size: 0.875rem;
    color: var(--color-text-light);
    white-space: nowrap;
}

/* ============================================
   CONTACT SECTION
   ============================================ */

.contact-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
}

.contact-lead {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    font-weight: 500;
    line-height: 1.5;
    margin-bottom: var(--space-lg);
}

.contact-details {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.contact-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    width: fit-content;
    max-width: 100%;
    color: var(--color-text-muted);
}

.contact-item svg {
    flex-shrink: 0;
    color: var(--color-accent);
}

.contact-item a {
    color: var(--color-text);
    line-height: 1.6;
}

/* Scale on hover: fine pointer only (no sticky hover/focus on touch) */
@media (hover: hover) and (pointer: fine) {
    .contact-item {
        transform-origin: left center;
        transition: transform 0.25s cubic-bezier(0.33, 1, 0.68, 1);
    }

    .contact-item:hover {
        transform: scale(1.03);
    }
}

@media (hover: none), (pointer: coarse) {
    .contact-item,
    .contact-item:hover,
    .contact-item:active {
        transform: none;
        transition: none;
    }
}

.contact-note {
    padding: var(--space-lg);
    background-color: var(--color-surface);
    border-radius: var(--border-radius);
    border: 1px solid var(--color-border-light);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    position: relative;
    transition:
        transform 0.22s cubic-bezier(0.33, 1, 0.68, 1),
        box-shadow 0.35s ease,
        border-color 0.3s ease;
}

@media (hover: hover) and (pointer: fine) {
    .contact-note:hover {
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.05);
        transform: translateY(-6px) scale(1.01);
        border-color: var(--color-accent-light);
        z-index: 10;
    }

    .contact-note:active,
    .contact-note:hover:active {
        transform: translateY(2px) scale(0.96);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    }
}

@media (hover: none), (pointer: coarse) {
    .contact-note,
    .contact-note:hover,
    .contact-note:active {
        transform: none;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
        transition: none;
    }
}

.contact-note h3 {
    font-size: 1rem;
    font-family: var(--font-sans);
    font-weight: 600;
    margin-bottom: var(--space-sm);
    transition: color 0.3s ease;
}

.contact-note p {
    font-size: 0.9375rem;
    color: var(--color-text-muted);
}

/* Contact columns: fade in from left / right on scroll (stacked layout uses vertical reveal below) */
#contact .contact-info.animate-on-scroll {
    transition:
        opacity 0.4s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    transform: translateX(-2rem);
}

/* Scroll reveal: only delay opacity; keep card lift/press transitions */
#contact .contact-note.animate-on-scroll {
    transition:
        opacity 0.4s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.22s cubic-bezier(0.33, 1, 0.68, 1),
        box-shadow 0.35s ease,
        border-color 0.3s ease;
    transition-delay: 0.03s, 0s, 0s, 0s;
    transform: none;
}

#contact .contact-info.animate-on-scroll.is-visible {
    opacity: 1;
    transform: translateX(0);
}

#contact .contact-note.animate-on-scroll.is-visible {
    opacity: 1;
    transform: none;
}

@media (max-width: 1024px) {
    #contact .contact-info.animate-on-scroll,
    #contact .contact-note.animate-on-scroll {
        transform: translateY(1.35rem);
        transition-delay: 0s;
    }

    #contact .contact-note.animate-on-scroll {
        transition-delay: 0.04s;
    }

    #contact .contact-info.animate-on-scroll.is-visible {
        transform: translateY(0);
    }

    #contact .contact-note.animate-on-scroll.is-visible {
        transform: none;
    }
}

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

.footer {
    padding: var(--space-lg) var(--space-lg);
    border-top: 1px solid var(--color-border);
    text-align: center;
}

.footer-inner {
    max-width: var(--max-width);
    margin: 0 auto;
}

.footer-social {
    display: flex;
    justify-content: center;
    gap: var(--space-lg);
    margin-bottom: var(--space-md);
}

.footer-icon {
    color: var(--color-text-light);
    transition: all var(--transition-fast);
    padding: var(--space-xs);
    opacity: 0.7;
}

@media (hover: hover) and (pointer: fine) {
    .footer-icon:hover {
        color: var(--color-accent);
        transform: translateY(-2px);
        opacity: 1;
    }
}

.footer p {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.footer-note {
    font-size: 0.75rem;
    color: var(--color-text-light);
    margin-top: var(--space-sm);
}

/* ============================================
   BACK TO TOP BUTTON
   ============================================ */

.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 44px;
    height: 44px;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all var(--transition-base);
    z-index: 999;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

@media (hover: hover) and (pointer: fine) {
    .back-to-top:hover {
        background-color: var(--color-accent);
        border-color: var(--color-accent);
        color: var(--color-on-accent);
        transform: translateY(-2px);
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    }
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

@media (max-width: 768px) {
    .back-to-top {
        bottom: 20px;
        right: 20px;
        /* Maintain WCAG 2.5.5 minimum 44x44 touch target. */
        width: 44px;
        height: 44px;
    }
}

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

@media (max-width: 900px) {
    .hero-content {
        grid-template-columns: 1fr;
        text-align: center;
    }
    
    .hero-image-wrapper {
        justify-self: center;
    }
    
    .hero-image {
        width: 220px;
        height: 220px;
    }
    
    .hero-greeting {
        justify-content: center;
    }
    
    .hero-interests {
        justify-content: center;
        gap: 0.4rem;
        margin-left: auto;
        margin-right: auto;
    }
    
    .hero-text {
        max-width: 100%;
    }
    
    .hero-links {
        justify-content: center;
    }

    [data-lang="zh"] .hero-greeting {
        display: none;
    }

    [data-lang="zh"] .hero-social {
        flex-basis: 100%;
        margin-left: 0;
        justify-content: center;
    }

    .publications-list {
        gap: 0.85rem;
    }

    .pub-item {
        max-width: 100%;
        margin-left: auto;
        margin-right: auto;
        padding: 0.9rem;
        cursor: pointer;
    }

    .pub-main {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .pub-thumbnail {
        display: none;
    }

    .pub-content {
        min-width: 0;
        gap: 0.28rem;
    }

    .pub-badges {
        gap: 0.3rem;
        margin-bottom: 0;
    }

    .pub-badge {
        font-size: 0.625rem;
        padding: 0.25rem 0.45rem;
    }

    .pub-title {
        font-size: 1rem;
        margin-top: 0;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .pub-authors,
    .pub-venue {
        font-size: 0.8125rem;
    }

    .pub-authors {
        margin-bottom: -0.1rem;
    }

    .pub-links {
        gap: 0.35rem;
        margin-top: 0.22rem;
    }

    .pub-link {
        font-size: 0.75rem;
        padding: 0.3rem 0.55rem;
    }

    .pub-abstract {
        font-size: 0.875rem;
    }
    
    .about-content {
        grid-template-columns: 1fr;
    }

    .about-news {
        position: static;
        top: auto;
    }
    
    
    .contact-content {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .hero-image-accent {
        --accent-x: 10px;
        --accent-y: 10px;
    }

    .section {
        content-visibility: visible;
        contain-intrinsic-size: auto;
    }
}

@media (max-width: 768px) {
    :root {
        --space-xl: 3rem;
        --space-2xl: 4rem;
        --space-3xl: 6rem;
    }

    .section {
        content-visibility: visible;
        contain-intrinsic-size: auto;
    }

    
    .nav-links {
        display: flex;
        flex-direction: column;
        gap: 0.2rem;
        margin-left: 0;
        margin-right: 0;
        padding-left: 0;
        padding-inline-start: 0;
        min-height: 0; /* allow max-height: 0 to collapse in flex layout */
        
        /* Animation - collapse to 0 height */
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        transition: max-height var(--transition-slow), 
                    opacity var(--transition-base);
    }
    
    .nav-links li {
        display: block;
        width: 100%;
    }
    
    .nav-links .nav-link {
        display: flex;
        align-items: center;
        min-height: 48px;
        padding: 0.625rem 0.75rem 0.625rem 0;
        font-size: 1.125rem;
        font-weight: 600;
        line-height: 1.35;
        width: 100%;
        box-sizing: border-box;
        border-radius: var(--border-radius);
        -webkit-tap-highlight-color: transparent;
    }

    .nav-links .nav-link:active {
        background-color: var(--color-bg-alt);
    }
    
    /* Adjust underline position for mobile */
    .nav-links .nav-link::after {
        bottom: 0.5rem;
        left: 0;
        width: 0;
    }

    .nav-links .nav-link.active::after {
        width: calc(100% - 0.75rem);
    }

    [lang^="zh"] .nav-links .nav-link {
        font-size: 1.2rem;
        letter-spacing: 0.04em;
    }
    
    .nav-links.active {
        max-height: min(70vh, 22rem);
        opacity: 1;
        padding-top: var(--space-sm);
        padding-bottom: var(--space-md);
    }

    body.no-scroll .nav {
        bottom: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        background: var(--nav-menu-overlay-bg);
        -webkit-backdrop-filter: blur(12px);
        backdrop-filter: blur(12px);
    }

    .nav-inner {
        position: relative;
        z-index: 1;
    }

    .nav-inner::before {
        content: '';
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        width: 100vw;
        top: 0;
        bottom: 0;
        background: var(--color-bg);
        border-bottom: 1px solid transparent;
        z-index: -1;
        opacity: 0;
        pointer-events: none;
        transition: opacity var(--transition-base), border-color var(--transition-base);
    }

    body.no-scroll .nav-inner::before {
        opacity: 1;
        border-bottom-color: var(--color-border-light);
    }

    .nav-links.nav-links--instant {
        transition: none !important;
    }
    
    .nav-toggle {
        display: flex;
    }
    
    /* Mobile nav layout: logo on left, controls on right, links below */
    .nav-inner {
        flex-wrap: wrap;
    }
    
    .nav-inner .nav-logo {
        flex-shrink: 0;
    }
    
    .nav-inner .nav-links {
        order: 3;
        width: 100%;
        flex-basis: 100%;
    }
    
    .nav-inner .nav-controls {
        order: 2;
        margin-left: auto;
    }
    
    .projects-grid {
        grid-template-columns: 1fr;
    }
    
    /* Compact project cards on mobile */
    .project-card {
        display: grid;
        grid-template-columns: 120px 1fr;
        gap: 0;
        min-height: 0;
        align-items: stretch;
    }
    
    .project-image {
        width: 120px;
        height: 100%; /* Stretch to fill card height */
        min-width: 120px;
        /* Removed fixed height/min-height constraints */
        aspect-ratio: auto; /* Override default aspect ratio */
        flex-shrink: 0;
        border-radius: var(--border-radius) 0 0 var(--border-radius);
    }
    
    .project-image img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    /* Keep focal subject (fingers) visible in the narrow thumbnail strip */
    #research-haptics .project-image img {
        object-position: 12% 62%;
        transition:
            opacity 0.5s ease-in-out,
            transform 0.7s cubic-bezier(0.19, 1, 0.22, 1),
            object-position 0.7s cubic-bezier(0.22, 1, 0.36, 1);
    }

    /* Pan + grow together on open (matches PROJECT_REVEAL_OPEN_TRANSITION) */
    #research-haptics[data-reveal-open="true"] .project-image img,
    #research-haptics.is-reveal-open:not(.is-reveal-closing) .project-image img,
    #research-haptics.expanded:not(.is-reveal-closing) .project-image img {
        object-position: 7% 90%;
    }

    /* Pan + shrink together on close (matches PROJECT_REVEAL_CLOSE_TRANSITION) */
    #research-haptics.is-reveal-closing .project-image img {
        object-position: 12% 62%;
        transition:
            opacity 0.5s ease-in-out,
            transform 0.7s cubic-bezier(0.19, 1, 0.22, 1),
            object-position 1s cubic-bezier(0.33, 1, 0.38, 1);
    }

    #research-eit .project-image img {
        object-position: 62% 25%;
        transition:
            opacity 0.5s ease-in-out,
            transform 0.7s cubic-bezier(0.19, 1, 0.22, 1),
            object-position 0.7s cubic-bezier(0.22, 1, 0.36, 1);
    }

    #research-eit[data-reveal-open="true"] .project-image img,
    #research-eit.is-reveal-open:not(.is-reveal-closing) .project-image img,
    #research-eit.expanded:not(.is-reveal-closing) .project-image img {
        object-position: 70% 25%;
    }

    #research-eit.is-reveal-closing .project-image img {
        object-position: 62% 25%;
        transition:
            opacity 0.5s ease-in-out,
            transform 0.7s cubic-bezier(0.19, 1, 0.22, 1),
            object-position 1s cubic-bezier(0.33, 1, 0.38, 1);
    }
    
    .project-content {
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        gap: var(--space-xs);
        padding: var(--space-sm) var(--space-md);
        min-width: 0;
        overflow: visible;
    }
    
    .project-title {
        font-size: 1.0625rem;
        margin-bottom: 0;
        display: block;
        overflow: visible;
        white-space: normal;
        line-height: 1.2;
    }
    
    .project-desc {
        font-size: 0.9rem;
        margin-bottom: 0;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .project-card.is-reveal-open .project-desc,
    .project-card.expanded .project-desc {
        display: block;
        -webkit-line-clamp: unset;
        line-clamp: unset;
        overflow: visible;
    }

    .project-card.is-reveal-open:not(.is-reveal-closing) .project-reveal::after,
    .project-card.expanded:not(.is-reveal-closing) .project-reveal::after {
        opacity: 0;
    }
    
    .course-item {
        flex-direction: column;
        gap: var(--space-sm);
    }
}

@media (max-width: 480px) {
    .hero {
        padding-top: 4.75rem;
        padding-bottom: 2.5rem;
    }

    .hero-image-accent {
        --accent-x: 8px;
        --accent-y: 8px;
    }

    .hero-image {
        width: 180px;
        height: 180px;
    }

    .hero-interests {
        gap: 0.35rem;
    }

    .hero-interests .interest-chip {
        font-size: 0.625rem;
        letter-spacing: 0.025em;
    }

    .hero-interests .interest-chip:not(:last-child)::after {
        width: 0.2rem;
        height: 0.2rem;
        margin-left: 0.35rem;
    }

    .hero-text::before {
        inset: -0.75rem -0.9rem;
    }

    .pub-item {
        padding: 0.8rem;
    }

    .pub-title {
        font-size: 0.9375rem;
    }

    .pub-venue {
        display: none;
    }
    
    .btn {
        padding: var(--space-sm) var(--space-sm);
        font-size: 0.8125rem;
    }
    
    .section {
        padding: var(--space-xl) var(--space-lg);
    }
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes skeleton-loading {
    0% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInCard {
    from { opacity: 0; }
    to { opacity: 1; }
}

.hero-content {
    animation: fadeInUp 0.8s ease-out;
}

.section-title {
    animation: fadeInUp 0.6s ease-out;
}

/* Staggered load-in for research cards (publications & teaching use scroll slide-in) */
.project-card {
    opacity: 0;
    animation: fadeInCard 0.5s ease-out forwards;
}

.project-card:nth-child(1) { animation-delay: 0.1s; }
.project-card:nth-child(2) { animation-delay: 0.2s; }
.project-card:nth-child(3) { animation-delay: 0.3s; }
.project-card:nth-child(4) { animation-delay: 0.4s; }

/* ============================================
   VIDEO PREVIEW
   ============================================ */
.pub-thumbnail {
    position: relative;
    overflow: hidden;
}

.pub-thumbnail video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 0;
    transition: opacity 0.4s ease;
    z-index: 2;
    background-color: var(--color-bg-alt);
}

/* Show video only after the first frame is ready */
.pub-thumbnail.playing video {
    opacity: 1;
}

.pub-thumbnail.playing img {
    opacity: 0;
}

.pub-thumbnail.is-video-loading::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    background: linear-gradient(
        110deg,
        transparent 30%,
        rgba(255, 255, 255, 0.35) 50%,
        transparent 70%
    );
    background-size: 200% 100%;
    animation: pub-video-shimmer 1.1s ease-in-out infinite;
}

@keyframes pub-video-shimmer {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

#pub-tactex .pub-thumbnail video {
    object-fit: cover;
    object-position: center;
}

/* ============================================
   MAGNETIC BUTTONS
   ============================================ */
.btn-icon {
    /* Existing styles remain, ensuring transitions don't conflict */
    transition: color 0.2s, background-color 0.2s, transform 0.1s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* ============================================
   INTERACTIVE EFFECTS
   ============================================ */

/* Spotlight Effect for Cards - Sensing the user's input */
.spotlight-card {
    position: relative;
    overflow: hidden;
    /* Ensure content is above the spotlight */
    z-index: 1;
}

.spotlight-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    pointer-events: none;
    transition: opacity 0.5s ease;
    opacity: 0;
    background: radial-gradient(
        600px circle at var(--mouse-x, 50%) var(--mouse-y, 50%), 
        var(--spotlight-gradient), 
        transparent 40%
    );
    mix-blend-mode: var(--spotlight-blend);
}

@media (hover: hover) and (pointer: fine) {
    .spotlight-card:hover::after {
        opacity: 1;
    }
}

/* ============================================
   PERF-LITE (narrow / touch Safari) — lighter motion, less compositing
   ============================================ */
html[data-perf-lite] .scroll-progress-container:has(.scroll-progress-bar:not(.scroll-progress--native)) {
    display: none;
}

html[data-perf-lite] .nav {
    will-change: auto;
    transition: background 0.2s ease, border-color 0.2s ease;
}

html[data-perf-lite] .nav.scrolled,
html[data-perf-lite] body.no-scroll .nav {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background: var(--nav-bg-safari);
}

@media (max-width: 768px) {
    html[data-perf-lite] body.no-scroll .nav {
        background: rgba(250, 250, 250, 0.82);
    }

    html[data-perf-lite][data-theme="dark"] body.no-scroll .nav {
        background: rgba(18, 18, 18, 0.86);
    }

    @media (prefers-color-scheme: dark) {
        html[data-perf-lite]:not([data-theme="light"]) body.no-scroll .nav {
            background: rgba(18, 18, 18, 0.86);
        }
    }
}

html[data-perf-lite] .section {
    content-visibility: visible;
    contain-intrinsic-size: auto;
}

html[data-perf-lite] h2.section-title {
    will-change: auto;
    transition: none;
    animation: none;
}

html[data-perf-lite] h2.section-title.active {
    transform: none;
}

html[data-perf-lite] .section-title::after {
    transition: none;
}

html[data-perf-lite] .section-title.active::after {
    width: 100%;
}

html[data-perf-lite] .hero-content {
    animation: none;
}

html[data-perf-lite] .project-card {
    animation: none;
    opacity: 1;
    transform: none;
}

html[data-perf-lite] .pub-thumbnail,
html[data-perf-lite] .pub-thumbnail.loaded {
    animation: none;
}

html[data-perf-lite] .pub-thumbnail.is-video-loading::after {
    animation: none;
    display: none;
}

html[data-perf-lite] .pub-item {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

html[data-perf-lite] .pub-abstract {
    transition: max-height 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

html[data-perf-lite] .animate-on-scroll {
    transform: none;
    transition: opacity 0.28s ease-out;
}

html[data-perf-lite] .publications-list > .pub-item.animate-on-scroll,
html[data-perf-lite] #teaching .teaching-list > .course-item.animate-on-scroll,
html[data-perf-lite] #contact .contact-info.animate-on-scroll,
html[data-perf-lite] #contact .contact-note.animate-on-scroll {
    transform: none;
    transition: opacity 0.28s ease-out;
    transition-delay: 0s !important;
}

html[data-perf-lite] .publications-list > .pub-item.animate-on-scroll.is-visible,
html[data-perf-lite] #teaching .teaching-list > .course-item.animate-on-scroll.is-visible,
html[data-perf-lite] #contact .contact-info.animate-on-scroll.is-visible,
html[data-perf-lite] #contact .contact-note.animate-on-scroll.is-visible {
    transform: none;
}

@media (prefers-reduced-motion: reduce) {
    .animate-on-scroll {
        transform: none !important;
        transition: opacity 0.2s ease !important;
    }

    .publications-list > .pub-item.animate-on-scroll,
    #teaching .teaching-list > .course-item.animate-on-scroll {
        transform: none !important;
        transition-delay: 0s !important;
    }
}

body.reduced-effects .spotlight-card::after {
    display: none !important;
}

body.reduced-effects *,
body.reduced-effects *::before,
body.reduced-effects *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
}

/* Print styles */
@media print {
    .nav {
        display: none;
    }
    
    .hero {
        min-height: auto;
        padding: var(--space-lg);
    }
    
    .section {
        padding: var(--space-lg);
    }
    
    .pub-item,
    .project-card {
        break-inside: avoid;
    }
}

/* Scroll Progress Bar */
.scroll-progress-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    z-index: 1001; /* Above nav */
    background: transparent;
    pointer-events: none;
}

.scroll-progress-bar {
    height: 100%;
    background: var(--color-accent);
    width: 100%;
    transform: scaleX(0);
    transform-origin: left center;
    /* No CSS transition: JS updates transform every frame; interpolating fights the updates and stutters. */
    transition: none;
    box-shadow: 0 0 8px var(--color-accent);
}

/* Progress tied to root scroll on the compositor (no per-frame JS). */
@keyframes scroll-progress-fill {
    from {
        transform: scaleX(0);
    }
    to {
        transform: scaleX(1);
    }
}

@supports (animation-timeline: scroll(root block)) {
    .scroll-progress-bar.scroll-progress--native {
        box-shadow: none;
        animation-name: scroll-progress-fill;
        animation-duration: auto;
        animation-timing-function: linear;
        animation-fill-mode: both;
        animation-timeline: scroll(root block);
    }
}

@supports (animation-timeline: scroll(root)) {
    @supports not (animation-timeline: scroll(root block)) {
        .scroll-progress-bar.scroll-progress--native {
            box-shadow: none;
            animation-name: scroll-progress-fill;
            animation-duration: auto;
            animation-timing-function: linear;
            animation-fill-mode: both;
            animation-timeline: scroll(root);
        }
    }
}

/* Hide on mobile if preferred, or keep small */
@media (max-width: 768px) {
    .scroll-progress-container {
        height: 2px;
        contain: layout paint;
        isolation: isolate;
    }

    /* Glow repaints the full bar each frame when driven from JS. */
    .scroll-progress-bar:not(.scroll-progress--native) {
        box-shadow: none;
    }

    /* content-visibility can cause extra layout work while scrolling on some mobile GPUs */
    .section {
        content-visibility: visible;
        contain-intrinsic-size: auto;
    }

    h2.section-title {
        will-change: auto;
        transition: transform 0.25s ease-out;
    }

    h2.section-title.active {
        transform: none;
    }

    .section-title::after {
        transition: width 0.22s ease-out;
    }

    .animate-on-scroll {
        transition: opacity 0.26s ease-out, transform 0.26s ease-out;
    }

    .publications-list > .pub-item.animate-on-scroll {
        transform: none;
        transition:
            opacity 0.32s cubic-bezier(0.22, 1, 0.36, 1),
            box-shadow 0.25s ease,
            border-color 0.25s ease;
    }

    #teaching .teaching-list > .course-item.animate-on-scroll {
        transform: translateY(1.25rem);
        transition:
            opacity 0.32s cubic-bezier(0.22, 1, 0.36, 1),
            transform 0.32s cubic-bezier(0.22, 1, 0.36, 1),
            box-shadow 0.25s ease,
            border-color 0.25s ease;
    }

    .publications-list > .pub-item.animate-on-scroll:nth-child(1) { transition-delay: 0s; }
    .publications-list > .pub-item.animate-on-scroll:nth-child(2) { transition-delay: 0.03s; }
    .publications-list > .pub-item.animate-on-scroll:nth-child(3) { transition-delay: 0.05s; }
    .publications-list > .pub-item.animate-on-scroll:nth-child(4) { transition-delay: 0.07s; }

    #teaching .teaching-list > .course-item.animate-on-scroll:nth-child(1) { transition-delay: 0s; }
    #teaching .teaching-list > .course-item.animate-on-scroll:nth-child(2) { transition-delay: 0.03s; }
    #teaching .teaching-list > .course-item.animate-on-scroll:nth-child(3) { transition-delay: 0.06s; }
}

/* ============================================
   DYNAMICALLY INJECTED STYLES (Previously in script.js)
   ============================================ */
.animate-on-scroll {
    opacity: 0;
    transform: translateY(18px);
    transition: opacity 0.36s ease-out, transform 0.36s ease-out;
}

.animate-on-scroll.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Publications: fade in only (translateY left empty space above the first card) */
.publications-list > .pub-item.animate-on-scroll {
    transform: none;
    transition:
        opacity 0.4s cubic-bezier(0.22, 1, 0.36, 1),
        box-shadow 0.35s ease,
        border-color 0.35s ease;
}

/* Teaching: upward slide + stagger on scroll into view */
#teaching .teaching-list > .course-item.animate-on-scroll {
    transform: translateY(2rem);
    transition:
        opacity 0.4s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.4s cubic-bezier(0.22, 1, 0.36, 1),
        box-shadow 0.35s ease,
        border-color 0.35s ease;
}

.publications-list > .pub-item.animate-on-scroll:nth-child(1) { transition-delay: 0s; }
.publications-list > .pub-item.animate-on-scroll:nth-child(2) { transition-delay: 0.04s; }
.publications-list > .pub-item.animate-on-scroll:nth-child(3) { transition-delay: 0.07s; }
.publications-list > .pub-item.animate-on-scroll:nth-child(4) { transition-delay: 0.1s; }

#teaching .teaching-list > .course-item.animate-on-scroll:nth-child(1) { transition-delay: 0s; }
#teaching .teaching-list > .course-item.animate-on-scroll:nth-child(2) { transition-delay: 0.05s; }
#teaching .teaching-list > .course-item.animate-on-scroll:nth-child(3) { transition-delay: 0.09s; }

.publications-list > .pub-item.animate-on-scroll.is-visible {
    opacity: 1;
}

#teaching .teaching-list > .course-item.animate-on-scroll.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* ----- About-section link preview popover ----- */
.link-preview {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    width: max-content;
    max-width: min(340px, calc(100vw - 16px));
    padding: 0.75rem 0.9rem;
    background-color: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.06);
    opacity: 0;
    visibility: hidden;
    transform: translateY(4px);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
    pointer-events: none;
    font-size: 0.85rem;
    line-height: 1.45;
}

.link-preview.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.link-preview[data-placement="bottom"] {
    transform: translateY(-4px);
}

.link-preview[data-placement="bottom"].is-visible {
    transform: translateY(0);
}

.link-preview::before {
    content: '';
    position: absolute;
    left: var(--arrow-x, 50%);
    width: 10px;
    height: 10px;
    background-color: inherit;
    border: 1px solid var(--color-border);
    transform: translateX(-50%) rotate(45deg);
}

.link-preview[data-placement="top"]::before {
    bottom: -6px;
    border-top: none;
    border-left: none;
}

.link-preview[data-placement="bottom"]::before {
    top: -6px;
    border-bottom: none;
    border-right: none;
}

.link-preview-head {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin-bottom: 0.4rem;
}

.link-preview-favicon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    border-radius: 4px;
    background-color: var(--color-bg-alt);
    object-fit: contain;
}

.link-preview-titles {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.25;
}

.link-preview-title {
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.link-preview-domain {
    font-size: 0.72rem;
    color: var(--color-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.link-preview-desc {
    margin: 0;
    color: var(--color-text-muted);
    font-size: 0.82rem;
    line-height: 1.5;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .link-preview {
        box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.3);
    }
}

[data-theme="dark"] .link-preview {
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.3);
}

@media (max-width: 768px), (hover: none), (pointer: coarse) {
    .link-preview,
    .map-preview {
        display: none !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .link-preview {
        transition: opacity 0.05s linear, visibility 0.05s;
        transform: none !important;
    }
}

/* ----- Contact address map preview ----- */
.map-preview {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    box-sizing: border-box;
    width: min(200px, calc(100vw - 16px));
    padding: 0.3rem 0.35rem 0.32rem;
    background-color: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.06);
    opacity: 0;
    visibility: hidden;
    transform: translateY(4px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
    pointer-events: none;
}

.map-preview.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.map-preview[data-placement="bottom"] {
    transform: translateY(-4px);
}

.map-preview[data-placement="bottom"].is-visible {
    transform: translateY(0);
}

.map-preview::before {
    content: '';
    position: absolute;
    left: var(--arrow-x, 50%);
    width: 10px;
    height: 10px;
    background-color: inherit;
    border: 1px solid var(--color-border);
    transform: translateX(-50%) rotate(45deg);
}

.map-preview[data-placement="top"]::before {
    bottom: -6px;
    border-top: none;
    border-left: none;
}

.map-preview[data-placement="bottom"]::before {
    top: -6px;
    border-bottom: none;
    border-right: none;
}

.map-preview[data-placement="right"] {
    transform: translateX(-4px);
}

.map-preview[data-placement="right"].is-visible {
    transform: translateX(0);
}

.map-preview[data-placement="right"]::before {
    left: -6px;
    top: var(--arrow-y, 50%);
    bottom: auto;
    border-top: none;
    border-right: none;
    transform: translateY(-50%) rotate(45deg);
}

.map-preview[data-placement="left"] {
    transform: translateX(4px);
}

.map-preview[data-placement="left"].is-visible {
    transform: translateX(0);
}

.map-preview[data-placement="left"]::before {
    right: -6px;
    left: auto;
    top: var(--arrow-y, 50%);
    bottom: auto;
    border-bottom: none;
    border-left: none;
    transform: translateY(-50%) rotate(45deg);
}

.map-preview-image {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 2 / 1;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--color-border-light);
    background-color: var(--color-bg-alt);
}

.map-preview-credit {
    display: block;
    margin: 0.2rem 0.15rem 0;
    font-size: 0.65rem;
    color: var(--color-text-light);
    line-height: 1.3;
}

.map-preview-caption {
    margin: 0.22rem 0 0;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--color-text);
    line-height: 1.25;
}

.map-preview-hint {
    display: block;
    margin: 0.05rem 0 0;
    font-size: 0.625rem;
    color: var(--color-text-muted);
    line-height: 1.2;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .map-preview {
        box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.3);
    }
}

[data-theme="dark"] .map-preview {
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.3);
}

@media (prefers-reduced-motion: reduce) {
    .map-preview {
        transition: opacity 0.05s linear, visibility 0.05s;
        transform: none !important;
    }
}
