/* ===== 基础 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --color-primary: #111827;
    --color-primary-dark: #000000;
    --color-text: #1f2937;
    --color-text-light: #6b7280;
    --color-text-muted: #9ca3af;
    --color-bg: #ffffff;
    --color-bg-alt: #f7f7f8;
    --color-border: #e5e7eb;
    --color-border-strong: #d1d5db;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 2px rgba(17, 24, 39, 0.04);
    --shadow-hover: 0 4px 12px rgba(17, 24, 39, 0.08);
    --card-pad: 24px;
    --max-width: 960px;
}

html {
    scroll-behavior: smooth;
}

/* 防止任何元素撑出横向滚动（移动端兜底） */
html, body {
    max-width: 100%;
    overflow-x: hidden;
}

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

/* 锚点跳转时为 sticky 导航预留空间，避免标题被遮 */
section[id] {
    scroll-margin-top: 80px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.75;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
}

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 24px;
}

/* ===== ① 顶部导航 ===== */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--color-border);
}

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

.nav-name {
    font-weight: 800;
    font-size: 1.05rem;
    letter-spacing: 0.02em;
    color: var(--color-primary);
}

.nav-links {
    display: flex;
    gap: 28px;
}

.nav-links a {
    font-size: 0.92rem;
    color: var(--color-text-light);
    transition: color 0.2s;
    position: relative;
}

.nav-links a:hover {
    color: var(--color-primary);
}

.nav-links a.active {
    color: var(--color-primary);
    font-weight: 600;
}

.nav-links a.active::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -6px;
    height: 2px;
    background: var(--color-primary);
    border-radius: 2px;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
}

.nav-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--color-text);
    border-radius: 2px;
    transition: 0.3s;
}

/* ===== ② 首屏 ===== */
.hero {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 60px);
    padding: 80px 24px;
    background: linear-gradient(180deg, var(--color-bg-alt) 0%, var(--color-bg) 100%);
}

.hero-inner {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 48px;
    max-width: var(--max-width);
    width: 100%;
}

.hero-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 20px;
    flex: 1;
    min-width: 0;
}

.avatar {
    width: clamp(180px, 16vw, 300px);   /* 随页面宽度缩放：最小180px，最大300px */
    height: auto;
    aspect-ratio: 1;                            /* 始终保持正圆 */
    border-radius: 50%;
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    font-weight: 600;
    font-size: 1rem;
    overflow: hidden;      /* 头像图片裁剪在圆圈内 */
    flex: none;            /* 防止被 flex 布局拉伸 */
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;     /* 等比裁剪填充圆形 */
    display: block;
}

.hero-name {
    font-size: clamp(3rem, 8vw, 5rem);
    font-weight: 800;
    letter-spacing: 0.02em;
    line-height: 1.1;
}

.hero-tagline {
    font-size: 1.15rem;
    color: var(--color-text-light);
    line-height: 1.7;
}

.hero-actions {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    justify-content: flex-start;
    margin-top: 8px;
}

.btn {
    padding: 12px 28px;
    border-radius: 999px;
    font-size: 0.95rem;
    font-weight: 600;
    transition: transform 0.15s, background 0.2s, border-color 0.2s, color 0.2s;
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--color-primary-dark);
    transform: translateY(-2px);
}

.btn-ghost {
    background: transparent;
    color: var(--color-primary);
    border: 1.5px solid var(--color-border-strong);
}

.btn-ghost:hover {
    border-color: var(--color-primary);
    background: var(--color-bg-alt);
    transform: translateY(-2px);
}

/* ===== 通用区块 ===== */
.section {
    padding: 80px 0;
}

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

.section-title {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: 0.01em;
    margin-bottom: 40px;
    text-align: center;
}

/* ===== ③ 教育背景 ===== */
.edu-card {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: var(--card-pad);
    box-shadow: var(--shadow);
    flex-wrap: wrap;
    gap: 12px;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.edu-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
    border-color: var(--color-border-strong);
}

