/* ============================================
   Tinghe Zhang — Pro Academic Homepage
   Light / Dark theme
   ============================================ */

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

    --bg: #f8fafc;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #0f172a;
    --muted: #64748b;
    --accent: #2563eb;
    --accent-bg: #eff6ff;

    --nav-h: 64px;
    --max-w: 900px;
    --nav-max-w: 1200px;
    --radius: 12px;
    --radius-sm: 8px;
    --ease: 0.2s ease;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-nav: 0 1px 4px rgba(0, 0, 0, 0.06);
    --space-section: 3.5rem;
    --space-block: 1.5rem;
}

[data-theme="dark"] {
    --bg: #0f172a;
    --surface: #1e293b;
    --border: #334155;
    --text: #f1f5f9;
    --muted: #94a3b8;
    --accent: #60a5fa;
    --accent-bg: rgba(59, 130, 246, 0.15);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-nav: 0 1px 3px rgba(0, 0, 0, 0.25);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    transition: background-color 0.25s ease, color 0.25s ease;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--ease);
}
a:hover {
    text-decoration: underline;
}
a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ----- Nav: full-width bar, single row ----- */
.site-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--nav-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-nav);
    z-index: 1000;
}

.nav-inner {
    max-width: var(--nav-max-w);
    margin: 0 auto;
    padding: 0 2.5rem;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

.nav-brand {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text);
    letter-spacing: 0.02em;
    transition: color var(--ease);
    white-space: nowrap;
}
.nav-brand:hover {
    text-decoration: none;
    color: var(--accent);
}
.nav-brand:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.nav-links {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.25rem 2rem;
    list-style: none;
    font-size: 0.9rem;
}

.nav-link {
    color: var(--muted);
    padding: 0.5rem 0.4rem;
    border-radius: var(--radius-sm);
    transition: color var(--ease), background var(--ease);
    white-space: nowrap;
}
.nav-link:hover,
.nav-link.active {
    color: var(--accent);
    text-decoration: none;
}
.nav-link:hover {
    background: var(--accent-bg);
}
.nav-link:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.theme-toggle {
    padding: 0.45rem 0.9rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--muted);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: color var(--ease), border-color var(--ease), background var(--ease);
    white-space: nowrap;
}
.theme-toggle:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-bg);
}
.theme-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ----- Page: wider content, more air ----- */
.page {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: calc(var(--nav-h) + 2.5rem) 2rem 4rem;
}

/* ----- Hero ----- */
.hero {
    margin-bottom: var(--space-section);
    padding-bottom: 2.5rem;
    border-bottom: 1px solid var(--border);
}

.hero-inner {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2.5rem;
    align-items: start;
}

.hero-name {
    font-size: 2.1rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    margin-bottom: 0.5rem;
    line-height: 1.2;
}

.hero-tagline {
    font-size: 1.05rem;
    color: var(--muted);
    margin-bottom: 1rem;
    min-height: 1.6em;
}

.hero-quote {
    font-size: 0.95rem;
    color: var(--muted);
    font-style: italic;
    margin-bottom: 1.25rem;
    line-height: 1.55;
}

.hero-info {
    font-size: 0.9rem;
    display: grid;
    gap: 0.35rem 1.5rem;
    grid-template-columns: auto 1fr;
}
.hero-info dt {
    color: var(--muted);
    font-weight: 500;
}
.hero-info dd {
    margin: 0;
}

.hero-photo-wrap {
    width: 100%;
    max-width: 220px;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transition: border-color var(--ease), box-shadow var(--ease);
}
.hero-photo-wrap:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.1);
}
[data-theme="dark"] .hero-photo-wrap:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.hero-photo-img {
    display: block;
    max-width: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    vertical-align: middle;
}

/* ----- Blocks ----- */
.block {
    margin-bottom: var(--space-section);
}

.block-title {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text);
    margin-bottom: 1.25rem;
    padding-bottom: 0.6rem;
    border-bottom: 2px solid var(--border);
}

/* ----- Entry ----- */
.entry {
    padding: 1.25rem 0;
    border-bottom: 1px solid var(--border);
    transition: background var(--ease);
    margin: 0 -0.75rem;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
    border-radius: var(--radius-sm);
}
.entry:hover {
    background: var(--accent-bg);
}
.entry:last-child {
    border-bottom: none;
}

