/* 基础样式与颜色变量 */
:root {
--primary-color: #2e7d32; /* 主绿色 */
--secondary-color: #4caf50; /* 次绿色 */
--light-green: #e8f5e9; /* 浅绿色背景 */
--text-color: #333; /* 主要文字颜色 */
--light-text: #666; /* 浅色文字 */
--white: #fff; /* 白色 */
--border-radius: 8px; /* 统一圆角 */
--box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); /* 统一阴影 */
--transition: all 0.3s ease; /* 统一过渡效果 */
}

* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

body {
font-family: 'Helvetica Neue', Arial, sans-serif;
line-height: 1.6;
color: var(--text-color);
background-color: #f9f9f9;
}

a {
text-decoration: none;
color: var(--primary-color);
transition: var(--transition);
}

a:hover {
color: var(--secondary-color);
}

/* 导航栏样式 */
.navbar {
background-color: var(--primary-color);
position: relative;
}

.nav-container {
max-width: 1200px;
margin: 0 auto;
padding: 1rem;
display: flex;
justify-content: space-between;
align-items: center;
}

.logo {
color: var(--white);
font-size: 1.5rem;
font-weight: bold;
}

.nav-menu {
display: flex;
list-style: none;
}

.nav-item {
margin-left: 2rem;
}

.nav-link {
color: var(--white);
font-weight: 500;
}

.nav-link:hover {
color: #a5d6a7;
}

.hamburger {
display: none;
cursor: pointer;
flex-direction: column;
justify-content: space-around;
width: 30px;
height: 21px;
}

.hamburger span {
display: block;
height: 3px;
width: 100%;
background-color: var(--white);
border-radius: 3px;
transition: var(--transition);
}

/* 主内容区域 */
.container {
max-width: 1200px;
margin: 2rem auto;
padding: 0 1rem;
}

.section {
margin-bottom: 3rem;
background-color: var(--white);
border-radius: var(--border-radius);
padding: 1.5rem;
box-shadow: var(--box-shadow);
}

.section-title {
font-size: 1.5rem;
margin-bottom: 1.5rem;
color: var(--primary-color);
padding-bottom: 0.5rem;
border-bottom: 2px solid var(--light-green);
}

/* 最新文章列表 - 已优化 */
.latest-articles {
margin: 0 auto;
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 1.5rem;
}

.article-card {
padding: 1rem;
border-radius: var(--border-radius);
background-color: var(--light-green);
transition: var(--transition);
display: flex;
flex-direction: column;
height: 100%;
}

.article-card:hover {
transform: translateY(-5px);
box-shadow: var(--box-shadow);
}

.article-title {
font-size: 1.2rem;
margin-bottom: 0.5rem;
/* 允许标题换行 */
white-space: normal;
overflow: visible;
text-overflow: clip;
line-height: 1.4;
}

.article-desc {
color: var(--light-text);
font-size: 0.9rem;
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
overflow: hidden;
flex-grow: 1;
margin-bottom: 0.5rem;
line-height: 1.5;
}

.article-meta {
font-size: 0.8rem;
color: var(--light-text);
margin-top: auto;
display: flex;
justify-content: space-between;
}

.article-meta span::before {
content: "📅"; /* 日历emoji */
margin-right: 0.3rem;
}

/* 推荐文章图片列表 */
.recommended-articles {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 1rem;
}

.recommended-article {
height: 200px;
border-radius: var(--border-radius);
overflow: hidden;
position: relative;
background-size: cover;
background-position: center;
transition: var(--transition);
}

.recommended-article:hover {
transform: scale(1.05);
}

.recommended-article::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
opacity: 0.7;
transition: var(--transition);
}

.recommended-article:hover::before {
opacity: 0.9;
}

.recommended-content {
position: absolute;
bottom: 0;
left: 0;
padding: 1rem;
color: var(--white);
width: 100%;
}

