/* =========================================================
   全站样式优化层 · optimize.css
   作用：修复错位 / 统一对齐 / 补齐响应式
   加载顺序：必须在 style.css 之后
   说明：只做覆盖与增强，不修改原始样式文件，便于回滚
   ========================================================= */

/* ---------------------------------------------------------
   01. 页面骨架：页脚永远贴底
   问题：内容少的页面（空栏目、404）页脚下方出现大片空白
   --------------------------------------------------------- */
html { min-height: 100%; }
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}
body > main,
body > #main { flex: 1 0 auto; width: 100%; }
body > .footer,
body > footer { flex: 0 0 auto; margin-top: auto; }
/* flex 容器下避免子元素被意外拉伸成散块 */
body > .topbar,
body > .site-header { flex: none; width: 100%; }

/* ---------------------------------------------------------
   02. 头部导航：间距均匀，不再挤成一团
   --------------------------------------------------------- */
.main-nav > ul { gap: 0; }
.main-nav a.nav-link {
  padding-inline: 10px;
  white-space: nowrap;
}
/* 下划线跟随新的内边距，保持与文字等宽 */
.main-nav a.nav-link::after { left: 10px; right: 10px; }
.header__actions { gap: 10px; }
.header__actions .btn,
.header__actions .link-quiet { white-space: nowrap; }

/* 1025–1280：菜单项较多时主动收敛，避免与右侧按钮挤在一起 */
@media (max-width: 1280px) and (min-width: 1025px) {
  .main-nav a.nav-link { font-size: .86rem; padding-inline: 7px; }
  .header__actions { gap: 8px; }
  .header__actions .link-quiet.actions-auth { display: none; }
}

/* ---------------------------------------------------------
   03. 通用：卡片等高 + 底部元素贴底
   适用于插件卡、定价卡、评价卡、案例卡等所有网格
   --------------------------------------------------------- */
.plugin-grid,
.plan-grid,
.quote-grid,
.case-grid,
.feature-grid,
.tpl-grid,
.post-grid { align-items: stretch; }

.plugin-card,
.plan,
.quote,
.feature-card,
.post-card,
.server-card,
.domain-card { height: 100%; }

/* 底部区域统一贴底（卡片高度不一致时也能底边对齐） */
.plugin-card__foot,
.plan .btn,
.quote figcaption,
.server-card__foot,
.domain-card__foot { margin-top: auto; }

/* ---------------------------------------------------------
   04. 插件卡：标签错位的根因修复
   问题：标题区容器没有 flex:1，导致"免费/付费"标签
        紧贴标题或与下方版本信息重叠，且各卡位置不一致
   --------------------------------------------------------- */
