/* PosterCard —— 库自身 UI 样式（模板样式在 tpl/<模板名>/index.html 内） */

/* Modal */
.pg-modal-backdrop {
  position: fixed;
  inset: 0;
  box-sizing: border-box;
  padding: 16px;
  background: rgba(18, 21, 24, 0.64);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100001;
}

.pg-modal {
  width: 432px;
  max-width: 100%;
  max-height: calc(100dvh - 32px);
  background: #f8f9fa;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 22px 70px rgba(7, 10, 12, 0.34);
  display: flex;
  flex-direction: column;
}

.pg-modal,
.pg-modal * {
  box-sizing: border-box;
}

.pg-modal:focus {
  outline: none;
}

.pg-modal-header {
  flex: 0 0 52px;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px 0 16px;
  border-bottom: 1px solid #dfe3e6;
  background: #ffffff;
}

.pg-modal-title {
  color: #252a2f;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.3;
}

.pg-modal-body {
  --pg-preview-width: 400px;
  --pg-preview-height: 540px;
  flex: 1 1 auto;
  min-height: 0;
  padding: 16px;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #eceff1;
}

.pg-modal-body > img {
  display: block;
  flex: 0 0 auto;
  width: var(--pg-preview-width);
  max-width: 100%;
  max-height: var(--pg-preview-height);
  height: auto;
  object-fit: contain;
  /* 不强制裁剪，忠实呈现生成的透明圆角边角 */
  /* 用 drop-shadow 而非 box-shadow：box-shadow 只认矩形边界框（方角、偏下），
     而生成的 PNG 常有透明圆角；drop-shadow 会沿图片真实 alpha 形状四周均匀投影 */
  filter: drop-shadow(0 0 20px rgba(30, 36, 40, 0.2));
}

.pg-modal-footer {
  flex: 0 0 64px;
  min-height: 64px;
  padding: 10px 12px 10px 16px;
  border-top: 1px solid #dfe3e6;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.pg-preview-meta {
  min-width: 0;
  overflow: hidden;
  color: #747b82;
  font-size: 12px;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pg-download {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 9px 15px;
  border: 0;
  border-radius: 6px;
  background: #286d8b;
  color: #ffffff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
}

.pg-download:hover {
  background: #215c76;
}

.pg-download:focus-visible,
.pg-close:focus-visible {
  outline: 2px solid #286d8b;
  outline-offset: 2px;
}

.pg-close {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: #4f565c;
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
}

.pg-close:hover {
  background: #eef1f3;
  color: #20252a;
}

@media (max-width: 480px) {
  .pg-modal-backdrop { padding: 8px; }
  .pg-modal { max-height: calc(100dvh - 16px); }
  .pg-modal-header { flex-basis: 48px; min-height: 48px; padding-left: 12px; }
  .pg-modal-body { padding: 10px; }
  .pg-modal-footer { flex-basis: 58px; min-height: 58px; padding: 9px 10px 9px 12px; gap: 10px; }
  .pg-preview-meta { font-size: 11px; }
  .pg-download { min-height: 36px; padding: 8px 12px; }
}

/* 生成用离屏容器（模板根节点挂这里，html2canvas 截图） */
.pg-staging {
  position: fixed;
  top: -10000px;
  left: -10000px;
  opacity: 1;
  pointer-events: none;
  z-index: -1;
}

/* Loading toast */
.pg-toast {
  position: fixed;
  left: 50%;
  top: 20px;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  z-index: 99999;
  display: none;
}

/* Center loading indicator while generating */
.pg-loading-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.22);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
  z-index: 100000;
}

.pg-loading-spinner {
  width: 48px;
  height: 48px;
  box-sizing: border-box;
  border: 4px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: pg-spin 0.9s linear infinite;
  will-change: transform;
  transform: translateZ(0);
  backface-visibility: hidden;
}

.pg-loading-text {
  color: #ffffff;
  font-size: 14px;
  line-height: 1;
}

@keyframes pg-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* 模板根节点基础兜底（模板文件内含完整样式，这里仅做最小保障） */
.pg-root {
  width: 400px;
  box-sizing: border-box;
  background: #fff;
  color: #111;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.pg-root,
.pg-root *,
.pg-root *::before,
.pg-root *::after {
  box-sizing: border-box;
}
