/* 定义CSS变量系统，便于主题切换和维护 */
:root {
    /* 浅色主题变量 */
    --bg-primary: #f8f9fa;          /* 主背景色 */
    --bg-secondary: #ffffff;        /* 次背景色 */
    --bg-tertiary: #f0f2f5;         /* 第三背景色 */
    --text-primary: #212529;        /* 主文本色 */
    --text-secondary: #495057;      /* 次文本色 */
    --text-muted: #6c757d;          /* 弱化文本色 */
    --border-color: #dee2e6;        /* 边框颜色 */
    --accent-color: #007bff;        /* 强调色/主题色 */
    --card-bg: #ffffff;             /* 卡片背景色 */
    --card-shadow: 0 1px 3px rgba(0,0,0,0.1); /* 卡片阴影 */
    --hero-overlay: rgba(0,0,0,0.6); /* 英雄区域遮罩 */
    --progress-bg: linear-gradient(to right, #4CAF50 0%, #00BCD4 25%, #2196F3 50%, #9C27B0 75%, #FF5722 100%); /* 进度条渐变 */
    --footer-bg: #f8f9fa;           /* 页脚背景色 */
    --footer-text: #495057;         /* 页脚文本色 */
    
    /* 热力图颜色等级 */
    --heatmap-0: #ebedf0;  /* 无活动 */
    --heatmap-1: #9be9a8;  /* 低活动 */
    --heatmap-2: #40c463;  /* 中活动 */
    --heatmap-3: #30a14e;  /* 高活动 */
    --heatmap-4: #216e39;  /* 极高活动 */
    
    /* 提示框样式 */
    --tooltip-bg: #212529;  /* 提示框背景 */
    --tooltip-text: #ffffff; /* 提示框文本 */
    
    /* 服务部分颜色变量 */
    --wiki-color: #4285f4;          /* Wiki服务主题色 */
    --nextcloud-color: #0082c9;     /* Nextcloud服务主题色 */
    --other-service-color: #666;    /* 其他服务主题色 */
}

/* 深色主题变量 - 使用媒体查询检测系统主题偏好 */
@media (prefers-color-scheme: dark) {
    :root {
        /* 深色主题对应的颜色变量 */
        --bg-primary: #121212;
        --bg-secondary: #1e1e1e;
        --bg-tertiary: #2d2d2d;
        --text-primary: #e9ecef;
        --text-secondary: #adb5bd;
        --text-muted: #6c757d;
        --border-color: #495057;
        --accent-color: #4dabf7;
        --card-bg: #2d2d2d;
        --card-shadow: 0 1px 3px rgba(0,0,0,0.3);
        --hero-overlay: rgba(0,0,0,0.8);
        --progress-bg: linear-gradient(to right, #2e7d32 0%, #00838f 25%, #1565c0 50%, #6a1b9a 75%, #d84315 100%);
        --footer-bg: #1a1a1a;
        --footer-text: #adb5bd;
        
        /* 深色模式热力图颜色 */
        --heatmap-0: #161b22;
        --heatmap-1: #0e4429;
        --heatmap-2: #006d32;
        --heatmap-3: #26a641;
        --heatmap-4: #39d353;
        
        /* 深色模式提示框颜色 */
        --tooltip-bg: #e9ecef;
        --tooltip-text: #121212;
        
        /* 深色模式服务颜色 */
        --wiki-color: #669df6;
        --nextcloud-color: #3399cc;
        --other-service-color: #adb5bd;
    }
}

/* 定义 LXGW WenKai Lite 字体家族 - 开源中文字体 */
@font-face {
    font-family: 'LXGW WenKai Lite';
    src: url('https://www.guohao.asia/cdn/font/lxgw-wenkai-lite/LXGWWenKaiLite-Light.woff2') format('woff2'),
         url('https://www.guohao.asia/cdn/font/lxgw-wenkai-lite/LXGWWenKaiLite-Light.woff') format('woff');
    font-weight: 300;  /* 细体字重 */
    font-style: normal;
    font-display: swap; /* 字体加载策略 */
}

@font-face {
    font-family: 'LXGW WenKai Lite';
    src: url('https://www.guohao.asia/cdn/font/lxgw-wenkai-lite/LXGWWenKaiLite-Regular.woff2') format('woff2'),
         url('https://www.guohao.asia/cdn/font/lxgw-wenkai-lite/LXGWWenKaiLite-Regular.woff') format('woff');
    font-weight: 400;  /* 常规字重 */
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'LXGW WenKai Lite';
    src: url('https://www.guohao.asia/cdn/font/lxgw-wenkai-lite/LXGWWenKaiLite-Medium.woff2') format('woff2'),
         url('https://www.guohao.asia/cdn/font/lxgw-wenkai-lite/LXGWWenKaiLite-Medium.woff') format('woff');
    font-weight: 500;  /* 中等字重 */
    font-style: normal;
    font-display: swap;
}

/* 定义等宽字体 - 用于代码显示 */
@font-face {
    font-family: 'LXGW WenKai Mono Lite';
    src: url('https://www.guohao.asia/cdn/font/lxgw-wenkai-lite/LXGWWenKaiMonoLite-Regular.woff2') format('woff2'),
         url('https://www.guohao.asia/cdn/font/lxgw-wenkai-lite/LXGWWenKaiMonoLite-Regular.woff') format('woff');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

/* 全局样式设置 */
body {
    font-family: 'LXGW WenKai Lite', -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif; /* 字体回退链 */
    background-color: var(--bg-primary);  /* 使用CSS变量 */
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    transition: background-color 0.3s ease, color 0.3s ease; /* 平滑过渡效果 */
}

/* 代码和预格式文本使用等宽字体 */
code, pre, kbd, samp {
    font-family: 'LXGW WenKai Mono Lite', Monaco, Consolas, "Courier New", monospace;
}

/* 标题样式 - 使用中等字重 */
h1, h2, h3, h4, h5, h6 {
    font-family: 'LXGW WenKai Lite', sans-serif;
    font-weight: 500;
    color: var(--text-primary);
}

/* ==================== 英雄区域文本颜色修复 ==================== */
/* 确保英雄区域所有文本为白色，不受主题影响 */
.hero,
.hero .container,
.hero .container *:not(.social-link):not(.social-link *),
.hero h1,
.hero .lead,
.hero .font-italic,
.hero .text-white,
.hero .text-white * {
    color: white !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5); /* 添加文字阴影增强可读性 */
}

/* 确保英雄区域链接也保持白色 */
.hero a:not(.social-link) {
    color: white !important;
    text-decoration: underline;
}

.hero a:not(.social-link):hover {
    color: #f8f9fa !important;
    text-decoration: underline;
}

/* 年度进度条样式 */
.elementor-annual-progress {
    width: 100%;
    height: 12px;
    background: var(--progress-bg);  /* 渐变背景 */
    position: relative;
    margin: 1px 0;
    border-radius: 1px;
    overflow: hidden;
}

/* 进度条填充部分 */
.elementor-progress-bar {
    height: 100%;
    width: 0;  /* 初始宽度为0，通过JS动态设置 */
    background: #000;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1); /* 缓动动画 */
    position: absolute;
    right: 0;  /* 从右侧开始填充 */
}

/* 进度条文本 */
.elementor-progress-text {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: white;
    font: bold 12px 'Segoe UI', sans-serif;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3); /* 文字阴影增强可读性 */
    right: 10px;
    white-space: nowrap; /* 防止文字换行 */
}

/* 左侧文本位置 */
.elementor-progress-text.left {
    left: 10px;
    right: auto;
}

/* 中文段落首行缩进 */
.text-indent {
    text-indent: 2em;
}

/* 加粗居中文本 */
.bold-center {
    font-weight: bold;
    text-align: center;
}

/* 区块样式 - 每个section占据完整视口高度 */
section {
    min-height: 100vh;  /* 最小高度为视口高度 */
    padding: 60px 0;
    display: flex;
    align-items: center;  /* 垂直居中 */
    background-color: var(--bg-primary);
    transition: background-color 0.3s ease;
}

/* 英雄区域样式 - 网站首屏 */
.hero {
    background: linear-gradient(var(--hero-overlay), var(--hero-overlay)), url('https://www.guohao.asia/html/img/20210424-YZ-1.jpg-webp');
    background-size: cover;  /* 背景图片覆盖整个区域 */
    background-position: center;
    color: white !important; /* 确保英雄区域文本为白色 */
    text-align: center;
    position: relative;
}

/* 灰色背景区域 */
.bg-gray {
    background-color: var(--bg-tertiary) !important;
}

/* 社交图标容器 */
.social-link-container {
    display: inline-block;
    text-align: center;
    margin: 0 15px;
    transition: transform 0.3s ease; /* 悬停动画 */
}

/* 社交图标悬停效果 */
.social-link-container:hover {
    transform: translateY(-5px);  /* 上浮效果 */
}

/* 社交链接样式 */
.social-link {
    display: inline-flex;
    width: 70px;
    height: 70px;
    line-height: 70px;
    border-radius: 50%;  /* 圆形按钮 */
    background-color: var(--bg-secondary);
    color: var(--text-secondary);
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-color);
}

