/*
Theme Name: X5H Portal
Theme URI: https://www.x5h.net
Author: Atlas
Description: 轻量级内容门户主题，面向搜索引擎优化，语义化标记、移动端自适应、内置结构化数据。
Version: 1.0.0
Requires at least: 6.0
Tested up to: 6.9
Requires PHP: 7.4
License: GNU General Public License v2 or later
Text Domain: x5h-portal
Tags: news, blog, custom-menu, featured-images, translation-ready
*/

:root {
  --primary: #1d4ed8;
  --primary-dark: #1e40af;
  --accent: #dc2626;
  --text: #16181d;
  --text-mid: #4b5563;
  --text-soft: #8b919c;
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --border: #e5e7eb;
  --radius: 8px;
  --wrap: 1200px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.75;
  color: var(--text);
  background: var(--bg);
  word-wrap: break-word;
}

img { max-width: 100%; height: auto; display: block; }

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 16px; }

.screen-reader-text {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px); white-space: nowrap;
}

/* ---------- 顶栏 ---------- */
.site-header {
  border-bottom: 1px solid var(--border);
  background: #fff;
  position: sticky; top: 0; z-index: 50;
}
.header-inner {
  display: flex; align-items: center; gap: 20px;
  min-height: 64px;
}
.site-brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.site-logo { max-height: 38px; width: auto; }
.site-title { font-size: 20px; font-weight: 700; margin: 0; line-height: 1.3; }
.site-title a { color: var(--text); }
.site-tagline { margin: 0; font-size: 12px; color: var(--text-soft); }

.main-nav { flex: 1; min-width: 0; }
.main-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.main-nav a {
  display: block; padding: 8px 12px; font-size: 15px; color: var(--text);
  border-radius: var(--radius); white-space: nowrap;
}
.main-nav a:hover { background: var(--bg-soft); color: var(--primary); }
.main-nav .current-menu-item > a,
.main-nav .current_page_item > a { color: var(--primary); font-weight: 600; }
.main-nav .sub-menu {
  position: absolute; display: none; flex-direction: column;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 6px; min-width: 160px; box-shadow: 0 6px 20px rgba(0,0,0,.07);
}
.main-nav li { position: relative; }
.main-nav li:hover > .sub-menu { display: flex; }

.header-search { flex-shrink: 0; }
.header-search form { display: flex; }
.header-search input[type="search"] {
  width: 160px; padding: 8px 12px; font-size: 14px; font-family: inherit;
  border: 1px solid var(--border); border-right: none;
  border-radius: var(--radius) 0 0 var(--radius); outline: none;
}
.header-search input[type="search"]:focus { border-color: var(--primary); }
.header-search button {
  padding: 8px 14px; font-size: 14px; font-family: inherit; cursor: pointer;
  color: #fff; background: var(--primary); border: 1px solid var(--primary);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.header-search button:hover { background: var(--primary-dark); }

.nav-toggle {
  display: none; padding: 8px 12px; cursor: pointer; font-size: 20px; line-height: 1;
  background: none; border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text);
}

/* ---------- 主体布局 ---------- */
.site-main { padding: 28px 0 48px; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 36px; align-items: start; }
.layout-full { grid-template-columns: minmax(0, 1fr); }

.breadcrumbs { font-size: 13px; color: var(--text-soft); margin-bottom: 16px; }
.breadcrumbs a { color: var(--text-mid); }
.breadcrumbs span.sep { margin: 0 6px; color: var(--text-soft); }

/* ---------- 文章卡片 ---------- */
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 2px solid var(--border); padding-bottom: 10px; margin: 0 0 20px;
}
.section-head h2 {
  font-size: 20px; font-weight: 700; margin: 0; position: relative; padding-left: 12px;
}
.section-head h2::before {
  content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 4px; height: 18px; background: var(--primary); border-radius: 2px;
}
.section-head .more { font-size: 13px; color: var(--text-soft); }

.post-list { display: grid; gap: 0; }
.post-item {
  display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 20px;
  padding: 20px 0; border-bottom: 1px solid var(--border);
}
.post-item:first-child { padding-top: 0; }
.post-item .thumb { border-radius: var(--radius); overflow: hidden; background: var(--bg-soft); aspect-ratio: 16 / 10; }
.post-item .thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.post-item:hover .thumb img { transform: scale(1.04); }
.post-item h3 { font-size: 18px; font-weight: 600; margin: 0 0 8px; line-height: 1.5; }
.post-item h3 a { color: var(--text); }
.post-item h3 a:hover { color: var(--primary); }
.post-item .excerpt { font-size: 14px; color: var(--text-mid); margin: 0 0 10px; line-height: 1.7; }

