/* ============================================================
   img-viewer.css — 图片查看器（遮罩 / 拖拽 / 缩放）
   由 js/img-viewer.js 驱动，覆盖卡片封面与阅读正文配图
   ============================================================ */

/* 可放大的图片给出放大镜光标提示 */
.card-img img,
.d-card-img img,
.article-body img,
.modal-content img {
  cursor: zoom-in;
}

.img-viewer {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 10, 0.88);
  opacity: 0;
  /* 关闭后必须同时隐藏并脱离鼠标命中：仅 opacity:0 会让透明遮罩继续
     盖住整页，stage 的 cursor:grab 与点击事件全部残留 */
  visibility: hidden;
  pointer-events: none;
  transition: opacity .18s ease, visibility 0s linear .18s;
  overscroll-behavior: contain;
}

.img-viewer.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity .18s ease, visibility 0s;
}

.img-viewer-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: none; /* 交给 pointer 事件处理拖拽/双指缩放 */
  cursor: grab;
}

.img-viewer-stage.dragging { cursor: grabbing; }

.img-viewer-img {
  position: absolute;
  /* 原点固定在视口左上角：JS 的 fit()/zoomAt() 以左上角为原点计算
     translate 完成居中与缩放锚点，此处不能再叠 50% 偏移 */
  left: 0;
  top: 0;
  max-width: none;
  max-height: none;
  user-select: none;
  -webkit-user-drag: none;
  will-change: transform;
  transform-origin: 0 0;
}

/* 工具条 */
.img-viewer-tools {
  position: absolute;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  background: rgba(24, 24, 24, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  backdrop-filter: blur(6px);
  z-index: 2;
}

.img-viewer-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #e8e8e8;
  cursor: pointer;
  transition: background-color .15s;
}

.img-viewer-btn:hover { background: rgba(255, 255, 255, 0.14); }

.img-viewer-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.img-viewer-zoom {
  min-width: 52px;
  text-align: center;
  font-size: 0.78rem;
  color: #cfcfcf;
  font-variant-numeric: tabular-nums;
}

.img-viewer-close {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 2;
  width: 40px;
  height: 40px;
  background: rgba(24, 24, 24, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 50%;
}

.img-viewer-close:hover { background: rgba(60, 60, 60, 0.9); }

/* 打开查看器时锁定底层滚动 */
body.img-viewer-lock { overflow: hidden; }

@media (max-width: 760px) {
  .img-viewer-tools { bottom: 18px; }
  .img-viewer-close { top: 14px; right: 14px; }
}
