/* ===== 全局样式 ===== */
/* 全局通用重置和边界盒模型 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 主题变量定义 */
:root {
    --primary-color: #e63946;
    --secondary-color: #f1faee;
    --text-color: #2d3436;
    --text-light: #636e72;
    --bg-color: #ffffff;
    --bg-light: #f8f9fa;
    --border-color: #e9ecef;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 5px 20px rgba(0, 0, 0, 0.15);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ===== 黑夜模式变量覆盖 ===== */
body.dark-mode,
html.dark-mode {
    --text-color: #fff !important;
    --text-light: #fff !important;
    --bg-color: #0a0a0a !important;
    --bg-light: #191919 !important;
    --border-color: #333 !important;
}

/* 夜间模式下侧边栏颜色单独覆盖 */
body.dark-mode .sidebar,
html.dark-mode .sidebar {
    background-color: #292929 !important;
}

/* ===== End 变量覆盖 ===== */

/* 全局平滑滚动 */
html {
    scroll-behavior: smooth;
    background: var(--bg-color);
}

/* 页面主体样式 */
body {
    font-family: var(--font-family);
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
    overflow-x: hidden;
}

body.dark-mode {
    background: var(--bg-color);
    color: var(--text-color);
}

/* ===== 移动端菜单按钮 ===== */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1001;
    cursor: pointer;
    flex-direction: column;
    gap: 4px;
}

.mobile-menu-toggle span {
    width: 25px;
    height: 3px;
    background-color: var(--text-color);
    transition: var(--transition);
}

.mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}
.mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
}
.mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

/* ===== 侧边导航栏 ===== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 140px;
    height: 100vh;
    background-color: var(--bg-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: var(--transition);
    /* 消除侧边栏收窄导致的底部白条 */
    min-width: 0;
    max-width: 100vw;
    overflow: hidden;
}

body.dark-mode .sidebar {
    background: var(--bg-color);
    border-right: 1px solid var(--border-color);
}

.nav-brand {
    padding: 40px 30px 20px;
    border-bottom: 1px solid var(--border-color);
}

.nav-brand h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-color);
    letter-spacing: -0.5px;
}

.nav-menu {
    flex: 1;
    padding: 30px 0;
    list-style: none;
}

.nav-menu li {
    margin: 0;
}

.nav-link {
    display: block;
    padding: 15px 30px;
    color: var(--text-light);
    text-decoration: none;
    font-weight: 400;
    font-size: 0.95rem;
    transition: var(--transition);
    position: relative;
}

body.dark-mode .nav-link.active,
body.dark-mode .nav-link:hover {
    background: #251b33;
    color: var(--primary-color);
}

.nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background-color: var(--primary-color);
}

