/* tb-share — 详情页统一卡片式分享 */

.tb-share {
  --tb-share-accent: #ff5745;
  --tb-share-accent-soft: rgba(255, 87, 69, 0.12);
  --tb-share-ink: #15202b;
  --tb-share-muted: #667085;
  --tb-share-line: rgba(21, 32, 43, 0.08);
  --tb-share-surface: #ffffff;
  --tb-share-surface-2: #f8fafc;
  --tb-share-radius: 20px;
  --tb-share-ease: cubic-bezier(0.22, 0.8, 0.28, 1);
  width: 100%;
}

.nice-dark-mode .tb-share {
  --tb-share-ink: #f2f4f7;
  --tb-share-muted: #a8b0bd;
  --tb-share-line: rgba(255, 255, 255, 0.1);
  --tb-share-surface: #1a2332;
  --tb-share-surface-2: #141c28;
  --tb-share-accent-soft: rgba(255, 87, 69, 0.18);
}

/* 卡片主体 */
.tb-share-card {
  position: relative;
  background: var(--tb-share-surface);
  border-radius: var(--tb-share-radius);
  overflow: hidden;
  box-shadow:
    0 1px 2px rgba(16, 24, 40, 0.05),
    0 12px 32px rgba(16, 24, 40, 0.1);
  border: 1px solid var(--tb-share-line);
}

/* 封面图 */
.tb-share-card-cover {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: linear-gradient(135deg, #e8edf2 0%, #d5dce6 100%);
}

.nice-dark-mode .tb-share-card-cover {
  background: linear-gradient(135deg, #2a3544 0%, #1e2836 100%);
}

.tb-share-card-cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s var(--tb-share-ease);
}

.tb-share-card:hover .tb-share-card-cover img {
  transform: scale(1.04);
}

.tb-share-card-cover-shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.08) 0%, transparent 35%),
    linear-gradient(180deg, transparent 45%, rgba(0, 0, 0, 0.55) 100%);
  pointer-events: none;
}

.tb-share-card-cover-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0.04em;
  color: #fff;
  background: rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

/* 内容区 */
.tb-share-card-body {
  padding: 1.15rem 1.2rem 0.95rem;
}

