/* ============================================
   首页样式（桌面端 + 通用）
   移动端覆盖见 style-mobile.css
   ============================================ */

/* ---------- 主内容布局 ---------- */
.main-content {
    max-width: 1200px;
    margin: 24px auto 0;
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    padding: 0 20px;
}

.content-left { min-width: 0; }
.sidebar { min-width: 0; }

/* ---------- 区块标题 ---------- */
.section-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 14px;
    padding-left: 10px;
    border-left: 4px solid #667eea;
}
.list-section { margin-top: 8px; }

/* ============================================
   搜索 + 排序：下拉菜单（桌面端）
   ============================================ */
.nav-filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 8px;
    flex-shrink: 0;
    position: relative;
}

.nav-search {
    display: flex;
    align-items: center;
    position: relative;
}
.nav-search input[type="text"] {
    width: 160px;
    padding: 6px 30px 6px 12px;
    border: 2px solid #e8e8e8;
    border-radius: 20px;
    font-size: 13px;
    transition: width 0.25s, border-color 0.25s;
    outline: none;
}
.nav-search input[type="text"]:focus {
    width: 200px;
    border-color: #667eea;
}
.nav-search button {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 0;
    line-height: 1;
    color: #888;
}
.nav-search button:hover { color: #667eea; }
.nav-search-clear {
    position: absolute;
    right: 28px;
    color: #e74c3c;
    font-size: 16px;
    text-decoration: none;
    line-height: 1;
}
.nav-search-clear:hover { color: #c0392b; }

.sort-dropdown {
    position: relative;
    flex-shrink: 0;
}
.sort-dropdown-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #f8f9fa;
    border: 2px solid #e8e8e8;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    color: #555;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    white-space: nowrap;
}
.sort-dropdown-toggle:hover {
    border-color: #667eea;
    color: #667eea;
    background: #f0f3ff;
}
.sort-dropdown-toggle.active {
    border-color: #667eea;
    color: #667eea;
    background: #f0f3ff;
}
.sort-dropdown-toggle .sort-icon { font-size: 14px; line-height: 1; }
.sort-dropdown-toggle .sort-label { font-size: 13px; }
.sort-dropdown-toggle .sort-caret {
    font-size: 10px;
    color: #999;
    transition: transform 0.2s;
    margin-left: 2px;
}
.sort-dropdown-toggle.active .sort-caret {
    transform: rotate(180deg);
    color: #667eea;
}

.sort-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 160px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    border: 1px solid #f0f0f0;
    padding: 6px;
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
}
.sort-dropdown-menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.sort-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 13px;
    color: #555;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}
.sort-dropdown-item:hover { background: #f5f7fa; color: #333; }
.sort-dropdown-item.active {
    background: #f0f3ff;
    color: #667eea;
    font-weight: 600;
}
.sort-dropdown-item .sort-icon { font-size: 15px; line-height: 1; }
.sort-dropdown-item .sort-label { flex: 1; }
.sort-dropdown-item .sort-check {
    color: #667eea;
    font-weight: 700;
    font-size: 13px;
}

/* ============================================
   文章网格
   ============================================ */
.article-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 16px;
    margin-bottom: 8px;
}

/* ============================================
   文章卡片（上中下三段式）
   ============================================ */
.article-card {
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.25s, transform 0.2s;
    cursor: pointer;
    position: relative;
    min-height: 0;
}
.article-card:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

/* 上：封面 */
.article-card-cover {
    width: 100%;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    background: #f0f0f0;
    position: relative;
    flex-shrink: 0;
}
.article-card-cover img,
.article-card-cover video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s;
}
.article-card:hover .article-card-cover img { transform: scale(1.05); }

.cover-offline-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    z-index: 1;
}