.edu-school {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.edu-major {
    color: var(--color-text-light);
    font-size: 0.98rem;
}

.edu-time {
    color: var(--color-text-light);
    font-size: 0.95rem;
    white-space: nowrap;
}

.edu-detail {
    margin-top: 20px;
    padding-left: 28px;
    color: var(--color-text-light);
    line-height: 1.8;
}

.edu-detail li {
    margin-bottom: 6px;
}

/* ===== ④ 项目经历 ===== */
.project-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

.project-card {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: var(--card-pad);
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.project-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
    border-color: var(--color-border-strong);
}

.project-title {
    font-size: 1.2rem;
    font-weight: 700;
}

.project-desc {
    color: var(--color-text-light);
    font-size: 0.95rem;
    line-height: 1.75;
    flex: 1;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag {
    font-size: 0.8rem;
    background: var(--color-bg-alt);
    color: var(--color-text);
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
}

/* ===== ⑤ 技能 ===== */
.skill-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}

.skill {
    padding: 8px 18px;
    border-radius: 999px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    font-size: 0.95rem;
    transition: transform 0.15s, color 0.2s, border-color 0.2s, background 0.2s;
}

.skill:hover {
    color: var(--color-primary);
    border-color: var(--color-border-strong);
    background: var(--color-bg-alt);
    transform: translateY(-2px);
}

/* ===== ⑥ 联系方式 ===== */
.contact-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 480px;
    margin: 0 auto;
}

.contact-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: var(--card-pad);
    box-shadow: var(--shadow);
    transition: transform 0.15s, border-color 0.2s;
}

.contact-item:hover {
    transform: translateY(-2px);
    border-color: var(--color-border-strong);
}

.contact-label {
    color: var(--color-text-light);
    font-size: 0.9rem;
}

.contact-value {
    color: var(--color-primary);
    font-weight: 600;
}

/* ===== 页脚 ===== */
.footer {
    border-top: 1px solid var(--color-border);
    padding: 24px 0;
    color: var(--color-text-light);
    font-size: 0.88rem;
}

.footer-inner {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

.footer-sub {
    margin-top: 8px;
    font-size: 0.82rem;
    color: var(--color-text-muted);
}

/* ===== 响应式 ===== */
@media (max-width: 860px) {
    .project-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .nav-toggle {
        display: flex;
    }

    .nav-links {
        position: absolute;
        top: 60px;
        left: 0;
        right: 0;
        flex-direction: column;
        background: var(--color-bg);
        border-bottom: 1px solid var(--color-border);
        padding: 12px 24px;
        gap: 16px;
        transform: translateY(-150%);
        opacity: 0;
        transition: transform 0.3s, opacity 0.3s;
        pointer-events: none;
    }

    .nav-links.open {
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
    }

    .nav-toggle.open span:nth-child(1) {
        transform: translateY(7px) rotate(45deg);
    }
    .nav-toggle.open span:nth-child(2) {
        opacity: 0;
    }
    .nav-toggle.open span:nth-child(3) {
        transform: translateY(-7px) rotate(-45deg);
    }

    .hero-inner {
        flex-direction: column-reverse;
        text-align: center;
        gap: 28px;
    }

    .hero-text {
        align-items: center;
    }

    .avatar {
        width: 110px;
        height: 110px;
        font-size: 0.9rem;
    }

    .hero-name {
        font-size: clamp(2.4rem, 12vw, 3rem);
    }

    .hero-actions {
        justify-content: center;
    }

    .section {
        padding: 64px 0;
    }

    .edu-card {
        flex-direction: column;
    }

    .footer-inner {
        flex-direction: column;
        text-align: center;
    }
}

/* ===== ⑦ 桌面端右侧悬浮导航 ===== */
.side-nav {
    display: none;
}

@media (min-width: 641px) {
    .nav-links {
        display: none;
    }

    .side-nav {
        display: flex;
        flex-direction: column;
        gap: 6px;
        position: fixed;
        right: 20px;
        top: 50%;
        transform: translateY(-50%);
        z-index: 100;
        background: rgba(255, 255, 255, 0.82);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        border: 1px solid var(--color-border);
        border-radius: 14px;
        padding: 10px 8px;
        box-shadow: 0 4px 16px rgba(17, 24, 39, 0.1);
    }

    .side-nav a {
        font-size: 0.85rem;
        color: var(--color-text-light);
        padding: 8px 14px;
        border-radius: 10px;
        white-space: nowrap;
        transition: color 0.2s, background 0.2s;
    }

    .side-nav a:hover {
        color: var(--color-primary);
        background: var(--color-bg-alt);
    }

    .side-nav a.active {
        color: #fff;
        background: var(--color-primary);
        font-weight: 600;
    }
}

/* 窄桌面（641~1260px）：为右侧悬浮导航预留空间，避免内容被遮挡；
   1260px 以上内容居中后右侧自然留白，无需预留 */
@media (min-width: 641px) and (max-width: 1260px) {
    body {
        padding-right: 150px;
    }
    /* 背景用负 margin 铺回全视口宽，消除右侧露白色差；内容仍由自身 padding 避开导航 */
    .hero, .section, .footer {
        margin-right: -150px;
        padding-right: 150px;
    }
    .hero {
        padding-right: 174px;  /* hero 自带 24px 水平 padding，叠加补齐 */
    }
}