/* 社交链接悬停状态 */
.social-link:hover {
    background-color: var(--accent-color);
    color: white;
    transform: scale(1.05);  /* 放大效果 */
}

/* 社交图标大小 */
.social-link i {
    font-size: 28px;
}

/* 社交文字说明 */
.social-text {
    margin-top: 10px;
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* 带下划线的标题样式 */
.lined {
    position: relative;
    padding-bottom: 15px;
    margin-bottom: 30px;
}

/* 标题下划线伪元素 */
.lined:after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background-color: var(--accent-color);
}

/* 紧凑版下划线 */
.lined-compact:after {
    width: 40px;
}

/* 区块图标样式 */
.icon {
    font-size: 2.5rem;
    color: var(--accent-color);
}

/* 滚动提示按钮 */
.scroll-btn {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 2rem;
    animation: bounce 2s infinite;  /* 弹跳动画 */
    cursor: pointer;
    z-index: 10;
}

/* 弹跳动画关键帧 */
@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateX(-50%) translateY(0);
    }
    40% {
        transform: translateX(-50%) translateY(-10px);
    }
    60% {
        transform: translateX(-50%) translateY(-5px);
    }
}

/* 页脚样式调整 */
#footer-section {
    min-height: auto;  /* 页脚不需要完整视口高度 */
    padding: 40px 0 20px;
    background-color: var(--footer-bg);
    transition: background-color 0.3s ease;
}

