/* 流水行船预习动画 · 专题样式
 * 风格：chengfeng/09「数学可视化」的交互版——深色底、干净几何、大字标注；
 *       只有讲数学所需的对象（岸/水/船），无装饰运动、无音效（设计稿 §四.1）。
 * 作用域：全部规则挂在 #riverLab 下（body[data-module="river"] 仅用于隐藏两个全局浮层）。
 * 触控：所有可点控件 min-height/min-width 44px（RIVER-11）；键盘焦点可见。
 * 划桨与水纹动画只在运动窗内由 .motion/.flow 类驱动（模型直写位置，位移本身不是动画）；
 * 等速抵住时船对岸不动，但桨与水纹照动（RIVER-03「仍在划、仍在流」的证据）。
 */

#riverLab {
  background: #10141f;
  color-scheme: dark;          /* 原生控件也用深色外观，避免 Safari 浅底浅字 */
  color: #eaeff7;
  min-height: 100vh;
  padding: 12px 14px 40px;
  font-family: 'PingFang SC', 'Noto Sans SC', sans-serif;
  box-sizing: border-box;
}

#riverLab .river-wrap { max-width: 860px; margin: 0 auto; width: 100%; }
/* why width:100%：.screen.active 是 flex 且 align-items:center，不钉宽度时 wrap 按内容撑宽，
   整屏在 #riverLab 内部横向滚动（html 无溢出、难发现）——火车专题实测踩过，钉死才受 375 约束。 */

/* ---- 顶栏 ---- */
#riverLab .river-topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
#riverLab .river-title { font-size: 1.25rem; font-weight: 700; flex: 1; min-width: 120px; }
#riverLab .river-home-btn {
  background: transparent; color: #9fb4d8; border: 1px solid #33405c;
  border-radius: 10px; padding: 0 14px; min-height: 44px; font-size: 0.95rem; cursor: pointer;
}

/* ---- 字幕条（状态区：aria-live 播报的文字源；镜/相位切换才换句） ---- */
#riverLab .river-caption {
  min-height: 54px; display: flex; align-items: center; justify-content: center;
  text-align: center; font-size: 1.3rem; font-weight: 700; color: #ffd166;
  background: #151a29; border: 1px solid #2a3450; border-radius: 14px;
  padding: 8px 14px; margin-bottom: 10px; line-height: 1.5;
}

/* ---- 舞台与 SVG 对象 ---- */
#riverLab .river-stage {
  background: #151a29; border: 1px solid #2a3450; border-radius: 14px;
  padding: 8px; margin-bottom: 10px;
}
#riverLab svg { display: block; width: 100%; height: auto; }
#riverLab .river-water-bg { fill: #1b3a5c; fill-opacity: 0.55; }
#riverLab .river-water-trail { fill: #58c4dd; fill-opacity: 0.30; }
#riverLab .river-bank-bg { fill: #141a2a; }
#riverLab .river-bank-line { stroke: #9fb4d8; stroke-width: 2.5; }
#riverLab .river-bank-name { fill: #9fb4d8; font-size: 24px; font-weight: 600; }
#riverLab .river-tick { stroke: #9fb4d8; stroke-width: 2; }
#riverLab .river-tick-num {
  fill: #cfd9ea; font-size: 27px; font-weight: 600; text-anchor: middle;
}
#riverLab .river-start-mark { fill: #ffd166; font-size: 24px; font-weight: 700; text-anchor: middle; }
#riverLab .river-water-dot { fill: #58c4dd; }
#riverLab .river-water-wave { stroke: #58c4dd; stroke-width: 3; fill: none; }
#riverLab .river-water-label { fill: #9fd8ef; font-size: 26px; font-weight: 700; text-anchor: middle; }
#riverLab .river-boat-hull { fill: #ffd166; }
#riverLab .river-boat-mast { stroke: #e8b23f; stroke-width: 3; }
#riverLab .river-boat-sail { fill: #ffedc2; }
#riverLab .river-boat-label { fill: #ffd166; font-size: 25px; font-weight: 700; text-anchor: middle; }
#riverLab .river-paddle { stroke: #ffedc2; stroke-width: 5; stroke-linecap: round;
  transform-box: fill-box; transform-origin: 50% 0%; }
