/*!
 * Theme Name:  Haoqun Blog
 * Theme URI:   https://www.haoqunw.com/
 * Author:      好群网
 * Author URI:  https://www.haoqunw.com/
 * Description: 好群网定制博客主题：双栏布局、右侧边栏、页脚小工具、广告位管理、友情链接、SEO 与自定义代码设置。主题设置基于 WordPress 原生定制器，无需任何前端构建工具。
 * Version:     1.0.0
 * Requires at least: 6.0
 * Tested up to: 6.4
 * Requires PHP: 7.0
 * License:     GNU General Public License v3.0 or later
 * License URI: https://www.gnu.org/licenses/gpl-3.0.html
 * Text Domain: haoqun
 */

/* ---------- 基础变量与重置 ---------- */
/* 带 ★ 的变量可在后台「主题设置」→ 颜色方案 / 字体样式 / 布局结构 中调整 */
/* 配色体系：墨黑（导航 / 页脚） + 深蓝（主色） + 暗金（装饰点缀） + 高级灰（页面底色） */
:root {
	--hq-primary: #1f3a5f;          /* ★ 主色调（深蓝） */
	--hq-primary-dark: #16294a;     /* ★ 主色调（深蓝·深） */
	--hq-gold: #b08d57;             /* 暗金：装饰线与点缀 */
	--hq-gold-light: #d3b57e;       /* 暗金：高亮态 */
	--hq-ink: #15181e;              /* 墨黑：导航与页脚底色 */
	--hq-ink-soft: #1d212a;         /* 墨黑：浮层 / 下拉底色 */
	--hq-ink-line: #2a2f39;         /* 墨黑：分隔线 */
	--hq-ink-text: #c9cdd5;         /* 墨黑底上的正文色 */
	--hq-text: #2b2f36;
	--hq-text-light: #7a8190;
	--hq-border: #e3e5ea;
	--hq-bg: #f0f1f4;
	--hq-card-bg: #ffffff;
	--hq-radius: 10px;
	--hq-shadow: 0 1px 3px rgba(16, 20, 28, 0.08);
	--hq-font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
	--hq-font-size: 16px;
	--hq-line-height: 1.7;
	--hq-container: 1180px;
	--hq-sidebar-w: 320px;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
	margin: 0;
	background: var(--hq-bg);
	color: var(--hq-text);
	font-family: var(--hq-font);
	font-size: var(--hq-font-size);
	line-height: var(--hq-line-height);
	-webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; }

a { color: var(--hq-primary); text-decoration: none; transition: color 0.2s ease; }
a:hover { color: var(--hq-primary-dark); }

.container { max-width: var(--hq-container); margin: 0 auto; padding: 0 20px; }

.screen-reader-text {
	border: 0;
	clip: rect(1px, 1px, 1px, 1px);
	clip-path: inset(50%);
	height: 1px;
	width: 1px;
	margin: -1px;
	overflow: hidden;
	padding: 0;
	position: absolute !important;
	word-wrap: normal !important;
}

.skip-link {
	position: absolute;
	left: -9999px;
	top: 0;
	background: #fff;
	color: var(--hq-text);
	padding: 8px 16px;
	z-index: 100000;
}
.skip-link:focus { left: 0; }

/* ---------- 顶部：墨黑导航 + 暗金底部饰线 ---------- */
.site-header {
	background: var(--hq-ink);
	border-bottom: 1px solid var(--hq-ink-line);
	box-shadow: inset 0 -2px 0 var(--hq-gold);
	position: sticky;
	top: 0;
	z-index: 100;
}
/* 页眉吸附可在「主题设置 → 页眉页脚」中关闭 */
body.hq-header-static .site-header { position: static; }

.header-inner { display: flex; align-items: center; gap: 24px; height: 64px; }

