/* ==========================================================================
   B45 · 手机端「上下固定区 × 内容滑动」解耦层（2026-11-16）
   --------------------------------------------------------------------------
   线上实测（390x844 真 Chrome 触屏）暴露的三处互相干扰：
     1. 60 个元素是 overflow-y:auto 滚动容器，全部 overscroll-behavior:auto、
        touch-action:auto —— 滑到边界会把滚动传给父层/整页（滚动链），
        手指从固定栏起滑也会牵动内容，就是「有时候很相互影响」。
     2. 错题本底栏「一次重做 5 道」原本 append 在 #wbBody 里，19 道错题时
        位于 8104px，要一路滑到底才看得见；惯性回弹还会把点按变成滑动。
     3. body / html 未锁滚动，真机地址栏收起、键盘弹起时 100vh 与 100vh;overflow-y:auto 滚动容器，全部 overscroll-behavior:auto、
        touch-action:auto —— 滑到边界会把滚动传给父层/整页（滚动链），
        手指从固定栏起滑也会牵动内容，就是「有时候很相互影响」。
     2. 错题本底栏「一次重做 5 道」原本 append 在 #wbBody 里，19 道错题时
        位于 8104px，要一路滑到底才看得见；惯性回弹还会把点按变成滑动。
     3. body / html 未锁滚动，真机地址栏收起、键盘弹起时 100vh 与 100dvh
        混用会把整屏连着固定栏一起拉动。

   手法：只做「滚动链隔离 + 固定区不接管手势 + 底栏脱离滚动流」，
   不改任何页面结构、不动 PC（>=900px 完全不生效）、不隐藏任何入口。
   ========================================================================== */

/* --------------------------------------------------------------------------
   B45 附：复习轻提醒 #zrdBar 是「首页级」浮层，z-index 9400 高过二级页
   （openLayer 递增到 9001+），会间歇盖住答题页底部「下一题」按钮 —— 这正是
   「有时候操作互相影响」的一种。它只在 /review/digest 有内容时出现，且
   review_digest.js 每 3s 会把非用户关闭的隐藏态抹掉，所以必须在 CSS 层
   按「二级页打开」这个状态强制收起，关闭二级页后自动恢复。
   -------------------------------------------------------------------------- */
body.zxb-layer-open #zrdBar,
body.zxb-layer-open #zrdPanel { display: none !important; }

/* B96：打开任何二级层（问题反馈/词书/讲解等）时，全局任务完成提示条一律收起。
   它本来是「提醒你回问啾啾看」用的，二级层里它只会压住正文和提交按钮
   （真机截图：问题反馈页提交按钮被「已回答完成」条盖住）。关层后自动恢复。 */
body.zxb-layer-open .zjb-toast,
body.zxb-layer-open #zvpNotify { display: none !important; }

/* ---------- 一、滚动链隔离（手机 + 平板档，含所有二级浮层） ---------- */
@media (max-width: 899px) {

  /* 每个可滚动容器自成一条链：滑到顶/底不再把滚动传给父层或整页。
     刻意不动 touch-action —— 父层写 pan-y 会和内部横向条的 pan-x 求交成
     none，反而把横滑弄坏（这是最典型的「互相影响」）。 */
  .view,
  .layer,
  .scr,
  .pr-body,
  .dsg .scr,
  .layer [style*="overflow-y:auto"],
  .view  [style*="overflow-y:auto"],
  [id$="Body"] {
    overscroll-behavior-y: contain !important;
    overscroll-behavior-x: contain !important;
    -webkit-overflow-scrolling: touch !important;
  }

  /* 固定区不接管滚动手势：在上面滑动不带动内容，轻点照常生效。
     只选纯按钮/标题型区域；聊天输入条含 input，不动它的 touch-action，
     以免把光标拖动和长按选择一起禁掉。 */
  .statusbar,
  .tabbar,
  .home-indicator,
  .layer > .pr-head,
  .layer > .al-wbfoot,
  .zlr-toolbar,
  .qhead,
  .qbar {
    touch-action: none !important;
    overscroll-behavior: contain !important;
    -webkit-user-select: none;
    user-select: none;
  }

  /* 横向胶囊条只吃横向手势，不再和纵向滚动抢 */
  .home-subj,
  .quick,
  [style*="overflow-x:auto"] {
    touch-action: pan-x !important;
    overscroll-behavior-x: contain !important;
  }

  /* 弹层头部吸顶：即使个别层仍是整层滚动，标题栏也不会被滑走 */
  .layer > .pr-head {
    position: sticky !important;
    top: 0 !important;
    z-index: 3;
  }

  /* ---------- 二、错题本底部主按钮：常驻、脱离滚动流 ---------- */
  .layer > .al-wbfoot {
    flex: 0 0 auto !important;
    position: relative !important;
    z-index: 4;
    margin: 0 !important;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px)) !important;
    background: #fff !important;
    border-top: 1px solid #E3F0E9 !important;
    border-radius: 0 !important;
    box-shadow: 0 -6px 18px rgba(15, 60, 40, .07) !important;
    text-align: center;
  }
  .layer > .al-wbfoot .al-wbmain {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    font-size: 14px;
    letter-spacing: .2px;
    -webkit-user-select: none;
    user-select: none;
  }
  /* B46：原来 busy 态用 pointer-events:none，用户点上去连事件都不触发，
     看起来就是「点了完全没反应」。改成保留可点，由 align.js 给明确提示，
     并由超时兜底自动解锁，任何状态下都不静默。 */
  .layer > .al-wbfoot .al-wbmain[data-busy="1"] { opacity: .72; cursor: progress; }
  .layer > .al-wbfoot .al-wbsub { margin-top: 6px; line-height: 1.5; }
  .layer > .pr-body { padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px)) !important; }

  /* 打开二级层时锁住底层首页滚动：scrollTop 会保留，关闭后原位恢复。
     class 由 mobile_scroll.js 同步（含 switchTab 直接摘 .on 的情况）。 */
  body.zxb-layer-open .views .scr {
    overflow-y: hidden !important;
    overscroll-behavior: contain !important;
  }
}

