/**
 * Gsage Theme - Modern Design System v2
 * Clean Typography • Perfect Spacing • Minimalist Beautiful
 */

/* === 基础变量 === */
:root {
    /* === 正常模式：#CC3333(红) #CCCCCC(灰) #003366(深蓝) === */
    --bg-primary: #ffffff;
    --bg-secondary: #f9f9f9;
    --bg-tertiary: #f0f0f0;
    
    --text-primary: #003366;
    --text-secondary: #444444;
    --text-tertiary: #777777;
    --text-muted: #999999;
    
    --gold: #CC3333;
    --gold-light: #dd4444;
    --gold-dark: #bb2222;
    
    --border: #CCCCCC;
    --border-light: #dddddd;
    
    --gradient-gold: linear-gradient(135deg, #CC3333 0%, #dd4444 100%);
    --shadow-gold: 0 4px 20px rgba(204, 51, 51, 0.2);
    
    /* 间距系统 - 8px 基准 */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 48px;
    --space-8: 64px;
    --space-9: 96px;
    
    /* 容器 */
    --container-max: 1080px;
    --container-narrow: 720px;
    
    /* 圆角 */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 999px;
    
    /* 阴影 */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.1);
}

@media (prefers-color-scheme: dark) {
    :root {
        /* === 暗黑模式：黑色渐变背景 === */
        --bg-page-start: #0a0e1a;
        --bg-page-mid: #1a1f2e;
        --bg-page-end: #0f141f;
        
        --text-primary: #FFFFCC;
        --text-secondary: #e0e0e0;
        --text-tertiary: #b0b0b0;
        --text-muted: #888888;
        
        --gold: #CC9933;
        --gold-light: #ddaa44;
        --gold-dark: #bb8822;
        
        --border: #333333;
        --border-light: #2a2a2a;
        
        --gradient-gold: linear-gradient(135deg, #CC9933 0%, #ddaa44 100%);
        --shadow-gold: 0 4px 20px rgba(204, 153, 51, 0.25);
    }
}

/* === 重置 === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(180deg, var(--bg-page-start) 0%, var(--bg-page-mid) 50%, var(--bg-page-end) 100%);
    color: var(--text-secondary);
    line-height: 1.75;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}

/* === 排版 === */
h1, h2, h3, h4 {
    color: var(--text-primary);
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.02em;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }

p { margin-bottom: 1em; }

a {
    color: inherit;
    text-decoration: none;
    transition: opacity 0.2s;
}

a:hover { opacity: 0.7; }

/* === 布局 === */
.container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 var(--space-5);
    width: 100%;
}

/* === 响应式容器 === */
@media (max-width: 768px) {
    .container {
        padding: 0 var(--space-4);
    }
}

/* === 头部导航 - 两层布局 === */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: #fff;
}

@media (prefers-color-scheme: dark) {
    .site-header {
        background: #1a1a1a;
    }
}

/* 清除之前的样式干扰 */
.header-desktop {
    display: block;
}

/* 第一层：Logo + 搜索 + 头像 */
.header-layer-top {
    height: 56px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
}

@media (prefers-color-scheme: dark) {
    .header-layer-top {
        border-bottom-color: #333;
    }
}

/* 第二层：菜单 */
.header-layer-bottom {
    height: 48px;
    background: #fafafa;
}

@media (prefers-color-scheme: dark) {
    .header-layer-bottom {
        background: #222;
    }
}

/* 内部容器 */
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    width: 100%;
    box-sizing: border-box;
}

/* 第一层布局 */
.header-layer-top .header-left {
    flex: 0 0 auto;
}

.header-layer-top .header-center {
    flex: 1;
    display: flex;
    justify-content: center;
    padding: 0 40px;
}

.header-layer-top .header-right {
    flex: 0 0 auto;
}

/* Logo */
.header-logo .custom-logo {
    height: 32px;
    width: auto;
}

/* 搜索框 */
.header-search .search-form {
    display: flex;
    align-items: center;
    background: #f5f5f5;
    border-radius: 24px;
    padding: 6px 16px;
    width: 100%;
    max-width: 400px;
}

@media (prefers-color-scheme: dark) {
    .header-search .search-form {
        background: #333;
    }
}

.header-search .search-field {
    border: none;
    background: transparent;
    padding: 4px;
    font-size: 14px;
    width: 100%;
    outline: none;
    color: #333;
}

@media (prefers-color-scheme: dark) {
    .header-search .search-field {
        color: #fff;
    }
}

.header-search .search-submit {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: #666;
}

