/*
Theme Name: CA-TPU Index
Theme URI: https://catpu.caiees.cn
Description: 中亚贸易政策不确定性指数（CA-TPU）专用轻量主题。
Version: 1.3
Author: Zhang Lijie Team, Xinjiang University
Text Domain: catpu
*/

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

:root {
  --c-primary: #2c5282;
  --c-accent: #d85a30;
  --c-text: #2d3748;
  --c-light: #718096;
  --c-muted: #a0aec0;
  --c-bg: #fff;
  --c-bg-alt: #f7fafc;
  --c-border: #e2e8f0;
  --f-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Microsoft YaHei', 'PingFang SC', 'Noto Sans SC', sans-serif;
  --max-w: 1100px;
}

html { font-size: 16px; scroll-behavior: smooth; }
body { font-family: var(--f-body); color: var(--c-text); background: var(--c-bg); line-height: 1.8; }
a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }

/* ====== Header ====== */
.site-header { border-bottom: 1px solid var(--c-border); background: var(--c-bg); position: sticky; top: 0; z-index: 100; }
.site-header-inner { max-width: var(--max-w); margin: 0 auto; padding: 0.8rem 1.5rem; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.5rem; }
.site-brand a { font-size: 1.1rem; font-weight: 700; color: var(--c-primary); text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.site-brand a:hover { text-decoration: none; }
.site-brand .custom-logo { display: inline-block; vertical-align: middle; max-height: 50px; width: auto; object-fit: contain; }
.site-brand .brand-title { vertical-align: middle; }
.site-brand .brand-sub { font-size: 0.72rem; color: var(--c-muted); font-weight: 400; display: block; line-height: 1.3; }

/* ====== Nav with Dropdown ====== */
.site-nav { display: flex; gap: 0.15rem; flex-wrap: wrap; align-items: center; }

.site-nav .menu-item { position: relative; }

.site-nav .menu-item > a {
  font-size: 0.85rem; color: var(--c-light); padding: 0.3rem 0.7rem; border-radius: 4px;
  text-decoration: none; transition: background 0.15s, color 0.15s; display: block; white-space: nowrap;
}
.site-nav .menu-item > a:hover,
.site-nav .current-menu-item > a,
.site-nav .current-menu-parent > a,
.site-nav .current-menu-ancestor > a {
  background: var(--c-bg-alt); color: var(--c-primary); text-decoration: none;
}

/* Dropdown arrow for parent items */
.site-nav .menu-item-has-children > a::after {
  content: ' ▾'; font-size: 0.7em; color: var(--c-muted); margin-left: 2px;
}

/* Dropdown panel */
.site-nav .sub-menu {
  display: none; position: absolute; top: 100%; left: 0; z-index: 200;
  background: var(--c-bg); border: 1px solid var(--c-border); border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08); padding: 0.4rem 0; min-width: 180px;
  list-style: none;
}
.site-nav .menu-item-has-children:hover > .sub-menu { display: block; }

.site-nav .sub-menu .menu-item > a {
  font-size: 0.83rem; padding: 0.4rem 1rem; border-radius: 0;
  color: var(--c-text); display: block;
}
.site-nav .sub-menu .menu-item > a:hover {
  background: var(--c-bg-alt); color: var(--c-primary);
}

/* ====== Main ====== */
.site-main { max-width: var(--max-w); margin: 0 auto; padding: 2rem 1.5rem 3rem; }

/* ====== Page Titles ====== */
.page-title { font-size: 1.6rem; font-weight: 700; color: var(--c-text); margin-bottom: 0.3rem; text-align: center; }
.page-subtitle { text-align: center; color: var(--c-light); font-size: 0.9rem; margin-bottom: 2rem; }

