/**
 * 正文图片 / 行内 SVG 放大预览（逻辑见 js/imgviewer.js，由 single.php 经 add_minify_css/js 注册）
 * - .ts-zoomable 由 mouseover 委托动态添加（放大镜光标），书籍 AJAX 换章替换正文后依然生效
 * - 弹窗层级 100001：高于结构弹窗（100000）/ 水印（3000）/ 购买弹窗（9999）
 */

/* 正文可预览元素：hover 放大镜光标 */
.ts-zoomable {
  cursor: zoom-in;
}

/* 弹窗骨架 */
.ts-imgviewer {
  position: fixed;
  inset: 0;
  z-index: 100001;
  background: rgba(255, 255, 255, .97); /* 默认白底 */
  opacity: 0;
  transition: opacity .18s ease, background-color .15s ease;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none; /* 手势（拖拽/捏合）交给脚本，阻止浏览器默认滚动与回弹 */
}
.ts-imgviewer.is-open {
  opacity: 1;
}
/* 背景色切换（默认白 ↔ 黑）：按钮在底部工具条「适配窗口」右侧，选择跨图片保持 */
.ts-imgviewer.bg-dark {
  background: rgba(0, 0, 0, .92);
}
.ts-imgviewer[hidden] {
  display: none;
}

/* 图片舞台：缩放直接落在内容宽高上（位图按最终显示尺寸重新光栅化，避免 transform scale 变模糊），
   transform 只承担纯位移（translate 百分比按当前宽高取值，始终居中） */
.ts-iv-holder {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  cursor: grab;
}
.ts-imgviewer.is-dragging .ts-iv-holder {
  cursor: grabbing;
}
.ts-iv-holder img,
.ts-iv-holder svg {
  display: block;
  max-width: none !important;
  pointer-events: none; /* 点击统一落到弹窗根上，由根处理关闭与拖拽 */
  -webkit-user-drag: none;
}

/* 关闭按钮：整个背景（视口）右上角 */
.ts-iv-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 52px;
  height: 52px;
  border: 2px solid #f9f506;
  border-radius: 14px;
  background: #f9f506;
  color: #0f0f0f;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .12s ease, background-color .12s ease, color .12s ease;
}
.ts-iv-close:hover {
  background: #0f0f0f; /* 白底时 hover 反色，黄字在白底上看不清 */
  border-color: #0f0f0f;
  color: #f9f506;
  transform: scale(1.06);
}
.ts-imgviewer.bg-dark .ts-iv-close:hover {
  background: transparent;
  border-color: #f9f506;
  color: #f9f506;
}

/* 底部工具条：缩小 / 百分比 / 放大 / 适配窗口 */
.ts-iv-toolbar {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px;
  background: rgba(15, 15, 15, .85);
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 999px;
}
.ts-iv-toolbar button {
  border: 0;
  background: transparent;
  color: #fff;
  height: 36px;
  min-width: 36px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 15px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.ts-iv-toolbar button:hover {
  background: rgba(255, 255, 255, .16);
  color: #f9f506;
}
.ts-iv-toolbar button:focus-visible {
  outline: 2px solid #f9f506;
  outline-offset: 2px;
}
.ts-iv-pct {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  min-width: 58px;
}
.ts-iv-sep {
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, .25);
  margin: 0 4px;
}

@media (max-width: 640px) {
  .ts-iv-close {
    top: 12px;
    right: 12px;
    width: 44px;
    height: 44px;
  }
  .ts-iv-toolbar {
    bottom: 12px;
  }
  .ts-iv-toolbar button {
    height: 34px;
    padding: 0 8px;
  }
  .ts-iv-pct {
    min-width: 48px;
  }
  .ts-iv-fit-text {
    display: none;
  }
}
