/* ================================
   Reset & Base Styles
   ================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ========== 紧凑化 Spacing 变量系统 ========== */
:root {
    /* 颜色系统 */
    --color-black: #111;
    --color-white: #ffffff;
    --color-gray-dark: #666;   /* 用于边框和按钮背景 */
    --color-gray-medium: #888;
    --color-gray-light: #aaa;
    --color-bg-alt: #fafafa;
    
    /* 文字颜色层级（全站统一系统） */
    --text-primary: #111111;                /* 主文字：标题、重要内容 */
    --text-secondary: rgba(17, 17, 17, 0.70); /* 次级文字：正文、描述 */
    --text-tertiary: rgba(17, 17, 17, 0.55);  /* 辅助文字：小标题、注释 */
    
    /* 背景系统 */
    --bg-base: #F3F4F6;       /* 雾面浅灰 */
    --bg-alt: #EEF0F3;        /* 分区浅灰 */
    
    /* 紧凑化 Spacing：缩小30-40% */
    --spacing-xs: 8px;
    --spacing-sm: 12px;
    --spacing-md: 24px;
    --spacing-lg: 48px;
    --spacing-xl: 64px;
    
    /* 其他 */
    --max-width: 1200px;
    --border-radius: 8px;
    --transition: all 0.25s ease;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 20px;
}

body {
    font-family: "Source Han Sans SC", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    background: linear-gradient(180deg, #F5F6F8 0%, #F2F3F6 100%);
    color: var(--text-primary);
    line-height: 1.7;
    font-size: 16px;
    position: relative;
    z-index: 0;
    overflow-x: hidden;
}

/* ================================
   Typography
   ================================ */

h1, h2, h3 {
    font-family: "HarmonyOS Sans SC", "Source Han Sans SC", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    font-weight: 500;
    line-height: 1.3;
    color: var(--text-primary);
}

/* 统一段落和常见文本元素颜色 */
p, li, span {
    color: var(--text-secondary);
}

h1 {
    font-size: 2.5rem;
    letter-spacing: 0.02em;
}

h2 {
    font-size: 2rem;
    letter-spacing: 0.01em;
}

h3 {
    font-size: 1.4rem;
    letter-spacing: 0.01em;
}

p {
    margin-bottom: 0;
}

a {
    text-decoration: none;
    color: inherit;
}

/* ================================
   Layout
   ================================ */

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

.section {
    padding: var(--spacing-lg) 0;
    position: relative;
    z-index: 1;
}

.section-alt {
    background-color: var(--color-bg-alt);
}

/* ========== Hero 封面区域（左文右图，人物贴近底部线） ========== */
.hero-section {
    padding: var(--spacing-xl) 0 0;
    border-bottom: 1px solid var(--color-black);
    overflow: hidden;
    position: relative;
    z-index: 1;
}

.hero-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
    align-items: flex-end;
    min-height: 420px;
    position: relative;
}

/* 背景级超大标题 PORTFOLIO */
.hero-bg-title {
    position: absolute;
    top: clamp(18px, 3vw, 42px);
    left: clamp(24px, 4vw, 72px);
    
    font-family: "Space Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: clamp(96px, 10vw, 190px);
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 0.85;
    
    color: rgba(0, 0, 0, 0.07);
    
    z-index: 0;
    pointer-events: none;
    user-select: none;
    white-space: nowrap;
    
    filter: blur(0.2px);
}

.hero-left {
    max-width: 560px;
    padding-bottom: var(--spacing-lg);
    position: relative;
    z-index: 1;
}

.hero-name {
    font-size: 3rem;
    margin-bottom: var(--spacing-xs);
    font-weight: 600;
    color: var(--text-primary);
}

.hero-title-cn {
    font-size: 1.2rem;
    margin-bottom: 4px;
    font-weight: 400;
    color: var(--text-primary);
}

.hero-title-en {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 300;
    margin-bottom: var(--spacing-md);
}

.hero-intro {
    margin: var(--spacing-md) 0;
}

