/* ===== ganxy03.cn 重建主题 ===== */

:root {
    --bg: #f7f8fa;
    --card-bg: #ffffff;
    --text: #1f2328;
    --text-muted: #6e7681;
    --text-link: #2563eb;
    --border: #eaecef;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --code-bg: #f6f8fa;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-hover: 0 6px 20px rgba(0, 0, 0, 0.08);
    --radius: 8px;
    --sidebar-w: 300px;
    --max-w: 1200px;
    --font-sans: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    --font-mono: "JetBrains Mono", "SF Mono", Consolas, "Liberation Mono", monospace;
}

[data-theme="dark"] {
    --bg: #0d1117;
    --card-bg: #161b22;
    --text: #e6edf3;
    --text-muted: #8b949e;
    --text-link: #58a6ff;
    --border: #30363d;
    --code-bg: #1c2128;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 6px 20px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.7;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--text-link); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

#web_bg {
    position: fixed; inset: 0; z-index: -1;
    background-size: cover; background-position: center;
    opacity: 0.04;
}
[data-theme="dark"] #web_bg { opacity: 0.08; }

/* ===== Header ===== */
#page-header {
    position: sticky; top: 0; z-index: 99;
    background: rgba(255,255,255,0.85);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
}
[data-theme="dark"] #page-header { background: rgba(13,17,23,0.85); }

@media (max-width: 600px) {
    #page-header { background: rgba(255,255,255,0.95); }
    [data-theme="dark"] #page-header { background: rgba(13,17,23,0.95); }
}

#nav {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 12px 24px;
    display: flex; justify-content: space-between; align-items: center;
}
#blog-info .site-name {
    font-size: 18px; font-weight: 700; color: var(--text);
}
#menus { display: flex; align-items: center; gap: 18px; }
.menus_items { display: flex; gap: 18px; }
@media (max-width: 600px) {
    .menus_items { gap: 10px; }
    .menus_item .site-page span { display: none; }   /* 手机端只留图标 */
    .menus_item .site-page i { font-size: 16px; }
}
.menus_item .site-page {
    color: var(--text); padding: 6px 4px; font-size: 14px;
    display: inline-flex; align-items: center; gap: 6px;
}
.menus_item .site-page:hover { color: var(--accent); text-decoration: none; }
#toggle-theme {
    cursor: pointer; padding: 6px 10px; border-radius: 6px;
    color: var(--text-muted);
}
#toggle-theme:hover { color: var(--accent); background: var(--border); }

/* ===== Layout ===== */
.layout {
    max-width: var(--max-w);
    margin: 24px auto;
    padding: 0 24px;
    display: grid;
    grid-template-columns: 1fr var(--sidebar-w);
    gap: 24px;
    align-items: start;
}
@media (max-width: 960px) {
    .layout { grid-template-columns: 1fr; padding: 0 16px; gap: 16px; margin: 16px auto; }
    :root { --sidebar-w: 100%; }
}
@media (max-width: 600px) {
    .layout { padding: 0 12px; }
    #recent-posts { gap: 12px; }
}

#recent-posts {
    display: flex; flex-direction: column; gap: 16px;
}

