/* ==========================================================================
   文章海报（生成 / 预览 / 下载）
   弹层样式与主题一致；海报卡片本身是离屏渲染的「真尺寸舞台」，
   由 html2canvas 截图成位图后再回到弹层里显示。
   卡片内部一律用绝对定位 + 块级元素，不用 flex / grid：
   克隆渲染时按「无 flex」的路径最稳，出图与预览差异最小。
   ========================================================================== */

/* ---------- 0. 日期字体 ---------- */

/* Rubik（SIL OFL，可免费商用）只用在封面左上角的日期上：
   100px 的日号 + 30px 的「月. 年」。文件是自建的极小子集（4.5KB / 65 字形），
   只含数字、点、空格与十二个月份缩写用到的字母，不含中文，正文标题不受影响。 */
@font-face {
  font-family: 'XPosterDate';
  src: url('fonts/Rubik.woff2') format('woff2');
  font-style: normal;
  font-display: swap;
}

/* ---------- 1. 弹层 ---------- */
.x-poster {
  position: fixed;
  inset: 0;
  z-index: 260;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s var(--x-ease), visibility 0s linear 0.2s;
}
.x-poster.is-open {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.2s var(--x-ease), visibility 0s;
}
.x-poster__mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
}
/* 不再有标题栏：弹层就是「一张海报 + 一排按钮」。
   面板本身透明，海报直接浮在遮罩上，靠圆角与投影成形。 */
.x-poster__panel {
  position: relative;
  width: min(440px, 100%);
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  transform: translateY(14px) scale(0.98);
  transition: transform 0.24s var(--x-ease);
}
.x-poster.is-open .x-poster__panel { transform: none; }

/* 关闭按钮贴在海报右上角外侧，不占版面，也不压住海报内容 */
.x-poster__close {
  position: absolute;
  top: -16px;
  right: -16px;
  z-index: 2;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  font-size: 21px;
  line-height: 1;
  cursor: pointer;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  transition: background var(--x-dur) var(--x-ease);
}
.x-poster__close:hover { background: rgba(255, 255, 255, 0.26); }

.x-poster__body {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 160px;
  overflow: auto;
}
.x-poster__img {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 200px);
  border-radius: 16px;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.55);
}
.x-poster__img[hidden] { display: none; }

/* 生成中的骨架：三条随机宽度的呼吸条，比转圈更接近「正在出图」的感觉 */
.x-poster__loading { text-align: center; padding: 48px 0; }
.x-poster__loading p {
  margin: 14px 0 0;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.66);
}
.x-poster__bars { display: inline-block; }
.x-poster__bars i {
  display: block;
  width: 132px;
  height: 8px;
  margin: 8px auto 0;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.18);
  animation: x-poster-pulse 1.2s var(--x-ease) infinite;
}
.x-poster__bars i:nth-child(2) { width: 96px; animation-delay: 0.15s; }
.x-poster__bars i:nth-child(3) { width: 64px; animation-delay: 0.3s; }
@keyframes x-poster-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* 按钮浮在遮罩上：底层是半透明白，主按钮反白，深色浅色主题都读得清 */
.x-poster__foot {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}
.x-poster__btn {
  flex: 1;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  transition: background var(--x-dur) var(--x-ease);
}
.x-poster__btn:hover { background: rgba(255, 255, 255, 0.22); }
.x-poster__btn--main {
  border-color: #ffffff;
  background: #ffffff;
  color: #16181c;
}
.x-poster__btn--main:hover { background: #ffffff; opacity: 0.9; }
.x-poster__btn[disabled] { opacity: 0.45; cursor: default; }
.x-poster__hint {
  margin: 0;
  padding: 12px 4px 0;
  font-size: 12px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.55);
  text-align: center;
}
.x-poster__hint[hidden] { display: none; }

/* ---------- 2. 离屏舞台 ---------- */
/* 不能给 opacity / visibility 打 0：html2canvas 会把这些一起画进去。
   移出视口即可，元素本身仍是正常渲染的。 */
.x-poster-stage {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 640px;
  pointer-events: none;
}

/* ---------- 3. 海报卡片 ---------- */
/* 版式参考 Jz52_xiazhi 的 bill 组件：白卡 + 满幅封面 + 左上角大日期 +
   黑色标签 + 大字标题 + 底部 logo / 二维码 / 署名。
   卡片内所有文字尺寸都按 640px 宽设计，导出时 scale:2 → 1280px 成图。 */
.x-poster-card {
  position: relative;
  width: 640px;
  background: #ffffff;
  color: #16181c;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", Arial, sans-serif;
  font-synthesis: none;
  text-align: left;
}
.x-poster-card * { box-sizing: border-box; }

/* 封面 */
.x-poster-card__cover {
  position: relative;
  height: 430px;
  overflow: hidden;
  background-color: #1f2430;
  background-position: center center;
  background-size: cover;
  background-repeat: no-repeat;
}
/* 顶部压一层很淡的暗角，保证亮照片上的日期也读得清。
   用 <img> 而不是 CSS 渐变：渐变图由 x-poster.js 现画成 PNG，
   不依赖渲染器对 linear-gradient 的支持，出图更稳。 */
.x-poster-card__scrim {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  width: 100%;
  height: 230px;
}
/* 无封面：深色渐变当主视觉，站点名绝对居中（不要用 display:table，
   那会把日期拆成第二个单元格并排） */