/* 用户头像 */
.header-user .user-avatar img,
.header-user .user-login img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

/* 第二层菜单 */
.header-layer-bottom .header-inner {
    justify-content: flex-start;
}

.header-layer-bottom .nav-menu {
    display: flex;
    list-style: none;
    gap: 0;
    margin: 0;
    padding: 0;
}

.header-layer-bottom .nav-menu > li > a {
    display: block;
    color: #333;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    padding: 14px 20px;
    position: relative;
}

@media (prefers-color-scheme: dark) {
    .header-layer-bottom .nav-menu > li > a {
        color: #ccc;
    }
}

.header-layer-bottom .nav-menu > li > a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 2px;
    background: #4FB3FF;
    transition: width 0.3s;
}

.header-layer-bottom .nav-menu > li > a:hover::after {
    width: 50%;
}

/* 响应式 */
.header-mobile {
    display: none;
}

@media (max-width: 768px) {
    .header-desktop {
        display: none;
    }
    .header-mobile {
        display: flex;
    }
    .site-header {
        height: 56px;
    }
}

.site-branding {
    flex-shrink: 0;
}

.site-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.site-title a {
    color: transparent;
}

.main-navigation {
    flex: 1;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: var(--space-6);
    margin: 0;
}

.nav-menu a {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    font-weight: 500;
    padding: var(--space-2) 0;
    position: relative;
}

.nav-menu a:hover,
.nav-menu .current-menu-item a {
    color: var(--text-primary);
}

.nav-menu a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--gold), var(--gold-light));
    transition: width 0.3s;
}

.nav-menu a:hover::after { width: 100%; }

.header-actions {
    display: flex;
    gap: var(--space-3);
}

.search-toggle,
.menu-toggle {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.search-toggle:hover {
    background: var(--bg-tertiary);
    color: var(--gold);
}

.menu-toggle { display: none; }

/* === Hero 区域 === */
.hero-section {
    position: relative;
    padding: var(--space-9) 0 var(--space-8);
    overflow: hidden;
    width: 100%;
}

.hero-bg-decoration {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    width: 100%;
}

.gradient-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.3;
}

.gradient-orb-1 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(201,169,89,0.3) 0%, transparent 70%);
    top: -200px;
    right: -100px;
}

.gradient-orb-2 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(201,169,89,0.2) 0%, transparent 70%);
    bottom: -150px;
    left: -100px;
}

.hero-content {
    position: relative;
    z-index: 1;
    max-width: var(--container-narrow);
    margin: 0 auto;
    text-align: center;
}

.hero-title {
    font-size: 3.5rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: var(--space-4);
}

.gradient-text {
    display: block;
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle-text {
    display: block;
    font-size: 0.5em;
    color: var(--text-tertiary);
    font-weight: 400;
    margin-top: var(--space-2);
}

.hero-description {
    font-size: 1.125rem;
    color: var(--text-tertiary);
    margin-bottom: var(--space-6);
    line-height: 1.8;
}

.hero-cta {
    display: flex;
    gap: var(--space-3);
    justify-content: center;
}

/* === 按钮 === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    font-weight: 600;
    transition: all 0.2s;
    cursor: pointer;
    border: none;
}

.btn-large {
    padding: var(--space-4) var(--space-7);
    font-size: 1rem;
}

.btn-gold {
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-light) 100%);
    color: #ffffff;
    box-shadow: var(--shadow-gold);
}

.btn-gold:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(201,169,89,0.35);
    opacity: 1;
}

.btn-ghost {
    background: transparent;
    color: var(--text-primary);
}

.btn-ghost:hover {
    background: var(--bg-tertiary);
    opacity: 1;
}

/* === Section === */
.content-section {
    padding: var(--space-8) 0;
    width: 100%;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-6);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--border);
    width: 100%;
}

.section-title {
    font-size: 1.75rem;
    font-weight: 600;
}

.section-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--text-secondary);
    font-size: 0.9375rem;
    font-weight: 500;
}

.section-link:hover {
    color: var(--gold);
}

/* === 文章网格 === */
.articles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--space-5);
    width: 100%;
}

@media (max-width: 768px) {
    .articles-grid {
        grid-template-columns: 1fr;
    }
}

.article-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all 0.3s;
    border: 1px solid var(--border-light);
}

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

.article-link {
    display: block;
}

.article-image {
    aspect-ratio: 16/10;
    overflow: hidden;
    background: var(--bg-tertiary);
}

.article-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.article-card:hover .article-image img {
    transform: scale(1.05);
}

.article-image-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
}

.article-content {
    padding: var(--space-5);
}

