/* ==========================================================================
   Wenxi's Blog - Share Poster Generator (Minimalist Edition)
   Clean, understated, native iOS / Desktop typography
   ========================================================================== */

/* 1. 彻底禁用冗余的大药丸按钮与悬浮按钮 */
#poster-big-btn-wrap,
.poster-big-btn-wrap,
#poster-float-btn,
.poster-float-btn {
  display: none !important;
}

/* 2. 文章底部原生分享栏图标 */
.share-item.poster-btn {
  color: var(--text-p1, #64748b);
  transition: all 0.2s ease;
  cursor: pointer;
}
.share-item.poster-btn:hover {
  color: var(--text, #0f172a) !important;
  transform: translateY(-2px);
}
[data-theme="dark"] .share-item.poster-btn {
  color: var(--text-p2, #94a3b8);
}
[data-theme="dark"] .share-item.poster-btn:hover {
  color: #ffffff !important;
}
.share-item.poster-btn svg {
  width: 20px;
  height: 20px;
  display: block;
}

/* 4. 弹窗遮罩与居中结构（使用 inset:0、100dvh 与 margin:auto 确保各端严格正中） */
.poster-modal-overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s ease, visibility 0.22s;
  overflow: hidden;
}
.poster-modal-overlay.active {
  opacity: 1;
  visibility: visible;
}
.poster-modal-backdrop {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.poster-modal-dialog {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 360px;
  max-height: min(84dvh, 600px);
  margin: auto;
  background: #ffffff;
  color: #0f172a;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 20px 48px -10px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  transform: scale(0.96);
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}
[data-theme="dark"] .poster-modal-dialog {
  background: #181a20;
  color: #f8fafc;
  box-shadow: 0 24px 50px -10px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.poster-modal-overlay.active .poster-modal-dialog {
  transform: scale(1);
}

/* 5. 弹窗顶部栏 (简约单线) */
.poster-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.poster-modal-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  font-weight: 600;
  color: #0f172a;
  letter-spacing: -0.01em;
}
[data-theme="dark"] .poster-modal-title {
  color: #f1f5f9;
}
.poster-modal-title svg {
  color: #64748b;
}
.poster-modal-close {
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
  color: #94a3b8;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 6px;
  transition: all 0.15s;
}
.poster-modal-close:hover {
  background: #f1f5f9;
  color: #0f172a;
}
[data-theme="dark"] .poster-modal-close:hover {
  background: #262a34;
  color: #ffffff;
}

/* 6. 四种风格切换标签 (原生 Segmented Control 质感) */
.poster-tabs {
  display: flex;
  background: #f1f5f9;
  padding: 3px;
  border-radius: 9px;
  margin-bottom: 12px;
  gap: 2px;
}
[data-theme="dark"] .poster-tabs {
  background: #232730;
}
.poster-tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 6px 0;
  font-size: 12px;
  font-weight: 500;
  color: #64748b;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
  white-space: nowrap;
}
[data-theme="dark"] .poster-tab-btn {
  color: #94a3b8;
}
.poster-tab-btn.active {
  background: #ffffff;
  color: #0f172a;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
[data-theme="dark"] .poster-tab-btn.active {
  background: #2f3442;
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* 7. 预览视口与加载器 */
.poster-preview-wrapper {
  position: relative;
  flex: 1;
  min-height: 0;
  max-height: 44dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
  border-radius: 12px;
  padding: 8px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.04);
}
[data-theme="dark"] .poster-preview-wrapper {
  background: #111317;
  border-color: rgba(255, 255, 255, 0.05);
}
.poster-result-img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  display: block;
}
.poster-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: inherit;
  border-radius: inherit;
  z-index: 2;
  transition: opacity 0.2s;
}
.poster-loading.hidden {
  opacity: 0;
  pointer-events: none;
}
.poster-spinner {
  width: 26px;
  height: 26px;
  border: 2px solid rgba(0, 0, 0, 0.1);
  border-top-color: #334155;
  border-radius: 50%;
  animation: posterSpin 0.7s linear infinite;
}
[data-theme="dark"] .poster-spinner {
  border-color: rgba(255, 255, 255, 0.1);
  border-top-color: #f1f5f9;
}
.poster-loading span {
  font-size: 12px;
  color: #64748b;
}
@keyframes posterSpin {
  to { transform: rotate(360deg); }
}

/* 8. 底部提示与操作按钮 (克制高级、无 emoji) */
.poster-actions {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.poster-tip {
  font-size: 11px;
  color: #94a3b8;
  text-align: center;
  line-height: 1.4;
  margin: 0;
  padding: 0;
}
.poster-btns {
  display: flex;
  gap: 8px;
}
.poster-act-btn {
  flex: 1;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.18s ease;
}
.poster-act-btn.primary {
  background: #0f172a;
  color: #ffffff;
}
[data-theme="dark"] .poster-act-btn.primary {
  background: #f8fafc;
  color: #0f172a;
}
.poster-act-btn.primary:hover {
  opacity: 0.9;
}
.poster-act-btn.secondary {
  background: #ffffff;
  color: #475569;
  border-color: #e2e8f0;
}
[data-theme="dark"] .poster-act-btn.secondary {
  background: #232730;
  color: #cbd5e1;
  border-color: rgba(255, 255, 255, 0.08);
}
.poster-act-btn.secondary:hover {
  background: #f8fafc;
}
[data-theme="dark"] .poster-act-btn.secondary:hover {
  background: #2b303c;
}

/* ==========================================================================
   海报离屏渲染容器（4 种模板专属排版）
   ========================================================================== */
#poster-staging {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 375px;
  z-index: -999;
  pointer-events: none;
}

.p-box {
  width: 375px;
  box-sizing: border-box;
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.p-cover {
  width: 100%;
  height: 180px;
  border-radius: 10px;
  object-fit: cover;
  display: block;
}
.p-qr {
  width: 64px;
  height: 64px;
  flex-shrink: 0;
}
.p-qr img, .p-qr canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* --- 模板 1：极简杂志风 (minimal) --- */
.p-minimal {
  background: #FBFBFA;
  color: #1E1E1E;
  font-family: 'Noto Serif SC', Georgia, serif;
}
.p-minimal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #E5E5E3;
  padding-bottom: 12px;
  margin-bottom: 16px;
}
.p-minimal-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.05em;
}
.p-minimal-date {
  font-size: 11px;
  color: #888884;
  font-family: monospace;
}
.p-minimal-tag {
  display: inline-block;
  background: #EEEEEC;
  color: #555552;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 4px;
  margin-right: 6px;
  margin-bottom: 8px;
}
.p-minimal-title {
  font-size: 19px;
  font-weight: 700;
  line-height: 1.35;
  margin: 10px 0;
  color: #111110;
}
.p-minimal-desc {
  font-size: 12px;
  line-height: 1.65;
  color: #5A5A56;
  margin-bottom: 16px;
}
.p-minimal-footer {
  border-top: 1px dashed #D5D5D2;
  padding-top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* --- 模板 2：暗黑极客风 (cyber) --- */
.p-cyber {
  background: #0d1117;
  color: #c9d1d9;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  position: relative;
  overflow: hidden;
}
.p-cyber::before {
  content: "";
  position: absolute;
  top: -80px;
  right: -80px;
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, rgba(4, 243, 255, 0.15) 0%, transparent 70%);
  pointer-events: none;
}
.p-cyber-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #21262d;
  padding-bottom: 12px;
  margin-bottom: 16px;
  font-family: monospace;
  font-size: 11px;
  color: #04f3ff;
}
.p-cyber-cover {
  width: 100%;
  height: 175px;
  border-radius: 10px;
  border: 1px solid rgba(4, 243, 255, 0.3);
  background: #161b22;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}
.p-cyber-tag {
  display: inline-block;
  background: #161b22;
  color: #04f3ff;
  border: 1px solid #30363d;
  font-size: 10px;
  font-family: monospace;
  padding: 2px 7px;
  border-radius: 4px;
  margin-right: 6px;
  margin-bottom: 8px;
}
.p-cyber-title {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.35;
  color: #f0f6fc;
  margin: 8px 0;
}
.p-cyber-desc {
  font-size: 12px;
  line-height: 1.6;
  color: #8b949e;
  margin-bottom: 16px;
}
.p-cyber-footer {
  border-top: 1px solid #21262d;
  padding-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* --- 模板 3：金句摘录风 (quote) --- */
.p-quote {
  background: #F4EFEA;
  color: #2C2724;
  font-family: 'Noto Serif SC', Georgia, serif;
}
.p-quote-header {
  text-align: center;
  margin-bottom: 16px;
  position: relative;
}
.p-quote-header span {
  font-size: 10px;
  letter-spacing: 0.15em;
  color: #8C7A6B;
  text-transform: uppercase;
}
.p-quote-line {
  width: 32px;
  height: 2px;
  background: #8C7A6B;
  margin: 4px auto 0;
}
.p-quote-body {
  border-left: 3px solid #8C7A6B;
  padding-left: 14px;
  margin: 16px 0 20px;
  position: relative;
}
.p-quote-mark {
  font-size: 38px;
  color: rgba(140, 122, 107, 0.3);
  position: absolute;
  top: -18px;
  left: 6px;
  line-height: 1;
}
.p-quote-highlight {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.6;
  color: #24201E;
}
.p-quote-author {
  font-size: 11px;
  color: #7A6C60;
  margin-top: 8px;
  display: block;
}
.p-quote-card {
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid #E3D9CE;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 16px;
}
.p-quote-card-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 4px;
  color: #24201E;
}
.p-quote-card-desc {
  font-size: 11px;
  color: #6E6258;
  line-height: 1.5;
}
.p-quote-footer {
  border-top: 1px solid #D9CFC4;
  padding-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* --- 模板 4：现代社交卡片风 (modern) --- */
.p-modern {
  background: #FFFFFF;
  color: #0F172A;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.p-modern-bar {
  height: 4px;
  border-radius: 2px;
  background: #0f172a;
  margin-bottom: 16px;
}
.p-modern-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.p-modern-brand-name {
  font-size: 13px;
  font-weight: 700;
  color: #0F172A;
}
.p-modern-badge {
  font-size: 10px;
  font-weight: 600;
  background: #f1f5f9;
  color: #475569;
  padding: 3px 8px;
  border-radius: 6px;
}
.p-modern-title {
  font-size: 17px;
  font-weight: 800;
  line-height: 1.35;
  color: #0F172A;
  margin: 10px 0 8px;
}
.p-modern-desc {
  font-size: 12px;
  line-height: 1.6;
  color: #64748B;
  margin-bottom: 16px;
}
.p-modern-footer-box {
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* 双轨暗色模式保底 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .poster-modal-dialog {
    background: #181a20;
    color: #f8fafc;
    box-shadow: 0 24px 50px -10px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.08);
  }
  :root:not([data-theme="light"]) .poster-modal-title {
    color: #f1f5f9;
  }
  :root:not([data-theme="light"]) .poster-tabs {
    background: #232730;
  }
  :root:not([data-theme="light"]) .poster-tab-btn {
    color: #94a3b8;
  }
  :root:not([data-theme="light"]) .poster-tab-btn.active {
    background: #2f3442;
    color: #ffffff;
  }
  :root:not([data-theme="light"]) .poster-preview-wrapper {
    background: #121418;
  }
}
