/* GossHub 首页样式 */

/* ========== 通用容器 ========== */
.container {
    max-width: var(--container);
    margin-left: auto;
    margin-right: auto;
    padding-left: calc((100vw - var(--container)) / 2);
    padding-right: calc((100vw - var(--container)) / 2);
}

/* ========== 导航栏 ========== */
.navbar {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    background: rgba(255,255,255,0.92);
}
[data-theme="dark"] .navbar {
    background: rgba(11,17,32,0.92);
    border-bottom-color: rgba(96,165,250,0.1);
}

.navbar-inner {
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--primary);
}

.navbar-brand-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.navbar-brand-icon img {
    display: block;
}

.navbar-brand-icon svg {
    width: 48px;
    height: 48px;
}

.navbar-brand-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.2;
}

.navbar-brand-en {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: 1px;
}

.navbar-brand-cn {
    font-size: 12px;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: 4px;
}

.navbar-search {
    display: flex;
    align-items: center;
    background: var(--bg);
    border-radius: 10px;
    padding: 8px 16px;
    width: 360px;
    border: 1.5px solid transparent;
    transition: all 0.2s;
    position: relative;
}
[data-theme="dark"] .navbar-search {
    background: rgba(96,165,250,0.06);
    border-color: rgba(96,165,250,0.1);
}
[data-theme="dark"] .navbar-search:focus-within {
    background: rgba(96,165,250,0.1);
    border-color: rgba(96,165,250,0.3);
    box-shadow: 0 0 0 3px rgba(96,165,250,0.1);
}

.navbar-search:focus-within {
    border-color: var(--primary-light);
    background: var(--white);
    box-shadow: 0 0 0 3px var(--primary-lighter);
}

.navbar-search i { color: var(--text-secondary); margin-right: 8px; }

.navbar-search input {
    border: none;
    background: none;
    outline: none;
    font-size: 14px;
    width: 100%;
    color: var(--text);
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ========== #5 AJAX 搜索结果下拉 ========== */
.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 8px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 400px;
    overflow-y: auto;
    display: none;
    z-index: 200;
}
[data-theme="dark"] .search-dropdown {
    background: #1A2332;
    border-color: rgba(96,165,250,0.12);
    box-shadow: 0 12px 32px rgba(0,0,0,0.5);
}
.search-dropdown.active { display: block; }

.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--text);
    transition: background 0.15s;
    border-bottom: 1px solid var(--border);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--primary-lighter); }
[data-theme="dark"] .search-result-item:hover { background: rgba(96,165,250,0.08); }
/* #26 键盘选中高亮 */
.search-result-item.search-active,
.search-result-item:focus { background: var(--primary-lighter); outline: none; }
[data-theme="dark"] .search-result-item.search-active,
[data-theme="dark"] .search-result-item:focus { background: rgba(96,165,250,0.08); }

.search-result-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
}

.search-result-info h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
    /* #5 搜索关键词高亮 */
}
.search-result-info h4 mark {
    background: var(--highlight);
    color: var(--text);
    padding: 0 2px;
    border-radius: 2px;
}
[data-theme="dark"] .search-result-info h4 mark {
    background: var(--highlight);
    color: var(--highlight-dark);
}

.search-result-info p {
    font-size: 12px;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.search-result-info p mark {
    background: var(--highlight);
    color: var(--text);
    padding: 0 2px;
    border-radius: 2px;
}

.search-empty {
    text-align: center;
    padding: 24px;
    color: var(--text-secondary);
    font-size: 14px;
}
.search-loading {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
    font-size: 14px;
}
.search-hint {
    text-align: center;
    padding: 12px;
    color: var(--text-secondary);
    font-size: 12px;
    border-top: 1px solid var(--border);
}

.btn-admin {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}
.btn-admin:hover { background: var(--primary-light); transform: translateY(-1px); }
[data-theme="dark"] .btn-admin {
    background: #2563EB;
    color: #fff;
}
[data-theme="dark"] .btn-admin:hover {
    background: #3B82F6;
}

/* ========== Hero 区域 ========== */
.hero {
    background: linear-gradient(135deg, var(--primary-dark) 0%, #2563EB 50%, var(--primary-light) 100%);
    padding: 48px 0;
    color: #fff;
    position: relative;
    overflow: hidden;
}
[data-theme="dark"] .hero {
    background: linear-gradient(135deg, #0C1929 0%, #142D52 40%, #1A3F6F 100%);
    position: relative;
}
[data-theme="dark"] .hero::after {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 30% 50%, rgba(96,165,250,0.08) 0%, transparent 60%),
        radial-gradient(ellipse at 70% 30%, rgba(59,130,246,0.06) 0%, transparent 50%);
    pointer-events: none;
}

.hero::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: rgba(255,255,255,0.05);
}

.hero::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: -10%;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    background: rgba(255,255,255,0.03);
}

