/* ============================================================
   课文原貌灯箱增强 v6（2026-10-15）
   v2：唯美背景 + 底部演示工具条
   v3：墨绿背景 · 拼页窄缝 · 倒V翻页钮 · 绘写工具 · 矮工具条
   v4：transform 缩放平移支持
   v6（本轮）：
   - 绘写层 #ymDraw 改为书页容器内绝对定位（随 transform 缩放平移，
     记号/高亮永远咬住文本；此前是全屏 fixed 层，放大后错位）
   - .lb-row 开启 transform-origin: center center；
   - 中缝阴影改锚在图片自身（inset 渐变用 ::after 覆盖在缝上随内容走，
     以 left:50% 相对行盒 + scale 反向补偿——直接随 row transform 走，
     v4 起 transform 作用于 row 本体，::after 在 row 内部自动跟随，
     修复放大后立体效果与文本错位）
   - 工具条间距收紧（翻页与比例相邻）
   - 拖拽光标强化
   ============================================================ */

/* 大号翻页钮（桌面端保留旧圆钮样式作兼容，v3 起隐藏） */
#yuanmaoLb .lb-nav { display: none; }

/* 关闭钮 */
#yuanmaoLb .lb-close {
  width: 52px;
  height: 52px;
  line-height: 52px;
  font-size: 34px;
  border: 1px solid rgba(255, 255, 255, .16);
  transition: background .2s ease, border-color .2s ease;
}
#yuanmaoLb .lb-close:hover {
  background: rgba(201, 168, 76, .30);
  border-color: rgba(201, 168, 76, .78);
}

/* 背景：墨绿为主 */
#yuanmaoLb {
  background:
    radial-gradient(1200px 480px at 50% -8%, rgba(201, 168, 76, .09), rgba(201, 168, 76, 0) 62%),
    radial-gradient(ellipse at 50% 115%, rgba(76, 110, 92, .42), rgba(0, 0, 0, 0) 55%),
    linear-gradient(165deg, #31453a 0%, #26382e 45%, #1d2e26 100%);
  overflow: hidden;   /* v4: transform 方案不需要滚动条，平移由 translate 承担 */
}

/* 左右页拼接：中缝零间距（教材双拼页紧贴，不要缝） */
#yuanmaoLb .lb-row { gap: 0; }

/* v6: 书页行开 transform；origin 居中，缩放以视口中心为锚 */
#yuanmaoLb .lb-row {
  position: relative;
  transform-origin: center center;
  will-change: transform;
}

/* 中缝立体阴影：锚在 row 内部，随 row 一起 transform —— 放大后不再错位 */
@media (min-width: 769px) {
  #yuanmaoLb .lb-row:has(>img:nth-child(2))::after {
    content: "";
    position: absolute;
    top: 0; bottom: 0;
    left: 50%;
    width: 64px;
    transform: translateX(-50%);
    pointer-events: none;
    z-index: 2;
    background: linear-gradient(90deg,
      rgba(0, 0, 0, 0) 0%,
      rgba(0, 0, 0, .26) 30%,
      rgba(0, 0, 0, .46) 50%,
      rgba(0, 0, 0, .26) 70%,
      rgba(0, 0, 0, 0) 100%);
  }
  #yuanmaoLb { padding: 5vh 24px 1.6vh; }
  #yuanmaoLb .lb-row { align-items: flex-end; }
}

/* 工具条（v3 调矮；v6 收紧间距） */
#ymToolbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: 5.5vh;
  min-height: 46px;
  max-height: 64px;
  z-index: 10002;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(5px, .9vw, 12px);          /* v6: 更紧凑，翻页紧挨比例 */
  padding: 0 clamp(10px, 2vw, 30px);
  background: linear-gradient(180deg, rgba(24, 32, 28, .96), rgba(15, 21, 18, .98));
  border-top: 1px solid rgba(201, 168, 76, .55);
  box-shadow: 0 -8px 30px rgba(0, 0, 0, .5);
  cursor: default;
  user-select: none;
}
#ymToolbar .ym-tb-btn {
  display: inline-flex;
  align-items: center;
  gap: .45em;
  height: 60%;
  padding: 0 .8em;
  border-radius: 10px;
  border: 1px solid rgba(201, 168, 76, .35);
  background: rgba(255, 255, 255, .04);
  color: #e9e2cf;
  font-size: clamp(12px, 1.6vh, 16px);
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: background .18s, border-color .18s, color .18s;
}
#ymToolbar .ym-tb-btn:hover {
  background: rgba(201, 168, 76, .22);
  border-color: rgba(201, 168, 76, .8);
  color: #fff;
}
#ymToolbar .ym-tb-btn.on {
  background: rgba(201, 168, 76, .32);
  border-color: #c9a84c;
  color: #ffe9a8;
}
#ymToolbar .ym-tb-ind {
  color: #cbbf9a;
  font-size: clamp(12px, 1.7vh, 17px);
  min-width: 4.2em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