.hero-intro p {
    line-height: 1.8;
    color: var(--text-secondary);
}

.hero-buttons {
    display: flex;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-md);
}

.hero-right {
    display: flex;
    justify-content: flex-end;
    align-items: flex-end;
    height: 100%;
    overflow: hidden;
    margin-left: -60px;
    position: relative;
    z-index: 1;
}

.hero-image {
    width: 480px;
    height: 650px;
    object-fit: cover;
    object-position: 50% 20%;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.06));
    display: block;
}

/* ========== About 精简区块 ========== */
.about-section {
    padding: var(--spacing-lg) 0 var(--spacing-md);
}

.section-title-small {
    font-size: 1.3rem;
    font-weight: 500;
    margin-bottom: var(--spacing-sm);
    letter-spacing: 0.05em;
    color: var(--text-primary);
}

.about-text-compact {
    max-width: 900px;
    line-height: 1.8;
    color: var(--text-secondary);
}

/* ================================
   Section Headers（缩小间距）
   ================================ */

.section-header {
    margin-bottom: var(--spacing-md);
    text-align: left;
}

.section-title {
    font-size: 1.8rem;
    margin-bottom: 6px;
    letter-spacing: 0.05em;
    color: var(--text-primary);
}

.section-subtitle {
    font-family: "Space Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 0.95rem;
    color: var(--text-tertiary);
    font-weight: 300;
    letter-spacing: 0.02em;
}

/* ================================
   Projects Grid（紧凑布局）
   ================================ */

.projects-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-md);
}

/* ================================
   Project Cards（统一紧凑化）
   ================================ */