.hero-inner {
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 24px;
    position: relative;
    z-index: 1;
}

.hero h1 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 8px;
}

.hero p {
    font-size: 16px;
    opacity: 0.85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ========== 分类导航 ========== */
.categories-bar {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 64px;
    z-index: 90;
}
[data-theme="dark"] .categories-bar {
    background: rgba(11,17,32,0.92);
    backdrop-filter: blur(12px);
    border-bottom-color: rgba(96,165,250,0.08);
}

.categories-inner {
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 0;
    overflow-x: auto;
    scrollbar-width: none;
    /* 用clip-path代替overflow裁剪水平溢出，但不影响fixed定位的下拉面板 */
    position: relative;
}

.categories-inner::-webkit-scrollbar { display: none; }

.cat-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 14px 18px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    border-bottom: 2.5px solid transparent;
    white-space: nowrap;
    transition: all 0.2s;
}

.cat-tab:hover { color: var(--primary-light); }

.cat-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}
[data-theme="dark"] .cat-tab.active {
    color: #93C5FD;
    border-bottom-color: #60A5FA;
}

.cat-tab i { font-size: 14px; }

.cat-count {
    background: var(--bg);
    color: var(--text-secondary);
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 10px;
    font-weight: 500;
}
[data-theme="dark"] .cat-count {
    background: rgba(96,165,250,0.1);
    color: #93C5FD;
}

.cat-tab.active .cat-count {
    background: var(--primary-lighter);
    color: var(--primary);
}

/* 二级分类导航 - hover下拉菜单 */
.cat-group {
    position: relative;
}

/* 一级分类右侧下拉箭头 */
.cat-arrow {
    font-size: 11px;
    margin-left: 2px;
    transition: transform 0.2s ease;
    color: var(--text-secondary);
    opacity: 0.5;
}
.cat-group:hover .cat-arrow {
    transform: rotate(180deg);
    opacity: 0.8;
}

/* 下拉面板 - 使用fixed定位脱离父级overflow裁剪 */
.cat-dropdown {
    position: fixed;
    min-width: 180px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    padding: 6px 0;
    z-index: 9999;
    /* 默认隐藏 */
    display: none;
}
.cat-dropdown.show {
    display: block;
    /* 入场动画 */
    animation: dropdownFadeIn 0.15s ease forwards;
}
@keyframes dropdownFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}
[data-theme="dark"] .cat-dropdown {
    background: #1e293b;
    border-color: rgba(96,165,250,0.15);
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

/* 下拉子分类项 */
.cat-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.12s, color 0.12s;
}
.cat-dropdown-item:hover {
    background: var(--primary-lighter);
    color: var(--primary);
}
[data-theme="dark"] .cat-dropdown-item:hover {
    background: rgba(96,165,250,0.08);
    color: #93C5FD;
}
.cat-dropdown-item.active {
    color: var(--primary);
    font-weight: 600;
    background: var(--primary-lighter);
}
[data-theme="dark"] .cat-dropdown-item.active {
    color: #93C5FD;
    background: rgba(96,165,250,0.1);
}
.cat-dropdown-item i { font-size: 13px; }
.cat-dropdown-name { flex: 1; }
.cat-dropdown-count {
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 10px;
    background: var(--bg);
    color: var(--text-secondary);
}
.cat-dropdown-item:hover .cat-dropdown-count,
.cat-dropdown-item.active .cat-dropdown-count {
    background: var(--primary);
    color: #fff;
}

/* 父分类在子分类激活时的高亮 */
.cat-tab.parent-active {
    border-bottom-color: var(--primary-light);
    color: var(--primary-light);
}
.cat-tab.parent-active .cat-arrow {
    color: var(--primary-light);
    opacity: 0.8;
}

/* ========== 主内容区 ========== */
.main {
    max-width: var(--container);
    margin: 0 auto;
    padding: 32px 24px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.section-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ========== 精选卡片 ========== */
.featured-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--gutter);
    margin-bottom: 48px;
}

.featured-card {
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    color: inherit;
    position: relative;
    display: flex;
    flex-direction: column;
}
[data-theme="dark"] .featured-card {
    border: 1px solid rgba(96,165,250,0.08);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
[data-theme="dark"] .featured-card:hover {
    border-color: rgba(96,165,250,0.2);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4), 0 0 0 1px rgba(96,165,250,0.15);
}

