/* 解决页面加载闪烁问题 */
html { height: 100%; }
* { margin: 0; padding: 0; box-sizing: border-box; }
/* 全局重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 基础样式 */
body {
    min-height: 100vh;
    font-family: system-ui, -apple-system, sans-serif;
    background: linear-gradient(135deg, #e0e7ff, #d1d5db, #e8eaf6);
    background-size: 200% 200%;
    animation: bgFlow 15s ease infinite;
    transition: background 0.3s ease;
    padding: 0;
    opacity: 0;
    animation: fadeIn 0.6s ease-in-out forwards, bgFlow 15s ease infinite;
}

/* 暗黑模式 */
.dark body {
    background: linear-gradient(135deg, #141516, #0f1112, #1e1b4b);
    background-size: 200% 200%;
}

/* 动画 */
@keyframes bgFlow {
    0% { background-position: 0% 0%; }
    50% { background-position: 100% 100%; }
    100% { background-position: 0% 0%; }
}

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

/* 加载进度条 */
#loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: transparent;
    z-index: 9999;
}

#loader-progress {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #4f46e5, #818cf8);
    transition: width 0.3s ease;
}

/* 链接样式 */
a {
    text-decoration: none;
}

/* 导航栏 */
nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 999;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
    overflow: hidden;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    padding: 0.75rem;
}

.dark nav {
    background: #1f2123;
    border-bottom: 1px solid #374151;
}

nav.scroll {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.dark nav.scroll {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.nav-content {
    max-width: 56rem;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
}

.nav-links a {
    color: #1f2937;
    font-size: 0.875rem;
    transition: color 0.3s ease;
}

.dark .nav-links a {
    color: #f9fafb;
}

/* 卡片容器 */
.card-container {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 1rem;
    transition: all 0.3s ease;
}

.dark .card-container {
    background: #262626;
    border: 1px solid #404040;
}

.shadow-effect {
    box-shadow: 5px 5px 15px rgba(0, 0, 0, 0.08);
}

.dark .shadow-effect {
    box-shadow: 5px 5px 15px rgba(0, 0, 0, 0.4);
}



/* 技能容器 */
.skills-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    width: 100%;
}

@media (min-width: 640px) {
    .skills-container {
        flex-wrap: nowrap;
        max-width: 20rem;
    }
}

.skill-card {
    cursor: default;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    padding: 0.75rem;
    flex: 1;
    text-align: center;
}

.dark .skill-card {
    background: #374151;
    border: 1px solid #4b5563;
}

.skill-card:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
}

.dark .skill-card:hover {
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2);
}

/* 联系方式容器 */
.contact-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    width: 100%;
}

@media (min-width: 640px) {
    .contact-container {
        flex-wrap: nowrap;
        max-width: 30rem;
    }
}

.contact-btn {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    background: #eff6ff;
    border: 1px solid #dbeafe;
    border-radius: 0.75rem;
    padding: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.dark .contact-btn {
    background: #1e3a8a;
    border: 1px solid #3b82f6;
}

.contact-btn:active {
    transform: scale(0.95);
    box-shadow: inset 2px 2px 5px rgba(0, 0, 0, 0.1);
}

.dark .contact-btn:active {
    box-shadow: inset 2px 2px 5px rgba(0, 0, 0, 0.3);
}

/* 项目卡片 */
.project-card {
    cursor: pointer;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    position: relative;
    overflow: hidden;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 1rem;
    padding: 1rem;
}

.dark .project-card {
    background: #262626;
    border: 1px solid #404040;
}

.project-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.dark .project-card:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}

.project-card:active {
    transform: translateY(-2px);
    transition: transform 0.1s ease;
}

.project-card h3 {
    position: relative;
    display: inline-block;
}

.project-card h3::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -2px;
    left: 0;
    background: #4f46e5;
    transition: width 0.3s ease;
}