.recommended-title {
font-size: 1rem;
margin-bottom: 0.5rem;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

.recommended-desc {
font-size: 0.8rem;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}

/* 热门文章列表 - 已修复移动端显示问题 */
.popular-articles {
margin: 0 auto;
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 1.5rem;
}

.popular-article {
display: flex;
flex-direction: column;
padding: 1rem;
border-radius: var(--border-radius);
background-color: var(--light-green);
width: 100%; /* 确保宽度为100% */
box-sizing: border-box; /* 确保内边距不增加宽度 */
}

.popular-title {
font-size: 1.1rem;
margin-bottom: 0.5rem;
word-break: break-word; /* 允许单词内换行 */
overflow-wrap: break-word; /* 确保长单词或URL可以换行 */
white-space: normal; /* 允许换行 */
line-height: 1.4; /* 增加行高提高可读性 */
}

.popular-desc {
color: var(--light-text);
font-size: 0.9rem;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
margin-bottom: 0.5rem;
line-height: 1.5;
}

.popular-meta {
display: flex;
justify-content: space-between;
font-size: 0.8rem;
color: var(--light-text);
}

.time::before {
content: "📅"; /* 日历emoji */
margin-right: 0.3rem;
}

.read-count::before {
content: "👁️"; /* 眼睛emoji */
margin-right: 0.3rem;
}

/* 文字介绍部分 */
.intro-section {
line-height: 1.8;
color: var(--light-text);
}

/* 友情链接部分 */
.friend-links {
display: flex;
flex-wrap: wrap;
gap: 1rem;
}

.friend-link {
padding: 0.5rem 1rem;
background-color: var(--light-green);
border-radius: 20px;
font-size: 0.9rem;
transition: var(--transition);
}

.friend-link:hover {
background-color: var(--secondary-color);
color: var(--white);
}

/* 底部版权信息 */
footer {
background-color: var(--primary-color);
color: var(--white);
text-align: center;
padding: 1.5rem;
margin-top: 2rem;
}

footer a{
color: var(--white);
}

/* 响应式设计 */
@media (max-width: 1024px) {
/* 平板样式 */
.recommended-articles {
grid-template-columns: repeat(2, 1fr);
}

.popular-articles {
grid-template-columns: repeat(2, 1fr);
width: 100%; /* 确保在平板上宽度为100% */
}

/* 平板和手机导航折叠 */
.hamburger {
display: flex;
}

.nav-menu {
position: absolute;
top: 100%;
left: 0;
width: 100%;
background-color: var(--primary-color);
flex-direction: column;
padding: 1rem 0;
clip-path: polygon(0 0, 100% 0, 100% 0, 0 0);
transition: var(--transition);
z-index: 100;
}

.nav-menu.active {
clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
}

.nav-item {
margin: 0;
text-align: center;
padding: 0.5rem 0;
}

/* 平板设备上隐藏友情链接 */
.friend-links-section {
display: none;
}

/* 热门文章meta信息在平板和手机上改为垂直布局 */
.popular-meta {
flex-direction: column;
gap: 0.3rem;
}

/* 最新文章在平板视图下调整为单列 */
.latest-articles {
grid-template-columns: 1fr;
}
}

@media (max-width: 768px) {
/* 内容区域响应式 */
.latest-articles {
grid-template-columns: 1fr;
width: 100%;
overflow: visible;
}

.article-card {
width: 100%;
margin: 0 auto;
padding: 1rem;
}

.article-title {
font-size: 1.1rem;
white-space: normal;
overflow: visible;
text-overflow: clip;
line-height: 1.4;
height: auto;
}

.article-desc {
-webkit-line-clamp: 3;
line-height: 1.5;
}

/* 热门文章在768px以下单列显示 */
.popular-articles {
grid-template-columns: 1fr;
width: 100%; /* 确保在手机上宽度为100% */
gap: 1rem; /* 调整间距适应小屏幕 */
}

.popular-article {
width: 100%; /* 确保每个文章卡片宽度为100% */
max-width: 100%; /* 防止超出容器 */
margin: 0; /* 移除可能的外边距 */
}

/* 热门文章meta信息在手机上改为垂直布局 */
.popular-meta {
flex-direction: column;
gap: 0.3rem;
}

/* 默认在768px以下单列显示 */
.recommended-articles {
grid-template-columns: 1fr;
}
}

/* 新增：在500px-768px之间显示2列 */
@media (max-width: 768px) and (min-width: 501px) {
.recommended-articles {
grid-template-columns: repeat(2, 1fr);
}
}

@media (max-width: 480px) {
/* 手机样式微调 */
.container {
padding: 0 0.5rem;
}

.section {
padding: 1rem;
margin-bottom: 2rem;
}

.section-title {
font-size: 1.3rem;
margin-bottom: 1rem;
}

.article-card {
padding: 0.8rem;
}

.article-title {
font-size: 1rem;
margin-bottom: 0.5rem;
}

.article-desc {
font-size: 0.85rem;
-webkit-line-clamp: 3;
}

.popular-article {
height: auto;
padding: 0.8rem;
width: 100%; /* 确保在手机上宽度为100% */
max-width: 100%; /* 防止超出容器 */
}

.popular-title {
font-size: 1rem;
word-break: break-word; /* 允许单词内换行 */
overflow-wrap: break-word; /* 确保长单词或URL可以换行 */
}

/* 手机设备上隐藏友情链接 */
.friend-links-section {
display: none;
}

/* 确保最新文章卡片不超出屏幕 */
.article-card {
width: 100%;
max-width: 100%;
margin: 0;
}

/* 热门文章meta信息在手机上改为垂直布局 */
.popular-meta {
flex-direction: column;
gap: 0.3rem;
}
}