/* ==========================================================================
   专业化视觉层 - 面向「标准 / 文档资源站」
   在 typography.css 之后加载（functions.php 里以 mtime 版本号入队）
   只调整视觉、排版与比例，不改动模板结构与功能
   ========================================================================== */

:root {
  /* 面板 / 卡片 */
  --pro-radius: 12px;
  --pro-radius-sm: 8px;
  --pro-border: 1px solid var(--color-border-light);
  --pro-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  --pro-shadow-hover: 0 8px 22px rgba(15, 23, 42, 0.07);
  --pro-panel-pad: 18px;

  /* 文档三栏比例：左右侧栏给够宽度，避免内容被压窄 */
  --doc-sidebar-width: 260px;
  --doc-toc-width: 240px;
}

/* 文档页（三栏）：画布加宽 + 右侧栏随屏幕变宽，
   让「本文目录 / 二维码 / 热门内容」有足够空间，同时保证正文行宽舒适 */
@media (min-width: 1100px) {
  :root {
    --doc-toc-width: 240px;
  }

  .ast-container:has(.left-doc-sidebar) {
    max-width: 1360px;
  }

  .ast-container:has(.left-doc-sidebar) #secondary {
    /* Astra 默认给侧栏留了 30px 左内边距，压缩了可用宽度 */
    padding: 1.5rem 0 3rem 1.25rem !important;
  }
}

@media (min-width: 1200px) {
  :root {
    --doc-toc-width: 280px;
  }
}

@media (min-width: 1360px) {
  :root {
    --doc-toc-width: 320px;
  }
}

/* ==========================================================================
   1. 顶部站点头部：更克制的边界与悬浮态
   ========================================================================== */

.site-header {
  border-bottom: var(--pro-border);
  box-shadow: none;
}

.site-header:hover {
  box-shadow: none;
}

.main-header-menu > .menu-item > .menu-link {
  padding: 0.5rem 0.25rem;
  transition: color 0.15s ease;
}

/* 站点标题与 logo 呼吸感 */
.ast-site-identity {
  padding: 0.75rem 0;
}

.site-title,
.site-title a {
  font-weight: var(--font-weight-bold);
  letter-spacing: -0.01em;
}

/* 搜索框：更像企业站的紧凑搜索 */
.ast-header-search .search-field,
.site-header .search-field {
  height: 38px;
  border-radius: var(--pro-radius-sm);
  background: var(--color-bg-secondary);
}

.ast-header-search .search-field:focus,
.site-header .search-field:focus {
  background: #ffffff;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(46, 133, 85, 0.12);
  outline: none;
}

/* ==========================================================================
   2. 侧栏统一为信息面板（右侧栏 + 左侧文档导航）
   ========================================================================== */

#secondary .widget,
.left-doc-sidebar .widget {
  margin: 0 0 var(--pro-gap);
  padding: var(--pro-panel-pad) !important;
  background: var(--color-bg-primary);
  border: var(--pro-border);
  border-radius: var(--pro-radius);
  box-shadow: var(--pro-shadow) !important;
}

#secondary .widget:last-child,
.left-doc-sidebar .widget:last-child {
  margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   文档页（三栏）右侧栏：只保留「本文目录」，sticky 跟随不变
   需要恢复某个组件时，把它的选择器加回下面 :not() 里即可
   -------------------------------------------------------------------------- */

/* 1) 除目录以外，右栏其它内容（公众号图片 / 热门文章 / 搜索等）一律不显示 */
.ast-container:has(.left-doc-sidebar) #secondary > *:not(.doc-right-toc) {
  display: none !important;
}

/* 2) 若该文档没有生成目录（正文无 h2/h3），右栏不再占位，正文自动占满 */
@media (min-width: 1100px) {
  .ast-container:has(.left-doc-sidebar):not(:has(.doc-right-toc)) #secondary {
    display: none !important;
  }

  .ast-container:has(.left-doc-sidebar):not(:has(.doc-right-toc)) #primary {
    max-width: calc(100% - var(--doc-sidebar-width)) !important;
  }
}

/* 面板标题：小号、字距加大，作为区块标签 */
#secondary .widget-title,
.left-doc-sidebar .widget-title,
.wp-block-search__label {
  display: block;
  margin: 0 0 0.875rem;
  padding: 0 0 0.625rem;
  border-bottom: var(--pro-border);
  font-size: 12px;
  font-weight: var(--font-weight-bold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-tertiary);
  line-height: 1.4;
}

.left-doc-sidebar .widget-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* 面板内的链接统一 */
#secondary .widget ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* --------------------------------------------------------------------------
   2.1 热门文章：带序号的紧凑列表
   -------------------------------------------------------------------------- */