/* ====== Page & Post Content (narrower for readability) ====== */
.page-content { font-size: 0.95rem; max-width: 800px; margin: 0 auto; }
.page-content h2 { font-size: 1.25rem; font-weight: 700; margin-top: 2rem; margin-bottom: 0.5rem; padding-bottom: 0.3rem; border-bottom: 2px solid var(--c-border); }
.page-content h3 { font-size: 1.05rem; font-weight: 600; margin-top: 1.5rem; margin-bottom: 0.4rem; color: #4a5568; }
.page-content table { border-collapse: collapse; width: 100%; margin: 1rem 0; font-size: 0.9rem; }
.page-content th { background: var(--c-bg-alt); padding: 8px 12px; text-align: left; border: 1px solid var(--c-border); font-weight: 600; }
.page-content td { padding: 8px 12px; border: 1px solid var(--c-border); vertical-align: top; }
.page-content ul, .page-content ol { padding-left: 1.5em; margin: 0.5em 0; }

/* ====== Post List ====== */
.post-list { list-style: none; padding: 0; }
.post-item { padding: 1.2rem 0; border-bottom: 1px solid var(--c-border); display: flex; gap: 1rem; align-items: baseline; }
.post-item:last-child { border-bottom: none; }
.post-date { font-size: 0.82rem; color: var(--c-muted); white-space: nowrap; min-width: 90px; font-variant-numeric: tabular-nums; }
.post-info { flex: 1; }
.post-item-title { font-size: 1rem; font-weight: 600; margin-bottom: 0.15rem; }
.post-item-title a { color: var(--c-text); }
.post-item-title a:hover { color: var(--c-primary); text-decoration: none; }
.post-excerpt { font-size: 0.88rem; color: var(--c-light); line-height: 1.6; }
.post-cat { display: inline-block; font-size: 0.72rem; padding: 1px 8px; border-radius: 3px; background: var(--c-bg-alt); color: var(--c-light); border: 1px solid var(--c-border); margin-right: 0.3rem; }

/* ====== Single Post ====== */
.post-header { margin-bottom: 2rem; text-align: center; }
.post-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.3rem; }
.post-meta { font-size: 0.85rem; color: var(--c-muted); }
.post-content { font-size: 0.95rem; line-height: 1.9; max-width: 800px; margin: 0 auto; }
.post-content h2 { font-size: 1.2rem; font-weight: 700; margin-top: 1.8rem; margin-bottom: 0.5rem; }
.post-content p { margin-bottom: 1rem; }
.post-nav { display: flex; justify-content: space-between; margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--c-border); font-size: 0.88rem; }