.x-poster-card__cover--empty {
  background-image: linear-gradient(135deg, #1b2431 0%, #2e3c50 52%, #46566e 100%);
}
.x-poster-card__empty {
  position: absolute;
  left: 48px;
  right: 48px;
  top: 0;
  bottom: 0;
  line-height: 430px;
  text-align: center;
  font-size: 40px;
  font-weight: 800;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: rgba(255, 255, 255, 0.94);
}

/* 日期：左边一日用超大号，下面是「月. 年」。
   字体是 Rubik（见文件开头的 @font-face），几何无衬线的骨架比系统字体更硬朗；
   取不到时自动退回 sans-serif，排版不会散。 */
.x-poster-card__date {
  position: absolute;
  left: 40px;
  top: 44px;
  color: #ffffff;
  text-shadow: 0 3px 16px rgba(0, 0, 0, 0.42);
  text-align: center;
  font-family: 'XPosterDate', -apple-system, 'Segoe UI', 'PingFang SC', sans-serif;
}
.x-poster-card__date b {
  display: block;
  /* 100px 对齐参考主题 gbll_docsint 的日号尺寸 */
  font-size: 100px;
  /* 只有 400 一份字体，700 靠浏览器合成（假粗）—— 参考主题 gbll_docsint
     就是这么做的，观感一致。别改成 300 900 的权重范围，那会让浏览器
     认为文件自带 700，反而不合成、字就细了。 */
  font-weight: 700;
  /* 假粗的力度比真 700 差一档，再用描边补半像素；html2canvas 会把它转成
     ctx.strokeText（见其 CanvasRenderer），预览与出图一致 */
  -webkit-text-stroke: 2px currentColor;
  line-height: 0.94;
  letter-spacing: 0;
  /* 不要写 font-variant-numeric：html2canvas 会把它拼进 ctx.font，
     整条 font 被当成非法值丢弃，字号退化到默认的 10px */
}
.x-poster-card__date span {
  display: block;
  margin-top: 14px;
  font-size: 30px;
  /* 参考主题的月份写 500，但字体只有 400 一份，浏览器对 400–500 区间
     不做合成加粗，实际就是 Regular。这里照旧用 400 */
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: 0.05em;
}

/* 正文 */
.x-poster-card__body {
  padding: 36px 48px 0;
}
/* 标签做成黑色小旗：右下一块折角，像贴上去的色块 */
.x-poster-card__tag {
  position: relative;
  display: inline-block;
  padding: 4px 23px 7px;
  background: #14161a;
  color: #ffffff;
  font-size: 21px;
  line-height: 1.5;
  font-weight: 400;
  letter-spacing: 0.04em;
}
.x-poster-card__tag i {
  position: absolute;
  left: 0;
  top: 100%;
  width: 0;
  height: 0;
  border-width: 9px;
  border-style: solid;
  border-color: #14161a transparent transparent #14161a;
}
.x-poster-card__title {
  margin: 30px 0 0;
  font-size: 35px;
  line-height: 1.34;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #16181c;
  word-break: break-word;
}
.x-poster-card__desc {
  margin: 18px 0 0;
  font-size: 24px;
  line-height: 1.6;
  letter-spacing: 0.015em;
  color: #585c5f;
  word-break: break-word;
}

/* 页脚：二维码浮右、logo 与标语占左侧。
   不用绝对定位 —— 一旦绝对，卡片高度就只由左侧文字决定，
   html2canvas 克隆到 iframe 后字体宽度略有差异，底部会被裁掉。 */
.x-poster-card__foot {
  padding: 30px 48px 44px;
}
.x-poster-card__qr {
  float: right;
  width: 132px;
  height: 132px;
  margin-left: 24px;
  background: #ffffff;
}
/* 二维码是脚本生成的 data URL 图（264px 绘制、132px 显示），
   剩下的 canvas 规则是给旧版库兜底的 */
.x-poster-card__qr img {
  display: block !important;
  width: 132px;
  height: 132px;
}
.x-poster-card__qr canvas { display: none !important; }

.x-poster-card__meta {
  min-height: 132px;
  padding-top: 2px;
  margin-right: 156px;
}
.x-poster-card__foot--noqr .x-poster-card__meta {
  margin-right: 0;
  min-height: 0;
}
.x-poster-card__logo {
  display: block;
  max-width: 260px;
  max-height: 52px;
  margin-bottom: 14px;
}
.x-poster-card__site {
  display: block;
  font-size: 32px;
  line-height: 1.3;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #16181c;
  word-break: break-word;
}
.x-poster-card__slogan {
  display: block;
  margin-top: 12px;
  font-size: 20px;
  line-height: 1.55;
  letter-spacing: 0.02em;
  color: #5f6469;
  word-break: break-word;
}

/* 底部署名：保留一小段装饰短线，但不要通栏分割线 */
.x-poster-card__power {
  clear: both;
  margin-top: 30px;
  padding-top: 0;
}
.x-poster-card__power i {
  display: block;
  width: 34px;
  height: 3px;
  background: #16181c;
}
.x-poster-card__power p {
  margin: 15px 0 0;
  font-size: 15px;
  line-height: 1.6;
  letter-spacing: 0.1em;
  color: #b7bdc8;
  word-break: break-word;
}

/* ---------- 4. 操作栏按钮 ---------- */
.x-action--poster { cursor: pointer; }

/* ---------- 5. 窄屏 ---------- */
@media (max-width: 520px) {
  .x-poster { padding: 64px 14px 20px; }
  .x-poster__panel { width: 100%; max-height: calc(100vh - 84px); }
  .x-poster__img { max-height: calc(100vh - 210px); }
  .x-poster__close { top: -46px; right: 0; }
}