.featured-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-3px);
}

.featured-badge {
    position: absolute;
    top: 16px;
    left: 16px;
    background: linear-gradient(135deg, var(--success), #059669);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
    z-index: 2;
}

/* #4 封面图支持 */
.featured-thumb {
    height: 180px;
    background: linear-gradient(135deg, var(--primary-lighter), var(--primary-lighter));
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}
[data-theme="dark"] .featured-thumb {
    background: linear-gradient(135deg, #0F1F35 0%, #162A46 100%);
    position: relative;
}
[data-theme="dark"] .featured-thumb::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 50%, rgba(96,165,250,0.04) 0%, transparent 70%);
    pointer-events: none;
}

.featured-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.featured-thumb i {
    font-size: 48px;
    color: var(--primary-light);
    opacity: 0.6;
}

/* 文字缩略图（无封面图时的fallback） */
.thumb-text {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    font-weight: 800;
    color: rgba(255,255,255,0.9);
    text-shadow: 0 2px 8px rgba(0,0,0,0.15);
    width: 100%;
    height: 100%;
}

.featured-body {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.featured-body .cat-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: 6px;
    margin-bottom: 10px;
    width: fit-content;
}
/* 暗黑模式下增强分类标签可读性 */
[data-theme="dark"] .featured-body .cat-label,
[data-theme="dark"] .article-body .cat-label {
    text-shadow: 0 0 8px currentColor;
    border: 1px solid currentColor;
    border-opacity: 0.2;
}

.featured-body h3 {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 8px;
    line-height: 1.4;
}

.featured-body p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
}

.featured-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}
[data-theme="dark"] .featured-meta {
    border-top-color: rgba(96,165,250,0.08);
}

.featured-date {
    font-size: 12px;
    color: var(--text-secondary);
}

.featured-read {
    font-size: 13px;
    font-weight: 600;
    color: var(--primary-light);
    display: flex;
    align-items: center;
    gap: 4px;
}
[data-theme="dark"] .featured-read {
    color: #60A5FA;
}

/* ========== 文章列表 ========== */
.articles-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--gutter);
}

.article-card {
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
}
[data-theme="dark"] .article-card {
    border: 1px solid rgba(96,165,250,0.08);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
[data-theme="dark"] .article-card:hover {
    border-color: rgba(96,165,250,0.2);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4), 0 0 0 1px rgba(96,165,250,0.15);
}

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

.article-thumb {
    height: 140px;
    background: linear-gradient(135deg, var(--primary-lighter), var(--primary-lighter));
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
[data-theme="dark"] .article-thumb {
    background: linear-gradient(135deg, #0F1F35 0%, #162A46 100%);
}

.article-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.article-thumb i {
    font-size: 36px;
    color: var(--primary-light);
    opacity: 0.5;
}

.article-body {
    padding: 18px 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.article-body .cat-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 5px;
    margin-bottom: 8px;
    width: fit-content;
}

.article-body h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 6px;
    line-height: 1.4;
}

.article-body p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
}

.article-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
    font-size: 12px;
    color: var(--text-secondary);
}

.article-views {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ========== 分页 ========== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 32px;
    padding-bottom: 16px;
}
.pagination a, .pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    background: var(--white);
}
.pagination a:hover { border-color: var(--primary-light); color: var(--primary-light); }
.pagination .active {
    background: var(--primary-light);
    color: var(--white);
    border-color: var(--primary-light);
}
[data-theme="dark"] .pagination a,
[data-theme="dark"] .pagination span {
    background: #1A2332;
    border-color: rgba(96,165,250,0.12);
}
[data-theme="dark"] .pagination a:hover {
    border-color: rgba(96,165,250,0.3);
    color: #93C5FD;
    background: rgba(96,165,250,0.08);
}
[data-theme="dark"] .pagination .active {
    background: #2563EB;
    border-color: #2563EB;
    color: #fff;
}
.pagination .disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ========== 响应式 ========== */
@media (max-width: 1024px) {
    .featured-grid,
    .articles-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .navbar-search { width: 200px; }
    .hero { padding: 32px 0; }
    .hero h1 { font-size: 24px; }
    .hero p { font-size: 14px; }
    .featured-grid,
    .articles-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .main { padding: 24px 16px; }
    .categories-inner { padding: 0 16px; }
    .hero-inner { padding: 0 16px; }
}

@media (max-width: 480px) {
    .navbar-inner { padding: 0 12px; }
    .navbar-search { width: 160px; }
    .hero h1 { font-size: 20px; }
    .main { padding: 16px 12px; }
}
