/* ================================================================
   张华祯个人主页 - 主样式表

   文件结构说明：
   1. 设计变量：统一管理颜色、间距和阴影
   2. 全局基础：重置浏览器默认样式
   3. 左侧栏：照片、基本信息和外部链接
   4. 右侧正文：简介、动态、论文和项目
   5. 响应式：平板与手机布局

   后续修改颜色或页面宽度时，优先改 :root 中的变量。
   ================================================================ */

/* ---------- 1. 设计变量 ---------- */
:root {
    --font-sans: "Inter", "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
    --color-ink: #172128;
    --color-text: #49565e;
    --color-muted: #78838a;
    --color-line: #dce3e6;
    --color-paper: #ffffff;
    --color-canvas: #f2f5f4;
    --color-sidebar: #f3f5f4;
    --color-accent: #2f7f91;
    --color-accent-soft: #e4f1f2;
    --color-sidebar-text: #29383f;
    --color-sidebar-muted: #6f7e84;

    --page-max-width: 1500px;
    --sidebar-width: 320px;
    --content-max-width: 960px;
    /* 控制每个栏目之间的纵向距离 */
    --section-gap: clamp(2.75rem, 5vw, 4.25rem);
    --shadow-photo: 0 16px 40px rgba(28, 47, 54, 0.12);
}

/* ---------- 2. 全局基础 ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 2rem;
}

body {
    min-width: 320px;
    margin: 0;
    color: var(--color-text);
    background: var(--color-canvas);
    font-family: var(--font-sans);
    /* 正文基准字号：桌面端使用 17px，避免高分辨率屏幕上文字过小 */
    font-size: 17px;
    line-height: 1.75;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

img {
    display: block;
    max-width: 100%;
}

a {
    color: inherit;
}

p,
h1,
h2,
h3 {
    overflow-wrap: anywhere;
}

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

/* 仅在键盘操作时显示“跳到主要内容”按钮 */
.skip-link {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 100;
    padding: 0.65rem 1rem;
    color: var(--color-paper);
    background: var(--color-accent);
    border-radius: 0.35rem;
    text-decoration: none;
    transform: translateY(-200%);
}

.skip-link:focus {
    transform: translateY(0);
}

/* 页面外框：桌面端左侧栏 + 右侧正文 */
.page-shell {
    display: grid;
    grid-template-columns: minmax(290px, var(--sidebar-width)) minmax(0, 1fr);
    max-width: var(--page-max-width);
    min-height: 100vh;
    margin: 0 auto;
    background: var(--color-paper);
    box-shadow: 0 0 80px rgba(25, 48, 57, 0.08);
}

/* ---------- 3. 左侧个人信息栏 ---------- */
.profile-sidebar {
    position: relative;
    color: var(--color-sidebar-text);
    background: var(--color-sidebar);
    border-right: 1px solid var(--color-line);
}

.profile-card {
    position: sticky;
    top: 0;
    display: flex;
    min-height: 100vh;
    padding: clamp(2rem, 4vw, 3.75rem) clamp(1.5rem, 3vw, 2.75rem);
    flex-direction: column;
    justify-content: center;
}

.profile-photo {
    width: min(100%, 200px);
    /* 必须显式覆盖 HTML 图片原始高度，否则原图的 2844px 高度会撑开侧栏 */
    height: auto;
    aspect-ratio: 4 / 5;
    margin-bottom: 2rem;
    object-fit: cover;
    object-position: center 18%;
    border: 1px solid #d5dcde;
    box-shadow: var(--shadow-photo);
}

.profile-heading {
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--color-line);
}

.profile-kicker {
    margin: 0 0 0.65rem;
    color: var(--color-accent);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.18em;
}

.profile-heading h1 {
    margin: 0;
    color: var(--color-ink);
    font-family: var(--font-sans);
    font-size: clamp(1.7rem, 2.3vw, 2.15rem);
    font-weight: 500;
    line-height: 1.1;
    letter-spacing: -0.035em;
}