.article-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: var(--space-2);
    line-height: 1.4;
}

.article-excerpt {
    color: var(--text-tertiary);
    font-size: 0.9375rem;
    margin-bottom: var(--space-4);
    line-height: 1.7;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.article-meta {
    display: flex;
    gap: var(--space-3);
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.article-date,
.article-category {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

/* === Features === */
.features-section {
    padding: var(--space-8) 0 var(--space-9);
    background: var(--bg-secondary);
    width: 100%;
    overflow-x: hidden;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: var(--space-5);
    width: 100%;
}

@media (max-width: 768px) {
    .features-grid {
        grid-template-columns: 1fr;
    }
}

.feature-card {
    display: flex;
    align-items: flex-start;
    gap: var(--space-4);
    padding: var(--space-6);
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    transition: all 0.3s;
    max-width: 100%;
}

@media (max-width: 768px) {
    .feature-card {
        padding: var(--space-5);
    }
}

.feature-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: transparent;
}

.feature-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, rgba(201,169,89,0.1) 0%, rgba(212,183,110,0.05) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gold);
    flex-shrink: 0;
}

.feature-content {
    flex: 1;
}

.feature-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: var(--space-1);
}

.feature-description {
    color: var(--text-tertiary);
    font-size: 0.875rem;
    margin: 0;
}

/* === 搜索模态框 === */
.search-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(10px);
    z-index: 9999;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 100px;
}

.search-modal.active {
    display: flex;
}

.search-modal-inner {
    width: 100%;
    max-width: 640px;
    padding: var(--space-5);
}

.search-modal-form {
    display: flex;
    gap: var(--space-3);
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: var(--space-3);
    box-shadow: var(--shadow-lg);
}

.search-modal-form input[type="search"] {
    flex: 1;
    border: none;
    outline: none;
    font-size: 1rem;
    padding: var(--space-2) var(--space-3);
    background: transparent;
}

.search-close {
    position: absolute;
    top: var(--space-5);
    right: var(--space-5);
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-md);
}

/* === 响应式 === */
@media (max-width: 768px) {
    html, body {
        overflow-x: hidden;
    }
    
    .site-header {
        overflow-x: hidden;
    }
    
    .nav-menu {
        position: fixed;
        top: 72px;
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--bg-primary);
        flex-direction: column;
        padding: var(--space-5);
        transform: translateX(100%);
        transition: transform 0.3s;
        overflow-y: auto;
        overflow-x: hidden;
    }
    
    .nav-menu.active {
        transform: translateX(0);
    }
    
    .menu-toggle { display: flex; }
    
    .hero-title { font-size: 2rem; }
    .hero-description { font-size: 1rem; }
    .hero-cta { flex-direction: column; }
    
    .articles-grid {
        grid-template-columns: 1fr;
    }
    
    .features-grid {
        grid-template-columns: 1fr;
    }
    
    /* 确保卡片不溢出 */
    .article-card,
    .feature-card {
        max-width: 100%;
    }
}

/* === 动画 === */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* === 防止溢出 === */
img, video, iframe {
    max-width: 100%;
    height: auto;
}

.site-content {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    margin-top: 104px;
}

@media (max-width: 768px) {
    .site-content {
        margin-top: 56px;
    }
}

/* === 全局防溢出 === */
.site-header,
.site-main,
.site-footer,
.container,
.header-container {
    max-width: 100%;
    overflow-x: hidden;
}

/* 移动端的额外保护 */
@media (max-width: 768px) {
    .site-content {
        margin-top: 60px;
    }
}
    .hero-title {
        word-break: break-word;
    }
    
    .article-content,
    .feature-content {
        max-width: 100%;
        overflow-wrap: break-word;
    }
}

/* === 行为按钮（点赞/收藏/不感兴趣） === */
.post-actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin: var(--space-5) 0;
    padding: var(--space-3) 0;
    border-top: 1px solid var(--border-light);
    border-bottom: 1px solid var(--border-light);
}

.post-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.post-action-btn:hover {
    border-color: var(--gold);
    color: var(--gold);
    background: var(--bg-secondary);
}

.post-action-btn.is-active {
    border-color: var(--gold);
    background: var(--gradient-gold);
    color: #fff;
    box-shadow: var(--shadow-gold);
}

/* 推荐卡片"不感兴趣" */
.carousel-ignore-btn {
    margin-top: 8px;
    padding: 3px 10px;
    font-size: 11px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.carousel-ignore-btn:hover {
    color: var(--gold);
    border-color: var(--gold);
    background: var(--bg-secondary);
}