#ymToolbar .ym-tb-sep {
  width: 1px;
  height: 44%;
  background: rgba(201, 168, 76, .3);
  margin: 0 clamp(2px, .5vw, 8px);
}
@keyframes ymTbFlash {
  0%, 100% { background: rgba(201, 168, 76, .32); }
  50% { background: rgba(220, 60, 50, .65); }
}
#ymToolbar .ym-tb-btn.flash { animation: ymTbFlash 1s infinite; color: #fff; }
#ymToolbar .ym-tb-btn[data-a="prev"],
#ymToolbar .ym-tb-btn[data-a="next"] { font-size: clamp(17px, 2.3vh, 23px); font-weight: 700; }

/* 激光笔（保留兼容） */
#ymLaser {
  display: none;
  position: fixed;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle, #ff6a5e 0%, rgba(255, 60, 50, .85) 35%, rgba(255, 60, 50, 0) 72%);
  box-shadow: 0 0 16px 5px rgba(255, 70, 60, .55);
  pointer-events: none;
  z-index: 10003;
  transform: translate(-50%, -50%);
}
#yuanmaoLb.laser-on { cursor: none; }

/* 四枚倒V/正V翻页钮 */
.ym-fnav {
  position: fixed;
  z-index: 10002;
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #e9e2cf;
  background: rgba(24, 36, 30, .38);
  border: 1px solid rgba(201, 168, 76, .28);
  border-radius: 12px;
  cursor: pointer;
  opacity: .35;
  transition: opacity .45s ease, background .2s ease, border-color .2s ease;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  user-select: none;
}
.ym-fnav svg { width: 20px; height: 20px; }
.ym-fnav:hover { background: rgba(201, 168, 76, .30); border-color: rgba(201, 168, 76, .75); }
.ym-fnav.hot { opacity: 1; }
.ym-fnav.lt  { left: 8px;  top: calc(50% - 48px); }
.ym-fnav.lbd { left: 8px;  top: calc(50% + 2px); }
.ym-fnav.rt  { right: 8px; top: calc(50% - 48px); }
.ym-fnav.rbd { right: 8px; top: calc(50% + 2px); }

/* v6: 绘写层改为书页容器内绝对定位（原为 fixed 全屏层——放大后与文本错位）
   画布尺寸=行盒布局尺寸，随 row 的 transform 一起缩放平移 */
#ymDraw {
  position: absolute;
  left: 0; top: 0;
  width: 100%;
  height: 100%;
  z-index: 3;                      /* 在中缝阴影(2)之上、工具条之下 */
  pointer-events: none;
}
#yuanmaoLb.draw-on #ymDraw { pointer-events: auto; cursor: crosshair; }
#yuanmaoLb.erase-on #ymDraw { cursor: cell; }
#yuanmaoLb .lb-close { z-index: 10002; }

/* 拖拽平移光标 */
#yuanmaoLb.pan-able .lb-row img { cursor: grab; }
#yuanmaoLb.pan-able .lb-row img { -webkit-user-drag: none; user-select: none; }
#yuanmaoLb.panning, #yuanmaoLb.panning .lb-row img { cursor: grabbing; }

@media (max-width: 768px) {
  .ym-fnav { width: 38px; height: 38px; }
  .ym-fnav.lt, .ym-fnav.lbd { left: 6px; }
  .ym-fnav.rt, .ym-fnav.rbd { right: 6px; }
}

/* ============================================================
   v7 增量（2026-10-15 二轮）
   ============================================================ */