#footer-section .container {
    background-color: var(--footer-bg);
    color: var(--footer-text);
    transition: all 0.3s ease;
}

#footer-section footer {
    background-color: var(--footer-bg) !important;
    border-top: 1px solid var(--border-color);
    color: var(--footer-text);
}

/* 页脚文本颜色 */
#footer-section .text-gray,
#footer-section .font-italic {
    color: var(--footer-text) !important;
}

#footer-section a {
    color: var(--accent-color);
}

#footer-section a:hover {
    color: var(--text-primary);
}

/* 区块内容容器 */
.section-content {
    width: 100%;
}

/* 微信二维码容器 */
.wechat-qr-container {
    position: relative;
    display: inline-block;
}

/* 微信二维码样式 */
.wechat-qr {
    position: absolute;
    bottom: 100%;  /* 显示在链接上方 */
    left: 50%;
    transform: translateX(-50%);
    display: none;  /* 默认隐藏 */
    background: var(--card-bg);
    padding: 15px;
    border-radius: 10px;
    box-shadow: var(--card-shadow);
    z-index: 1000;
    min-width: 140px;
    text-align: center;
    margin-bottom: 15px;
    border: 1px solid var(--border-color);
}

.wechat-qr img {
    width: 120px;
    height: 120px;
    display: block;
    margin: 0 auto;
}

/* 二维码下方三角形指示器 */
.wechat-qr::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 10px;
    border-style: solid;
    border-color: var(--card-bg) transparent transparent transparent;
}

/* 悬停显示二维码 */
.wechat-link:hover + .wechat-qr,
.wechat-qr:hover {
    display: block;
}

/* ==================== 服务部分样式 ==================== */
/* 服务卡片样式 */
.service-card {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 2rem;
    height: 100%;
    box-shadow: var(--card-shadow);
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
}

.service-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
}

.service-icon {
    font-size: 3rem;
    margin-bottom: 1.5rem;
    display: block;
    transition: color 0.3s ease;
}

.service-card.wiki .service-icon {
    color: var(--wiki-color);
}

.service-card.nextcloud .service-icon {
    color: var(--nextcloud-color);
}

.service-card.other .service-icon {
    color: var(--other-service-color);
}

