/* ============================================================
   responsive.css —— 全站自适应补丁（手机 / iPad mini / 小屏）
   由构建脚本统一注入到每个 HTML 的 </head> 之前，最后加载，
   因此在同等优先级下可覆盖各页内联样式。
   ============================================================ */

/* ---------- 基础：页面永不横向溢出 ---------- */
html, body {
  max-width: 100%;
  overflow-x: hidden;
  overflow-x: clip;              /* clip 不会破坏 sticky 定位 */
  -webkit-text-size-adjust: 100%; /* iOS 不自动放大字号 */
}
img, svg, video, iframe, canvas, embed, object {
  max-width: 100%;
  height: auto;
}
table { max-width: 100%; }
pre {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ---------- 平板竖屏及以下（iPad mini 竖屏 768px） ---------- */
@media (max-width: 900px) {
  /* 压住所有写死的固定宽度 / 最小宽度 */
  body * { max-width: 100%; min-width: 0 !important; }

  /* 表格：内容超宽时横向滑动，而不是撑破页面 */
  table {
    display: block;
    width: 100% !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* 固定多栏网格 -> 收拢栏数 */
  .quick { grid-template-columns: repeat(2, 1fr) !important; }
  .grid2 { grid-template-columns: 1fr 1fr !important; }
  .quad  { grid-template-columns: 1fr 1fr !important; }
  .pbars { grid-template-columns: repeat(2, 1fr) !important; }
  .bmc   { grid-template-columns: 1fr 1fr !important; }
  .chain .sup { grid-template-columns: 1fr 1fr !important; }

  /* 侧栏式布局 -> 上下堆叠 */
  .stats { grid-template-columns: 1fr !important; }  /* 240px 1fr */
  .fml   { grid-template-columns: 1fr !important; }  /* 230px 1fr auto */
  .ff    { grid-template-columns: 1fr !important; }  /* 1fr auto 1fr */

  /* 顶部导航：更大的点击区域 */
  .topbar { padding: 8px 12px !important; }
  .topbar a { padding: 8px 13px !important; font-size: 14px !important; }

  /* 首屏标题区收紧 */
  .hero { padding: 44px 18px 24px !important; }
}

/* ---------- 手机（≤640px） ---------- */
@media (max-width: 640px) {
  body { font-size: 15px; line-height: 1.72; }  /* 行距收一点，同屏多看几行 */

  /* 复杂多栏 -> 单栏 */
  .bmc, .chain .sup, .pbars { grid-template-columns: 1fr !important; }
  .quadw { grid-template-columns: 1fr !important; }

  /* 公式 / 代码类长行：横滑查看 */
  .formula, .code, .codeblock {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* 悬浮笔记按钮往里收一点，避免遮挡正文 */
  .nb-topbtn.nb-fab { right: 14px !important; bottom: 70px !important; }
}