.entry-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.entry-title {
    font-size: 1.02rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.4;
}

.entry-date {
    font-size: 0.8rem;
    color: var(--muted);
    white-space: nowrap;
}

.entry-badge {
    font-size: 0.72rem;
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
    background: var(--accent-bg);
    color: var(--accent);
    font-weight: 500;
    letter-spacing: 0.02em;
}
.entry-badge-active {
    background: rgba(34, 197, 94, 0.12);
    color: #16a34a;
}
[data-theme="dark"] .entry-badge-active {
    color: #4ade80;
}

.entry-org,
.entry-desc {
    font-size: 0.925rem;
    color: var(--muted);
    margin-bottom: 0.35rem;
    line-height: 1.55;
}

.entry-meta {
    font-size: 0.8rem;
    color: var(--muted);
}

.entry-desc.placeholder {
    color: var(--muted);
    font-style: italic;
}

/* ----- Paper ----- */
.paper {
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--border);
    margin: 0 -0.75rem;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
    border-radius: var(--radius-sm);
    transition: background var(--ease);
}
.paper:hover {
    background: var(--accent-bg);
}
.paper:last-child {
    border-bottom: none;
}

.paper-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    line-height: 1.45;
    color: var(--text);
}

.paper-authors {
    font-size: 0.875rem;
    color: var(--muted);
    margin-bottom: 0.3rem;
    line-height: 1.5;
}

.paper-venue {
    font-size: 0.825rem;
    color: var(--muted);
    margin-bottom: 0.75rem;
}

.paper-figures {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}
.paper-figures img {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.paper-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.btn {
    display: inline-block;
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--accent);
    background: var(--accent-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color var(--ease), background var(--ease), color var(--ease);
}
.btn:hover {
    text-decoration: none;
    border-color: var(--accent);
    background: var(--accent);
    color: var(--surface);
}
.btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ----- Contact ----- */
.contact-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.contact-card {
    display: block;
    padding: 1.2rem 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: border-color var(--ease), background var(--ease), transform var(--ease), box-shadow var(--ease);
}
.contact-card:hover {
    border-color: var(--accent);
    background: var(--accent-bg);
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.1);
}
[data-theme="dark"] .contact-card:hover {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}
@media (prefers-reduced-motion: reduce) {
    .contact-card:hover {
        transform: none;
    }
}
.contact-card:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.contact-label {
    display: block;
    font-size: 0.75rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.3rem;
}

.contact-value {
    font-size: 0.95rem;
    color: var(--text);
    font-weight: 500;
}

/* ----- Footer ----- */
.site-footer {
    margin-top: 3rem;
    padding: 2rem 2rem;
    border-top: 1px solid var(--border);
    font-size: 0.9rem;
    color: var(--muted);
    background: var(--surface);
}

.footer-inner {
    max-width: var(--nav-max-w);
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.footer-links {
    display: flex;
    gap: 1.25rem;
}
.footer-links a {
    color: var(--muted);
    transition: color var(--ease);
}
.footer-links a:hover {
    color: var(--accent);
}

/* ----- Responsive ----- */
@media (max-width: 900px) {
    .nav-inner {
        padding: 0 1.5rem;
        gap: 1rem;
    }
    .nav-links {
        flex-wrap: wrap;
        gap: 0.25rem 1rem;
    }
}

@media (max-width: 640px) {
    .nav-inner {
        padding: 0 1.25rem;
    }
    .nav-links {
        display: none;
    }

    .page {
        padding-left: 1.25rem;
        padding-right: 1.25rem;
        padding-bottom: 3rem;
    }

    .hero {
        margin-bottom: 2.5rem;
        padding-bottom: 2rem;
    }
    .hero-inner {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    .hero-name {
        font-size: 1.75rem;
    }
    .hero-photo-wrap {
        max-width: 180px;
    }

    .block {
        margin-bottom: 2.5rem;
    }
    .block-title {
        font-size: 1.15rem;
        margin-bottom: 1rem;
    }
}
