/* 全局重置与基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f9f9f9;
}

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

ul {
    list-style: none;
}

/* 容器 */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* 头部 */
header {
    background-color: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    padding: 0; /* 调整 padding，让导航占满高度 */
    margin-bottom: 30px;
    position: relative;
    z-index: 100;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: #2c3e50;
}

/* 导航栏 & 下拉菜单 */
nav > ul {
    display: flex;
    gap: 30px;
    height: 100%;
    align-items: center;
}

nav li {
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
}

nav a {
    color: #666;
    transition: color 0.3s;
    padding: 10px 0;
    display: block;
}

nav a:hover {
    color: #2c3e50;
}

/* 二级菜单样式 */
nav ul ul {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #fff;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    min-width: 160px;
    border-radius: 0 0 4px 4px;
    padding: 10px 0;
    flex-direction: column;
    gap: 0;
}

nav ul li:hover > ul {
    display: flex;
}

nav ul ul li {
    height: auto;
    display: block;
    width: 100%;
}

nav ul ul a {
    padding: 10px 20px;
    color: #666;
    white-space: nowrap;
    display: block;
}

nav ul ul a:hover {
    background-color: #f5f5f5;
    color: #2c3e50;
}

/* 首页：文章列表网格 (一行四列) */
.post-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* 强制一行四列 */
    gap: 20px;
    padding-bottom: 50px;
}

.post-card {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.3s, box-shadow 0.3s;
    box-shadow: 0 2px 10px rgba(0,0,0,0.03);
    display: flex;
    flex-direction: column;
}

.post-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.08);
}

.post-image {
    width: 100%;
    padding-top: 133%; /* 3:4 比例 (高大于宽) */
    position: relative;
    overflow: hidden;
}

.post-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s;
}

.post-card:hover .post-image img {
    transform: scale(1.05);
}

.post-content {
    padding: 15px;
}

.post-title {
    font-size: 1.1rem;
    margin-bottom: 8px;
    line-height: 1.4;
    color: #2c3e50;
    /* 限制标题行数 */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.post-date {
    font-size: 0.8rem;
    color: #999;
}

/* 内页布局 (带侧边栏) */
.page-layout {
    display: flex;
    gap: 40px; /* 增加间距 */
    margin-bottom: 50px;
    align-items: flex-start;
}

/* 文章主体 */
.article-container {
    flex: 7; /* 调整比例，让侧边栏更宽 (7:3) */
    background: #fff;
    padding: 50px; /* 增加内边距 */
    border-radius: 8px;
    margin: 0;
    max-width: none;
}

/* 侧边栏 */
.sidebar {
    flex: 3; /* 调整比例，让侧边栏更宽 */
    display: flex;
    flex-direction: column;
    gap: 30px;
    min-width: 300px; /* 确保最小宽度 */
}

/* 侧边栏小工具样式 */
.widget {
    margin-bottom: 30px;
}

.widget-title {
    font-size: 1.1rem;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.widget-list li {
    margin-bottom: 10px;
}

.widget-list a {
    color: #666;
    font-size: 0.95rem;
    line-height: 1.5;
    display: block;
}

.widget-list a:hover {
    color: #2c3e50;
    text-decoration: underline;
}

/* 标签云样式 */
.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.tag-cloud a {
    background: #f0f0f0;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.85rem;
    color: #666;
    transition: background-color 0.3s, color 0.3s;
}

.tag-cloud a:hover {
    background: #e0e0e0;
    color: #2c3e50;
}

/* 首页友情链接 */
.friend-links-box {
    background: #fff;
    padding: 30px;
    border-radius: 8px;
    margin-bottom: 50px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.03);
}

.friend-links-title {
    font-size: 1.2rem;
    color: #2c3e50;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.friend-links-list {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    flex-direction: row; /* 显式指定方向 */
}

.friend-links-list li {
    width: auto; /* 防止被撑满 */
}

.friend-links-list a {
    color: #666;
    transition: color 0.3s;
    display: inline-block; /* 确保是行内块 */
}

.friend-links-list a:hover {
    color: #2c3e50;
    text-decoration: underline;
}

/* 文章头部样式优化 */
.article-header {
    margin-bottom: 40px;
    text-align: left; /* 改为左对齐，更现代 */
    border-bottom: 1px solid #eee;
    padding-bottom: 30px;
}

.article-title {
    font-size: 1.8rem; /* 减小标题字号 */
    color: #2c3e50;
    margin-bottom: 20px;
    line-height: 1.3;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.article-meta {
    color: #7f8c8d;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 15px;
}

.article-meta span {
    display: inline-flex;
    align-items: center;
}

/* 文章内容样式优化 */
.article-content {
    font-size: 1.15rem; /* 稍微加大正文字号 */
    line-height: 1.9;
    color: #34495e;
}

.article-content p {
    margin-bottom: 25px;
    text-align: justify; /* 两端对齐 */
}

.article-content h2 {
    margin-top: 50px;
    margin-bottom: 25px;
    font-size: 1.6rem;
    color: #2c3e50;
    border-left: 4px solid #3498db; /* 增加左侧装饰线 */
    padding-left: 15px;
    line-height: 1.2;
}

.article-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 50px 0; /* 大幅增加图片上下间距 */
    box-shadow: 0 8px 20px rgba(0,0,0,0.08); /* 增加图片阴影 */
    display: block;
}

/* 页脚优化 */
footer {
    background-color: #2c3e50;
    color: #ecf0f1;
    padding-top: 60px;
    margin-top: auto;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 40px;
    padding-bottom: 40px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.footer-section h3 {
    color: #fff;
    font-size: 1.2rem;
    margin-bottom: 20px;
}

.footer-section p {
    font-size: 0.9rem;
    line-height: 1.6;
    color: #bdc3c7;
}

.footer-links li {
    margin-bottom: 10px;
}

.footer-links a {
    color: #bdc3c7;
    transition: color 0.3s;
}

.footer-links a:hover {
    color: #fff;
    padding-left: 5px;
}

.footer-bottom {
    text-align: center;
    padding: 20px 0;
    font-size: 0.85rem;
    color: #95a5a6;
}

/* 响应式适配 */
@media (max-width: 1024px) {
    .post-grid {
        grid-template-columns: repeat(3, 1fr); /* 平板 3列 */
    }
}

@media (max-width: 768px) {
    .post-grid {
        grid-template-columns: repeat(2, 1fr); /* 手机横屏 2列 */
        gap: 15px;
    }

    .page-layout {
        flex-direction: column;
    }
    
    .article-container, .sidebar {
        width: 100%;
        flex: none;
    }

    nav > ul {
        display: none; /* 移动端暂隐藏导航，实际项目需做汉堡菜单 */
    }
}

@media (max-width: 480px) {
    .post-grid {
        grid-template-columns: 1fr; /* 小屏手机 1列 */
    }
}