/* ===== Article card ===== */
.recent-post-items { display: flex; flex-direction: column; gap: 16px; }
.recent-post-item {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px 24px;
    transition: box-shadow .3s ease, transform .3s ease;
}
@media (max-width: 600px) {
    .recent-post-item { padding: 14px 16px; }
    .recent-post-info .article-title { font-size: 16px; }
    .article-meta-wrap { font-size: 12px; }
}
.recent-post-item:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.recent-post-info .article-title {
    display: block;
    font-size: 18px; font-weight: 600; color: var(--text);
    margin-bottom: 8px; line-height: 1.4;
}
.recent-post-info .article-title:hover { color: var(--accent); text-decoration: none; }
.article-meta-wrap {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
    color: var(--text-muted); font-size: 13px; margin-bottom: 8px;
}
.article-meta-wrap a { color: var(--text-muted); }
.article-meta-wrap a:hover { color: var(--accent); }
.article-meta-separator { color: var(--border); }
.article-meta i { margin-right: 4px; }
.recent-post-info .content {
    color: var(--text-muted); font-size: 14px; line-height: 1.7;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ===== Sidebar ===== */
.aside-content {
    display: flex; flex-direction: column; gap: 16px;
    position: sticky; top: 80px;
}
@media (max-width: 960px) {
    .aside-content { position: static; }
}

.card-widget {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 20px;
}
@media (max-width: 600px) {
    .card-widget { padding: 14px 16px; }
    .avatar-img img { width: 72px; height: 72px; }
}
.card-info { text-align: center; }
.avatar-img img {
    width: 96px; height: 96px; border-radius: 50%;
    object-fit: cover; margin-bottom: 10px;
    border: 2px solid var(--border);
}
.author-info-name { font-size: 16px; font-weight: 600; }
.author-info-description {
    color: var(--text-muted); font-size: 13px; min-height: 24px;
    margin: 6px 0 12px;
}
.site-data {
    display: flex; justify-content: space-around;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 10px 0; margin-bottom: 14px;
}
.site-data > a { color: var(--text); }
.site-data > a:hover { color: var(--accent); text-decoration: none; }
.site-data .headline { font-size: 12px; color: var(--text-muted); }
.site-data .length-num { font-size: 18px; font-weight: 700; }
#card-info-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 16px; border-radius: 999px;
    background: var(--accent); color: #fff; font-size: 13px;
}
#card-info-btn:hover { background: var(--accent-hover); color: #fff; text-decoration: none; }

.card-announcement .item-headline,
.card-recent-post .item-headline,
.card-categories .item-headline {
    font-size: 14px; font-weight: 600; margin-bottom: 12px;
    display: flex; align-items: center; gap: 6px;
    color: var(--text);
}
.card-announcement .item-headline i,
.card-recent-post .item-headline i,
.card-categories .item-headline i { color: var(--accent); }
.announcement_content { color: var(--text-muted); font-size: 13px; }