/* ====== Pagination ====== */
.pagination { text-align: center; margin-top: 2rem; font-size: 0.9rem; }
.pagination a, .pagination span { display: inline-block; padding: 0.3rem 0.8rem; margin: 0 0.15rem; border-radius: 4px; }
.pagination .current { background: var(--c-primary); color: #fff; }

/* ====== Footer ====== */
.site-footer { border-top: 1px solid var(--c-border); background: var(--c-bg-alt); padding: 1.5rem; text-align: center; font-size: 0.78rem; color: var(--c-muted); line-height: 1.7; }
.site-footer p { margin: 0.3rem 0; }
.site-footer a { color: var(--c-light); }


/* ============================================================
   Shared Components (WPCode snippets)
   ============================================================ */

.tpu-notice { background: #fffbeb; border: 1px solid #f6e05e; border-radius: 6px; padding: 10px 16px; margin-bottom: 1rem; font-size: 13px; color: #975a16; line-height: 1.6; }
.tpu-notice strong { color: #744210; }
.tpu-notice em { color: #b7791f; }
.tpu-info { background: #f0f7ff; border-left: 3px solid var(--c-primary); border-radius: 0 6px 6px 0; padding: 12px 18px; margin: 1em 0; font-size: 0.92em; }
.tpu-note { background: #fef9ef; border-left: 3px solid #d4a017; border-radius: 0 6px 6px 0; padding: 12px 18px; margin: 1em 0; font-size: 0.92em; }
.tpu-formula { background: #f8f9fa; border-left: 3px solid var(--c-primary); border-radius: 0 6px 6px 0; padding: 14px 20px; margin: 1em 0; overflow-x: auto; text-align: center; }
.tpu-step { display: inline-block; width: 28px; height: 28px; line-height: 28px; text-align: center; background: var(--c-primary); color: #fff; border-radius: 50%; font-size: 13px; font-weight: 600; margin-right: 8px; }
.tpu-tag-t { background: #e3f2fd; color: #1565c0; padding: 2px 8px; border-radius: 3px; font-size: 0.88em; font-weight: 500; }
.tpu-tag-p { background: #fce4ec; color: #c62828; padding: 2px 8px; border-radius: 3px; font-size: 0.88em; font-weight: 500; }
.tpu-tag-u { background: #fff3e0; color: #e65100; padding: 2px 8px; border-radius: 3px; font-size: 0.88em; font-weight: 500; }
.tpu-ru { color: #555; }
.tpu-dl-btn { display: inline-flex; align-items: center; gap: 4px; padding: 5px 14px; border: 1px solid var(--c-primary); border-radius: 5px; font-size: 13px; color: var(--c-primary); text-decoration: none; background: #fff; }
.tpu-dl-btn:hover { background: #ebf4ff; text-decoration: none; }
.tpu-stats { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 1rem; font-size: 12px; color: #888; }
.tpu-stats span { background: var(--c-bg-alt); border: 1px solid var(--c-border); border-radius: 4px; padding: 3px 10px; }
.tpu-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 1rem; }
.tpu-filters select, .tpu-filters input { padding: 5px 10px; border: 1px solid #d0d5dd; border-radius: 5px; font-size: 13px; background: #fff; font-family: var(--f-body); }
.tpu-filters label { font-size: 12px; color: #888; display: block; margin-bottom: 2px; }
.tpu-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tpu-table thead th { background: var(--c-bg-alt); padding: 7px 10px; text-align: left; border-bottom: 2px solid var(--c-border); font-weight: 600; color: #4a5568; cursor: pointer; user-select: none; position: sticky; top: 0; z-index: 1; white-space: nowrap; }
.tpu-table thead th:hover { background: #edf2f7; }
.tpu-table thead th .sa { font-size: 10px; margin-left: 3px; color: var(--c-muted); }
.tpu-table tbody td { padding: 6px 10px; border-bottom: 1px solid #f0f0f0; }
.tpu-table tbody tr:hover { background: var(--c-bg-alt); }
.c-kz { color: #2c5282; font-weight: 600; }
.c-uz { color: #9c4221; font-weight: 600; }
.c-kg { color: #276749; font-weight: 600; }
.c-tj { color: #6b46c1; font-weight: 600; }
.tpu-zero { color: #d0d5dd; }
.tpu-bool-y { color: #38a169; font-weight: 700; }
.tpu-bool-n { color: #e2e8f0; }
.tpu-kw { display: inline-block; padding: 1px 5px; border-radius: 3px; font-size: 11px; margin: 1px 2px; line-height: 1.4; }
.tpu-kw-t { background: #e3f2fd; color: #1565c0; }
.tpu-kw-p { background: #fce4ec; color: #c62828; }
.tpu-kw-u { background: #fff3e0; color: #e65100; }
.tpu-kw-none { color: #d0d5dd; font-size: 11px; }
.tpu-bar { display: inline-block; height: 10px; border-radius: 2px; vertical-align: middle; }
.tpu-bar-or { background: rgba(50,102,173,0.3); }
.tpu-bar-and { background: var(--c-accent); }
.tpu-pager { display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 1rem; font-size: 13px; }
.tpu-pager button { padding: 4px 10px; border: 1px solid #d0d5dd; border-radius: 4px; background: #fff; cursor: pointer; font-size: 12px; color: #555; font-family: var(--f-body); }
.tpu-pager button:disabled { opacity: 0.4; cursor: default; }
.tpu-pager button.active { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }
.tpu-pager-info { color: var(--c-muted); font-size: 12px; }
.tpu-team-card { background: #f9f9f9; border-radius: 10px; padding: 20px 24px; margin: 1em 0; }
.tpu-team-card-leader { background: #f0f4fa; border-left: 4px solid var(--c-primary); }
.tpu-team-card-ack { background: #fafaf5; border-left: 4px solid #bbb; }
.tpu-team-name { font-size: 1.15em; font-weight: 600; color: #222; margin-bottom: 2px; }
.tpu-team-name-en { font-size: 0.88em; color: #888; font-weight: 400; }
.tpu-team-role { display: inline-block; font-size: 0.78em; color: #fff; padding: 2px 10px; border-radius: 3px; margin-bottom: 8px; }
.tpu-role-leader { background: var(--c-primary); }
.tpu-role-researcher { background: #5a9e6f; }
.tpu-role-ack { background: #b0b0b0; }
.tpu-team-bio { font-size: 0.9em; color: #666; line-height: 1.7; margin-top: 6px; }
.tpu-team-bio-ph { font-size: 0.85em; color: #bbb; font-style: italic; }
.tpu-zoom-btn { padding: 4px 12px; border: 1px solid #ddd; border-radius: 4px; background: #fff; cursor: pointer; font-size: 12px; color: #555; font-family: var(--f-body); }
.tpu-zoom-btn:hover { background: var(--c-bg-alt); }
.tpu-zoom-reset { border-color: var(--c-accent); color: var(--c-accent); }
.home-section-title { font-size: 1.15rem; font-weight: 700; margin-top: 2.5rem; margin-bottom: 0.8rem; padding-bottom: 0.3rem; border-bottom: 2px solid var(--c-border); }

/* ====== Responsive ====== */
@media (max-width: 640px) {
  .site-header-inner { flex-direction: column; align-items: flex-start; }
  .site-nav { width: 100%; }
  .site-nav .sub-menu { position: static; box-shadow: none; border: none; padding-left: 1rem; }
  .site-nav .menu-item-has-children:hover > .sub-menu { display: block; }
  .post-item { flex-direction: column; gap: 0.2rem; }
  .post-date { min-width: auto; }
  .page-title { font-size: 1.3rem; }
  .tpu-filters { flex-direction: column; }
}