/* 中：标题 ✅ 使用变量 */
.article-card-title {
    padding: 12px 14px 6px;
    font-size: var(--font-title-card);
    font-weight: 600;
    color: #333;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
    overflow-wrap: break-word;
    flex-shrink: 0;
    transition: color 0.2s;
}
.article-card:hover .article-card-title { color: #667eea; }

.article-card-title .offline-badge {
    display: inline-block;
    background: #e74c3c;
    color: #fff;
    font-size: 11px;
    padding: 1px 8px;
    border-radius: 10px;
    margin-right: 6px;
    vertical-align: middle;
    font-weight: 400;
}
.article-card-title .offline-title { color: #888; }

/* 下：作者 + 标签 */
.article-card-footer {
    padding: 6px 14px 12px;
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.article-author {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: var(--font-author-name);
    color: #888;
    min-width: 0;
}
.article-author-avatar {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid #e8ecf1;
    flex-shrink: 0;
}
.article-author-name {
    color: #666;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 70px;
}
.article-stat {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    color: #999;
    font-size: var(--font-author-name);
    flex-shrink: 0;
}
.article-stat .stat-item {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    white-space: nowrap;
}

.article-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    overflow: hidden;
    max-height: 22px;
}
.article-tags .tag {
    background: #f0f0f0;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: var(--font-tag);
    color: #666;
    white-space: nowrap;
    transition: background 0.2s;
}
.article-tags .tag:hover { background: #e0e0e0; }
.article-tags .tag-more {
    background: #f0f3ff;
    color: #667eea;
    font-weight: 500;
}

/* 无封面卡片 */
.article-card.no-cover {
    background: linear-gradient(135deg, #f8faff 0%, #f0f4ff 100%);
    border: 1px solid #e8ecf1;
}
.article-card.no-cover .article-card-title {
    padding-top: 16px;
    min-height: 68px;
}
.article-card.no-cover .article-card-footer { padding-top: 8px; }

/* 管理操作 */
.article-card-actions {
    display: flex;
    gap: 6px;
    padding: 10px 14px 12px;
    flex-wrap: wrap;
    border-top: 1px dashed #f0f0f0;
    margin-top: 4px;
}
.article-card-actions .btn-sm {
    padding: 3px 10px;
    font-size: 11px;
}

/* ============================================
   侧边栏
   ============================================ */
.sidebar-widget {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    margin-bottom: 20px;
}
.sidebar-widget h3 {
    font-size: 16px;
    margin-bottom: 12px;
    color: #333;
    padding-bottom: 8px;
    border-bottom: 2px solid #f0f0f0;
}

.featured-widget {
    background: linear-gradient(135deg, #fef9f0 0%, #fdf2e9 100%);
    border: 1px solid #fdebd0;
}
.featured-widget h3 { color: #f39c12; border-bottom-color: #fdebd0; }
.featured-list,
.announcement-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 220px;
    overflow-y: auto;
}
.featured-list li,
.announcement-list li {
    padding: 8px 0;
    border-bottom: 1px solid #fdebd0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
}
.featured-list li:last-child,
.announcement-list li:last-child { border-bottom: none; }

.featured-link,
.announcement-link {
    color: #333;
    text-decoration: none;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
}
.featured-link:hover { color: #f39c12; }
.announcement-link:hover { color: #667eea; }

.featured-title,
.announcement-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.featured-star,
.announcement-badge { font-size: 13px; flex-shrink: 0; }
.popup-badge { font-size: 12px; color: #f39c12; flex-shrink: 0; }
.featured-time,
.announcement-time { font-size: 11px; color: #999; flex-shrink: 0; }

.announcement-widget {
    background: linear-gradient(135deg, #f8faff 0%, #f0f4ff 100%);
    border: 1px solid #e8ecf1;
}
.announcement-widget h3 { color: #667eea; border-bottom-color: #dce3f5; }
.announcement-list li { border-bottom-color: #e8ecf1; }

.tools-widget {
    background: linear-gradient(135deg, #f0f9ff 0%, #e8f4fd 100%);
    border: 1px solid #d4e8f7;
}
.tools-widget h3 { color: #3498db; border-bottom-color: #d4e8f7; }
.tools-list { list-style: none; margin: 0; padding: 0; }
.tools-list li { border-bottom: 1px solid #e0eef8; }
.tools-list li:last-child { border-bottom: none; }
.tool-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 0;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s;
}
.tool-link:hover { color: #3498db; }
.tool-icon-sm { font-size: 18px; flex-shrink: 0; }
.tool-name-sm { flex: 1; }
.tool-arrow-sm {
    color: #3498db;
    font-size: 13px;
    opacity: 0;
    transform: translateX(-4px);
    transition: all 0.2s;
}
.tool-link:hover .tool-arrow-sm { opacity: 1; transform: translateX(0); }

.sidebar-empty { color: #999; font-size: 13px; margin: 0; }
.view-all-link {
    display: inline-block;
    margin-top: 10px;
    font-size: 13px;
    color: #667eea;
    text-decoration: none;
}
.view-all-link:hover { text-decoration: underline; }

/* ============================================
   公告弹窗
   ============================================ */
.announcement-popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: popupFadeIn 0.3s ease;
}
.announcement-popup {
    background: #fff;
    border-radius: 16px;
    max-width: 520px;
    width: 92%;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: popupSlideUp 0.4s ease;
    position: relative;
}
.popup-close {
    position: absolute;
    top: 14px; right: 18px;
    background: none;
    border: none;
    font-size: 28px;
    color: #999;
    cursor: pointer;
    z-index: 1;
    line-height: 1;
}
.popup-close:hover { color: #e74c3c; }
.popup-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 24px 12px;
    border-bottom: 2px solid #f0f0f0;
}
.popup-header .popup-icon { font-size: 28px; }
.popup-header h2 { margin: 0; font-size: 20px; color: #333; }
.popup-body {
    padding: 20px 24px 16px;
    max-height: 50vh;
    overflow-y: auto;
}
.popup-body h3 { font-size: 18px; color: #333; margin-bottom: 12px; }
.popup-body .popup-content {
    font-size: 15px;
    line-height: 1.8;
    color: #555;
    white-space: pre-wrap;
    word-break: break-word;
}
.popup-body .popup-meta {
    display: flex;
    gap: 16px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid #f0f0f0;
    font-size: 13px;
    color: #999;
}
.popup-footer { padding: 12px 24px 24px; text-align: center; }
.popup-footer .btn { padding: 10px 40px; font-size: 15px; }

@keyframes popupFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popupSlideUp {
    from { opacity: 0; transform: translateY(30px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ============================================
   中等屏（≤1100px）：卡片自动缩小
   ============================================ */
@media (max-width: 1100px) {
    .article-grid {
        grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
        gap: 14px;
    }
    .article-card.no-cover .article-card-title {
        min-height: 62px;
    }
}