.tb-share-card-title {
  margin: 0 0 0.5rem;
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: -0.02em;
  color: var(--tb-share-ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tb-share-card-desc {
  margin: 0 0 0.9rem;
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--tb-share-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* 作者 + 二维码 */
.tb-share-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 0.9rem;
  border-radius: 14px;
  background: var(--tb-share-surface-2);
  border: 1px solid var(--tb-share-line);
}

.tb-share-card-author {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  flex: 1;
}

.tb-share-card-avatar {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--tb-share-surface);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  background: #f0f2f5;
}

.tb-share-card-author-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.tb-share-card-author-label {
  font-size: 0.625rem;
  color: var(--tb-share-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.tb-share-card-author-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--tb-share-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tb-share-card-qr {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  min-width: 84px;
  padding: 8px 8px 6px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

.nice-dark-mode .tb-share-card-qr {
  background: #fff;
}

.tb-share-card-qr-img {
  width: 72px;
  height: 72px;
  border-radius: 6px;
  object-fit: contain;
  display: block;
  background: #fff;
}

.tb-share-card-qr-img.is-loading {
  background: linear-gradient(90deg, #f0f2f5 25%, #e4e8ed 50%, #f0f2f5 75%);
  background-size: 200% 100%;
  animation: tb-share-shimmer 1.2s infinite;
}

@keyframes tb-share-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.tb-share-card-qr-hint {
  font-size: 0.625rem;
  font-weight: 600;
  color: #667085;
  letter-spacing: 0.04em;
  line-height: 1.2;
  white-space: nowrap;
}

/* 卡片底部品牌 */
.tb-share-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--tb-share-line);
}

.tb-share-card-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.6875rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--tb-share-accent);
}

.tb-share-card-brand-mark {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: linear-gradient(135deg, #ff5745, #ff8a65);
  color: #fff;
  font-size: 0.5625rem;
  letter-spacing: 0;
}

.tb-share-card-url {
  font-size: 0.6875rem;
  color: var(--tb-share-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 55%;
  text-align: right;
}

/* 主操作：保存 / 分享图片 */
.tb-share-primary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  margin-top: 1rem;
}

.tb-share-primary-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.72rem 0.75rem;
  border-radius: 14px;
  border: 0;
  font-size: 0.8125rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s var(--tb-share-ease), box-shadow 0.2s, opacity 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

.tb-share-primary-btn .iconfont {
  font-size: 1.05rem;
}

.tb-share-primary-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.tb-share-primary-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

.tb-share-save {
  color: #fff;
  background: linear-gradient(135deg, #ff5745 0%, #ff7043 100%);
  box-shadow: 0 6px 16px rgba(255, 87, 69, 0.28);
}

.tb-share-save:hover:not(:disabled) {
  box-shadow: 0 8px 20px rgba(255, 87, 69, 0.35);
}

.tb-share-native {
  color: var(--tb-share-ink);
  background: var(--tb-share-surface-2);
  border: 1px solid var(--tb-share-line);
}

.tb-share-native:hover:not(:disabled) {
  border-color: rgba(255, 87, 69, 0.35);
  color: var(--tb-share-accent);
}

/* 分享操作栏 */
.tb-share-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.45rem;
  margin-top: 0.55rem;
}

.tb-share-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.28rem;
  padding: 0.6rem 0.3rem;
  border: 1px solid var(--tb-share-line);
  border-radius: 12px;
  background: var(--tb-share-surface);
  color: var(--tb-share-ink);
  font-size: 0.6875rem;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s var(--tb-share-ease);
  -webkit-appearance: none;
  appearance: none;
}

.tb-share-action:hover {
  background: var(--tb-share-accent-soft);
  border-color: rgba(255, 87, 69, 0.25);
  color: var(--tb-share-accent);
  transform: translateY(-1px);
}

.tb-share-action .iconfont {
  font-size: 1.2rem;
  line-height: 1;
}

.tb-share-action-weibo:hover { color: #e6162d; border-color: rgba(230, 22, 45, 0.3); background: rgba(230, 22, 45, 0.06); }
.tb-share-action-qq:hover { color: #1ebafc; border-color: rgba(30, 186, 252, 0.3); background: rgba(30, 186, 252, 0.06); }
.tb-share-action-wechat:hover { color: #2ba245; border-color: rgba(43, 162, 69, 0.3); background: rgba(43, 162, 69, 0.06); }

.tb-share-primary-btn.is-busy .iconfont,
.tb-share-action.is-busy .iconfont {
  animation: tb-share-spin 0.8s linear infinite;
}

@keyframes tb-share-spin {
  to { transform: rotate(360deg); }
}

/* 弹窗适配 — 长内容可滚动，避免 MacBook 视口截断 */
.nice-popup-md:has(.tb-share) {
  align-items: flex-start;
  padding: max(0.75rem, env(safe-area-inset-top)) 0 max(0.75rem, env(safe-area-inset-bottom));
  z-index: 10050;
}

.nice-popup-md .nice-popup-content:has(.tb-share) {
  padding: 1rem 1.05rem 1.1rem;
  border-radius: 22px;
  max-height: calc(100vh - 1.5rem - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.nice-popup-md .nice-popup-body:has(.tb-share) {
  max-width: 430px;
  max-height: none;
  margin: 0 auto;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

@media (max-width: 767.98px) {
  .tb-share-card-body {
    padding: 1rem 1rem 0.85rem;
  }

  .tb-share-card-title {
    font-size: 1.05rem;
  }

  .tb-share-card-qr-img {
    width: 64px;
    height: 64px;
  }

  .tb-share-card-qr {
    min-width: 76px;
    padding: 6px;
  }

  .tb-share-primary-btn {
    font-size: 0.75rem;
    padding: 0.65rem 0.5rem;
  }

  .tb-share-actions {
    gap: 0.35rem;
  }

  .tb-share-action {
    padding: 0.5rem 0.2rem;
    font-size: 0.625rem;
  }
}

/* 微信 QR 大图弹窗 */
.tb-share-wechat-popup {
  text-align: center;
}

.tb-share-wechat-popup img {
  width: 200px;
  height: 200px;
  border-radius: 12px;
  background: #fff;
  padding: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.tb-share-wechat-popup .tb-share-wechat-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: var(--tb-share-ink, #15202b);
}

.tb-share-wechat-popup .tb-share-wechat-desc {
  font-size: 0.75rem;
  color: var(--tb-share-muted, #667085);
  margin-bottom: 1rem;
}

/* 导出预览弹窗 */
.tb-share-preview-popup {
  text-align: center;
}

.tb-share-preview-popup img {
  width: 100%;
  max-width: 320px;
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
}

.tb-share-preview-popup .tb-share-preview-hint {
  margin-top: 0.75rem;
  font-size: 0.75rem;
  color: var(--tb-share-muted, #667085);
}