.project-card {
    background-color: var(--color-white);
    border: 1px solid var(--color-black);
    padding: 28px;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.section-alt .project-card {
    background-color: var(--color-white);
}

.project-card:hover {
    box-shadow: 0 3px 16px rgba(0, 0, 0, 0.08);
    border-color: var(--color-gray-dark);
}

.project-content {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    height: 100%;
}

.project-title {
    font-size: 1.4rem;
    margin-bottom: 6px;
    line-height: 1.3;
    font-weight: 500;
    color: var(--text-primary);
}

.project-subtitle {
    font-size: 0.9rem;
    color: var(--text-tertiary);
    margin-bottom: 6px;
    font-weight: 300;
}

.project-description {
    color: var(--text-secondary);
    line-height: 1.75;
    margin-bottom: var(--spacing-sm);
    flex-grow: 1;
    font-size: 0.95rem;
}

/* ========== 新增：能力标签样式 ========== */
.project-skills {
    font-size: 0.85rem;
    color: var(--text-tertiary);
    line-height: 1.5;
    font-style: italic;
    margin-bottom: var(--spacing-sm);
}

/* ================================
   Buttons（统一样式 - 小按钮，禁止长条）
   ================================ */

.project-buttons {
    display: flex;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
    margin-top: auto;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    padding: 10px 14px;
    font-size: 14px;
    transition: var(--transition);
    cursor: pointer;
    border: 1px solid var(--color-black);
    text-align: center;
    border-radius: 10px;
    font-family: inherit;
    background: transparent;
    white-space: nowrap;
}

.btn-primary {
    background-color: var(--color-black);
    color: var(--color-white);
}

.btn-primary:hover {
    background-color: var(--color-gray-dark);
}

.btn-secondary {
    background-color: var(--color-white);
    color: var(--color-black);
}

.btn-secondary:hover {
    background-color: var(--color-bg-alt);
}

/* ========== 简历弹窗 Modal（A4预览尺寸优化）========== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.active {
    display: flex;
    opacity: 1;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.75);
    cursor: pointer;
}

.modal-content {
    position: relative;
    background-color: var(--color-white);
    max-width: min(900px, 92vw);
    max-height: 92vh;
    border-radius: var(--border-radius);
    overflow: hidden;
    z-index: 10000;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    background-color: var(--color-white);
    border: 1px solid var(--color-black);
    border-radius: 50%;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    transition: var(--transition);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background-color: var(--color-black);
    color: var(--color-white);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.resume-image {
    max-width: 100%;
    max-height: 85vh;
    height: auto;
    width: auto;
    object-fit: contain;
    display: block;
}

.modal-footer {
    padding: var(--spacing-sm) var(--spacing-md);
    border-top: 1px solid var(--color-gray-light);
    text-align: center;
    flex-shrink: 0;
}

.modal-link {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-decoration: underline;
}

.modal-link:hover {
    color: var(--text-primary);
}

/* ================================
   Footer
   ================================ */

.footer {
    padding: var(--spacing-md) 0;
    border-top: 1px solid var(--color-black);
    margin-top: var(--spacing-lg);
}

.footer-content {
    text-align: center;
    color: var(--text-tertiary);
    font-size: 0.9rem;
}

/* ================================
   Responsive Design（移动端优化）
   ================================ */

@media (max-width: 900px) {
    /* Hero 区域改为上下布局 */
    .hero-content {
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
        min-height: auto;
    }
    
    .hero-left {
        padding-bottom: var(--spacing-md);
    }
    
    .hero-bg-title {
        font-size: clamp(72px, 14vw, 140px);
        left: 20px;
        top: 14px;
    }
    
    .hero-right {
        justify-content: center;
        order: -1; /* 人物图移到上方 */
        margin-left: 0;
    }
    
    .hero-image {
        width: 100%;
        max-width: 360px;
        height: auto;
        max-height: 400px;
        object-fit: cover;
        object-position: 50% 25%;
    }
    
    .hero-name {
        font-size: 2.5rem;
    }
    
    /* 项目网格改为单列 */
    .projects-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.25rem;
    }
    
    .hero-name {
        font-size: 2rem;
    }
    
    .hero-bg-title {
        font-size: clamp(64px, 14vw, 120px);
        left: 16px;
        top: 12px;
        color: rgba(0, 0, 0, 0.06);
    }

    .section {
        padding: var(--spacing-md) 0;
    }
    
    .hero-section {
        padding: var(--spacing-md) 0 0;
    }
    
    .about-section {
        padding: var(--spacing-md) 0 var(--spacing-sm);
    }

    .section-header {
        margin-bottom: var(--spacing-sm);
    }

    .projects-grid {
        gap: var(--spacing-sm);
    }

    .project-card {
        padding: 20px;
    }

    .project-buttons {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .btn {
        width: auto;
    }
    
    .hero-buttons {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .hero-buttons .btn {
        width: auto;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 var(--spacing-sm);
    }
    
    .hero-name {
        font-size: 1.75rem;
    }
    
    .hero-bg-title {
        font-size: clamp(56px, 15vw, 100px);
        left: 12px;
        top: 8px;
        opacity: 0.7;
    }
    
    .hero-image {
        height: clamp(240px, 45vh, 320px);
        max-height: 320px;
    }
    
    .project-card {
        padding: 16px;
    }
    
    .modal-content {
        max-width: 95vw;
        max-height: 95vh;
    }
    
    .resume-image {
        max-height: 82vh;
    }
}

/* ================================
   Print Styles
   ================================ */

@media print {
    .hero-section {
        border-bottom: 2px solid var(--color-black);
    }
    
    .modal {
        display: none;
    }

    .project-card {
        page-break-inside: avoid;
        border: 2px solid var(--color-black);
    }

    .btn {
        border: 2px solid var(--color-black);
    }
    
    .footer {
        border-top: 2px solid var(--color-black);
    }
}

/* ================================
   全局背景系统 v3（Blueprint + 柔光 + 鼠标光晕）
   层级顺序（从下到上）：Body雾面灰 -> Glow柔光 -> Grid网格 -> Cursor光晕 -> 内容
   ================================ */

/* 背景系统容器（全屏固定，在所有内容下方） */
.bg-system {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    overflow: hidden;
}

/* Layer 1: 柔光层（超慢漂移，空间感来源） */
.bg-glow {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    
    background: 
        radial-gradient(600px 420px at 28% 22%, rgba(255, 255, 255, 0.65), transparent 65%),
        radial-gradient(720px 520px at 72% 78%, rgba(220, 225, 235, 0.35), transparent 70%);
    
    filter: blur(70px);
    opacity: 0.35;
    
    animation: glowFloat 48s ease-in-out infinite;
    will-change: transform;
}

@keyframes glowFloat {
    0%   { transform: translate3d(-1.2%, -0.8%, 0) scale(1.02); }
    50%  { transform: translate3d( 1.2%,  0.8%, 0) scale(1.05); }
    100% { transform: translate3d(-1.2%, -0.8%, 0) scale(1.02); }
}

/* Layer 2: Blueprint微纹理网格（几乎看不见但存在） */
.bg-grid {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    
    background-image: 
        /* 小网格 24px */
        linear-gradient(to right, rgba(0, 0, 0, 0.04) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(0, 0, 0, 0.04) 1px, transparent 1px),
        /* 大网格 120px（每5个小网格一条略明显的线） */
        linear-gradient(to right, rgba(0, 0, 0, 0.06) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(0, 0, 0, 0.06) 1px, transparent 1px);
    
    background-size: 
        24px 24px,
        24px 24px,
        120px 120px,
        120px 120px;
    
    background-position: 0 0, 0 0, 0 0, 0 0;
    
    filter: blur(0.15px);
    opacity: 0.55;
    mix-blend-mode: multiply;
    
    will-change: transform;
    transition: transform 0.12s ease-out;
}

/* Layer 3: 鼠标光晕层（跟随鼠标移动） */
.bg-cursor {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    
    background: radial-gradient(
        circle 320px at var(--mx, 50%) var(--my, 50%),
        rgba(255, 255, 255, 0.35),
        rgba(255, 255, 255, 0.10) 40%,
        transparent 70%
    );
    
    mix-blend-mode: soft-light;
    opacity: 0.35;
    
    will-change: background-position;
    transition: opacity 0.3s ease;
}

/* 移动端优化：关闭光晕，减少柔光模糊 */
@media (max-width: 768px) {
    .bg-glow {
        filter: blur(40px);
        opacity: 0.25;
    }
    
    .bg-grid {
        opacity: 0.4;
    }
    
    .bg-cursor {
        display: none; /* 触屏设备不显示鼠标光晕 */
    }
}

/* ================================
   自定义圆形鼠标光标（Cursor Follower）
   ================================ */

/* 桌面端隐藏系统鼠标 */
@media (hover: hover) and (pointer: fine) {
    body {
        cursor: none;
    }
    
    a, button, .btn, [role="button"], input, textarea {
        cursor: none;
    }
}

/* 圆形光标样式 */
#cursor-dot {
    position: fixed;
    top: 0;
    left: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(17, 17, 17, 0.85);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
    pointer-events: none;
    z-index: 99999;
    
    /* 性能关键：只用 transform 移动 */
    transform: translate3d(-100px, -100px, 0);
    will-change: transform;
    transition: none;
}

/* 鼠标按下时轻微缩放 */
#cursor-dot.is-down {
    transform: translate3d(var(--cx), var(--cy), 0) scale(0.88);
    transition: transform 0.1s cubic-bezier(0.22, 1, 0.36, 1);
}

/* hover 可点击元素时变化 */
#cursor-dot.is-hover {
    background: rgba(17, 17, 17, 0.95);
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.22);
    transform: translate3d(var(--cx), var(--cy), 0) scale(1.15);
    transition: transform 0.15s cubic-bezier(0.22, 1, 0.36, 1),
                background 0.15s ease,
                box-shadow 0.15s ease;
}

/* 移动端/触屏禁用 */
@media (hover: none), (pointer: coarse) {
    #cursor-dot {
        display: none;
    }
    
    body, a, button, .btn {
        cursor: auto;
    }
}