.aside-list { display: flex; flex-direction: column; gap: 10px; }
.aside-list-item .title {
    display: block; color: var(--text); font-size: 13px; line-height: 1.5;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.aside-list-item .title:hover { color: var(--accent); text-decoration: none; }
.aside-list-item time { display: block; color: var(--text-muted); font-size: 11px; margin-top: 2px; }

.card-category-list { list-style: none; padding: 0; margin: 0; }
.card-category-list-item { padding: 6px 0; border-bottom: 1px dashed var(--border); }
.card-category-list-item:last-child { border-bottom: none; }
.card-category-list-link {
    display: flex; justify-content: space-between; align-items: center;
    color: var(--text); font-size: 13px;
}
.card-category-list-link:hover { color: var(--accent); text-decoration: none; }
.card-category-list-count {
    background: var(--border); color: var(--text-muted);
    border-radius: 999px; padding: 1px 8px; font-size: 11px;
}

/* ===== Pagination ===== */
#pagination { display: flex; justify-content: center; margin-top: 8px; }
.pagination { display: flex; gap: 6px; flex-wrap: wrap; }
.page-number {
    display: inline-block; min-width: 32px; padding: 6px 10px;
    background: var(--card-bg); color: var(--text-muted);
    border-radius: 6px; text-align: center; font-size: 13px;
    box-shadow: var(--shadow);
}
@media (max-width: 600px) {
    .page-number { min-width: 28px; padding: 5px 8px; font-size: 12px; }
    .pagination { gap: 4px; }
}
.page-number:hover { color: var(--accent); text-decoration: none; }
.page-number.current { background: var(--accent); color: #fff; }

/* ===== Article detail ===== */
#post {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px 36px;
}
@media (max-width: 600px) {
    #post { padding: 18px 18px; border-radius: 6px; }
}
.post-info { border-bottom: 1px solid var(--border); padding-bottom: 18px; margin-bottom: 24px; }
.post-title { margin: 0 0 12px; font-size: 26px; line-height: 1.35; }
@media (max-width: 600px) {
    .post-title { font-size: 20px; }
    .article-content { font-size: 15px; line-height: 1.8; }
}
.article-content { font-size: 15px; line-height: 1.85; }
.article-content h1, .article-content h2, .article-content h3,
.article-content h4, .article-content h5, .article-content h6 {
    margin: 1.4em 0 .8em; font-weight: 700; line-height: 1.4;
}
.article-content h1 { font-size: 1.6em; }
.article-content h2 { font-size: 1.4em; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.article-content h3 { font-size: 1.2em; }
.article-content p { margin: .8em 0; }
.article-content ul, .article-content ol { padding-left: 1.6em; margin: .6em 0; }
.article-content li { margin: .3em 0; }
.article-content blockquote {
    margin: 1em 0; padding: 10px 16px;
    background: var(--code-bg); border-left: 4px solid var(--accent);
    color: var(--text-muted); border-radius: 0 var(--radius) var(--radius) 0;
}
.article-content code {
    font-family: var(--font-mono); font-size: .9em;
    background: var(--code-bg); padding: 2px 6px; border-radius: 4px;
}
.article-content pre {
    background: var(--code-bg); border-radius: var(--radius);
    padding: 14px 16px; overflow-x: auto; line-height: 1.5;
    border: 1px solid var(--border);
}
.article-content pre code {
    background: transparent; padding: 0; font-size: 13px;
}
.article-content table {
    border-collapse: collapse; margin: 1em 0; width: 100%; font-size: 14px;
    display: block;
    overflow-x: auto;
    white-space: nowrap;
}
.article-content th, .article-content td {
    border: 1px solid var(--border); padding: 8px 12px; text-align: left;
}
.article-content th { background: var(--code-bg); font-weight: 600; }
@media (max-width: 600px) {
    .article-content th, .article-content td { padding: 6px 8px; font-size: 13px; }
    .article-content pre { font-size: 12px; padding: 10px 12px; }
    .article-content pre code { font-size: 12px; }
    .article-content img { border-radius: 4px; }
}
.article-content img { max-width: 100%; height: auto; border-radius: var(--radius); }
.article-content hr { border: none; border-top: 1px solid var(--border); margin: 2em 0; }
.article-content input[type=checkbox] { margin-right: 6px; }
.article-content .wikilink {
    background: rgba(59,130,246,0.08);
    padding: 1px 6px; border-radius: 4px;
}

.post-nav {
    display: flex; justify-content: space-between; gap: 12px;
    margin-top: 28px; padding-top: 18px;
    border-top: 1px solid var(--border);
}
@media (max-width: 600px) {
    .post-nav { flex-direction: column; gap: 8px; }
    .post-nav a { font-size: 12px; padding: 8px 12px; }
}
.post-nav a {
    flex: 1; padding: 10px 14px;
    background: var(--code-bg); border-radius: var(--radius);
    color: var(--text); font-size: 13px;
    display: flex; align-items: center; gap: 8px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.post-nav a:hover { background: var(--border); text-decoration: none; }
.prev-post i { flex-shrink: 0; }
.next-post { justify-content: flex-end; text-align: right; }
.next-post i { flex-shrink: 0; }

/* ===== Category / Archive pages ===== */
.category-header {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px 28px;
    margin-bottom: 16px;
}
.category-header h2 { margin: 0 0 6px; font-size: 20px; }
.category-meta { color: var(--text-muted); font-size: 13px; margin: 0; }

.categories-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
}
@media (max-width: 600px) {
    .categories-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .category-card { padding: 18px 12px; }
    .category-card i { font-size: 22px; }
}
.category-card {
    background: var(--card-bg); border-radius: var(--radius);
    padding: 24px 16px; text-align: center;
    box-shadow: var(--shadow); transition: box-shadow .3s, transform .3s;
    color: var(--text); display: block;
}
.category-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); text-decoration: none; }
.category-card i { font-size: 28px; color: var(--accent); margin-bottom: 10px; display: block; }
.category-name { font-weight: 600; margin-bottom: 4px; }
.category-count { font-size: 12px; color: var(--text-muted); }

.archive-list .archive-group { margin-bottom: 24px; }
.archive-year {
    font-size: 18px; font-weight: 700; color: var(--text);
    border-bottom: 2px solid var(--accent); padding-bottom: 4px; margin-bottom: 12px;
}
.archive-list ul { list-style: none; padding: 0; margin: 0; }
.archive-list li {
    padding: 6px 0; display: flex; align-items: center; gap: 10px;
    border-bottom: 1px dashed var(--border); font-size: 14px;
}
.archive-list time { color: var(--text-muted); font-size: 12px; min-width: 40px; }
.archive-cat { color: var(--text-muted); font-size: 12px; }

/* ===== 404 ===== */
.error-page {
    background: var(--card-bg); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 60px 24px;
    text-align: center;
}
.error-page h1 { font-size: 64px; margin: 0; color: var(--accent); }
.error-page p { color: var(--text-muted); }

