/*
Theme Name: InsightNews
Theme URI: https://github.com/insightnews/insightnews
Author: WorkBuddy
Author URI: https://workbuddy.cn
Description: 一个面向博客/资讯站的现代化 WordPress 主题，参考 JustNews 的视觉风格，内置深度 SEO 与 GEO（生成式引擎优化）能力：TDK 自动获取、关键词内链、结构化数据、API 推送（百度/Bing/Google）、llms.txt 生成等。
Version: 1.0.2
Requires at least: 6.0
Tested up to: 6.7
Requires PHP: 7.4
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: insightnews
Domain Path: /languages
Tags: blog, news, seo, geo, responsive, custom-colors, custom-logo, featured-images, threaded-comments, translation-ready, block-styles, wide-blocks
*/

/* ==========================================================================
   1. 设计变量（可通过 Customizer 覆盖 --accent）
   ========================================================================== */
:root {
    --accent: #2563eb;
    --accent-dark: #1d4ed8;
    --accent-soft: #eff4ff;
    --text: #1a1a1a;
    --text-2: #555;
    --text-3: #999;
    --bg: #f5f6f8;
    --card: #ffffff;
    --border: #ebedf0;
    --radius: 10px;
    --shadow: 0 2px 16px rgba(20, 30, 60, .06);
    --shadow-hover: 0 8px 28px rgba(20, 30, 60, .12);
    --container: 1200px;
    --header-h: 64px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

/* ==========================================================================
   2. 基础重置
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    margin: 0;
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    line-height: 1.7;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; transition: color .2s ease; }
a:hover { color: var(--accent); }
img { max-width: 100%; height: auto; display: block; }
h1, h2, h3, h4, h5, h6 { margin: 0 0 .6em; line-height: 1.3; color: var(--text); font-weight: 700; }
p { margin: 0 0 1.2em; }
ul, ol { margin: 0 0 1.2em; padding-left: 1.4em; }
blockquote {
    margin: 1.5em 0; padding: 1em 1.2em;
    border-left: 4px solid var(--accent);
    background: var(--accent-soft); border-radius: 0 var(--radius) var(--radius) 0;
    color: var(--text-2);
}
code, pre { font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace; }
pre { background: #1e2330; color: #e6e9f0; padding: 16px; border-radius: var(--radius); overflow: auto; }
hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ==========================================================================
   3. 布局容器
   ========================================================================== */
.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 16px; }
.site-content { padding: 28px 0 48px; }
/* 默认单列满宽；仅当侧边栏存在（body.has-sidebar）时才显示两列，
   避免未挂小工具时右侧出现空白列 */
.layout { display: grid; grid-template-columns: 1fr; gap: 28px; align-items: start; }
.has-sidebar .layout { grid-template-columns: minmax(0, 1fr) 320px; }
.layout-full { display: block; }

@media (max-width: 960px) {
    .layout, .has-sidebar .layout { grid-template-columns: 1fr; }
    .sidebar { display: none; }
}

/* ==========================================================================
   4. 头部 / 导航
   ========================================================================== */
.site-header {
    position: sticky; top: 0; z-index: 100;
    background: #fff; border-bottom: 1px solid var(--border);
    transition: box-shadow .25s ease;
}
.site-header.is-stuck { box-shadow: var(--shadow); }
.header-inner { display: flex; align-items: center; gap: 20px; height: var(--header-h); }
.site-logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; white-space: nowrap; color: var(--text); }
.site-logo img { height: 34px; width: auto; }
.site-logo .logo-text { letter-spacing: .5px; }
.site-brand { display: flex; flex-direction: column; justify-content: center; line-height: 1.15; }
.site-subtitle { font-size: 12px; color: var(--text-3); margin-top: 2px; font-weight: 400; }
.site-logo .logo-text b { color: var(--accent); }