/* 顶部导航条（站标 + 标题 + 页码翻页 + 关闭） */
#ymTopbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 46px;
  z-index: 10002;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  background: linear-gradient(90deg, #0a0a1a, #161622);
  color: #d8d0c0;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  cursor: default;
  user-select: none;
}
#ymTopbar .ym-logo {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}
#ymTopbar .ym-logo img {
  height: 28px;
  width: auto;
  display: block;
  opacity: .95;
  transition: .2s;
}
#ymTopbar .ym-logo:hover img { opacity: 1; }
#ymTopbar .ym-logo span {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, .7);
  letter-spacing: .5px;
  white-space: nowrap;
}
#ymTopbar .ym-tb-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 600;
  color: rgba(255, 255, 255, .82);
  letter-spacing: .5px;
}
#ymTopbar .ym-tb-pg {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  color: #cbbf9a;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
#ymTopbar .ym-tb-arrow {
  width: 28px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(201, 168, 76, .35);
  border-radius: 7px;
  background: rgba(255, 255, 255, .04);
  color: #e9e2cf;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background .18s, border-color .18s, color .18s;
}
#ymTopbar .ym-tb-arrow:hover {
  background: rgba(201, 168, 76, .22);
  border-color: rgba(201, 168, 76, .8);
  color: #fff;
}
/* 顶栏关闭钮（取代原右上角浮动圆钮） */
#ymTopbar .ym-tb-close {
  flex: 0 0 auto;
  width: 30px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 4px;
  border: 1px solid rgba(201, 168, 76, .35);
  border-radius: 7px;
  background: rgba(255, 255, 255, .04);
  color: #e9e2cf;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  transition: background .18s, border-color .18s, color .18s;
}
#ymTopbar .ym-tb-close:hover {
  background: rgba(220, 60, 50, .45);
  border-color: rgba(255, 120, 110, .8);
  color: #fff;
}

/* 布局均衡：顶栏 46px 与底栏(min 46px)高度一致；
   100% 时书页再放大：底部定位不动（贴工具条上缘），顶部溢出被顶栏遮盖
   （遮住教材页眉出版字样）。row 绝对定位锁定可视区，img 超高部分向上溢出 */
#yuanmaoLb.has-topbar { padding: 0; }
#yuanmaoLb.has-topbar .lb-row {
  position: absolute;
  top: 46px; bottom: 46px; left: 0; right: 0;
  margin: 0;
  min-height: 0;              /* 覆盖页内 min-height:100%（否则行盒撑破 bottom 约束） */
  align-items: flex-end;
}
#yuanmaoLb.has-topbar .lb-row img {
  max-height: calc(100vh - 46px - 46px + 34px);
  max-width: 49vw;
}

/* 旧右上角浮动关闭钮隐藏（功能已移至顶栏） */
#yuanmaoLb .lb-close { display: none; }

/* 页内「教材原貌」画廊：双拼缩略图零间距（覆盖页内 gap:14px；css 文件后加载，同特异性后者胜） */
.ym-gallery { gap: 0; }
.ym-fig { margin: 0; line-height: 0; }
.ym-fig img { display: block; }

/* 面包屑（logo 后）：人民教育出版社 › 册 › 单元 › 课文名（作者） */
#ymTopbar .ym-crumbs {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: rgba(255, 255, 255, .78);
  letter-spacing: .3px;
}
#ymTopbar .ym-crumbs .ym-sep {
  margin: 0 7px;
  color: rgba(201, 168, 76, .65);
}
/* 右下站名：落在底部工具条上（tabnav 内 tab-brand 同款） */
#ymBrand {
  flex: 0 0 auto;
  margin-left: 10px;
  padding: 0 4px 0 12px;
  border-left: 1px solid rgba(201, 168, 76, .25);
  font: 500 11px "Noto Sans SC", sans-serif;
  color: rgba(184, 144, 47, .5);
  letter-spacing: .5px;
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
}
#ymToolbar .ym-tb-btn .ym-rect-ico {
  width: 1.05em;
  height: 1.05em;
  display: inline-block;
  vertical-align: -0.12em;
}
#yuanmaoLb.draw-on .lb-row img { -webkit-user-drag: none; user-select: none; }
@media (max-width: 768px) {
  #ymTopbar { height: 40px; padding: 0 10px; }
  #ymTopbar .ym-tb-title { font-size: 12.5px; }
  #yuanmaoLb.has-topbar { padding-top: 46px; }
}