.widget_spv_popular_posts .spv-popular-posts {
  counter-reset: spv-rank;
}

.widget_spv_popular_posts .spv-popular-posts li {
  display: flex;
  align-items: baseline;
  gap: 0.625rem;
  padding: 0.5rem 0;
  border-bottom: 1px dashed var(--color-border-light);
  font-size: 12.5px;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
}

.widget_spv_popular_posts .spv-popular-posts li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.widget_spv_popular_posts .spv-popular-posts li::before {
  counter-increment: spv-rank;
  content: counter(spv-rank);
  flex: 0 0 1.25rem;
  font-size: 12px;
  font-weight: var(--font-weight-bold);
  color: var(--color-border-dark);
  text-align: right;
}

.widget_spv_popular_posts .spv-popular-posts li a {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 14px;
  font-weight: var(--font-weight-medium);
  line-height: 1.55;
  color: var(--color-text-secondary);
  text-decoration: none;
}

.widget_spv_popular_posts .spv-popular-posts li a:hover {
  color: var(--color-link);
}

/* --------------------------------------------------------------------------
   2.2 搜索面板
   -------------------------------------------------------------------------- */

.wp-block-search {
  margin: 0;
}

.wp-block-search .wp-block-search__inside-wrapper {
  display: flex;
  gap: 0.5rem;
  padding: 0;
  border: 0;
}

.wp-block-search .wp-block-search__input {
  flex: 1 1 auto;
  min-width: 0;
  height: 40px;
  padding: 0 0.75rem;
  border: 1px solid var(--color-border-medium);
  border-radius: var(--pro-radius-sm);
  font-size: 14px;
  background: #ffffff;
}

.wp-block-search .wp-block-search__input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(46, 133, 85, 0.12);
  outline: none;
}

/* --------------------------------------------------------------------------
   2.3 图片 / 二维码面板
   -------------------------------------------------------------------------- */

#secondary .widget_media_image {
  text-align: center;
}

#secondary .widget_media_image figure {
  margin: 0;
}

#secondary .widget_media_image img {
  max-width: 100%;
  width: 100%;
  height: auto;
  border-radius: var(--pro-radius-sm);
  border: var(--pro-border);
}

/* --------------------------------------------------------------------------
   2.4 左侧文档导航
   -------------------------------------------------------------------------- */

.left-doc-sidebar .recent-category-posts .widget-title {
  margin: 0 0 0.5rem;
  padding: 0 var(--pro-panel-pad) 0.625rem;
  border-bottom: var(--pro-border);
}

.left-doc-sidebar .widget {
  padding: 0;
  border: 0;
  box-shadow: none;
  background: transparent;
}

.left-doc-sidebar .recent-category-posts .widget-title {
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

.left-doc-sidebar .recent-category-posts .post-list a {
  padding: 0.5rem 1.25rem 0.5rem 1.1rem;
  border-left: 2px solid transparent;
  font-size: 13.5px;
  line-height: 1.5;
}

.left-doc-sidebar .recent-category-posts .post-list .current-post a {
  border-left-color: var(--color-primary);
  background: rgba(46, 133, 85, 0.08);
  color: var(--color-primary-dark);
  font-weight: var(--font-weight-semibold);
}

.left-doc-sidebar .recent-category-posts .more-category-link a {
  padding-left: 1.1rem;
  font-size: 12.5px;
  letter-spacing: 0.02em;
}

/* ==========================================================================
   3. 文章页：头部、元信息、正文比例
   ========================================================================== */

.single .entry-header {
  margin-bottom: 1.75rem;
  padding-bottom: 1.25rem;
  border-bottom: var(--pro-border);
}

.single .entry-title {
  margin: 0.5rem 0 0.875rem;
  font-size: clamp(25px, 2.6vw, 33px);
  line-height: 1.3;
}

.single .entry-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  font-size: 13px;
  color: var(--color-text-tertiary);
}

