/**
 * WangXi Theme - Main Stylesheet
 * 基于 Stellar 主题设计理念
 */

/* ========== 基础样式 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--stellar-font-sans);
    font-size: var(--stellar-font-base);
    line-height: 1.7;
    color: var(--stellar-text);
    background-color: var(--stellar-bg);
    transition: var(--stellar-transition);
}

a {
    color: var(--stellar-link);
    text-decoration: none;
    transition: var(--stellar-transition-fast);
}

a:hover {
    color: var(--stellar-link-hover);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ========== 容器 ========== */
.container {
    max-width: var(--stellar-container-width);
    margin: 0 auto;
    padding: 0 var(--stellar-spacing-lg);
}

/* ========== 加载动画 ========== */
.loading-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--stellar-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s, visibility 0.3s;
}

.loading-wrapper.loaded {
    opacity: 0;
    visibility: hidden;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid var(--stellar-border);
    border-top-color: var(--stellar-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========== 头部导航 ========== */
.site-header {
    position: sticky;
    top: 0;
    height: var(--stellar-header-height);
    background: var(--stellar-bg);
    border-bottom: 1px solid var(--stellar-border);
    z-index: 1000;
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.9);
}

[data-theme="dark"] .site-header,
.theme-dark .site-header {
    background: rgba(26, 26, 26, 0.9);
}

.header-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
}

.site-branding {
    display: flex;
    align-items: center;
}

.site-logo img {
    height: 40px;
    width: auto;
}

.site-title {
    font-size: var(--stellar-font-xl);
    font-weight: 700;
    color: var(--stellar-text);
}

/* 导航菜单 */
.site-nav {
    flex: 1;
    display: flex;
    justify-content: center;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: var(--stellar-spacing-lg);
}

.menu-item a {
    display: flex;
    align-items: center;
    gap: var(--stellar-spacing-xs);
    padding: var(--stellar-spacing-sm) var(--stellar-spacing-md);
    color: var(--stellar-text-secondary);
    font-weight: 500;
    border-radius: var(--stellar-radius-md);
    transition: var(--stellar-transition-fast);
}

.menu-item a:hover,
.menu-item.current a {
    color: var(--stellar-primary);
    background: var(--stellar-bg-secondary);
}

/* 头部工具 */
.header-tools {
    display: flex;
    align-items: center;
    gap: var(--stellar-spacing-sm);
}

.search-toggle,
.mobile-menu-toggle {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--stellar-radius-md);
    color: var(--stellar-text-secondary);
    cursor: pointer;
    transition: var(--stellar-transition-fast);
}

.search-toggle:hover,
.mobile-menu-toggle:hover {
    background: var(--stellar-bg-secondary);
    color: var(--stellar-primary);
}

.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
}

.mobile-menu-toggle span {
    width: 20px;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
    transition: var(--stellar-transition-fast);
}

/* ========== 搜索面板 ========== */
.search-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: var(--stellar-transition);
}

.search-panel.active {
    opacity: 1;
    visibility: visible;
}

.search-panel-inner {
    position: relative;
    width: 90%;
    max-width: 600px;
    padding: var(--stellar-spacing-2xl);
    background: var(--stellar-bg);
    border-radius: var(--stellar-radius-xl);
    box-shadow: var(--stellar-shadow-lg);
}

.search-close {
    position: absolute;
    top: var(--stellar-spacing-md);
    right: var(--stellar-spacing-md);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--stellar-radius-md);
    color: var(--stellar-text-secondary);
    cursor: pointer;
    transition: var(--stellar-transition-fast);
}

.search-close:hover {
    background: var(--stellar-bg-secondary);
    color: var(--stellar-text);
}

.search-form {
    display: flex;
    gap: var(--stellar-spacing-sm);
}

.search-input {
    flex: 1;
    padding: var(--stellar-spacing-md);
    font-size: var(--stellar-font-lg);
    background: var(--stellar-bg-secondary);
    border: 2px solid var(--stellar-border);
    border-radius: var(--stellar-radius-md);
    color: var(--stellar-text);
    transition: var(--stellar-transition-fast);
}