.project-card:hover h3::after {
    width: 100%;
}

.dark .project-card h3::after {
    background: #818cf8;
}

/* 文字颜色 */
.text-primary {
    color: #1f2937;
    transition: color 0.3s ease;
}

.dark .text-primary {
    color: #f9fafb;
}

.text-secondary {
    color: #4b5563;
    transition: color 0.3s ease;
}

.dark .text-secondary {
    color: #d1d5db;
}

.dark .project-card .text-secondary {
    color: #e5e7eb;
}

/* 区块动画 */
.section-animate {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.section-animate.show {
    opacity: 1;
    transform: translateY(0);
}

/* 通用样式类 */
.w-10 { width: 2.5rem; }
.h-10 { height: 2.5rem; }
.max-w-4xl { max-width: 56rem; }
.mx-auto { margin-left: auto; margin-right: auto; }
.mb-4 { margin-bottom: 1rem; }
.mb-10 { margin-bottom: 2.5rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.5rem; }

main {
    padding-top: 6rem;
    padding-bottom: 3rem;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
    max-width: 56rem;
    margin: 0 auto;
}

.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-5 { padding: 1.25rem; }
.p-6 { padding: 1.5rem; }
.py-1 { padding-top: 0.25rem; padding-bottom: 0.25rem; }
.rounded-full { border-radius: 9999px; }
.rounded-xl { border-radius: 0.75rem; }
.rounded-2xl { border-radius: 1rem; }
.flex { display: flex; }
.grid { display: grid; }
.hidden { display: none; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.text-center { text-align: center; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.font-bold { font-weight: 700; }
.overflow-hidden { overflow: hidden; }
.object-cover { object-fit: cover; }
.mr-1 { margin-right: 0.15rem; }
.ml-2 { margin-left: 0.5rem; }

/* 响应式 */
@media (min-width: 640px) {
    .md\:flex-row { flex-direction: row; }
    .md\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .md\:text-left { text-align: left; }
    .avatar-container {
        width: 7rem;
        height: 7rem;
    }
    main {
        padding-top: 5rem;
    }
}

/* 主题切换按钮 */
.theme-icon {
    font-size: 1.4em;
    line-height: 1;
}

#themeToggle {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    cursor: pointer;
    border: none;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dark #themeToggle {
    background: #374151;
    border: 1px solid #4b5563;
}

#themeToggle:active {
    transform: scale(0.92);
    box-shadow: inset 2px 2px 4px rgba(0,0,0,0.1);
}

.dark #themeToggle:active {
    box-shadow: inset 2px 2px 4px rgba(0,0,0,0.3);
}

/* 头像容器 - 修复版 无遮挡+完美圆形裁切 */
.avatar-container {
    width: 6rem;
    height: 6rem;
    border-radius: 50%;
    overflow: hidden;
    transition: transform 0.5s ease-in-out;
    cursor: pointer;
    flex-shrink: 0;
    z-index: 10;
    position: relative;
    border: 2px solid #4f46e5;
}
.dark .avatar-container {
    border: 2px solid #818cf8;
}
.avatar-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: relative;
    z-index: 11;
}
.avatar-container:hover {
    transform: rotate(360deg);
}
@media (min-width: 640px) {
    .avatar-container {
        width: 7rem;
        height: 7rem;
    }
}
/* 返回顶部按钮 */
#backToTop {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.2s ease;
    z-index: 900;
    border: none;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
}

.dark #backToTop {
    background: #262626;
    border: 1px solid #404040;
}

#backToTop.show {
    opacity: 1;
    visibility: visible;
}

#backToTop:active {
    transform: scale(0.9);
}

.back-icon {
    font-size: 1.2em;
}

/* 页脚 */
footer {
    width: 100%;
    padding: 0.5rem 0;
    text-align: center;
    color: #4b5563;
    font-size: 0.75rem;
}

.dark footer {
    color: #d1d5db;
}