#riverLab .river-wave-flow { stroke: #58c4dd; stroke-width: 2.5; stroke-dasharray: 14 18;
  fill: none; opacity: 0.55; }
/* 划桨往复与水纹右移只在运动窗内（.motion）且播放中（非 .paused）运行；
   水纹还要 w>0（.flow）——水不流时水纹静止，与浮标不漂一致 */
@keyframes riverRow {
  0% { transform: rotate(-16deg); }
  50% { transform: rotate(18deg); }
  100% { transform: rotate(-16deg); }
}
@keyframes riverFlow {
  0% { stroke-dashoffset: 0; }
  100% { stroke-dashoffset: -32; }
}
#riverLab svg.motion .river-paddle { animation: riverRow 0.9s ease-in-out infinite; }
#riverLab svg.motion.flow .river-wave-flow { animation: riverFlow 1.1s linear infinite; }
#riverLab svg.paused .river-paddle,
#riverLab svg.paused .river-wave-flow { animation-play-state: paused; }
#riverLab .river-stop-dot { fill: #ff8f8f; }
#riverLab .river-stop-num { fill: #ff8f8f; font-size: 24px; font-weight: 700; text-anchor: middle; }
#riverLab .river-result-ring {
  fill: none; stroke: #7bd88f; stroke-width: 5; stroke-dasharray: 10 7;
}
/* 条件预告箭头（m08/m10）：水/船两支运动箭头＋数值，动作前画面就能读出条件 */
#riverLab .river-cond-arrow-w { stroke: #58c4dd; stroke-width: 6; }
#riverLab .river-cond-arrow-b { stroke: #ffd166; stroke-width: 6; }
#riverLab .river-cond-head-w { fill: #58c4dd; }
#riverLab .river-cond-head-b { fill: #ffd166; }
#riverLab .river-cond-label-w { fill: #9fd8ef; font-size: 26px; font-weight: 700; text-anchor: middle; }
#riverLab .river-cond-label-b { fill: #ffd166; font-size: 26px; font-weight: 700; text-anchor: middle; }

/* ---- 介绍屏（待开始：首片预备好才开放有声入口） ---- */
#riverLab .river-intro {
  background: #181e2e; border: 1px solid #3a4767; border-radius: 14px;
  padding: 14px 12px; margin-bottom: 10px; text-align: center;
}
#riverLab .river-intro-status { font-size: 1rem; color: #cfd9ea; margin-bottom: 10px; }
#riverLab .river-intro-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
#riverLab .river-start-sound { font-size: 1.15rem; font-weight: 700; padding: 0 22px; }

/* ---- 声音恢复面板（拒播/失败/偏好关闭各有入口；不暗中无声推进） ---- */
#riverLab .river-recovery {
  background: #2a2132; border: 1px solid #6b4f7a; border-radius: 14px;
  padding: 14px 12px; margin-bottom: 10px; text-align: center;
}
#riverLab .river-rec-msg { font-size: 1.1rem; font-weight: 700; color: #ffd166; margin-bottom: 10px; }
#riverLab .river-rec-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

/* ---- 试船面板 ---- */
#riverLab .river-trial {
  background: #181e2e; border: 1px solid #3a4767; border-radius: 14px;
  padding: 12px; margin-bottom: 10px;
}
#riverLab .river-trial-title { font-size: 1.05rem; font-weight: 700; color: #cfd9ea; margin: 6px 2px; }
#riverLab .river-trial-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
#riverLab .river-trial-hint { min-height: 24px; font-size: 0.98rem; color: #ffd166; margin: 4px 2px; }
#riverLab .river-trial-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }

/* ---- 入口按钮、步进提示与底部控制条 ---- */
#riverLab .river-entries { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
#riverLab .river-step-hint { min-height: 22px; font-size: 0.95rem; color: #ffd166; margin: 2px 2px 6px; }
#riverLab .river-controls { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
#riverLab .river-btn {
  min-height: 44px; min-width: 44px; padding: 0 16px; border-radius: 12px;
  border: 1px solid #3a4767; background: #233052; color: #eaeff7;
  font-size: 1rem; font-weight: 600; cursor: pointer;
}
#riverLab .river-btn.primary { background: #58c4dd; color: #0d1420; border-color: #58c4dd; }
#riverLab .river-btn.warm { background: #ffd166; color: #0d1420; border-color: #ffd166; }
#riverLab .river-btn.ghost { background: transparent; color: #9fb4d8; }
#riverLab .river-btn.on { background: #2c3d63; color: #ffd166; border-color: #58c4dd; }
#riverLab .river-btn:disabled { opacity: 0.38; cursor: default; }
/* 键盘焦点可见（RIVER-11）：:focus-visible 只在键盘聚焦时出现，触摸/鼠标点击不出框 */
#riverLab button:focus-visible { outline: 3px solid #58c4dd; outline-offset: 2px; }

/* ---- 家长说明折叠区（含 38 条旁白试听清单） ---- */
#riverLab details.river-parent {
  margin-top: 14px; background: #151a29; border: 1px solid #2a3450; border-radius: 12px; padding: 4px 14px;
}
#riverLab details.river-parent summary {
  min-height: 44px; display: flex; align-items: center; cursor: pointer;
  color: #9fb4d8; font-size: 1rem; font-weight: 600;
}
#riverLab details.river-parent .river-parent-body { font-size: 0.92rem; color: #8b98b5; line-height: 1.8; padding-bottom: 12px; }
#riverLab details.river-parent a { color: #58c4dd; }
#riverLab .river-clip-title { color: #cfd9ea; font-weight: 700; margin: 8px 0 6px; }
#riverLab .river-clip-row {
  display: flex; align-items: center; gap: 10px; padding: 4px 0;
  border-top: 1px solid #232c44;
}
#riverLab .river-clip-play { min-height: 44px; min-width: 44px; padding: 0 12px; flex-shrink: 0; }
#riverLab .river-clip-text { color: #cfd9ea; font-size: 0.92rem; }

/* 只在本专题隐藏两个全局浮层（积分条会盖住深色画布标题，草稿入口悬在控制区）；
   离开后 data-module 变化，两条规则自动失效、其它专题原样恢复。 */
body[data-module="river"] .student-bar { display: none !important; }
body[data-module="river"] #scratchpadBar { display: none !important; }

/* 视觉隐藏的播报区（屏幕阅读器可读，不占画面） */
#riverLab .river-sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* ---- 小手机适配：375 宽 ---- */
@media (max-width: 420px) {
  #riverLab { padding: 10px 8px 32px; }
  #riverLab .river-title { font-size: 1.1rem; }
  #riverLab .river-caption { font-size: 1.15rem; }
  #riverLab .river-btn { padding: 0 12px; }
  /* SVG 标注按「实际渲染字号 × 阅读角色」定（UI 设计系统 Typography）：
     viewBox 900 在 375 手机只显示 ~343px（缩放 ≈0.38）。
     关键数学信息＝船/水/出发与实际落点留痕 → 重要信息档 ≥18px
     （坐标系 48px ×0.379 ≈ 18.2px）；普通岸格刻度与「岸边」标注 → 辅助档 ≥13px
     （36px ×0.379 ≈ 13.6px）。横屏画布不缩小硬塞，字随窄屏媒体查询放大。 */
  #riverLab .river-water-label,
  #riverLab .river-boat-label { font-size: 48px; }
  #riverLab .river-start-mark { font-size: 48px; }
  #riverLab .river-stop-num { font-size: 48px; }
  /* 条件箭头数值同属关键数学信息 → 重要信息档（48px ×0.379 ≈ 18.2px） */
  #riverLab .river-cond-label-w,
  #riverLab .river-cond-label-b { font-size: 48px; }
  #riverLab .river-cond-arrow-w,
  #riverLab .river-cond-arrow-b { stroke-width: 9; }
  #riverLab .river-tick-num,
  #riverLab .river-bank-name { font-size: 36px; }
}

/* ---- 减少动态效果：位移动画本就没有（位置由模型直写），此处压界面过渡与桨/水纹 ---- */
@media (prefers-reduced-motion: reduce) {
  #riverLab * { transition: none !important; animation: none !important; }
}