.search-input:focus {
    outline: none;
    border-color: var(--stellar-primary);
}

.search-submit {
    padding: 0 var(--stellar-spacing-lg);
    background: var(--stellar-primary);
    border: none;
    border-radius: var(--stellar-radius-md);
    color: white;
    font-size: var(--stellar-font-lg);
    cursor: pointer;
    transition: var(--stellar-transition-fast);
}

.search-submit:hover {
    background: var(--stellar-primary-dark);
}

.search-tips {
    margin-top: var(--stellar-spacing-md);
    text-align: center;
    color: var(--stellar-text-secondary);
    font-size: var(--stellar-font-sm);
}

.search-tips kbd {
    padding: 2px 6px;
    background: var(--stellar-bg-secondary);
    border: 1px solid var(--stellar-border);
    border-radius: var(--stellar-radius-sm);
    font-family: var(--stellar-font-mono);
    font-size: var(--stellar-font-xs);
}

/* ========== 主内容区 ========== */
.stellar-main {
    min-height: calc(100vh - var(--stellar-header-height) - 200px);
    padding: var(--stellar-spacing-2xl) 0;
}

.content-wrapper {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: var(--stellar-spacing-2xl);
}

.main-content {
    min-width: 0;
}

/* ========== 文章卡片 ========== */
.post-list {
    display: flex;
    flex-direction: column;
    gap: var(--stellar-spacing-xl);
}

.post-card {
    background: var(--stellar-bg);
    border: 1px solid var(--stellar-border);
    border-radius: var(--stellar-radius-lg);
    overflow: hidden;
    transition: var(--stellar-transition);
}

.post-card:hover {
    box-shadow: var(--stellar-shadow-md);
    transform: translateY(-2px);
}

.post-cover {
    position: relative;
    width: 100%;
    height: 240px;
    overflow: hidden;
}

.post-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.post-card:hover .post-cover img {
    transform: scale(1.05);
}

.post-card-body {
    padding: var(--stellar-spacing-xl);
}

.post-header {
    margin-bottom: var(--stellar-spacing-md);
}

.post-title {
    font-size: var(--stellar-font-2xl);
    font-weight: 700;
    line-height: 1.4;
    margin-bottom: var(--stellar-spacing-sm);
}

.post-title a {
    color: var(--stellar-text);
}

.post-title a:hover {
    color: var(--stellar-primary);
}

.post-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--stellar-spacing-md);
    font-size: var(--stellar-font-sm);
    color: var(--stellar-text-secondary);
}

.post-meta > * {
    display: flex;
    align-items: center;
    gap: var(--stellar-spacing-xs);
}

.post-excerpt {
    color: var(--stellar-text-secondary);
    line-height: 1.8;
    margin-bottom: var(--stellar-spacing-md);
}

.post-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.read-more {
    display: inline-flex;
    align-items: center;
    gap: var(--stellar-spacing-xs);
    padding: var(--stellar-spacing-sm) var(--stellar-spacing-lg);
    background: var(--stellar-primary);
    color: white;
    border-radius: var(--stellar-radius-md);
    font-weight: 500;
    transition: var(--stellar-transition-fast);
}

.read-more:hover {
    background: var(--stellar-primary-dark);
    transform: translateX(4px);
}

/* ========== 分页 ========== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--stellar-spacing-sm);
    margin-top: var(--stellar-spacing-2xl);
}

.pagination a,
.pagination span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 var(--stellar-spacing-md);
    background: var(--stellar-bg);
    border: 1px solid var(--stellar-border);
    border-radius: var(--stellar-radius-md);
    color: var(--stellar-text);
    transition: var(--stellar-transition-fast);
}

.pagination a:hover {
    background: var(--stellar-primary);
    border-color: var(--stellar-primary);
    color: white;
}

.pagination .current {
    background: var(--stellar-primary);
    border-color: var(--stellar-primary);
    color: white;
}

/* ========== 侧边栏 ========== */
.sidebar {
    position: sticky;
    top: calc(var(--stellar-header-height) + var(--stellar-spacing-lg));
    height: fit-content;
}