/* ---------- 三、真机档：锁死最外层，杜绝整屏橡皮筋 ----------
   <=430px 由 index.html 铺满，431~599px 由 mobile_edge.css 铺满；
   600~899px 是平板/预览窗口，仍保留原来的居中手机壳与页面滚动，不能锁。 */
@media (max-width: 599px) {
  html, body {
    overscroll-behavior: none !important;
    overflow: hidden !important;
  }
  body {
    height: 100vh !important;
    height:100vh;height:100dvh !important;
    max-height:100vh;max-height:100dvh !important;
    overflow: hidden !important;
  }
  body > .phone {
    height: 100vh !important;
    height:100vh;height:100dvh !important;
    max-height:100vh;max-height:100dvh !important;
  }
  body > .phone > .screen { height: 100% !important; }
}

/* ==========================================================================
   B65 · 章节页（教材单元列表）手机端滑不动（2026-11-18）
   --------------------------------------------------------------------------
   现象：初二下册生物 8 个单元，第 7、8 个在屏幕外，手指怎么拖都不动；
        语文 8 单元、英语 6 单元、道法 8 单元同样中招，凡是「一册单元数 >
        一屏」的册子都会截断，最后一两个单元永远点不到。

   根因：两套互相打架的机制，最后谁都没干活。
     · 旧方案（dsg-design.css / dsg-app.css 的 M03 段）想让整页滚：
         .layer#v-chapter .phone{height:auto;overflow:visible}
         .layer#v-chapter .scr{height:auto;overflow:visible}
       —— 让内容把 .layer（overflow-y:auto）撑高，由 .layer 滚。
     · 新方案（同一文件「layer 内的设计稿骨架」段）把 .phone 钉死：
         .layer > .dsg > .phone{height:100%!important;overflow:hidden!important}
       —— .phone 恒等于视口高且裁剪，.layer 的子节点永远刚好一屏，
          .layer 没有可滚内容，就一动不动。
     · 而 #v-chapter 的 .scr{overflow:visible} 用的是 id 选择器，优先级高于
       .layer > .dsg > .phone > .scr{overflow-y:auto}，于是 .scr 也不滚。
     结果：内容 1215px 塞在 844px 盒子里，被 .phone 剪掉 371px，且没有任何
     一条滚动链 —— 不是「滑不动」，是下面那段根本不存在于可交互区域。

   修法：只改手机档（PC ≥900px 本来就是好的，不动），让 .scr 承担滚动。
   不改结构、不改 DOM、不隐藏单元、不缩字号。
   ========================================================================== */
@media (max-width: 899px) {
  .layer#v-chapter > .dsg > .phone,
  .layer#v-doquiz > .dsg > .phone {
    height: 100% !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }
  .layer#v-chapter > .dsg > .phone > .scr,
  .layer#v-doquiz > .dsg > .phone > .scr {
    height: 100% !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
  }
  /* B-fix 2026-11-22：解答题点「做完了，对照解析」后，"我做对了/我做错了"
     与「下一题」按钮在长答案下方。若 .qbody 被 flex 压缩，按钮落在屏幕外且
     .scr 滚不到，表现为"点不动/卡死"。这里确保 qbody 不压缩、按钮始终随内容
     一起进入滚动区，且解析展开后自动滚到自评按钮。 */
  .layer#v-doquiz .qbody{flex:none!important;min-height:0!important}
  .layer#v-doquiz .opts textarea{max-width:100%}
}

/* ==========================================================================
   B145 · 通用滚动兜底（16:50）
   现象：用一段时间后个别页面滑不动，必须刷新。根因多为「浮层里某个滚动
   容器没做滚动链隔离」或「幽灵 .on 层导致底层 .scr 被永久锁」。
   这里做两件低风险兜底：①任何浮层内 overflow:auto 容器统一 contain，
   手势到边不再外溢/被吞；②iframe 内文档滚动独立成链。
   不改结构、不改 PC（>=900px 不生效）、不隐藏任何入口。
   ========================================================================== */
@media (max-width: 899px) {
  .layer [style*="overflow-y:auto"],
  .layer [style*="overflow-y: auto"],
  .layer .pr-body,
  .layer .scr,
  .layer .lh-scroll,
  .layer .eb-scroll {
    overscroll-behavior-y: contain !important;
    overscroll-behavior-x: contain !important;
    -webkit-overflow-scrolling: touch !important;
  }
  /* 3D 实验 iframe：内部 document 自成滚动链，手势不外溢到宿主浮层 */
  .layer iframe { overscroll-behavior: contain; }
}