.nav-footer {
    padding: 20px 30px;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

body.dark-mode .nav-footer p {
    color: var(--text-light);
}

/* ===== 主内容区 ===== */
.main-content {
    margin-left: 140px; /* 修正为与.sidebar相同, 解决白条问题 */
    min-height: 100vh;
    width: calc(100vw - 140px); /* 避免右侧空白/白条 */
    transition: var(--transition);
}

body.dark-mode .main-content {
    background: var(--bg-color);
}

/* 全局防止内容区出现白条 */
html, body, .main-content, .section {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

.section {
    padding: 80px 60px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    box-sizing: border-box;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

.section-header {
    margin-bottom: 60px;
    text-align: center;
}

.section-title {
    font-size: 2.5rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 15px;
    letter-spacing: -1px;
}

.section-subtitle {
    font-size: 1.1rem;
    color: var(--text-light);
    font-weight: 300;
}

/* ===== Hero Section ===== */
.hero-section {
    background: linear-gradient(135deg, var(--bg-color) 0%, var(--bg-light) 100%);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero-content {
    max-width: 800px;
    margin: 0 auto;
    animation: fadeInUp 1s ease-out;
}

.hero-title {
    font-size: 3.5rem;
    font-weight: 300;
    line-height: 1.2;
    margin-bottom: 30px;
    letter-spacing: -2px;
}

.title-line {
    display: block;
    color: var(--text-light);
    font-size: 1.2rem;
    font-weight: 400;
    margin-bottom: 10px;
    animation: fadeInUp 1s ease-out 0.2s both;
}

.title-name {
    display: block;
    color: var(--text-color);
    font-weight: 600;
    animation: fadeInUp 1s ease-out 0.4s both;
}

.hero-subtitle {
    font-size: 1.3rem;
    color: var(--text-light);
    margin-bottom: 20px;
    font-weight: 300;
    animation: fadeInUp 1s ease-out 0.6s both;
}

.hero-description {
    margin-bottom: 60px;
    animation: fadeInUp 1s ease-out 0.8s both;
}

.hero-description p {
    font-size: 1rem;
    color: var(--text-light);
    font-weight: 300;
}

.scroll-indicator {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    animation: fadeInUp 1s ease-out 1s both;
}

.scroll-arrow {
    width: 2px;
    height: 30px;
    background-color: var(--text-light);
    margin: 0 auto 10px;
    position: relative;
    animation: bounce 2s infinite;
}

.scroll-arrow::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: -3px;
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--text-light);
    border-bottom: 2px solid var(--text-light);
    transform: rotate(45deg);
}

.scroll-indicator span {
    font-size: 0.8rem;
    color: var(--text-light);
    font-weight: 300;
}

/* ===== 关于我 ===== */
.about-section {
    background-color: var(--bg-color);
}

.about-content {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 60px;
    align-items: center;
    max-width: 1000px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

.about-text p {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-color);
    margin-bottom: 20px;
    font-weight: 300;
}

.about-image {
    text-align: center;
}

.avatar {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.avatar:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-hover);
}

/* ===== 作品集 ===== */
.portfolio-section {
    background-color: var(--bg-light);
}

.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 30px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

.portfolio-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
    background-color: var(--bg-color);
    box-shadow: var(--shadow);
}

body.dark-mode .portfolio-item,
body.dark-mode .contact-item,
body.dark-mode .article-item,
body.dark-mode .btn {
    background: #312449;
    color: var(--text-color);
}

.portfolio-item:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

.portfolio-image {
    width: 100%;
    height: 250px;
    object-fit: cover;
    transition: var(--transition);
}

.portfolio-item:hover .portfolio-image {
    transform: scale(1.05);
}

.portfolio-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    color: white;
    padding: 30px 20px 20px;
    transform: translateY(100%);
    transition: var(--transition);
}

.portfolio-item:hover .portfolio-overlay {
    transform: translateY(0);
}

.portfolio-overlay h3 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 5px;
}

.portfolio-overlay p {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* ===== 文章 ===== */
.articles-section {
    background-color: var(--bg-color);
}

.articles-list {
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

.article-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 30px 0;
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
    width: 100%;
    box-sizing: border-box;
    margin: 0;
}

body.dark-mode .article-item {
    background: #312449;
    color: var(--text-color);
}

.article-item:hover {
    background-color: var(--bg-light);
    margin: 0;
    padding: 30px;
    border-radius: 8px;
}

.article-content {
    flex: 1;
}

.article-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 10px;
    line-height: 1.4;
}

.article-excerpt {
    color: var(--text-light);
    margin-bottom: 15px;
    line-height: 1.6;
}

.article-meta {
    display: flex;
    gap: 20px;
    font-size: 0.85rem;
}

.article-date {
    color: var(--text-light);
}

.article-category {
    color: var(--primary-color);
    font-weight: 500;
}

.article-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
    white-space: nowrap;
}

.article-link:hover {
    color: var(--text-color);
}

.article-link i {
    transition: var(--transition);
}
.article-link:hover i {
    transform: translateX(3px);
}

/* ===== 联系 ===== */
.contact-section {
    background-color: var(--bg-light);
}

.contact-content {
    max-width: 800px;
    margin: 0 auto;
    text-align: center;
    width: 100%;
    box-sizing: border-box;
}

.contact-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 40px;
    margin-bottom: 60px;
    width: 100%;
    box-sizing: border-box;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 30px;
    background-color: var(--bg-color);
    border-radius: 12px;
    box-shadow: var(--shadow);
    transition: var(--transition);
    width: 100%;
    box-sizing: border-box;
}

body.dark-mode .contact-item {
    background: #312449;
    color: var(--text-color);
}

.contact-item:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}