.widget {
    background: var(--stellar-bg);
    border: 1px solid var(--stellar-border);
    border-radius: var(--stellar-radius-lg);
    padding: var(--stellar-spacing-lg);
    margin-bottom: var(--stellar-spacing-lg);
}

.widget-title {
    font-size: var(--stellar-font-lg);
    font-weight: 700;
    margin-bottom: var(--stellar-spacing-md);
    padding-bottom: var(--stellar-spacing-sm);
    border-bottom: 2px solid var(--stellar-primary);
}

.widget-content {
    font-size: var(--stellar-font-sm);
}

/* 关于小部件 */
.site-avatar {
    width: 80px;
    height: 80px;
    margin: 0 auto var(--stellar-spacing-md);
    border-radius: 50%;
    overflow: hidden;
}

.site-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.site-name {
    text-align: center;
    font-size: var(--stellar-font-xl);
    margin-bottom: var(--stellar-spacing-sm);
}

.site-desc {
    text-align: center;
    color: var(--stellar-text-secondary);
    line-height: 1.6;
}

/* 最新文章 */
.recent-posts {
    list-style: none;
}

.recent-item {
    padding: var(--stellar-spacing-sm) 0;
    border-bottom: 1px solid var(--stellar-border-light);
}

.recent-item:last-child {
    border-bottom: none;
}

.recent-item a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--stellar-spacing-sm);
    color: var(--stellar-text);
}

.recent-item a:hover .recent-title {
    color: var(--stellar-primary);
}

.recent-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: var(--stellar-transition-fast);
}

.recent-date {
    color: var(--stellar-text-tertiary);
    font-size: var(--stellar-font-xs);
}

/* 分类列表 */
.category-list,
.archive-list {
    list-style: none;
}

.category-item,
.archive-item {
    padding: var(--stellar-spacing-sm) 0;
    border-bottom: 1px solid var(--stellar-border-light);
}

.category-item:last-child,
.archive-item:last-child {
    border-bottom: none;
}

.category-item a,
.archive-item a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--stellar-text);
}

.category-item a:hover,
.archive-item a:hover {
    color: var(--stellar-primary);
}

.category-count,
.archive-count {
    padding: 2px 8px;
    background: var(--stellar-bg-secondary);
    border-radius: var(--stellar-radius-sm);
    font-size: var(--stellar-font-xs);
    color: var(--stellar-text-secondary);
}

/* 标签云 */
.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: var(--stellar-spacing-sm);
}

.tag-item {
    padding: var(--stellar-spacing-xs) var(--stellar-spacing-md);
    background: var(--stellar-bg-secondary);
    border: 1px solid var(--stellar-border);
    border-radius: var(--stellar-radius-md);
    color: var(--stellar-text);
    font-size: var(--stellar-font-sm);
    transition: var(--stellar-transition-fast);
}

.tag-item:hover {
    background: var(--stellar-primary);
    border-color: var(--stellar-primary);
    color: white;
    transform: translateY(-2px);
}

/* ========== 页脚 ========== */
.site-footer {
    margin-top: var(--stellar-spacing-2xl);
    padding: var(--stellar-spacing-2xl) 0;
    background: var(--stellar-bg-secondary);
    border-top: 1px solid var(--stellar-border);
}

.footer-content {
    text-align: center;
}

.footer-info {
    color: var(--stellar-text-secondary);
    font-size: var(--stellar-font-sm);
    line-height: 1.8;
}

.footer-info a {
    color: var(--stellar-text);
}

.footer-info a:hover {
    color: var(--stellar-primary);
}

.footer-social {
    margin-top: var(--stellar-spacing-lg);
}

.social-links {
    display: flex;
    justify-content: center;
    gap: var(--stellar-spacing-md);
}

