/* style.css */

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #f0f2f5;
    color: #333;
    line-height: 1.6;
    margin: 0;
    padding: 20px;
    display: flex; 
    flex-direction: column;
    min-height: 100vh;
}
.container {
    max-width: 960px;
    margin: 30px auto;
    background-color: #fff;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    flex: 1;
    display: flex; 
    flex-direction: column; 
    position: relative;
}
h1 {
    text-align: center;
    color: #3b82f6;
    margin-bottom: 20px; 
}
.message {
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 20px;
    text-align: center;
    font-size: 0.95em;
}
.message.success { background-color: #e6ffed; color: #28a745; border: 1px solid #28a745; }
.message.error { background-color: #ffebe6; color: #dc3545; border: 1px solid #dc3545; }
.message.info { background-color: #e6f7ff; color: #007bff; border: 1px solid #007bff; }
.message.warning { background-color: #fff3cd; color: #856404; border: 1px solid #ffc107; }

/* 导航样式 */
.navbar {
    display: flex;
    flex-direction: column; 
    align-items: center; 
    margin-bottom: 30px; 
    background-color: #eaf3ff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    padding: 15px 10px; 
    width: 100%; 
    box-sizing: border-box; 
}
.navbar-top-links, .navbar-main-links {
    display: flex; 
    flex-wrap: wrap;
    justify-content: center;
    width: 100%; 
    margin: 0; 
    padding: 0;
    margin-bottom: 15px; 
}
.navbar-top-links {
    border-bottom: 1px solid #d1e4ff; 
    padding-bottom: 15px; 
}
.navbar-main-links {
    margin-bottom: 0; 
}
.nav-item {
    text-align: center;
    padding: 10px 20px; 
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    user-select: none;
    border-radius: 25px; 
    margin: 5px; 
    transition: all 0.3s ease; 
    background-color: #ffffff; 
    color: #4a4a4a; 
    border: 1px solid #e0e0e0; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.08); 
}
.nav-item:hover {
    background-color: #e6f0ff; 
    color: #3b82f6; 
    border-color: #a3c2f0;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15); 
    transform: translateY(-2px); 
}
.nav-item.active {
    background-color: #3b82f6; 
    color: white;
    border-color: #3b82f6;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.2), 0 2px 5px rgba(0,0,0,0.1); 
    transform: translateY(0); 
}
.nav-item.external-link {
    background-color: #6C5CE7; 
    color: white;
    border-color: #6C5CE7;
    box-shadow: 0 2px 5px rgba(108, 92, 231, 0.3); 
}
.nav-item.external-link:hover {
    background-color: #5d4cd9; 
    border-color: #5d4cd9;
    box-shadow: 0 4px 10px rgba(108, 92, 231, 0.4);
}

/* 主内容区域容器 */
#homepage-sections {
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 20px;
    position: relative; 
    display: grid; 
}
/* JS 会在 #homepage-sections 上切换 these two classes 来控制列数 */
.grid-multi-column {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); /* 调整 minmax 适应小屏幕 */
    gap: 20px;
}
.grid-single-column {
    grid-template-columns: 1fr; /* 默认单列布局，在媒体查询中再调整为双列 */
    gap: 20px;
    justify-items: stretch; /* 确保内容撑开宽度 */
}

/* 通用的 .section 卡片样式 */
.section {
    padding: 20px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background-color: #fdfdfd;
    box-sizing: border-box; 
    display: flex;
    flex-direction: column; 
    justify-content: space-between; 
    height: 100%;
    width: 100%;
    margin-bottom: 0;
    transition: opacity 0.3s ease-in-out;
}

/* 分类页卡片 (#paged-category-section) 特有样式：使其在单列布局时始终占据全部宽度 */
#paged-category-section {
    grid-column: 1 / -1; 
}

/* 统一标题样式 */
.section h2 {
    text-align: left;
    color: #3b82f6;
    margin-bottom: 15px; 
    padding-bottom: 5px; 
    border-bottom: none; 
}
.quote-item {
    margin-bottom: 15px;
    padding: 10px 0;
    border-bottom: 1px dashed #eee;
}
.quote-item:last-child {
    border-bottom: none;
}
.quote-content {
    font-size: 1.1em;
    color: #555;
    position: relative;
    word-wrap: break-word; /* 防止长单词溢出 */
}
.quote-author {
    text-align: right;
    font-style: italic;
    color: #777;
    margin-top: 5px;
    font-size: 0.95em;
    word-wrap: break-word;
}
.quote-author::before {
    content: "—— ";
}
.more-button-container {
    text-align: center;
    margin-top: auto; 
    padding-top: 20px;
    border-top: 1px solid #eee;
}
.more-button {
    display: inline-block;
    padding: 10px 20px;
    background-color: #3b82f6;
    color: white;
    border-radius: 5px;
    text-decoration: none;
    transition: background-color 0.3s ease;
}
.more-button:hover {
    background-color: #2563eb;
}

/* 分页样式 */
.pagination {
    display: flex;
    justify-content: center;
    margin-top: 30px;
    flex-wrap: wrap; 
}
.pagination a, .pagination span {
    display: block;
    padding: 8px 12px;
    margin: 0 4px;
    border: 1px solid #ccc;
    border-radius: 4px;
    text-decoration: none;
    color: #3b82f6;
    background-color: #fff;
    transition: all 0.3s ease;
}
.pagination a:hover {
    background-color: #e6f7ff;
    border-color: #3b82f6;
}
.pagination .current-page {
    background-color: #3b82f6;
    color: white;
    border-color: #3b82f6;
    cursor: default;
}
.pagination .disabled {
    color: #ccc; 
    background-color: #f0f0f0; 
    cursor: not-allowed;
}
.loading-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3b82f6;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    position: absolute; 
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 10; 
    display: none; 
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* JS 控制的显示/隐藏/布局类 */
.content-hidden {
    display: none !important; 
}
.content-active {
    opacity: 1;
    pointer-events: auto;
}
.content-fade { 
    opacity: 0;
    pointer-events: none; 
}

.footer {
    margin-top: auto; 
    padding: 20px;
    text-align: center;
    color: #777;
    font-size: 0.9em;
    background-color: #f8f8f8;
    border-top: 1px solid #eee;
    width: 100%;
    box-sizing: border-box;
}

/* --- 回到顶部按钮样式 --- */
.scroll-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background-color: #3b82f6;
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 1.5em;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    z-index: 999;
}

