/* ==========================================================================
   内容保护 · 样式层
   - 只负责「不能选择 / 不能拖拽 / 打印时隐藏」这类纯样式防护
   - 交互拦截与提示逻辑全部在 assets/js/content-guard.js，两者互相独立
   ========================================================================== */

/* ---------- 1. 全局禁止文本选中 ---------- */
/* 注意：必须保留表单控件的选择能力，否则用户无法正常填写/修改内容 */
html.cg-guard,
html.cg-guard body,
html.cg-guard body * {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  /* iOS Safari 长按弹出系统菜单 */
  -webkit-touch-callout: none;
}

/* 表单控件与可编辑区域：恢复正常的选中 / 输入能力 */
html.cg-guard input,
html.cg-guard textarea,
html.cg-guard select,
html.cg-guard option,
html.cg-guard [contenteditable="true"],
html.cg-guard [contenteditable=""] {
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

/* 可编辑区域内部的子节点也要能选中 */
html.cg-guard input *,
html.cg-guard textarea *,
html.cg-guard [contenteditable="true"] *,
html.cg-guard [contenteditable=""] * {
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
}

/* ---------- 2. 图片 / 画布禁止拖拽与长按保存 ---------- */
html.cg-guard img,
html.cg-guard canvas,
html.cg-guard svg {
  -webkit-user-drag: none;
  -khtml-user-drag: none;
  -moz-user-drag: none;
  -o-user-drag: none;
  user-drag: none;
  pointer-events: auto; /* 保留 hover / click 交互，只禁拖拽 */
}

/* 被拖拽中的图片加一层透明遮罩，避免出现系统拖拽残影 */
html.cg-guard img.cg-dragging {
  opacity: .85;
}

/* ---------- 3. 打印防护 ---------- */
/* 打印时隐藏全部内容，并显示一行版权提示，防止「打印成 PDF」带走内容 */
@media print {
  html.cg-guard,
  html.cg-guard body {
    background: #ffffff !important;
  }

  html.cg-guard body > * {
    display: none !important;
  }

  html.cg-guard body::after {
    content: "© 本站内容受保护 · 禁止打印或另存";
    display: block !important;
    position: fixed;
    inset: 0;
    padding-top: 45vh;
    text-align: center;
    font: 600 16px/1.6 "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
    color: #333333;
    letter-spacing: .05em;
  }
}

/* ---------- 4. 居中提示弹窗 ---------- */
#cg-toast {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 2147483647; /* 层级最高，避免被页面的 9999 之类覆盖 */
  max-width: min(86vw, 420px);
  padding: 16px 26px;
  border-radius: 14px;

  background: rgba(18, 12, 26, .93);
  border: 1px solid rgba(255, 61, 143, .45);
  box-shadow:
    0 18px 50px rgba(0, 0, 0, .55),
    0 0 32px rgba(255, 61, 143, .18);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);

  color: #ffd9e8;
  font: 600 14px/1.55 "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  letter-spacing: .02em;
  text-align: center;
  white-space: normal;
  word-break: break-word;

  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, -50%) scale(.94);
  transition: opacity .25s ease, transform .25s ease, visibility .25s ease;
}

#cg-toast.cg-show {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}

/* 提示左侧的小圆点，纯装饰 */
#cg-toast::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 9px;
  border-radius: 50%;
  background: #ff3d8f;
  box-shadow: 0 0 10px rgba(255, 61, 143, .9);
  vertical-align: middle;
}

/* 尊重系统的「减少动态效果」偏好 */
@media (prefers-reduced-motion: reduce) {
  #cg-toast {
    transition: opacity .12s linear, visibility .12s linear;
  }
}