.single .entry-meta > span {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

.single .entry-meta > span + span::before {
  content: "";
  width: 1px;
  height: 12px;
  margin-right: 0.5rem;
  background: var(--color-border-medium);
}

/* 「最后更新 / 阅读次数」做成克制的元信息行 */
.last-modified-info {
  margin-top: 0.625rem;
  font-size: 13px;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

/* 正文行宽与首段观感 */
.entry-content > p:first-of-type {
  font-size: 1.0625rem;
  color: var(--color-text-secondary);
}

/* 正文中的图片：细边框，规整 */
.entry-content .wp-block-image img,
.entry-content img.alignnone,
.entry-content img.aligncenter {
  border: var(--pro-border);
}

/* 表格：更接近书面报告 */
.entry-content table {
  border-collapse: collapse;
  width: 100%;
  font-size: 15px;
}

/* ==========================================================================
   4. 归档 / 列表页：从「博客卡片」变成「资源目录」
   ========================================================================== */

.blog .ast-article-post,
.archive .ast-article-post,
.search .ast-article-post {
  padding: 1.25rem;
  margin-bottom: 1.25rem !important;
  background: var(--color-bg-primary);
  border: var(--pro-border);
  border-radius: var(--pro-radius);
  /* Astra 生成的是奶黄色阴影，改为中性冷灰，观感更专业 */
  box-shadow: var(--pro-shadow) !important;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.blog .ast-article-post:hover,
.archive .ast-article-post:hover,
.search .ast-article-post:hover {
  border-color: rgba(46, 133, 85, 0.35);
  box-shadow: var(--pro-shadow-hover) !important;
  transform: translateY(-2px);
}

.ast-article-post .post-thumb img,
.ast-article-post .post-thumb-img-content img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: var(--pro-radius-sm);
  border: var(--pro-border);
}

.ast-article-post .entry-title {
  margin-bottom: 0.5rem;
  font-size: 20px;
  line-height: 1.4;
}

.ast-article-post .entry-meta {
  font-size: 12.5px;
  color: var(--color-text-muted);
}

.ast-article-post .entry-content,
.ast-article-post .ast-excerpt {
  -webkit-line-clamp: 2;
  font-size: 15px;
  line-height: 1.75;
}

/* 「阅读全文」按钮化 */
.ast-article-post .read-more,
.ast-article-post .more-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.75rem;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--color-border-medium);
  border-radius: 999px;
  font-size: 13px;
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: all 0.18s ease;
}

.ast-article-post .read-more:hover,
.ast-article-post .more-link:hover {
  border-color: var(--color-primary);
  background: rgba(46, 133, 85, 0.06);
  color: var(--color-primary-dark);
}

/* 分页：整齐的方块按钮 */
.ast-pagination .nav-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 2rem;
}

.ast-pagination .nav-links .page-numbers {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 0.5rem;
  border: var(--pro-border);
  border-radius: var(--pro-radius-sm) !important;
  background: #ffffff;
  font-size: 14px;
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: all 0.18s ease;
}

/* Astra 默认把页码做成圆形，改为圆角方形以显得规整 */
.ast-pagination .nav-links .page-numbers.current,
.ast-pagination .nav-links .page-numbers:hover {
  border-radius: var(--pro-radius-sm) !important;
}

.ast-pagination .nav-links .page-numbers:hover {
  border-color: var(--color-primary);
  color: var(--color-primary-dark);
}

.ast-pagination .nav-links .page-numbers.current {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: #ffffff;
}

.ast-pagination .nav-links .page-numbers.dots {
  border-color: transparent;
  background: transparent;
}

/* ==========================================================================
   5. 页脚（非首页）：规整的两段式
   ========================================================================== */

.site-footer .site-primary-footer-wrap {
  padding: 3rem 0 2rem;
}

.site-footer .site-below-footer-wrap {
  padding: 1.125rem 0;
  font-size: 13px;
}

/* ==========================================================================
   6. 响应式与移动端
   ========================================================================== */

@media (max-width: 1099px) {
  .left-doc-sidebar .widget,
  #secondary .widget {
    padding: 1rem;
  }

  .site-footer .site-primary-footer-wrap {
    padding: 2.25rem 0 1.5rem;
  }
}

@media (max-width: 767px) {
  .blog .ast-article-post,
  .archive .ast-article-post,
  .search .ast-article-post {
    padding: 1rem;
  }

  .single .entry-header {
    margin-bottom: 1.25rem;
  }

  .ast-pagination .nav-links .page-numbers {
    min-width: 36px;
    height: 36px;
  }
}

/* ==========================================================================
   7. 打印样式：直接打印文档也规整
   ========================================================================== */

@media print {
  .site-header,
  #secondary,
  .left-doc-sidebar,
  .ast-pagination,
  .csrwiki-gate,
  .ast-breadcrumbs-wrapper,
  .ast-mobile-popup,
  #reading-progress {
    display: none !important;
  }

  .ast-container,
  .ast-container:has(.left-doc-sidebar) #primary {
    display: block !important;
    max-width: 100% !important;
    padding: 0 !important;
  }

  body,
  .entry-content,
  .entry-content p {
    color: #000000 !important;
    font-size: 11.5pt;
    line-height: 1.6;
  }

  .entry-content a {
    color: #000000 !important;
    text-decoration: underline;
  }

  .entry-content h2,
  .entry-content h3,
  .entry-content h4,
  .entry-title {
    color: #000000 !important;
    page-break-after: avoid;
  }

  .site-footer {
    display: none !important;
  }
}