.name-cn {
    margin: 0.45rem 0 0;
    color: var(--color-sidebar-muted);
    font-size: 1.05rem;
    font-weight: 550;
    letter-spacing: 0.16em;
}

.profile-role {
    max-width: 25ch;
    margin: 1.25rem 0 1.75rem;
    color: var(--color-sidebar-text);
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1.55;
}

.contact-list {
    margin: 0;
    font-style: normal;
}

.contact-list p {
    margin: 0 0 1rem;
    color: var(--color-sidebar-text);
    font-size: 0.92rem;
    line-height: 1.55;
}

.contact-label {
    display: block;
    margin-bottom: 0.15rem;
    color: var(--color-sidebar-muted);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.contact-list a {
    text-decoration-color: #9babb0;
    text-underline-offset: 0.2em;
}

.profile-links {
    display: grid;
    margin-top: 1.25rem;
    border-top: 1px solid var(--color-line);
}

.profile-links a {
    display: flex;
    padding: 0.7rem 0;
    align-items: center;
    justify-content: space-between;
    color: var(--color-sidebar-text);
    border-bottom: 1px solid var(--color-line);
    font-size: 0.84rem;
    font-weight: 650;
    letter-spacing: 0.025em;
    text-decoration: none;
    transition: color 160ms ease, padding 160ms ease;
}

.profile-links a span {
    color: var(--color-accent);
}

.profile-links a:hover,
.profile-links a:focus-visible {
    padding-left: 0.35rem;
    color: var(--color-accent);
}

/* ---------- 4. 右侧正文通用布局 ---------- */
.main-content {
    width: 100%;
    max-width: calc(var(--content-max-width) + clamp(3rem, 10vw, 9rem));
    padding: clamp(3.5rem, 8vw, 7rem) clamp(1.75rem, 6vw, 5rem) 0;
}

.content-section {
    display: grid;
    grid-template-columns: 3rem minmax(0, 1fr);
    gap: clamp(1rem, 3vw, 2.25rem);
    padding-bottom: var(--section-gap);
}

.section-number {
    margin: 0.35rem 0 0;
    color: var(--color-accent);
    font-family: var(--font-sans);
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 0.12em;
}

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

.section-body h2 {
    margin: 0 0 clamp(1rem, 2vw, 1.4rem);
    color: var(--color-ink);
    font-family: var(--font-sans);
    font-size: clamp(1.75rem, 2.8vw, 2.35rem);
    font-weight: 500;
    line-height: 1.08;
    letter-spacing: -0.035em;
}

/* Biography 两段正文采用完全一致的字号与行距，仅用间距划分段落 */
.biography-copy {
    display: grid;
    max-width: 70ch;
    gap: 1.15rem;
}

.biography-copy p {
    margin: 0;
    color: var(--color-text);
    font-size: 1rem;
    line-height: 1.8;
    /* 英文正文使用两端对齐；最后一行保持左对齐，避免被强行拉伸 */
    hyphens: auto;
    text-align: justify;
    text-align-last: left;
    text-justify: inter-word;
}

.section-heading {
    display: flex;
    gap: 1rem;
    margin-bottom: clamp(1rem, 2vw, 1.4rem);
    align-items: flex-end;
    justify-content: space-between;
}

.section-heading h2 {
    margin-bottom: 0;
}

/* 研究方向标签 */
.research-tags {
    display: flex;
    margin: 1.5rem 0 0;
    padding: 0;
    gap: 0.6rem;
    flex-wrap: wrap;
    list-style: none;
}

.research-tags li {
    padding: 0.35rem 0.75rem;
    color: #286573;
    background: var(--color-accent-soft);
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 650;
}

/* 最新动态时间线 */
.news-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.news-item {
    position: relative;
    display: grid;
    grid-template-columns: 7rem minmax(0, 1fr);
    gap: 1.5rem;
    padding: 1.2rem 0;
    border-top: 1px solid var(--color-line);
}

.news-item:last-child {
    border-bottom: 1px solid var(--color-line);
}

.news-item time {
    color: var(--color-accent);
    font-family: var(--font-sans);
    font-size: 0.98rem;
    font-weight: 700;
}

.news-item p {
    margin: 0;
    color: var(--color-text);
}

/* 论文列表：桌面端图片与文字并排，所有内容始终可见 */
.publication-list {
    display: grid;
    gap: 1.75rem;
}

.publication-card {
    display: grid;
    grid-template-columns: minmax(190px, 38%) minmax(0, 1fr);
    gap: clamp(1.25rem, 3vw, 2rem);
    padding-bottom: 1.8rem;
    border-bottom: 1px solid var(--color-line);
}

.publication-image {
    display: block;
    align-self: start;
    overflow: hidden;
    background: #f7f9f9;
    border: 1px solid var(--color-line);
    text-decoration: none;
}

.publication-image img {
    width: 100%;
    aspect-ratio: 16 / 10;
    padding: 0.5rem;
    object-fit: contain;
}

.publication-info {
    align-self: center;
}

.publication-type {
    margin: 0 0 0.65rem;
    color: var(--color-accent);
    font-size: 0.74rem;
    font-weight: 750;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

.publication-info h3,
.project-card h3 {
    margin: 0 0 0.75rem;
    color: var(--color-ink);
    font-family: var(--font-sans);
    font-size: clamp(1.05rem, 1.55vw, 1.24rem);
    font-weight: 600;
    line-height: 1.42;
    /* 标题使用均衡换行，比强制两端对齐更适合较大的英文字体 */
    text-wrap: balance;
}

.journal {
    margin: 0;
    color: var(--color-muted);
    font-size: 0.94rem;
    font-style: italic;
}

.paper-link {
    display: inline-block;
    margin-top: 1.1rem;
    color: var(--color-ink);
    font-size: 0.86rem;
    font-weight: 750;
    letter-spacing: 0.03em;
    text-decoration-color: var(--color-accent);
    text-underline-offset: 0.28em;
}

/* 项目卡片 */
.project-card {
    display: grid;
    grid-template-columns: minmax(190px, 38%) minmax(0, 1fr);
    gap: clamp(1.25rem, 3vw, 2rem);
    align-items: center;
}

.project-card > img {
    width: 100%;
    aspect-ratio: 16 / 10;
    padding: 0.5rem;
    object-fit: contain;
    background: #f7f9f9;
    border: 1px solid var(--color-line);
}

.project-card p:last-child {
    margin: 0;
    color: var(--color-muted);
    font-size: 0.96rem;
}

/* 页脚放在正文底部，与栏目左边缘对齐 */
.site-footer {
    display: flex;
    margin-left: calc(3rem + clamp(1rem, 3vw, 2.25rem));
    padding: 2rem 0;
    gap: 1rem;
    justify-content: space-between;
    color: var(--color-muted);
    border-top: 1px solid var(--color-line);
    font-size: 0.82rem;
}

.site-footer p {
    margin: 0;
}

/* 所有可点击元素的键盘焦点样式 */
a:focus-visible {
    outline: 3px solid rgba(73, 167, 184, 0.5);
    outline-offset: 4px;
}

/* ---------- 5. 平板适配：适当收窄左侧栏 ---------- */
@media (max-width: 1040px) {
    :root {
        --sidebar-width: 290px;
    }

    .profile-card {
        padding-inline: 1.75rem;
    }

    .publication-card,
    .project-card {
        grid-template-columns: minmax(170px, 35%) minmax(0, 1fr);
    }
}

/* 桌面设备高度较小时取消固定，避免左栏底部内容被遮挡 */
@media (max-height: 820px) and (min-width: 861px) {
    .profile-card {
        position: static;
        min-height: auto;
        justify-content: flex-start;
    }
}

/* ---------- 6. 手机适配：改为单栏，个人信息移到顶部 ---------- */
@media (max-width: 860px) {
    html {
        scroll-padding-top: 1rem;
    }

    .page-shell {
        display: block;
        max-width: none;
        box-shadow: none;
    }

    .profile-sidebar {
        border-right: 0;
        border-bottom: 1px solid var(--color-line);
    }

    .profile-card {
        position: static;
        display: grid;
        min-height: auto;
        padding: 2.25rem max(1.25rem, env(safe-area-inset-left)) 2.5rem;
        grid-template-columns: 104px minmax(0, 1fr);
        gap: 0 1.25rem;
        justify-content: initial;
    }

    .profile-photo {
        width: 104px;
        height: auto;
        margin: 0;
        grid-column: 1;
        grid-row: 1 / span 2;
        box-shadow: 0 10px 28px rgba(28, 47, 54, 0.13);
    }

    .profile-heading {
        padding: 0 0 0.85rem;
        align-self: end;
    }

    .profile-kicker {
        font-size: 0.64rem;
    }

    .profile-heading h1 {
        font-size: clamp(1.45rem, 5.5vw, 1.75rem);
    }

    .name-cn {
        font-size: 0.98rem;
    }

    .profile-role {
        max-width: 30ch;
        margin: 0.8rem 0 0;
        align-self: start;
        font-size: 0.9rem;
    }

    .contact-list,
    .profile-links {
        grid-column: 1 / -1;
    }

    .contact-list {
        display: grid;
        margin-top: 1.75rem;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.75rem 1rem;
    }

    .contact-list p {
        margin: 0;
        font-size: 0.84rem;
    }

    .contact-list p:first-child {
        grid-row: span 2;
    }

    .profile-links {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        margin-top: 1.5rem;
    }

    .profile-links a {
        padding: 0.7rem 0.5rem;
        justify-content: center;
        border-right: 1px solid var(--color-line);
        font-size: 0.8rem;
    }

    .profile-links a:last-child {
        border-right: 0;
    }

    .profile-links a span {
        margin-left: 0.3rem;
    }

    .profile-links a:hover,
    .profile-links a:focus-visible {
        padding-left: 0.5rem;
    }

    .main-content {
        max-width: none;
        padding: 3rem max(1.25rem, env(safe-area-inset-left)) 0;
    }

    .content-section {
        grid-template-columns: 1fr;
        gap: 0.55rem;
        padding-bottom: 3.25rem;
    }

    .section-number {
        margin: 0;
    }

    .section-body h2 {
        margin-bottom: 1rem;
        font-size: clamp(1.7rem, 7vw, 2.1rem);
    }

    .section-heading {
        display: block;
        margin-bottom: 1rem;
    }

    .section-heading h2 {
        margin-bottom: 0.5rem;
    }

    .news-item {
        grid-template-columns: 1fr;
        gap: 0.35rem;
        padding: 1.1rem 0;
    }

    .publication-list {
        gap: 1.65rem;
    }

    .publication-card,
    .project-card {
        grid-template-columns: 1fr;
        gap: 1.1rem;
    }

    .publication-card {
        padding-bottom: 1.65rem;
    }

    .publication-image img,
    .project-card > img {
        aspect-ratio: 16 / 9;
    }

    .site-footer {
        display: block;
        margin-left: 0;
        padding-bottom: calc(2rem + env(safe-area-inset-bottom));
    }

    .site-footer p + p {
        margin-top: 0.25rem;
    }
}

/* 极窄屏幕：联系方式与链接改为更稳妥的纵向布局 */
@media (max-width: 440px) {
    .profile-card {
        grid-template-columns: 88px minmax(0, 1fr);
        gap: 0 1rem;
    }

    .profile-photo {
        width: 88px;
    }

    .profile-kicker {
        letter-spacing: 0.1em;
    }

    .profile-heading h1 {
        font-size: 1.45rem;
    }

    .contact-list {
        grid-template-columns: 1fr;
    }

    .contact-list p:first-child {
        grid-row: auto;
    }

    .profile-links {
        grid-template-columns: 1fr;
    }

    .profile-links a {
        justify-content: space-between;
        border-right: 0;
    }
}

/* 尊重系统的“减少动态效果”设置 */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
