/* 自定义样式和动画 */

/* 字体设置 */
.font-inter {
    font-family: 'Inter', sans-serif;
}

.font-playfair {
    font-family: 'Playfair Display', serif;
}

/* 平滑滚动 */
html {
    scroll-behavior: smooth;
}

/* 导航栏样式 */
nav {
    transition: all 0.3s ease;
}

/* 导航链接悬停效果 */
.nav-link {
    position: relative;
    text-decoration: none;
    font-weight: 500;
}

.nav-link::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -4px;
    left: 0;
    background-color: #2563eb;
    transition: width 0.3s ease;
}

.nav-link:hover::after {
    width: 100%;
}

/* 英雄区域动画 */
#home {
    animation: fadeInUp 1s ease-out;
}

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

/* 项目卡片动画 */
.project-card {
    animation: fadeIn 0.8s ease-out;
}

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

/* 项目卡片悬停效果增强 */
.project-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

/* 按钮悬停动画 */
button:hover, .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

button:active, .btn:active {
    transform: translateY(0);
}

/* 联系表单输入框样式 */
input:focus, textarea:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* 社交媒体图标悬停效果 */
.social-icon {
    transition: all 0.3s ease;
}

.social-icon:hover {
    transform: translateY(-3px) scale(1.1);
}

/* 页脚链接悬停效果 */
footer a {
    transition: all 0.3s ease;
    position: relative;
}

footer a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 1px;
    bottom: -2px;
    left: 0;
    background-color: #60a5fa;
    transition: width 0.3s ease;
}

footer a:hover::after {
    width: 100%;
}

/* 响应式导航菜单动画 */
#mobile-menu {
    transition: all 0.3s ease;
    transform-origin: top;
}

#mobile-menu:not(.hidden) {
    animation: slideDown 0.3s ease-out;
}

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

/* 滚动时的导航栏效果 */
nav.scrolled {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #2563eb;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 成功消息样式 */
.success-message {
    background: #10b981;
    color: white;
    padding: 1rem;
    border-radius: 0.5rem;
    margin-top: 1rem;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* 错误消息样式 */
.error-message {
    background: #ef4444;
    color: white;
    padding: 1rem;
    border-radius: 0.5rem;
    margin-top: 1rem;
    animation: shake 0.3s ease-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* 技能标签悬停效果 */
.skill-tag {
    transition: all 0.3s ease;
    cursor: default;
}

.skill-tag:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* 图片悬停效果 */
img {
    transition: all 0.3s ease;
}

img:hover {
    filter: brightness(1.05);
}

/* 渐变背景动画 */
.gradient-bg {
    background: linear-gradient(-45deg, #2563eb, #7c3aed, #0891b2, #059669);
    background-size: 400% 400%;
    animation: gradientShift 8s ease infinite;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* 移动端优化 */
@media (max-width: 768px) {
    /* 移动端导航栏 */
    nav .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* 移动端英雄区域 */
    #home h1 {
        font-size: 2.5rem;
    }
    
    /* 移动端项目卡片 */
    .project-card {
        margin-bottom: 1.5rem;
    }
    
    /* 移动端联系表单 */
    #contact-form input,
    #contact-form textarea {
        font-size: 16px; /* 防止iOS缩放 */
    }
}

/* 平板设备优化 */
@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        max-width: 90%;
    }
}

/* 大桌面设备优化 */
@media (min-width: 1280px) {
    .container {
        max-width: 1200px;
    }
}

/* 高分辨率屏幕优化 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* 暗色模式支持（可选） */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #1a1a1a;
        --text-color: #e5e5e5;
    }
}

/* 打印样式 */
@media print {
    nav, footer {
        display: none;
    }
    
    body {
        background: white;
        color: black;
    }
    
    .project-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

/* 可访问性增强 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    html {
        scroll-behavior: auto;
    }
}

/* 焦点样式增强 */
button:focus,
a:focus,
input:focus,
textarea:focus {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

/* 自定义滚动条 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}