.site-branding { flex-shrink: 0; display: flex; align-items: center; }
.site-title { font-size: 22px; font-weight: 700; margin: 0; line-height: 1.2; letter-spacing: 0.5px; }
.site-title a { color: #f2f3f5; }
.site-title a:hover { color: var(--hq-gold-light); }
.custom-logo { max-height: 46px; width: auto; display: block; }

.main-nav { margin-left: auto; }

/* 导航按钮：文字 + 暗金下划线动效（悬停 / 当前项展开） */
.nav-list { display: flex; gap: 6px; list-style: none; margin: 0; padding: 0; }
.nav-list > li > a {
	position: relative;
	display: block;
	padding: 8px 14px;
	color: var(--hq-ink-text);
	border-radius: 6px;
	font-size: 15px;
	letter-spacing: 0.5px;
	transition: color 0.2s ease;
}
.nav-list > li > a::after {
	content: "";
	position: absolute;
	left: 14px;
	right: 14px;
	bottom: 3px;
	height: 2px;
	border-radius: 1px;
	background: var(--hq-gold);
	transform: scaleX(0);
	transform-origin: left center;
	transition: transform 0.25s ease;
}
.nav-list > li > a:hover { color: #ffffff; }
.nav-list > li > a:hover::after,
.nav-list > .current-menu-item > a::after,
.nav-list > .current_page_item > a::after,
.nav-list > .current-menu-ancestor > a::after { transform: scaleX(1); }
.nav-list > .current-menu-item > a,
.nav-list > .current_page_item > a,
.nav-list > .current-menu-ancestor > a { color: var(--hq-gold-light); }
.nav-list .sub-menu {
	display: none;
	position: absolute;
	background: var(--hq-ink-soft);
	border: 1px solid var(--hq-ink-line);
	border-radius: 8px;
	box-shadow: 0 12px 28px rgba(8, 10, 14, 0.35);
	list-style: none;
	padding: 6px;
	min-width: 160px;
	margin: 0;
}
.nav-list > li { position: relative; }
.nav-list > li:hover > .sub-menu { display: block; }
.nav-list .sub-menu a { display: block; padding: 7px 12px; font-size: 14px; color: var(--hq-ink-text); border-radius: 6px; transition: color 0.2s ease, background 0.2s ease; }
.nav-list .sub-menu a:hover { background: rgba(195, 162, 104, 0.12); color: var(--hq-gold-light); }

.nav-toggle {
	display: none;
	flex-direction: column;
	justify-content: center;
	gap: 5px;
	width: 40px;
	height: 40px;
	background: transparent;
	border: 0;
	cursor: pointer;
	margin-left: auto;
	padding: 0;
}
.nav-toggle span { display: block; width: 22px; height: 2px; background: #e8eaee; border-radius: 2px; transition: transform 0.25s ease, opacity 0.25s ease; }
body.nav-open .nav-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
body.nav-open .nav-toggle span:nth-child(2) { opacity: 0; }
body.nav-open .nav-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- 主体布局：双栏（侧边栏位置 / 宽度可在主题设置中调整） ---------- */
.site-content { display: grid; grid-template-columns: minmax(0, 1fr) var(--hq-sidebar-w); gap: 28px; padding: 28px 0 48px; }
body.hq-sidebar-left .site-content { grid-template-columns: var(--hq-sidebar-w) minmax(0, 1fr); }
body.hq-sidebar-left .widget-area { order: -1; }
body.no-sidebar .site-content { grid-template-columns: minmax(0, 1fr); }

/* ---------- 文章卡片列表 ---------- */
.post-list { display: flex; flex-direction: column; gap: 20px; }

.post-card {
	display: flex;
	gap: 18px;
	background: var(--hq-card-bg);
	border: 1px solid var(--hq-border);
	border-radius: var(--hq-radius);
	padding: 18px;
	box-shadow: var(--hq-shadow);
}
.card-thumb { flex-shrink: 0; width: 240px; display: block; border-radius: 8px; overflow: hidden; background: #e9ebef; }
.card-thumb img,
.card-thumb .thumb-placeholder { width: 100%; height: 170px; object-fit: cover; display: block; }

/* 无特色图与正文图时的占位图（显示分类名）：深蓝渐变，与主色同源 */
.thumb-placeholder {
	display: flex;
	align-items: center;
	justify-content: center;
	background: linear-gradient(135deg, #1c2c4a, #3a5273);
	color: #fff;
	overflow: hidden;
}
.thumb-placeholder .ph-text {
	font-size: 18px;
	font-weight: 600;
	letter-spacing: 1px;
	opacity: 0.95;
	text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}
.card-body { min-width: 0; flex: 1; }
.card-title { font-size: 19px; margin: 0 0 8px; line-height: 1.45; }
.card-title a { color: var(--hq-text); }
.card-title a:hover { color: var(--hq-primary); }
.sticky-badge {
	display: inline-block;
	background: rgba(176, 141, 87, 0.14);
	color: #8a6d3b;
	font-size: 12px;
	line-height: 1.6;
	padding: 1px 8px;
	border-radius: 4px;
	margin-right: 8px;
	vertical-align: 2px;
}
.entry-meta { font-size: 13px; color: var(--hq-text-light); margin-bottom: 10px; }
.entry-meta a { color: var(--hq-text-light); }
.entry-meta a:hover { color: var(--hq-primary); }
.meta-sep { margin: 0 6px; }
.card-excerpt {
	font-size: 14px;
	color: #565c66;
	margin: 0 0 10px;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}
.read-more { font-size: 14px; font-weight: 500; }

/* ---------- 面包屑 ---------- */
.breadcrumb { font-size: 13px; color: var(--hq-text-light); margin-bottom: 16px; }
.breadcrumb a { color: var(--hq-text-light); }
.breadcrumb a:hover { color: var(--hq-primary); }
.crumb-sep { margin: 0 6px; }

/* ---------- 文章/页面内容 ---------- */
.single-post,
.page-post,
.error-404,
.comments-area {
	background: var(--hq-card-bg);
	border: 1px solid var(--hq-border);
	border-radius: var(--hq-radius);
	padding: 32px 36px;
	box-shadow: var(--hq-shadow);
}
.single-post .entry-title,
.page-post .entry-title { font-size: 26px; margin: 0 0 12px; line-height: 1.4; }
.single-thumb { margin-bottom: 18px; }
.single-thumb img { border-radius: 8px; width: 100%; }

.entry-content { font-size: 1em; overflow-wrap: break-word; }
.entry-content h1, .entry-content h2, .entry-content h3, .entry-content h4 { line-height: 1.4; margin: 1.4em 0 0.6em; }
.entry-content h2 { font-size: 22px; }
.entry-content h3 { font-size: 19px; }
.entry-content p { margin: 0 0 1em; }
.entry-content a { text-decoration: underline; }
.entry-content ul, .entry-content ol { padding-left: 1.6em; margin: 0 0 1em; }
.entry-content blockquote {
	margin: 1.2em 0;
	padding: 10px 18px;
	border-left: 4px solid var(--hq-gold);
	background: #f7f8fa;
	color: #565c66;
	border-radius: 0 6px 6px 0;
}
.entry-content pre { background: #282c34; color: #abb2bf; padding: 16px; border-radius: 8px; overflow: auto; font-size: 14px; line-height: 1.6; }
.entry-content code { background: #e9ebef; padding: 2px 6px; border-radius: 4px; font-size: 90%; }
.entry-content pre code { background: transparent; padding: 0; }
.entry-content img { border-radius: 8px; }
.entry-content table { width: 100%; border-collapse: collapse; margin: 1em 0; }
.entry-content table th, .entry-content table td { border: 1px solid var(--hq-border); padding: 8px 12px; }
.entry-content .wp-post-image { border-radius: 8px; }

.entry-tags { margin: 24px 0 0; color: var(--hq-text-light); font-size: 14px; }
.entry-tags a { margin-right: 8px; }

/* ---------- 上下篇导航 ---------- */
.post-navigation { display: flex; gap: 12px; margin: 24px 0 0; font-size: 14px; }
.post-navigation .nav-previous, .post-navigation .nav-next { min-width: 0; }
.post-navigation .nav-next { margin-left: auto; text-align: right; }
.post-navigation a {
	display: block;
	background: var(--hq-card-bg);
	border: 1px solid var(--hq-border);
	border-radius: 8px;
	padding: 10px 16px;
	color: var(--hq-text);
	max-width: 100%;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.post-navigation a:hover { border-color: var(--hq-primary); color: var(--hq-primary); }
.nav-sub { display: block; font-size: 12px; color: var(--hq-text-light); }

/* ---------- 推荐阅读 ---------- */
.related-posts {
	background: var(--hq-card-bg);
	border: 1px solid var(--hq-border);
	border-radius: var(--hq-radius);
	padding: 24px 28px;
	margin-top: 24px;
	box-shadow: var(--hq-shadow);
}
.related-title {
	font-size: 17px;
	margin: 0 0 16px;
	padding-bottom: 10px;
	border-bottom: 2px solid var(--hq-gold);
}
/* 纯文字列表：标题 + 日期，不含缩略图 */
.related-list { list-style: none; margin: 0; padding: 0; }
.related-item { padding: 12px 0; border-bottom: 1px dashed var(--hq-border); }
.related-item:first-child { padding-top: 0; }
.related-item:last-child { border-bottom: 0; padding-bottom: 0; }
.rel-title {
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	font-size: 15px;
	line-height: 1.6;
	color: var(--hq-text);
}
.rel-title:hover { color: var(--hq-primary); }
.rel-date { display: block; margin-top: 4px; font-size: 12px; color: var(--hq-text-light); }

/* ---------- 分页 ---------- */
.nav-links { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 28px 0 0; }
.page-numbers {
	min-width: 38px;
	height: 38px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: var(--hq-card-bg);
	border: 1px solid var(--hq-border);
	border-radius: 6px;
	padding: 0 12px;
	color: var(--hq-text);
}
.page-numbers.current { background: var(--hq-primary); border-color: var(--hq-primary); color: #fff; }
a.page-numbers:hover { border-color: var(--hq-primary); color: var(--hq-primary); }

/* ---------- 侧边栏 ---------- */
.widget-area .widget {
	background: var(--hq-card-bg);
	border: 1px solid var(--hq-border);
	border-radius: var(--hq-radius);
	padding: 20px;
	margin-bottom: 20px;
	box-shadow: var(--hq-shadow);
}
.widget-title { font-size: 16px; margin: 0 0 14px; padding-bottom: 10px; border-bottom: 2px solid var(--hq-gold); }
.widget ul { list-style: none; margin: 0; padding: 0; }
.widget ul li { padding: 7px 0; border-bottom: 1px dashed var(--hq-border); font-size: 14px; }
.widget ul li:last-child { border-bottom: 0; }
.widget ul li a { color: var(--hq-text); }
.widget ul li a:hover { color: var(--hq-primary); }

/* 侧边栏：文章列表（最新 / 随机 / 热门） */
.sb-posts { list-style: none; margin: 0; padding: 0; }
.sb-posts li { display: flex; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px dashed var(--hq-border); }
.sb-posts li:last-child { border-bottom: 0; padding-bottom: 0; }
.sb-thumb { flex-shrink: 0; width: 64px; display: block; border-radius: 6px; overflow: hidden; background: #e9ebef; }
.sb-thumb img,
.sb-thumb .thumb-placeholder { width: 100%; height: 44px; object-fit: cover; display: block; }
.sb-thumb .thumb-placeholder .ph-text { font-size: 11px; letter-spacing: 0; }
.sb-post-title {
	flex: 1;
	min-width: 0;
	font-size: 14px;
	line-height: 1.55;
	color: var(--hq-text);
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}
.sb-post-title:hover { color: var(--hq-primary); }

/* 侧边栏：分类模块 */
.cat-list .cat-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cat-list .cat-item a { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-count { flex-shrink: 0; font-size: 12px; color: var(--hq-text-light); background: #f0f1f4; border-radius: 10px; padding: 1px 8px; }
.cat-list .children { padding-left: 14px; }

/* 侧边栏：标签云（主题输出与 WP 默认标签云小工具统一风格） */
.tag-cloud,
.widget .tagcloud,
.widget .wp-tag-cloud {
	display: flex;
	flex-wrap: wrap;
	gap: 6px 12px;
	align-items: baseline;
	line-height: 1.7;
}
.tag-cloud .tag-link,
.widget .tagcloud a,
.widget .tag-cloud-link { color: var(--hq-primary); text-decoration: none; }
.tag-cloud .tag-link:hover,
.widget .tagcloud a:hover,
.widget .tag-cloud-link:hover { color: var(--hq-primary-dark); text-decoration: underline; }

/* 侧边栏：WP 默认「分类目录」小工具（无子分类时右侧显示文章数） */
.widget_categories .cat-item:not(:has(.children)) {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
}
.widget_categories .cat-item a { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 侧边栏：最后一个模块不留多余间距（分类 / 标签迁移后仍贴合底部） */
.widget-area > .widget:last-child { margin-bottom: 0; }

/* ---------- 搜索表单 ---------- */
.search-form { display: flex; gap: 8px; }
.search-field { flex: 1; min-width: 0; padding: 9px 12px; border: 1px solid var(--hq-border); border-radius: 6px; font-size: 14px; }
.search-field:focus { outline: none; border-color: var(--hq-primary); }
.search-submit {
	padding: 9px 18px;
	background: var(--hq-primary);
	color: #fff;
	border: 0;
	border-radius: 6px;
	cursor: pointer;
	font-size: 14px;
}
.search-submit:hover { background: var(--hq-primary-dark); }

/* ---------- 广告位 ---------- */
.hq-ad-slot, .ad-slot { margin: 16px 0; text-align: center; overflow: hidden; }
.header-ad { padding-top: 20px; }
.list-ad { background: var(--hq-card-bg); border: 1px solid var(--hq-border); border-radius: var(--hq-radius); padding: 12px; }

/* ---------- 评论 ---------- */
.comments-area { margin-top: 28px; }
.comments-title { font-size: 18px; margin: 0 0 16px; }
.comment-list { list-style: none; margin: 0; padding: 0; }
.comment-list .comment { padding: 16px 0; border-bottom: 1px solid var(--hq-border); }
.comment-list .comment:last-child { border-bottom: 0; }
.comment-meta { font-size: 13px; color: var(--hq-text-light); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.comment-meta .comment-author { color: var(--hq-text); font-weight: 600; }
.comment-author img { border-radius: 50%; margin-right: 8px; vertical-align: middle; }
.comment-content { margin-top: 8px; font-size: 15px; }
.comment-content p { margin: 0 0 0.6em; }
.children { list-style: none; padding-left: 28px; margin: 0; }
.reply { font-size: 13px; }
.comment-form label { display: block; font-size: 13px; color: var(--hq-text-light); margin-bottom: 4px; }
.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form input[type="url"],
.comment-form textarea {
	width: 100%;
	border: 1px solid var(--hq-border);
	border-radius: 6px;
	padding: 9px 12px;
	font-size: 14px;
	font-family: inherit;
}
.comment-form input:focus, .comment-form textarea:focus { outline: none; border-color: var(--hq-primary); }
.comment-form .submit {
	background: var(--hq-primary);
	color: #fff;
	border: 0;
	border-radius: 6px;
	padding: 10px 26px;
	cursor: pointer;
	font-size: 15px;
}
.comment-form .submit:hover { background: var(--hq-primary-dark); }
.no-comments { color: var(--hq-text-light); }

/* ---------- 页脚：墨黑底 + 暗金顶线，与导航呼应 ---------- */
.site-footer { background: #101318; color: #8b919c; padding: 26px 0; font-size: 13px; border-top: 2px solid var(--hq-gold); }
.site-footer a { color: #b9bec7; }
.site-footer a:hover { color: var(--hq-gold-light); }
.site-info { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; }
.site-info p { margin: 0 0 4px; }
.site-info .footer-nav ul { display: flex; flex-wrap: wrap; gap: 14px; list-style: none; margin: 0; padding: 0; }
.footer-links { margin-top: 6px; }
.footer-links a { margin: 0 6px 0 0; }

/* ---------- 404 ---------- */
.error-404 { text-align: center; padding: 60px 20px; }
.error-code { font-size: 80px; font-weight: 700; color: var(--hq-primary); margin: 0; line-height: 1.1; }
.error-404 .search-form { max-width: 380px; margin: 24px auto; }
.error-404 .button {
	display: inline-block;
	background: var(--hq-primary);
	color: #fff;
	padding: 10px 26px;
	border-radius: 6px;
	margin-top: 8px;
}
.error-404 .button:hover { background: var(--hq-primary-dark); color: #fff; }
.error-404 .widget-list { text-align: left; margin-top: 28px; }
.error-404 .widget-list h3 { font-size: 15px; }
.error-404 .widget-list ul { list-style: none; padding: 0; }
.error-404 .widget-list li { padding: 6px 0; border-bottom: 1px dashed var(--hq-border); font-size: 14px; }

/* ---------- 返回顶部 ---------- */
#back-to-top {
	position: fixed;
	right: 24px;
	bottom: 32px;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	border: 0;
	background: var(--hq-primary);
	color: #fff;
	font-size: 18px;
	cursor: pointer;
	opacity: 0;
	visibility: hidden;
	transform: translateY(10px);
	transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
	z-index: 99;
	box-shadow: 0 2px 8px rgba(20, 30, 50, 0.25);
}
#back-to-top.show { opacity: 1; visibility: visible; transform: none; }
#back-to-top:hover { background: var(--hq-primary-dark); }

/* ---------- 响应式 ---------- */
@media (max-width: 991px) {
	.site-content { grid-template-columns: minmax(0, 1fr); }
	.nav-toggle { display: flex; }
	.main-nav {
		display: none;
		position: absolute;
		top: 64px;
		left: 0;
		right: 0;
		background: var(--hq-ink);
		border-bottom: 1px solid var(--hq-ink-line);
		padding: 10px 20px 16px;
		margin: 0;
		box-shadow: 0 12px 24px rgba(8, 10, 14, 0.3);
	}
	body.nav-open .main-nav { display: block; }
	.nav-list { flex-direction: column; gap: 2px; }
	/* 侧边栏（含分类 / 标签）在窄屏下一律移到正文下方，占满整行 */
	.widget-area { width: 100%; }
	body.hq-sidebar-left .widget-area { order: 0; }
}

@media (max-width: 600px) {
	.header-inner { height: 56px; }
	.main-nav { top: 56px; }
	.card-thumb { width: 120px; }
	.card-thumb img,
	.card-thumb .thumb-placeholder { height: 92px; }
	.card-thumb .thumb-placeholder .ph-text { font-size: 14px; }
	.card-title { font-size: 17px; }
	.card-excerpt { -webkit-line-clamp: 2; }
	.single-post, .page-post, .comments-area { padding: 22px 18px; }
	.single-post .entry-title { font-size: 21px; }
	.related-posts { padding: 20px 18px; }
	.rel-title { font-size: 14px; }
	.post-navigation { flex-direction: column; }
	.post-navigation .nav-next { text-align: left; margin-left: 0; }
}
