/* ============================================================
 * 文章页分享海报样式 —— 仅在文章页（body data-page="article"）生效
 * 包含：右下角悬浮按钮 + 全屏预览遮罩 + 海报展示 + 微信内长按提示
 * ============================================================ */

/* 浮窗按钮：右下角，半径 56px，主色渐变背景 + 阴影 */
.poster-fab {
  position: fixed;
  right: 20px;
  bottom: 90px; /* 预留「回到顶部」按钮的空间 */
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 12px 18px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, #b08d57 0%, #d8c39a 100%);
  color: #fff;
  font: 600 14px/1 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  box-shadow: 0 8px 24px rgba(176, 141, 87, 0.36), 0 2px 4px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease, bottom .25s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.poster-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(176, 141, 87, 0.42);
}
.poster-fab:active {
  transform: translateY(0);
}
.poster-fab svg {
  display: block;
  flex-shrink: 0;
}

/* 当页面滚动时，让按钮稍微靠下，避免遮挡尾部 CTA */
@media (max-width: 700px) {
  .poster-fab {
    right: 14px;
    bottom: 80px;
    padding: 10px 14px;
    font-size: 13px;
  }
}

/* 全屏预览遮罩 */
.poster-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  flex-direction: column;
  animation: poster-fade-in .25s ease;
}
@keyframes poster-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* 海报画布：3:4 竖版（750×1334），按屏幕宽度自适应，最大不超过 420px */
.poster-canvas-wrap {
  position: relative;
  width: min(420px, calc(100vw - 32px));
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.poster-canvas-wrap canvas {
  display: block;
  width: 100%;
  height: auto;
}

/* 海报最终以 <img> 渲染：微信内置浏览器只对 <img> 元素响应长按弹出
   "保存到相册 / 发送给朋友 / 分享到朋友圈"菜单，对 <canvas> 无任何反应。
   user-select: none 防止长按时选中文字；pointer-events 保证触摸穿透； */
.poster-canvas-wrap img.poster-canvas-img {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: default;
  pointer-events: auto;
  -webkit-user-drag: none;
}

/* toDataURL 失败时的兜底容器样式 */
.poster-canvas-wrap--fallback canvas {
  display: block;
  width: 100%;
  height: auto;
}

/* 加载 / 错误态 */
.poster-loading,
.poster-error {
  color: #fff;
  font: 500 16px/1.6 'PingFang SC', 'Microsoft YaHei', sans-serif;
  text-align: center;
  padding: 40px 20px;
}
.poster-loading::before {
  content: '';
  display: block;
  width: 32px;
  height: 32px;
  margin: 0 auto 16px;
  border: 3px solid rgba(255, 255, 255, 0.18);
  border-top-color: #d8c39a;
  border-radius: 50%;
  animation: poster-spin 0.9s linear infinite;
}
@keyframes poster-spin {
  to { transform: rotate(360deg); }
}
.poster-error {
  color: #ffb3b3;
}

/* 关闭按钮：右上角 */
.poster-close {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 1001;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  transition: background .2s ease;
}
.poster-close:hover {
  background: rgba(255, 255, 255, 0.24);
}
.poster-close svg {
  display: block;
}

/* 底部操作区（长按提示 + 备用下载按钮） */
.poster-actions {
  margin-top: 20px;
  color: rgba(255, 255, 255, 0.86);
  font: 400 14px/1.6 'PingFang SC', 'Microsoft YaHei', sans-serif;
  text-align: center;
  max-width: 420px;
}
.poster-actions strong {
  display: block;
  font-size: 15px;
  color: #fff;
  margin-bottom: 4px;
  font-weight: 600;
}
.poster-actions .poster-actions__small {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.62);
}
.poster-actions button.poster-download {
  display: inline-block;
  margin-top: 12px;
  padding: 8px 18px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 999px;
  background: transparent;
  color: #fff;
  font: 500 13px/1 'PingFang SC', 'Microsoft YaHei', sans-serif;
  cursor: pointer;
  transition: background .2s ease, border-color .2s ease;
}
.poster-actions button.poster-download:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.5);
}

/* 微信内置浏览器内的强化提示 */
.poster-overlay.is-wechat .poster-actions {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 14px 18px;
  border-radius: 12px;
}