.main-nav { flex: 1; }
.main-nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 4px; }
.main-nav li { position: relative; }
.main-nav > ul > li > a {
    display: block; padding: 0 14px; height: var(--header-h); line-height: var(--header-h);
    font-weight: 600; color: var(--text-2); font-size: 15px;
}
.main-nav > ul > li:hover > a, .main-nav > ul > li.current-menu-item > a { color: var(--accent); }
.main-nav .sub-menu {
    position: absolute; top: 100%; left: 0; min-width: 200px;
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 8px 0; opacity: 0; visibility: hidden; transform: translateY(6px);
    transition: all .2s ease; z-index: 50; list-style: none;
}
.main-nav li:hover > .sub-menu { opacity: 1; visibility: visible; transform: translateY(0); }
.main-nav .sub-menu a { display: block; padding: 8px 16px; color: var(--text-2); font-size: 14px; }
.main-nav .sub-menu a:hover { background: var(--accent-soft); color: var(--accent); }
.menu-toggle { display: none; background: none; border: 0; cursor: pointer; padding: 8px; }
.menu-toggle span { display: block; width: 22px; height: 2px; background: var(--text); margin: 4px 0; transition: .2s; }

.header-actions { display: flex; align-items: center; gap: 12px; }
.search-toggle { background: none; border: 0; cursor: pointer; color: var(--text-2); padding: 6px; font-size: 18px; }
.btn-primary { background: var(--accent); color: #fff; border: 0; border-radius: 999px; padding: 8px 18px; font-weight: 600; cursor: pointer; transition: background .2s; }
.btn-primary:hover { background: var(--accent-dark); color: #fff; }

/* 顶部搜索条 */
.search-bar { display: none; border-top: 1px solid var(--border); background: #fff; }
.search-bar.open { display: block; }
.search-bar form { display: flex; gap: 8px; padding: 12px 0; }
.search-bar input[type="search"] { flex: 1; border: 1px solid var(--border); border-radius: 999px; padding: 10px 16px; font-size: 15px; }
.search-bar button { border: 0; background: var(--accent); color: #fff; border-radius: 999px; padding: 0 22px; cursor: pointer; }

@media (max-width: 960px) {
    .main-nav { position: fixed; top: var(--header-h); left: 0; right: 0; bottom: 0;
        background: #fff; transform: translateX(-100%); transition: transform .3s ease; overflow-y: auto; z-index: 99; }
    .main-nav.open { transform: translateX(0); }
    .main-nav > ul { flex-direction: column; gap: 0; padding: 8px 0; }
    .main-nav > ul > li > a { height: 50px; line-height: 50px; padding: 0 20px; border-bottom: 1px solid var(--border); }
    .main-nav .sub-menu { position: static; opacity: 1; visibility: visible; transform: none; box-shadow: none; border: 0; padding-left: 16px; }
    .menu-toggle { display: block; }
}

/* ==========================================================================
   5. 首页模块
   ========================================================================== */
.hero { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin-bottom: 28px; }
@media (max-width: 768px) { .hero { grid-template-columns: 1fr; } }

/* 焦点图轮播 */
.slider { position: relative; border-radius: var(--radius); overflow: hidden; background: #000; min-height: 380px; }
.slides { display: flex; transition: transform .5s ease; }
.slide { position: relative; min-width: 100%; height: 380px; }
.slide img { width: 100%; height: 100%; object-fit: cover; }
.slide::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,.7), transparent 55%); }
.slide-caption { position: absolute; left: 22px; bottom: 20px; right: 22px; color: #fff; z-index: 2; }
.slide-caption h3 { color: #fff; font-size: 22px; margin: 0; text-shadow: 0 2px 8px rgba(0,0,0,.4); }
.slider-nav button {
    position: absolute; top: 50%; transform: translateY(-50%); z-index: 3;
    width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(255,255,255,.85);
    cursor: pointer; font-size: 20px; color: #333; display: grid; place-items: center;
}
.slider-nav .prev { left: 12px; } .slider-nav .next { right: 12px; }
.slider-dots { position: absolute; bottom: 14px; right: 18px; z-index: 3; display: flex; gap: 6px; }
.slider-dots span { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.55); cursor: pointer; }
.slider-dots span.active { background: #fff; width: 22px; border-radius: 4px; }

/* 头条推荐 */
.headlines { display: flex; flex-direction: column; gap: 14px; }
.headline { display: flex; gap: 12px; background: var(--card); border-radius: var(--radius); padding: 10px; box-shadow: var(--shadow); transition: box-shadow .2s; }
.headline:hover { box-shadow: var(--shadow-hover); }
.headline img { width: 110px; height: 80px; object-fit: cover; border-radius: 8px; flex: 0 0 auto; }
.headline h4 { margin: 0 0 6px; font-size: 15px; line-height: 1.4; }
.headline .meta { font-size: 12px; color: var(--text-3); }

/* 区块标题 */
.section { margin: 36px 0; }
.section-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.section-head h2 { margin: 0; font-size: 20px; position: relative; padding-left: 14px; }
.section-head h2::before { content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%); width: 5px; height: 20px; background: var(--accent); border-radius: 3px; }
.section-head .more { margin-left: auto; font-size: 13px; color: var(--text-3); }

/* 文章卡片网格 */
.post-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
@media (max-width: 768px) { .post-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .post-grid { grid-template-columns: 1fr; } }
.post-card {
    background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
    transition: box-shadow .2s ease, transform .2s ease; display: flex; flex-direction: column;
}
.post-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-3px); }
.post-card .thumb { position: relative; aspect-ratio: 16/10; overflow: hidden; }
.post-card .thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s ease; }
.post-card:hover .thumb img { transform: scale(1.06); }
.post-card .cat-tag { position: absolute; top: 10px; left: 10px; background: var(--accent); color: #fff; font-size: 12px; padding: 3px 10px; border-radius: 999px; }
.post-card .body { padding: 14px 16px 18px; flex: 1; display: flex; flex-direction: column; }
.post-card h3 { font-size: 16px; line-height: 1.45; margin: 0 0 10px; }
.post-card h3 a { color: var(--text); }
.post-card h3 a:hover { color: var(--accent); }
.post-card .excerpt { color: var(--text-2); font-size: 13px; margin: 0 0 10px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.post-card .meta { margin-top: auto; font-size: 12px; color: var(--text-3); display: flex; gap: 12px; flex-wrap: wrap; }

/* 列表式条目（侧边栏/归档） */
.post-list { display: flex; flex-direction: column; gap: 14px; }
.post-list .item { display: flex; gap: 12px; }
.post-list .item img { width: 90px; height: 64px; object-fit: cover; border-radius: 8px; flex: 0 0 auto; }
.post-list .item h4 { font-size: 14px; margin: 0 0 6px; line-height: 1.4; }
.post-list .item .meta { font-size: 12px; color: var(--text-3); }

/* ==========================================================================
   6. 侧边栏与小工具
   ========================================================================== */
.sidebar { position: sticky; top: calc(var(--header-h) + 16px); display: flex; flex-direction: column; gap: 22px; }
.widget { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.widget-title { font-size: 16px; margin: 0 0 14px; padding-left: 12px; position: relative; }
.widget-title::before { content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%); width: 4px; height: 16px; background: var(--accent); border-radius: 2px; }
.widget ul { list-style: none; margin: 0; padding: 0; }
.widget ul li { padding: 8px 0; border-bottom: 1px dashed var(--border); }
.widget ul li:last-child { border-bottom: 0; }
.tagcloud { display: flex; flex-wrap: wrap; gap: 8px; }
.tagcloud a { background: var(--accent-soft); color: var(--accent); padding: 4px 12px; border-radius: 999px; font-size: 13px; }
.tagcloud a:hover { background: var(--accent); color: #fff; }

/* ==========================================================================
   7. 文章详情页
   ========================================================================== */
.breadcrumb { font-size: 13px; color: var(--text-3); margin-bottom: 14px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { color: #ccc; }

.single-header { background: var(--card); border-radius: var(--radius); padding: 26px 28px; box-shadow: var(--shadow); margin-bottom: 22px; }
.single-header .cat-tag { display: inline-block; background: var(--accent-soft); color: var(--accent); font-size: 13px; padding: 3px 12px; border-radius: 999px; margin-bottom: 12px; }
.single-header h1 { font-size: 28px; line-height: 1.35; margin: 0 0 14px; }
.entry-meta { display: flex; flex-wrap: wrap; gap: 16px; font-size: 13px; color: var(--text-3); align-items: center; }
.entry-meta .author { display: flex; align-items: center; gap: 8px; }
.entry-meta .author img { width: 28px; height: 28px; border-radius: 50%; }

.entry-content { background: var(--card); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); }
.entry-content > p:first-child::first-letter { /* 可选首字下沉，关闭以免干扰 */ }
.entry-content img { border-radius: 8px; margin: 1.2em auto; }
.entry-content h2 { font-size: 22px; margin-top: 1.6em; padding-bottom: 8px; border-bottom: 2px solid var(--border); }
.entry-content h3 { font-size: 18px; margin-top: 1.4em; }
.entry-content a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.entry-content a.internal-link { color: var(--accent); font-weight: 600; }
.entry-content ul, .entry-content ol { padding-left: 1.6em; }
.entry-content table { width: 100%; border-collapse: collapse; margin: 1.4em 0; }
.entry-content table th, .entry-content table td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.entry-content table th { background: var(--accent-soft); }

/* 文章内关键词内链高亮（自动） */
.entry-content .auto-internal-link { color: var(--accent); font-weight: 600; text-decoration: none; border-bottom: 1px dashed var(--accent); }

.tags-row { margin-top: 22px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tags-row .label { font-size: 13px; color: var(--text-3); }
.tags-row a { background: var(--accent-soft); color: var(--accent); padding: 4px 12px; border-radius: 999px; font-size: 13px; }
.tags-row a:hover { background: var(--accent); color: #fff; }

/* 作者信息框 */
.author-box { display: flex; gap: 16px; background: var(--card); border-radius: var(--radius); padding: 22px; margin-top: 22px; box-shadow: var(--shadow); align-items: center; }
.author-box img { width: 64px; height: 64px; border-radius: 50%; }
.author-box h4 { margin: 0 0 4px; font-size: 16px; }
.author-box p { margin: 0; color: var(--text-2); font-size: 14px; }

/* 相关文章 */
.related { margin-top: 30px; }

/* 分享/操作条 */
.post-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.post-actions button, .post-actions a { border: 1px solid var(--border); background: #fff; border-radius: 999px; padding: 7px 16px; font-size: 13px; cursor: pointer; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; }
.post-actions button:hover, .post-actions a:hover { border-color: var(--accent); color: var(--accent); }

/* ==========================================================================
   8. 评论
   ========================================================================== */
.comments-area { background: var(--card); border-radius: var(--radius); padding: 26px; margin-top: 24px; box-shadow: var(--shadow); }
.comment-list { list-style: none; margin: 0; padding: 0; }
.comment-list .comment { padding: 16px 0; border-bottom: 1px solid var(--border); }
.comment-list .comment .avatar { float: left; margin-right: 12px; border-radius: 50%; }
.comment-list .comment .comment-meta { font-size: 13px; color: var(--text-3); margin-bottom: 6px; }
.comment-list .comment .comment-author { font-weight: 700; color: var(--text); }
.comment-form input[type="text"], .comment-form input[type="email"], .comment-form textarea {
    width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font-size: 14px; font-family: inherit;
}
.comment-form .form-submit input { background: var(--accent); color: #fff; border: 0; border-radius: 999px; padding: 10px 24px; cursor: pointer; font-weight: 600; }

/* ==========================================================================
   9. 归档 / 搜索 / 404
   ========================================================================== */
.archive-header { margin-bottom: 22px; }
.archive-header h1 { font-size: 24px; margin: 0 0 4px; }
.archive-header .desc { color: var(--text-2); font-size: 14px; }
.pagination { display: flex; gap: 8px; justify-content: center; margin-top: 34px; flex-wrap: wrap; }
.pagination a, .pagination span { min-width: 38px; height: 38px; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--border); background: #fff; color: var(--text-2); padding: 0 12px; }
.pagination .current, .pagination a:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

.error-404 { text-align: center; padding: 60px 20px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.error-404 h1 { font-size: 96px; color: var(--accent); margin: 0; }
.error-404 p { color: var(--text-2); }

/* ==========================================================================
   10. 页脚
   ========================================================================== */
.site-footer { background: #14181f; color: #b9c0cc; margin-top: 40px; }
.footer-widgets { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 30px; padding: 44px 0; }
.footer-widgets h4 { color: #fff; font-size: 16px; margin: 0 0 16px; }
.footer-subtitle { font-size: 13px; color: #c9d0da; margin: 4px 0 12px; }
.footer-widgets a { color: #b9c0cc; }
.footer-widgets a:hover { color: #fff; }
.footer-widgets ul { list-style: none; margin: 0; padding: 0; }
.footer-widgets ul li { padding: 5px 0; }
.footer-bottom { border-top: 1px solid rgba(255,255,255,.08); padding: 18px 0; text-align: center; font-size: 13px; color: #7b828d; }
.footer-bottom a { color: #9aa2ad; }
@media (max-width: 768px) { .footer-widgets { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .footer-widgets { grid-template-columns: 1fr; } }

/* 移动端底部导航 */
.mobile-tabbar { display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 90; background: #fff; border-top: 1px solid var(--border); padding: 6px 0; box-shadow: 0 -2px 12px rgba(0,0,0,.06); }
.mobile-tabbar a { flex: 1; text-align: center; font-size: 12px; color: var(--text-3); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.mobile-tabbar a.active, .mobile-tabbar a:hover { color: var(--accent); }
.mobile-tabbar .icon { font-size: 20px; }
@media (max-width: 960px) { .mobile-tabbar { display: flex; } body { padding-bottom: 56px; } }

/* ==========================================================================
   11. GEO / 无障碍 / 杂项
   ========================================================================== */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--accent); color: #fff; padding: 8px 16px; z-index: 200; }
.skip-link:focus { left: 8px; top: 8px; }

/* FAQ（GEO 结构化） */
.faq-item { border: 1px solid var(--border); border-radius: var(--radius); margin: 12px 0; overflow: hidden; }
.faq-item .faq-q { padding: 14px 18px; font-weight: 700; cursor: pointer; display: flex; justify-content: space-between; align-items: center; background: var(--accent-soft); }
.faq-item .faq-a { padding: 14px 18px; display: none; }
.faq-item.open .faq-a { display: block; }

/* 返回顶部 */
.to-top { position: fixed; right: 20px; bottom: 76px; width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: #fff; border: 0; cursor: pointer; font-size: 20px; display: none; align-items: center; justify-content: center; z-index: 80; box-shadow: var(--shadow-hover); }
.to-top.show { display: flex; }
@media (max-width: 960px) { .to-top { bottom: 70px; } }

/* Gutenberg 区块对齐支持 */
.alignwide { width: 100%; max-width: calc(var(--container) + 120px); margin-left: 50%; transform: translateX(-50%); }
.alignfull { width: 100vw; margin-left: 50%; transform: translateX(-50%); }
.wp-block-image img { border-radius: 8px; }
.wp-block-quote { border-left: 4px solid var(--accent); background: var(--accent-soft); padding: 1em 1.2em; border-radius: 0 var(--radius) var(--radius) 0; }