.post-meta { font-size: 13px; color: var(--text-soft); display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
.post-meta a { color: var(--text-soft); }
.post-meta a:hover { color: var(--primary); }

.cat-badge {
  display: inline-block; padding: 2px 8px; font-size: 12px; border-radius: 4px;
  background: rgba(29,78,216,.08); color: var(--primary);
}
.cat-badge.is-hot { background: rgba(220,38,38,.08); color: var(--accent); }

/* 置顶大图 */
.featured-lead {
  display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 24px; margin-bottom: 36px;
}
.featured-lead .lead-main { position: relative; border-radius: var(--radius); overflow: hidden; }
.featured-lead .lead-main img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.featured-lead .lead-main .lead-body {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 44px 22px 18px;
  background: linear-gradient(to top, rgba(0,0,0,.82), rgba(0,0,0,0));
}
.featured-lead .lead-main h2 { font-size: 24px; margin: 0 0 6px; line-height: 1.4; }
.featured-lead .lead-main h2 a { color: #fff; }
.featured-lead .lead-main .post-meta, .featured-lead .lead-main .post-meta a { color: rgba(255,255,255,.78); }
.lead-side { display: grid; gap: 14px; }
.lead-side .post-item { grid-template-columns: 110px minmax(0, 1fr); gap: 12px; padding: 0 0 14px; }
.lead-side .post-item:last-child { border-bottom: none; }
.lead-side .post-item h3 { font-size: 15px; margin: 0 0 4px; }
.lead-side .post-item .excerpt { display: none; }

/* ---------- 文章页 ---------- */
.article-header { margin-bottom: 20px; }
.article-header h1 { font-size: 30px; line-height: 1.4; font-weight: 700; margin: 8px 0 14px; }
.entry-content { font-size: 17px; line-height: 1.9; }
.entry-content h2 { font-size: 22px; margin: 36px 0 14px; padding-left: 12px; border-left: 4px solid var(--primary); }
.entry-content h3 { font-size: 19px; margin: 28px 0 12px; }
.entry-content p { margin: 0 0 18px; }
.entry-content ul, .entry-content ol { margin: 0 0 18px; padding-left: 24px; }
.entry-content li { margin-bottom: 8px; }
.entry-content img { border-radius: var(--radius); margin: 20px 0; }
.entry-content blockquote {
  margin: 20px 0; padding: 12px 18px; border-left: 4px solid var(--border);
  background: var(--bg-soft); color: var(--text-mid); border-radius: 0 var(--radius) var(--radius) 0;
}
.entry-content table { width: 100%; border-collapse: collapse; margin: 20px 0; font-size: 15px; }
.entry-content th, .entry-content td { border: 1px solid var(--border); padding: 10px 12px; text-align: left; }
.entry-content th { background: var(--bg-soft); font-weight: 600; }
.entry-content pre {
  background: #1f2430; color: #e6e9ef; padding: 16px; border-radius: var(--radius);
  overflow-x: auto; font-size: 14px; line-height: 1.7;
}
.entry-content code { background: var(--bg-soft); padding: 2px 6px; border-radius: 4px; font-size: 15px; }
.entry-content pre code { background: none; padding: 0; }

.tag-list { margin: 28px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.tag-list a {
  font-size: 13px; padding: 4px 12px; background: var(--bg-soft);
  border-radius: 20px; color: var(--text-mid);
}
.tag-list a:hover { background: var(--primary); color: #fff; }

.post-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 32px 0 0; }
.post-nav a {
  display: block; padding: 14px 16px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 14px; color: var(--text); line-height: 1.6;
}
.post-nav a:hover { border-color: var(--primary); color: var(--primary); }
.post-nav .label { display: block; font-size: 12px; color: var(--text-soft); margin-bottom: 4px; }
.post-nav .next { text-align: right; }

.related { margin-top: 40px; }

/* ---------- 侧边栏 ---------- */
.widget { margin-bottom: 28px; }
.widget-title {
  font-size: 16px; font-weight: 700; margin: 0 0 14px; padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.widget ul { list-style: none; margin: 0; padding: 0; }
.widget li { padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.widget li:last-child { border-bottom: none; }
.rank-list li { display: flex; gap: 10px; align-items: flex-start; }
.rank-list .rank-no {
  flex-shrink: 0; width: 20px; height: 20px; line-height: 20px; text-align: center;
  font-size: 12px; border-radius: 4px; background: var(--bg-soft); color: var(--text-soft);
}
.rank-list li:nth-child(1) .rank-no { background: var(--accent); color: #fff; }
.rank-list li:nth-child(2) .rank-no { background: #f97316; color: #fff; }
.rank-list li:nth-child(3) .rank-no { background: #f59e0b; color: #fff; }
.rank-list a { color: var(--text); }
.rank-list a:hover { color: var(--primary); }

/* ---------- 分页 ---------- */
.pagination { margin: 32px 0 0; display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; }
.pagination .page-numbers {
  display: inline-block; padding: 7px 13px; font-size: 14px;
  border: 1px solid var(--border); border-radius: var(--radius); color: var(--text-mid);
}
.pagination .page-numbers.current,
.pagination .page-numbers:hover { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- 空状态 / 404 ---------- */
.empty-state { text-align: center; padding: 64px 20px; }
.empty-state h1 { font-size: 26px; margin: 0 0 12px; }
.empty-state p { color: var(--text-mid); margin: 0 0 20px; }
.btn {
  display: inline-block; padding: 10px 22px; background: var(--primary); color: #fff;
  border-radius: var(--radius); font-size: 15px;
}
.btn:hover { background: var(--primary-dark); color: #fff; }

/* ---------- 页脚 ---------- */
.site-footer { background: #1b1f27; color: #a8afbc; padding: 40px 0 24px; margin-top: 40px; font-size: 14px; }
.footer-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 28px; }
.site-footer h3 { color: #fff; font-size: 15px; margin: 0 0 14px; }
.site-footer a { color: #a8afbc; }
.site-footer a:hover { color: #fff; }
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { padding: 4px 0; }
.footer-bottom {
  margin-top: 28px; padding-top: 18px; border-top: 1px solid rgba(255,255,255,.1);
  font-size: 13px; color: #767e8c; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px;
}

/* ---------- 响应式 ---------- */
@media (max-width: 1024px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .featured-lead { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 768px) {
  .header-inner { flex-wrap: wrap; padding: 10px 0; }
  .nav-toggle { display: block; order: 3; }
  .main-nav { order: 4; flex-basis: 100%; display: none; }
  .main-nav.is-open { display: block; }
  .main-nav ul { flex-direction: column; gap: 0; }
  .main-nav .sub-menu { position: static; display: flex; border: none; box-shadow: none; padding-left: 16px; }
  .header-search { order: 2; margin-left: auto; }
  .header-search input[type="search"] { width: 120px; }
  .article-header h1 { font-size: 23px; }
  .entry-content { font-size: 16px; }
  .post-item { grid-template-columns: 120px minmax(0, 1fr); gap: 14px; }
  .post-item h3 { font-size: 16px; }
  .post-item .excerpt { display: none; }
  .post-nav { grid-template-columns: 1fr; }
  .featured-lead .lead-main h2 { font-size: 19px; }
}
@media (max-width: 480px) {
  .header-search input[type="search"] { width: 88px; }
  .site-title { font-size: 17px; }
  .site-tagline { display: none; }
}

/* ---------- 语言切换 ---------- */
.header-tools { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }

.lang-switch {
  display: inline-flex; align-items: center; gap: 2px; padding: 3px;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 20px;
}
.lang-link {
  display: inline-block; padding: 4px 11px; font-size: 13px; line-height: 1.5;
  color: var(--text-mid); border-radius: 16px; white-space: nowrap;
}
.lang-link:hover { color: var(--primary); }
.lang-link.is-current { background: var(--primary); color: #fff; }
.lang-link.is-current:hover { color: #fff; }

.site-footer .lang-switch { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.14); }
.site-footer .lang-link { color: #c6ccd6; }
.site-footer .lang-link.is-current { background: #fff; color: #1b1f27; }
.footer-note { margin: 0 0 12px; font-size: 13px; color: #767e8c; }

/* ---------- 采集来源标注 ---------- */
.source-note {
  margin: 26px 0 0; padding: 12px 16px; font-size: 14px;
  background: var(--bg-soft); border-left: 3px solid var(--primary); border-radius: 0 var(--radius) var(--radius) 0;
}
.source-note .source-label { color: var(--text-soft); margin-right: 6px; }
.src-badge {
  display: inline-block; padding: 1px 8px; font-size: 12px;
  color: var(--text-soft); background: var(--bg-soft); border-radius: 10px;
}

/* ---------- 文章配图与排版 ---------- */
.article-figure { margin: 0 0 24px; }
.article-figure img { border-radius: var(--radius); width: 100%; height: auto; }
.entry-content img { border-radius: var(--radius); }
.entry-content figure { margin: 24px 0; }
.entry-content figcaption { font-size: 13px; color: var(--text-soft); text-align: center; margin-top: 8px; }
.entry-content table { width: 100%; border-collapse: collapse; margin: 20px 0; font-size: 15px; }
.entry-content th, .entry-content td { border: 1px solid var(--border); padding: 9px 12px; text-align: left; }
.entry-content th { background: var(--bg-soft); }
.entry-content iframe { max-width: 100%; }

/* ---------- 404 搜索框 ---------- */
.nf-search { max-width: 440px; margin: 0 auto 24px; }
.nf-search-row { display: flex; }
.nf-search-row input[type="search"] {
  flex: 1; min-width: 0; padding: 10px 14px; font-size: 15px; font-family: inherit;
  border: 1px solid var(--border); border-right: none; border-radius: 8px 0 0 8px; outline: none;
}
.nf-search-row .btn { border-radius: 0 8px 8px 0; border: none; cursor: pointer; }

@media (max-width: 768px) {
  .header-tools { order: 2; margin-left: auto; }
  .site-footer .lang-switch { margin-top: 4px; }
}
@media (max-width: 480px) {
  .header-tools { gap: 8px; }
  .lang-link { padding: 4px 8px; font-size: 12px; }
}