.service-title {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.service-description {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.service-link {
    display: inline-block;
    padding: 0.5rem 1.5rem;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    text-decoration: none;
    border-radius: 5px;
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
    font-weight: 500;
}

.service-link:hover {
    background: var(--accent-color);
    color: #fff;
    border-color: var(--accent-color);
}

.services-intro {
    text-align: center;
    max-width: 800px;
    margin: 0 auto 3rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ==================== 博客活动区域样式 ==================== */
.blog-activity { 
    margin: 40px 0; 
    padding: 20px; 
    background: var(--card-bg); 
    border-radius: 6px; 
    box-shadow: var(--card-shadow); 
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    color: var(--text-primary);
}
.activity-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-bottom: 20px; 
}
.activity-title { 
    font-size: 1.2rem; 
    font-weight: 600; 
    color: var(--text-primary); 
}
.activity-stats { 
    display: flex; 
    gap: 20px; 
    font-size: 0.9rem; 
    color: var(--text-secondary); 
}
.contribution-graph { 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    gap: 10px; 
    width: 100%; 
}
.graph-container {
    width: 100%;
    display: flex;
    justify-content: center;
    overflow: visible;
    position: relative;
}
/* 热力图网格布局 - 53周 x 7天 */
.graph-squares { 
    display: grid; 
    grid-template-columns: repeat(53, 1fr); 
    grid-template-rows: repeat(7, 1fr); 
    gap: 2px; 
    width: 100%;
    max-width: 800px;
    aspect-ratio: 53 / 7;  /* 保持宽高比 */
}
.contribution-square { 
    width: 100%; 
    height: 100%; 
    border-radius: 2px; 
    background-color: var(--heatmap-0); 
    transition: all 0.2s ease; 
    cursor: pointer; 
    position: relative; 
    min-width: 4px;
    min-height: 4px;
    border: 1px solid var(--border-color);
}
.contribution-square:hover { 
    transform: scale(1.2); 
    z-index: 10; 
}
/* 根据数据等级设置颜色 */
.contribution-square[data-level="1"] { background-color: var(--heatmap-1); }
.contribution-square[data-level="2"] { background-color: var(--heatmap-2); }
.contribution-square[data-level="3"] { background-color: var(--heatmap-3); }
.contribution-square[data-level="4"] { background-color: var(--heatmap-4); }

/* 提示框样式 */
.contribution-tooltip { 
    position: absolute; 
    top: -45px;
    left: 50%; 
    transform: translateX(-50%); 
    background: var(--tooltip-bg) !important;
    color: var(--tooltip-text) !important;
    padding: 8px 12px; 
    border-radius: 4px; 
    font-size: 0.8rem; 
    white-space: nowrap; 
    z-index: 1000;
    pointer-events: none; 
    opacity: 0; 
    transition: opacity 0.2s; 
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    min-width: 140px;
    text-align: center;
}

.contribution-square:hover .contribution-tooltip { 
    opacity: 1; 
}

/* 智能提示框位置调整 - 第一行提示框显示在下方 */
.contribution-square:nth-child(-n+53) .contribution-tooltip {
    top: 100%;
    bottom: auto;
}

.recent-posts { 
    margin-top: 30px; 
    border-top: 1px solid var(--border-color); 
    padding-top: 20px; 
}
.recent-posts h4 { 
    margin-bottom: 15px; 
    color: var(--text-primary); 
}
.post-item { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    padding: 8px 0; 
    border-bottom: 1px solid var(--border-color); 
}
.post-title { 
    color: var(--accent-color); 
    text-decoration: none; 
    font-size: 0.9rem; 
}
.post-title:hover {
    color: var(--text-primary);
    text-decoration: underline;
}
.post-date { 
    color: var(--text-secondary); 
    font-size: 0.8rem; 
}
.loading { 
    text-align: center; 
    padding: 40px; 
    color: var(--text-secondary); 
}
.error { 
    text-align: center; 
    padding: 40px; 
    color: #cf222e; 
    background: #ffebe9; 
    border-radius: 6px; 
}
.legend { 
    display: flex; 
    align-items: center; 
    justify-content: center;
    gap: 5px; 
    font-size: 0.8rem; 
    color: var(--text-secondary); 
    margin-top: 10px; 
    flex-wrap: wrap;
}
.legend-text { 
    margin: 0 8px; 
    white-space: nowrap;
}
.legend-items {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* ==================== 响应式设计 ==================== */
@media (max-width: 768px) {
    section {
        min-height: auto;
        padding: 40px 0;
    }
    
    .hero {
        min-height: 100vh;  /* 移动端保持全屏英雄区域 */
    }
    
    .social-link-container {
        margin: 0 10px 20px;
    }
    
    .social-link {
        width: 60px;
        height: 60px;
        line-height: 60px;
    }
    
    .social-link i {
        font-size: 24px;
    }
    
    /* 移动端二维码位置调整 */
    .wechat-qr {
        left: 0;
        transform: none;
    }
    
    .wechat-qr::after {
        left: 30px;
    }
    
    /* 服务卡片移动端适配 */
    .service-card {
        padding: 1.5rem;
    }
    
    .service-icon {
        font-size: 2.5rem;
    }
    
    .service-title {
        font-size: 1.3rem;
    }
    
    /* 热力图响应式调整 */
    .graph-squares {
        gap: 1px;
        max-width: 95vw; /* 限制最大宽度为视口宽度的95% */
    }
    .contribution-tooltip {
        font-size: 0.7rem;
        padding: 6px 10px;
        min-width: 120px;
    }
    .legend {
        flex-wrap: wrap;
    }
    .contribution-square {
        min-width: 3px;
        min-height: 3px;
    }
}

@media (max-width: 480px) {
    .graph-squares {
        gap: 1px;
        max-width: 92vw;
    }
    .contribution-tooltip {
        font-size: 0.6rem;
        padding: 4px 8px;
        min-width: 100px;
    }
    .legend {
        flex-direction: column;
        gap: 8px;
    }
    .contribution-square {
        min-width: 2px;
        min-height: 2px;
    }
    .contribution-square:hover {
        transform: scale(1.3);
    }
    
    /* 服务卡片小屏幕适配 */
    .service-card {
        padding: 1rem;
    }
    
    .service-icon {
        font-size: 2rem;
    }
    
    .service-title {
        font-size: 1.2rem;
    }
    
    .services-intro {
        margin-bottom: 2rem;
    }
}

@media (max-width: 320px) {
    .graph-squares {
        gap: 0.5px;
        max-width: 90vw;
    }
    .contribution-square {
        min-width: 1px;
        min-height: 1px;
    }
}

/* ==================== 深色模式特定调整 ==================== */
@media (prefers-color-scheme: dark) {
    /* 调整图片亮度 */
    img {
        filter: brightness(0.9);
    }
    
    /* 调整链接颜色 */
    a {
        color: var(--accent-color);
    }
    
    a:hover {
        color: #74c0fc;
    }
    
    /* 调整弱化文本颜色 */
    .text-muted {
        color: var(--text-muted) !important;
    }
    
    /* 调整卡片阴影 */
    .blog-activity {
        box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    }
    
    /* 修复页脚链接颜色 */
    #copyright a,
    #copyright-info a {
        color: var(--accent-color) !important;
    }
    
    #copyright a:hover,
    #copyright-info a:hover {
        color: var(--text-primary) !important;
    }
    
    /* 深色模式下的错误提示和提示框修复 */
    .error {
        background: #2d1c1c;
        color: #ff7b72;
    }
    
    .blog-activity * {
        color: inherit;
    }
    
    .blog-activity strong {
        color: var(--text-primary);
    }
    
    /* 确保提示框在暗色模式下可见 */
    .contribution-tooltip {
        background: var(--tooltip-bg) !important;
        color: var(--tooltip-text) !important;
        border: 1px solid var(--border-color);
        box-shadow: 0 2px 8px rgba(0,0,0,0.5);
    }
    
    /* 服务卡片深色模式适配 */
    .service-card:hover {
        box-shadow: 0 10px 25px rgba(0,0,0,0.4);
    }
    
    .service-link {
        background: var(--bg-secondary);
    }
    
    /* 确保英雄区域在深色模式下仍然显示白色文字 */
    .hero,
    .hero .container,
    .hero .container *:not(.social-link):not(.social-link *),
    .hero h1,
    .hero .lead,
    .hero .font-italic,
    .hero .text-white,
    .hero .text-white * {
        color: white !important;
        text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7); /* 深色模式下阴影更深 */
    }
}

/* 热力图自适应缩放提示 */
.scale-hint {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 5px;
}