.social-links a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--stellar-bg);
    border: 1px solid var(--stellar-border);
    border-radius: 50%;
    color: var(--stellar-text-secondary);
    transition: var(--stellar-transition-fast);
}

.social-links a:hover {
    background: var(--stellar-primary);
    border-color: var(--stellar-primary);
    color: white;
    transform: translateY(-2px);
}

/* ========== 工具按钮 ========== */
.back-to-top,
.theme-toggle {
    position: fixed;
    bottom: var(--stellar-spacing-xl);
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--stellar-primary);
    border: none;
    border-radius: 50%;
    color: white;
    box-shadow: var(--stellar-shadow-md);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: var(--stellar-transition);
    z-index: 999;
}

.back-to-top {
    right: var(--stellar-spacing-xl);
}

.theme-toggle {
    right: calc(var(--stellar-spacing-xl) + 64px);
}

.back-to-top.show,
.theme-toggle.show {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover,
.theme-toggle:hover {
    background: var(--stellar-primary-dark);
    transform: translateY(-4px);
}

.theme-toggle .icon-sun {
    display: none;
}

.theme-toggle .icon-moon {
    display: block;
}

[data-theme="dark"] .theme-toggle .icon-sun,
.theme-dark .theme-toggle .icon-sun {
    display: block;
}

[data-theme="dark"] .theme-toggle .icon-moon,
.theme-dark .theme-toggle .icon-moon {
    display: none;
}

/* ========== 响应式设计 ========== */
@media (max-width: 992px) {
    .content-wrapper {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        position: static;
    }
    
    .site-nav {
        display: none;
    }
    
    .mobile-menu-toggle {
        display: flex;
    }
}

@media (max-width: 768px) {
    .post-cover {
        height: 200px;
    }
    
    .post-title {
        font-size: var(--stellar-font-xl);
    }
    
    .back-to-top,
    .theme-toggle {
        width: 40px;
        height: 40px;
        bottom: var(--stellar-spacing-lg);
    }
    
    .back-to-top {
        right: var(--stellar-spacing-lg);
    }
    
    .theme-toggle {
        right: calc(var(--stellar-spacing-lg) + 52px);
    }
}

@media (max-width: 576px) {
    .stellar-main {
        padding: var(--stellar-spacing-lg) 0;
    }
    
    .post-card-body {
        padding: var(--stellar-spacing-lg);
    }
    
    .post-meta {
        font-size: var(--stellar-font-xs);
    }
}

/* ========== 移动端菜单 ========== */
.mobile-menu {
    position: fixed;
    top: 0;
    right: -100%;
    width: 280px;
    height: 100%;
    background: var(--stellar-bg);
    box-shadow: var(--stellar-shadow-lg);
    z-index: 2001;
    transition: var(--stellar-transition);
}

.mobile-menu.active {
    right: 0;
}

.mobile-menu-inner {
    padding: var(--stellar-spacing-2xl) var(--stellar-spacing-lg);
}

.mobile-nav-menu {
    list-style: none;
}

.mobile-nav-menu .menu-item {
    margin-bottom: var(--stellar-spacing-sm);
}

.mobile-nav-menu .menu-item a {
    display: flex;
    align-items: center;
    gap: var(--stellar-spacing-sm);
    padding: var(--stellar-spacing-md);
    color: var(--stellar-text);
    border-radius: var(--stellar-radius-md);
    transition: var(--stellar-transition-fast);
}

.mobile-nav-menu .menu-item a:hover,
.mobile-nav-menu .menu-item.current a {
    background: var(--stellar-bg-secondary);
    color: var(--stellar-primary);
}

.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: var(--stellar-transition);
}

.mobile-menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ========== 无文章提示 ========== */
.no-post {
    padding: var(--stellar-spacing-2xl);
    text-align: center;
    color: var(--stellar-text-secondary);
    background: var(--stellar-bg-secondary);
    border-radius: var(--stellar-radius-lg);
}