.scroll-to-top.show {
    opacity: 1;
    visibility: visible;
}

.scroll-to-top:hover {
    background-color: #2563eb;
}

/* --- 响应式设计 --- */

/* 针对手机等小屏幕设备 */
@media (max-width: 768px) {
    body {
        padding: 10px; /* 减少总体内边距 */
    }
    .container {
        margin: 10px auto;
        padding: 20px; /* 减少容器内边距 */
    }
    h1 {
        font-size: 1.8em; /* 调整标题字号 */
    }
    .navbar {
        padding: 10px 5px; /* 调整导航栏内边距 */
    }
    .nav-item {
        padding: 8px 15px; /* 调整导航项内边距 */
        font-size: 0.9em; /* 调整导航项字号 */
        margin: 3px; /* 减少导航项间距 */
    }
    .navbar-top-links, .navbar-main-links {
        margin-bottom: 10px; /* 调整行间距 */
    }

    /* 首页多列布局在小屏幕上变为单列 */
    .grid-multi-column {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    /* 分类单列布局在小屏幕上保持单列 */
    .grid-single-column {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    .section {
        padding: 15px; /* 调整卡片内边距 */
    }
    .section h2 {
        font-size: 1.3em;
        margin-bottom: 10px;
    }
    .quote-content {
        font-size: 1em; /* 调整名言内容字号 */
    }
    .quote-author {
        font-size: 0.9em; /* 调整作者字号 */
    }
    .more-button {
        padding: 8px 15px;
        font-size: 0.9em;
    }
    .pagination a, .pagination span {
        padding: 6px 10px;
        font-size: 0.85em;
        margin: 0 3px;
    }
    .scroll-to-top {
        bottom: 20px;
        right: 20px;
        width: 45px;
        height: 45px;
        font-size: 1.3em;
    }
}

/* 针对平板等中等屏幕设备 */
@media (min-width: 769px) and (max-width: 992px) {
    .container {
        padding: 25px;
    }
    /* 在中等屏幕维持首页两列布局 */
    .grid-multi-column {
        grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
        gap: 18px;
    }
    /* 分类页在平板一般也显示为单列，除非内容很窄 */
    .grid-single-column {
        grid-template-columns: 1fr;
    }
    .nav-item {
        padding: 9px 18px;
        font-size: 0.95em;
    }
}

/* 针对大屏幕设备 (993px 及以上) */
@media (min-width: 993px) {
    /* 恢复或保持在大屏幕上的两列布局，并确保 paged-category-section 跨列 */
    .grid-multi-column {
        grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    }
    /* 对于分类页面在大屏幕上强制两列，让内容更宽 */
    .grid-single-column {
        grid-template-columns: minmax(400px, 1fr) minmax(400px, 1fr); 
    }
}