.contact-item i {
    font-size: 1.5rem;
    color: var(--primary-color);
    width: 40px;
    text-align: center;
}

.contact-item h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 5px;
}

.contact-item a {
    color: var(--text-light);
    text-decoration: none;
    transition: var(--transition);
}

.contact-item a:hover {
    color: var(--primary-color);
}

.contact-actions {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ===== 按钮样式 ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 15px 30px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
    border: none;
    cursor: pointer;
    font-size: 1rem;
}

body.dark-mode .btn {
    background: #312449;
    color: var(--text-color);
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

body.dark-mode .btn-primary {
    background: var(--primary-color);
    color: #fff;
}

.btn-primary:hover {
    background-color: #d62839;
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.btn-secondary {
    background-color: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

body.dark-mode .btn-secondary {
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    background: transparent;
}

.btn-secondary:hover {
    background-color: var(--primary-color);
    color: white;
    transform: translateY(-2px);
}

body.dark-mode .btn-secondary:hover {
    background: var(--primary-color);
    color: #fff;
}

/* ===== Lightbox ===== */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

body.dark-mode .lightbox {
    background-color: rgba(20, 16, 24, 0.96);
}

.lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
}

.lightbox-close {
    position: absolute;
    top: -40px;
    right: 0;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    z-index: 2001;
}

#lightbox-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
}

.lightbox-caption {
    color: white;
    text-align: center;
    margin-top: 20px;
    font-size: 1.1rem;
}

/* ===== 动画 ===== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

/* ===== 响应式设计 ===== */
@media (max-width: 1024px) {
    .main-content {
        margin-left: 140px;
        width: calc(100vw - 140px);
    }
    .section {
        padding: 60px 40px;
    }
    .hero-title {
        font-size: 3rem;
    }
    .section-title {
        font-size: 2.2rem;
    }
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex;
    }
    .sidebar {
        transform: translateX(-100%);
        width: 100vw;
        min-width: 0;
        border-right: 0;
    }
    .sidebar.active {
        transform: translateX(0);
        width: 100vw;
        min-width: 0;
    }
    .main-content {
        margin-left: 0;
        width: 100vw;
        max-width: 100vw;
    }
    .section {
        padding: 40px 20px;
        width: 100vw;
        max-width: 100vw;
        overflow-x: hidden;
    }
    .hero-title {
        font-size: 2.5rem;
    }
    .title-line {
        font-size: 1rem;
    }
    .section-title {
        font-size: 2rem;
    }
    .about-content {
        grid-template-columns: 1fr;
        gap: 40px;
        text-align: center;
        width: 100vw;
        max-width: 100vw;
        box-sizing: border-box;
    }
    .portfolio-grid {
        grid-template-columns: 1fr;
        gap: 20px;
        width: 100vw;
        max-width: 100vw;
        box-sizing: border-box;
    }
    .article-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 20px;
        width: 100vw;
        max-width: 100vw;
        box-sizing: border-box;
    }
    .contact-info {
        grid-template-columns: 1fr;
        gap: 20px;
        width: 100vw;
        max-width: 100vw;
        box-sizing: border-box;
    }
    .contact-actions {
        flex-direction: column;
        align-items: center;
    }
    .btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .hero-title {
        font-size: 2rem;
    }
    .section-title {
        font-size: 1.8rem;
    }
    .portfolio-grid {
        grid-template-columns: 1fr;
    }
    .contact-item {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }
    .main-content,
    .section,
    .about-content,
    .portfolio-grid,
    .contact-info,
    .articles-list {
        width: 100vw !important;
        max-width: 100vw !important;
        box-sizing: border-box;
    }
}

/* ===== 滚动条样式 ===== */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-light);
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

/* ===== 选择文本样式 ===== */
::selection {
    background-color: var(--primary-color);
    color: white;
}

/* ===== 焦点样式 ===== */
*:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ===== 打印样式 ===== */
@media print {
    .sidebar,
    .mobile-menu-toggle,
    .scroll-indicator {
        display: none;
    }
    .main-content {
        margin-left: 0;
        width: 100vw;
    }
    .section {
        padding: 20px 0;
        page-break-inside: avoid;
        width: 100vw;
        max-width: 100vw;
    }
}
