/* --- 全局样式 --- */
:root {
    --primary-color: #704214;
    --accent-color: #f7b32b;
    --bg-color: #fffaeb;
    --text-color: #333;
    --card-bg: #fff9e6;
    --border-color: #e0d8c5;
    --header-bg: #fff5d6;
    --shadow: 0 4px 8px rgba(112, 66, 20, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Noto Sans SC', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    padding-top: 80px; /* 为固定导航栏留出空间 */
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* --- 导航栏 --- */
.navbar {
    background-color: var(--header-bg);
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    box-shadow: var(--shadow);
    z-index: 1000;
    padding: 15px 0;
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.logo-icon {
    font-size: 2rem;
    margin-right: 10px;
    color: var(--accent-color);
}

.logo-text {
    color: var(--primary-color);
    font-size: 1.5rem;
    font-weight: bold;
}

.nav-links {
    display: flex;
    gap: 20px;
}

.nav-links a {
    text-decoration: none;
    color: var(--primary-color);
    font-weight: 500;
    padding: 5px 10px;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.nav-links a:hover, .nav-links a.active {
    background-color: var(--accent-color);
    color: white;
}

/* --- 卡通风格的横幅 --- */
.banner {
    background-color: var(--header-bg);
    border-radius: 15px;
    padding: 30px;
    margin: 20px 0;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow);
    border: 2px solid var(--border-color);
}

.banner::before {
    content: "";
    position: absolute;
    top: -20px;
    right: -20px;
    width: 150px;
    height: 150px;
    background-color: var(--accent-color);
    border-radius: 50%;
    opacity: 0.2;
    z-index: 0;
}

.banner-content {
    position: relative;
    z-index: 1;
}

.banner h1 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 2.2rem;
}

.banner p {
    font-size: 1.1rem;
    max-width: 80%;
}

/* --- 公告板 --- */
.announcements {
    background-color: var(--card-bg);
    border-radius: 15px;
    padding: 20px;
    margin: 20px 0;
    box-shadow: var(--shadow);
    border: 2px solid var(--border-color);
}

.section-title {
    color: var(--primary-color);
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 10px;
    margin-bottom: 20px;
    position: relative;
    display: inline-block;
}

.section-title::after {
    content: "📢";
    position: absolute;
    right: -30px;
    top: 0;
}

.announcement-item {
    background-color: white;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 15px;
    border-left: 4px solid var(--accent-color);
}

.announcement-date {
    color: #888;
    font-size: 0.9rem;
}

.announcement-title {
    font-weight: bold;
    margin: 5px 0;
    color: var(--primary-color);
}

.announcement-content {
    margin-top: 5px;
}

/* --- 小说板块 --- */
.novels-section {
    margin: 30px 0;
}

.novels-title::after {
    content: "📚";
}

.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.book-card, .book-item {
    background-color: var(--card-bg);
    border-radius: 10px;
    overflow: hidden; /* 保持 overflow hidden 以便圆角生效 */
    box-shadow: var(--shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease; /* 添加 box-shadow 过渡 */
    border: 1px solid var(--border-color);
    cursor: pointer;
    display: flex; /* 改为 flex 布局，方便标题在下方 */
    flex-direction: column; /* 垂直排列 */
}

.book-card:hover, .book-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(112, 66, 20, 0.2); /* 悬停时阴影更明显 */
}

.book-cover {
    /* 移除固定高度 height: 240px; */
    /* 移除 overflow: hidden; 因为父元素 .book-item 已经有了 */
    position: relative; /* 重要：为内部绝对定位的 synopsis 提供容器 */
    background-color: #e8e0d0; /* 保留背景色，以防图片加载失败 */
    width: 100%; /* 宽度占满父容器 */
    aspect-ratio: 3 / 4; /* 强制 3:4 的宽高比 */
    display: flex; /* 用于居中 no-cover 内容 */
    align-items: center;
    justify-content: center;
}

.book-cover img {
    display: block; /* 移除图片下方的空白 */
    width: 100%;
    height: 100%; /* 高度充满 aspect-ratio 定义的容器 */
    object-fit: cover; /* 使用 cover 填充，允许裁剪以保持比例并填满 */
    /* 如果你绝对不希望裁剪，可以用 contain，但这可能会留白 */
    /* object-fit: contain; */
    transition: opacity 0.3s ease-in-out; /* 为悬停效果添加过渡 */
    position: absolute; /* 让图片和简介可以重叠 */
    top: 0;
    left: 0;
}

/* 新增：简介样式 */
.book-synopsis {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(112, 66, 20, 0.9); /* 使用 primary color 带透明度 */
    color: white;
    padding: 15px; /* 内边距 */
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    opacity: 0; /* 默认隐藏 */
    transition: opacity 0.3s ease-in-out; /* 过渡效果 */
    overflow-y: auto; /* 如果简介过长，允许滚动 */
    font-size: 0.9rem; /* 合适的字体大小 */
    line-height: 1.4; /* 增加行高 */
    box-sizing: border-box; /* padding 不会撑大元素 */
    z-index: 1; /* 确保在图片上方 */
}

/* 悬停效果 */
.book-item:hover .book-cover img {
    opacity: 0; /* 悬停时图片透明 */
}

.book-item:hover .book-cover .book-synopsis {
    opacity: 1; /* 悬停时简介显示 */
}

.no-cover {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%; /* 确保 no-cover 也撑满 */
    color: #a09078;
    position: absolute; /* 确保在 .book-cover 内居中 */
    top: 0;
    left: 0;
    z-index: 0; /* 确保在简介下方 */
}
.no-cover-icon {
    font-size: 3rem;
    margin-bottom: 10px;
    opacity: 0.6;
}

.no-cover-text {
    font-size: 0.9em;
    opacity: 0.7;
}

.book-info, .book-title { /* 现在 .book-title 在 .book-info 外部 */
    padding: 10px 15px; /* 调整标题区域的 padding */
    font-weight: 500;
    color: var(--primary-color);
    text-align: center;
    /* 移除之前的文本截断样式，如果需要可以重新添加 */
    /* display: -webkit-box; */
    /* -webkit-line-clamp: 2; */
    /* -webkit-box-orient: vertical; */
    /* overflow: hidden; */
    width: 100%; /* 确保标题占满宽度 */
    background-color: var(--card-bg); /* 和卡片背景一致 */
    margin-top: auto; /* 将标题推到底部（如果flex布局允许） */
}
/* 调整 .book-item 结构对应的标题样式 */
.book-item .book-title {
    padding: 10px 15px;
    font-weight: 500;
    color: var(--primary-color);
    text-align: center;
    background-color: var(--card-bg); /* 背景与卡片一致 */
    /* 不再需要 margin-top: auto，因为它是 flex item */
}

/* 加载和错误提示文本 */
.loading-text,
.error-text {
    font-size: 1.2em;
    color: #888;
    text-align: center;
    padding: 20px;
    width: 100%;
    grid-column: 1 / -1; /* 让提示文本跨越所有列 */
}
.error-text { color: #c00; }

/* --- 联系方式 --- */
.contact-section {
    background-color: var(--card-bg);
    border-radius: 15px;
    padding: 20px;
    margin: 30px 0;
    box-shadow: var(--shadow);
    border: 2px solid var(--border-color);
}

.contact-title::after {
    content: "📧";
}

.contact-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.contact-card {
    padding: 15px;
    background-color: white;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.contact-icon {
    font-size: 2rem;
    color: var(--accent-color);
}

.contact-info h4 {
    color: var(--primary-color);
    margin-bottom: 5px;
}

.contact-info p {
    color: #666;
}

/* --- 施工中板块 --- */
.under-construction {
    background-color: var(--card-bg);
    border-radius: 15px;
    padding: 20px;
    margin: 30px 0;
    box-shadow: var(--shadow);
    border: 2px solid var(--border-color);
    text-align: left;
}

.construction-title::after {
    content: "🚧";
}

.construction-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 20px;
    background-color: white;
    padding: 30px;
    border-radius: 10px;
}

.construction-icon {
    font-size: 4rem;
    color: var(--accent-color);
    margin-bottom: 20px;
}

/* --- 页脚 --- */
.footer {
    background-color: var(--header-bg);
    padding: 25px 0;
    margin-top: 50px;
    border-top: 1px solid var(--border-color);
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.footer-links {
    margin-bottom: 15px;
}

.footer-links a {
    color: var(--primary-color);
    text-decoration: none;
    margin: 0 10px;
}

.footer-links a:hover {
    text-decoration: underline;
}

.footer-info {
    text-align: center;
    color: #666;
    font-size: 0.9rem;
}

.beian {
    margin-top: 10px;
}

.beian a {
    color: #666;
    text-decoration: none;
}

.beian a:hover {
    text-decoration: underline;
}

/* --- 响应式设计 --- */
@media (max-width: 768px) {
    .banner h1 {
        font-size: 1.8rem;
    }
    
    .banner p {
        max-width: 100%;
        font-size: 1rem;
    }
    
    .book-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 15px;
    }
    
    .book-cover {
        height: 180px;
    }
    
    .nav-container {
        flex-direction: column;
    }
    
    .nav-links {
        margin-top: 15px;
    }
}

@media (max-width: 480px) {
    .book-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 10px;
    }
    
    .book-cover {
        height: 160px;
    }
    
    .contact-grid {
        grid-template-columns: 1fr;
    }
}