/* ===== Footer ===== */
#footer {
    text-align: center; padding: 24px; color: var(--text-muted); font-size: 12px;
    border-top: 1px solid var(--border); margin-top: 40px;
}
#footer .sep { margin: 0 8px; color: var(--border); }

/* ===== AdSense 广告位 ===== */
.ad-slot {
    margin: 1.5rem auto;
    text-align: center;
    min-height: 90px;            /* 顶部/底部默认占位高度，防 CLS 抖动 */
    box-sizing: border-box;
}

/* 顶部 banner —— flex 兜底居中，防止 AdSense JS 改 <ins> display/width */
.ad-top {
    width: 100%;
    max-width: 1200px;            /* PC 端限宽 1200px */
    margin: 1.5rem auto;
    padding: 0 16px;              /* 屏幕窄时留出左右呼吸空间 */
    min-height: 90px;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow: hidden;            /* 防止 <ins> 异常宽时撑破布局 */
}
.ad-top > ins.adsbygoogle {
    display: block !important;
    margin: 0 auto;
    max-width: 100%;
}

/* 侧边栏广告 —— 卡片样式，贴近现有 card-widget 视觉 */
.ad-sidebar {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 12px;
    max-width: 300px;
    margin: 1rem auto;
    min-height: 250px;           /* 300x250 中等矩形 */
}

/* 文章底部 —— 与正文同宽，flex 兜底居中 */
.ad-article-bottom {
    width: 100%;
    max-width: 728px;
    margin: 2rem auto;
    min-height: 90px;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow: hidden;
}
.ad-article-bottom > ins.adsbygoogle {
    display: block !important;
    margin: 0 auto;
    max-width: 100%;
}

/* 首页底部 —— 与列表同宽，flex 兜底居中 */
.ad-home-bottom {
    width: 100%;
    max-width: 728px;
    margin: 2rem auto;
    min-height: 90px;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow: hidden;
}
.ad-home-bottom > ins.adsbygoogle {
    display: block !important;
    margin: 0 auto;
    max-width: 100%;
}

/* ===== 移动端广告位适配 ===== */

/* 平板及以下 (≤768px)：侧边栏隐藏，三处响应式广告收窄、减留白 */
@media (max-width: 768px) {
    /* 侧边栏广告 —— 直接隐藏，避免挤掉正文 */
    .ad-sidebar { display: none; }

    /* 顶部 banner —— 屏幕宽度减去左右间距 */
    .ad-top {
        max-width: 100%;             /* 让屏幕宽度说了算 */
        margin: 0.75rem auto;
        padding: 0 8px;              /* 左右各 8px 留白 */
        min-height: 50px;            /* 320×50 / 320×100 适配 */
    }
    .ad-top > ins.adsbygoogle { min-height: 50px; }

    /* 文章底部 —— 收紧上下留白 */
    .ad-article-bottom {
        margin: 1.25rem auto;
        padding: 0 8px;
        min-height: 60px;
    }
    .ad-article-bottom > ins.adsbygoogle { min-height: 60px; }

    /* 首页底部 —— 同上 */
    .ad-home-bottom {
        margin: 1.25rem auto;
        padding: 0 8px;
        min-height: 60px;
    }
    .ad-home-bottom > ins.adsbygoogle { min-height: 60px; }

    /* 顶部 banner 与上方导航的间距留足，避免紧贴 */
    .recent-posts { margin-top: 0.5rem; }

    /* 占位文字缩小 */
    .ad-slot:empty::before {
        font-size: 11px;
        padding: 16px 0;
    }
}

/* 超窄屏 (≤380px)：进一步压缩 padding */
@media (max-width: 380px) {
    .ad-article-bottom, .ad-home-bottom {
        padding: 0 6px;
    }
}

/* 工具类：在任意位置给广告位追加 hide-on-mobile 即可在移动端隐藏 */
@media (max-width: 768px) {
    .ad-top.hide-on-mobile,
    .ad-sidebar.hide-on-mobile,
    .ad-article-bottom.hide-on-mobile,
    .ad-home-bottom.hide-on-mobile { display: none; }
}

/* 广告未填充时给个视觉占位，避免突兀空白 */
.ad-slot:empty::before {
    content: "广告位";
    display: block;
    color: var(--text-muted);
    font-size: 12px;
    padding: 24px 0;
    opacity: 0.4;
}