.plugin-card__head { align-items: flex-start; }
.plugin-card__head > div { flex: 1 1 auto; min-width: 0; }
.plugin-card__head > .tag {
  flex: none;
  margin-left: auto;
  margin-top: 1px;
  white-space: nowrap;
}
.plugin-card__head h3 { min-width: 0; }
.plugin-card__head h3 a {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------------------------------------------------------
   05. 定价卡：三卡等高、价格与按钮水平对齐
   --------------------------------------------------------- */
.plan { height: 100%; }
.plan__list { flex: 1 1 auto; }
.plan__for { min-height: 3.2em; }
.plan .btn { width: 100%; justify-content: center; }
/* 防止推荐卡出现意外的垂直位移，保证三卡顶边齐平 */
.plan-grid > .plan { margin-top: 0; }
.plan-grid > .plan--featured { transform: none; }
.plan-grid > .plan--featured:hover { transform: translateY(-3px); }

/* ---------------------------------------------------------
   05b. 服务支持区：左右两栏垂直居中，描述与按钮留出呼吸
   --------------------------------------------------------- */
.support { align-items: center; }
.support__copy .btn { margin-top: 22px; }
.support__list li { height: 100%; }

/* ---------------------------------------------------------
   06. 评价卡：正文撑开，作者行贴底对齐
   --------------------------------------------------------- */
.quote blockquote { flex: 1 1 auto; }
.quote figcaption { margin-top: auto; padding-top: 16px; }
.quote__mark { pointer-events: none; }

/* ---------------------------------------------------------
   07. 案例卡：封面统一比例、标题统一两行
   --------------------------------------------------------- */
.case-card { display: flex; flex-direction: column; }
.case-cover { aspect-ratio: 4 / 3; }
.case-card h3 { min-height: 3.1em; }

/* ---------------------------------------------------------
   07b. 域名卡：封面改为图标，标题不再被截断
   --------------------------------------------------------- */
.domain-card__top { align-items: center; }
.domain-card__ico { width: 54px; height: 54px; color: #fff; opacity: .92; }
.domain-card__body { display: flex; flex-direction: column; flex: 1; }
.domain-card__body h3 {
  font-size: 1rem;
  line-height: 1.55;
  min-height: 3.1em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.domain-card__body p {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.domain-card__foot { margin-top: auto; }

/* 服务器卡：品牌行与标题不重复、底部对齐 */
.server-card__brand { letter-spacing: .04em; }
.server-card__body h3 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 3.1em;
}

/* ---------------------------------------------------------
   08. 广告位占位框：隐藏裸露的占位区域
   说明：模板自带"AD 广告位 / 建议尺寸 970×90"占位框，
        未投放时是明显的破洞。此处统一隐藏，
        以后要放广告，删掉本节即可恢复。
   --------------------------------------------------------- */
.ad-band,
.ad-slot,
.cloud-brand-ads { display: none !important; }

/* ---------------------------------------------------------
   09. 英雄区装饰：避免渐变光斑溢出到相邻板块
   --------------------------------------------------------- */
.hero-home,
.hero-home__inner { overflow: visible; }
.hero-home::before,
.hero-home::after { pointer-events: none; }
.hero-home__visual::after { pointer-events: none; }
/* 装饰元素在窄屏下容易压到文字，直接隐藏 */
@media (max-width: 880px) {
  .hero-home::before,
  .hero-home::after,
  .hero-home__visual::after { display: none; }
}

/* ---------------------------------------------------------
   10. 正文排版：表格与长内容不撑破容器
   新增长文含大量表格与命令行，窄屏必须可横向滚动
   --------------------------------------------------------- */
.article-body { overflow-wrap: break-word; word-break: break-word; }
.article-body > h2:first-child,
.article-body > h3:first-child { margin-top: 0; }
.article-body table { max-width: 100%; }
.article-body table th,
.article-body table td { min-width: 80px; }
.article-body img { max-width: 100%; height: auto; }

@media (max-width: 820px) {
  .article-body table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
  .article-body pre { font-size: .78rem; padding: 14px; }
}
@media (max-width: 640px) {
  .article-body { font-size: .92rem; line-height: 1.9; }
  .article-body h2 { font-size: 1.12rem; margin-top: 1.7em; }
  .article-body h3 { font-size: 1rem; }
  .article-body th,
  .article-body td { padding: 9px 12px; font-size: .84rem; }
}

/* ---------------------------------------------------------
   11. 列表页：侧栏顺序与主内容比例
   问题：1024 以下侧栏 order:-1 跑到内容前面，手机上先看到
        "热门文章"，正文被推到下面
   --------------------------------------------------------- */
@media (max-width: 1024px) {
  .detail-aside { order: 0; margin-top: 8px; }
  .detail-layout { gap: 26px; }
}

/* 中等屏幕的列表列数收敛，避免卡片过窄导致文字换行难看 */
@media (max-width: 1180px) {
  .domain-grid { grid-template-columns: repeat(2, 1fr); }
  .server-grid { grid-template-columns: repeat(2, 1fr); }
  .tpl-grid { grid-template-columns: repeat(3, 1fr); }
  .case-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 820px) {
  .case-grid { grid-template-columns: repeat(2, 1fr); }
  .tpl-grid { grid-template-columns: repeat(2, 1fr); }
  .domain-grid,
  .server-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .case-grid { grid-template-columns: 1fr; }
}

/* 520 以下：两列卡片过窄，统一改为单列，避免文字挤压 */
@media (max-width: 520px) {
  .plugin-grid,
  .case-grid,
  .tpl-grid,
  .feature-grid,
  .quote-grid,
  .support__list { grid-template-columns: 1fr; }
  .quote-grid .quote:last-child,
  .plan-grid .plan--featured { grid-column: auto; }
}

/* ---------------------------------------------------------
   12. 板块间距：统一节奏，消除忽大忽小的留白
   --------------------------------------------------------- */
.section > .container > .sec-head:first-child,
.section--soft > .container > .sec-head:first-child { margin-top: 0; }
.sec-head { margin-bottom: clamp(24px, 3vw, 36px); }
.sec-head--split { align-items: flex-end; }
.sec-head--split .sec-head__actions { flex: none; }

/* ---------------------------------------------------------
   13. 侧栏卡片：热门排行与导航列表对齐
   --------------------------------------------------------- */
.side-card + .side-card { margin-top: 0; }
.side-list a,
.hot-rank a { border-radius: var(--r-sm); }
.side-card__more { display: inline-flex; margin-top: 12px; }

/* ---------------------------------------------------------
   14. 分页与工具栏：与内容左对齐
   --------------------------------------------------------- */
.pagination { margin-top: clamp(24px, 3vw, 36px); justify-content: center; }
.list-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* ---------------------------------------------------------
   15. 移动端细节：触控友好、禁止横向溢出
   --------------------------------------------------------- */
@media (max-width: 640px) {
  .container { padding-inline: 16px; }
  .btn--sm { padding: 8px 14px; }
  .page-hero__title { font-size: 1.5rem; }
  .section { padding-block: 40px; }
  .section--tight { padding-block: 30px; }
}
/* 兜底：长单词/长链接不撑破容器（不使用 overflow:hidden，
   以免让 position:sticky 的头部失效） */
.article-body a,
.crumb,
.breadcrumb { overflow-wrap: anywhere; }

/* ---------------------------------------------------------
   16. GEO 栏目文章行：meta 图标与文字同行（svg 全局为 block，
       原样式会让浏览量图标另起一行）
   --------------------------------------------------------- */
.post-row__meta span { display: inline-flex; align-items: center; gap: 4px; line-height: 1.4; }
.post-row__meta span svg { margin-right: 0; flex: none; }
.post-row__meta .cat { display: inline-flex; align-items: center; }

/* GEO 页面方法论锚点滚动时不被固定头部遮挡 */
#geo-method { scroll-margin-top: 88px; }

/* 对比表在窄屏可横向滑动，不撑破容器 */
.compare-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 720px) {
  .compare-table { min-width: 620px; }
  .geo-hero__stats { grid-template-columns: repeat(2, 1fr); }
}

/* ---------------------------------------------------------
   17. GEO 页面移动端收敛：防止 Hero 网格被内容撑宽
   --------------------------------------------------------- */
@media (max-width: 720px) {
  .geo-hero__inner { grid-template-columns: minmax(0, 1fr); gap: 26px; }
  .geo-hero__copy { min-width: 0; max-width: 100%; }
  .geo-hero__visual { min-width: 0; max-width: 100%; }
  .geo-hero__title { font-size: clamp(1.45rem, 7.4vw, 2rem); line-height: 1.32; }
  .geo-hero__desc { font-size: .9rem; line-height: 1.8; }
  .geo-hero__cta { flex-direction: column; align-items: stretch; gap: 10px; }
  .geo-hero__cta .btn { width: 100%; flex: none; }
  .geo-trust { justify-content: center; flex-wrap: wrap; row-gap: 6px; }
  .geo-hero__stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 10px; }
  .ft-chip { font-size: .74rem; padding: 8px 12px; }
  .ft-chip--a { left: 0; top: -12px; }
  .ft-chip--b { right: 0; }
  .ft-chip--c { left: 0; bottom: -10px; }
  .post-row { flex-direction: column; gap: 14px; }
  .post-row__thumb { width: 100%; min-height: 0; aspect-ratio: 16 / 6; }
  .post-row__meta { gap: 6px 12px; }
  .cta-band__btns .btn { width: 100%; }
}
@media (max-width: 720px) {
  html, body { overflow-x: clip; }  /* clip 不创建滚动容器，不影响 sticky 头部 */
}
