/* ============================================================
   短视频H5视频下载分发系统 - 自定义样式
   Version: V1.2
   ============================================================ */

/* ---------- 全局重置 ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial,
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---------- 9:16 竖屏容器 ---------- */
.app-container {
  /* 手机端全屏；PC 端模拟手机竖屏 */
  width: 100%;
  max-width: 430px;
  min-height: 100vh;
  min-height: 100dvh;
  /* 启用容器查询：内部元素使用 cqw 单位即可随容器宽度自适应
     （PC 端 430px 卡片 / 手机端任意视窗宽度都能精准缩放） */
  container-type: inline-size;
  container-name: app;
}

/* PC 端模拟手机卡片效果 */
@media (min-width: 768px) {
  .app-container {
    border-radius: 24px;
    min-height: auto;
    height: 90vh;
    max-height: 900px;
  }
}

/* ---------- 视频区域：9:16 宽高比 ---------- */
.video-section {
  aspect-ratio: 9 / 16;
  max-height: 75vh;
  max-height: 75dvh;
  overflow: hidden;
}

/* 封面图平滑过渡 */
.cover-img {
  transition: opacity 0.3s ease;
}

/* 播放按钮 */
.play-btn {
  transition: opacity 0.25s ease;
}

/* 视频就绪前隐藏播放按钮的容器 */
.video-section.playing .play-btn {
  opacity: 0;
  pointer-events: none;
}

.video-section.playing .cover-img {
  opacity: 0;
  pointer-events: none;
}

/* ---------- 信息区域 ---------- */
.info-section {
  background: #fff;
  /* 内边距随容器宽度自适应：320px → 12px，430px → 16px */
  padding-left: clamp(12px, 4cqw, 16px);
  padding-right: clamp(12px, 4cqw, 16px);
  padding-top: clamp(12px, 3.5cqw, 16px);
  padding-bottom: clamp(12px, 3.5cqw, 16px);
}

/* 标题：字号 / 行高 / 间距随容器自适应 */
.video-title {
  font-size: clamp(13px, 4cqw, 16px);
  line-height: 1.5;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* 标题区域上方留白自适应 */
.title-area {
  padding-top: clamp(8px, 2.5cqw, 16px);
  margin-bottom: clamp(8px, 2.5cqw, 12px);
}

/* 话题容器间距自适应 - 缩小 */
.topics-area {
  gap: clamp(3px, 1cqw, 6px);
  margin-bottom: clamp(8px, 2.5cqw, 12px);
}

/* 标题自动刷新闪烁效果 */
@keyframes title-flash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.title-refreshing {
  animation: title-flash 0.4s ease-in-out;
}

/* ---------- 话题标签 ---------- */
.topic-tag {
  display: inline-block;
  /* padding 随容器宽度自适应 - 缩小 */
  padding: clamp(2px, 0.6cqw, 3px) clamp(6px, 2cqw, 10px);
  /* 字号自适应：缩小一档 320px → 10px，430px → 12px */
  font-size: clamp(10px, 2.5cqw, 12px);
  line-height: 1.4;
  color: #3b82f6;
  background: #eff6ff;
  border-radius: 9999px;
  white-space: nowrap;
}

/* ---------- 下载按钮 ---------- */
.download-btn {
  /* 字号自适应：320px → 14px，430px → 16px */
  font-size: clamp(14px, 4cqw, 16px);
  /* 上下内边距自适应 */
  padding-top: clamp(10px, 3cqw, 14px);
  padding-bottom: clamp(10px, 3cqw, 14px);
  /* 圆角自适应 */
  border-radius: clamp(10px, 3cqw, 14px);
}

.download-btn:disabled {
  opacity: 0.5;
  pointer-events: none;
  cursor: not-allowed;
}

/* ---------- Loading 骨架屏 ---------- */
.skeleton-video {
  aspect-ratio: 9 / 16;
}

/* 骨架屏内边距与 .info-section 保持一致，避免切换跳动 */
.skeleton-body {
  padding-left: clamp(12px, 4cqw, 16px);
  padding-right: clamp(12px, 4cqw, 16px);
  padding-top: clamp(12px, 3.5cqw, 16px);
  padding-bottom: clamp(12px, 3.5cqw, 16px);
}

.skeleton-line-title {
  height: clamp(16px, 4cqw, 20px);
  width: 85%;
  margin-bottom: clamp(8px, 2.5cqw, 12px);
}

.skeleton-line-short {
  height: clamp(13px, 3cqw, 16px);
  width: 60%;
  margin-bottom: clamp(10px, 3cqw, 16px);
}

.skeleton-tag {
  width: clamp(48px, 14cqw, 60px);
  height: clamp(20px, 5cqw, 24px);
}

.skeleton-line-btn {
  height: clamp(42px, 11cqw, 50px);
  width: 100%;
}

/* 骨架屏渐隐 */
.skeleton.hide {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

/* ---------- 空状态 ---------- */
.empty-state {
  display: flex;
}

.empty-state.show {
  display: flex;
}

/* ---------- Toast ---------- */
.toast.show {
  opacity: 1;
}

/* ---------- 复制标记闪光 ---------- */
.copy-badge.show {
  opacity: 1;
}

/* ---------- 微信 X5 内核兼容 ---------- */
video::-webkit-media-controls {
  display: none !important;
}

/* 防止 iOS 橡皮筋效果导致页面回弹 */
html, body {
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
}

/* iOS 安全区域适配：在自适应 padding 基础上叠加安全区域高度 */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .info-section {
    padding-bottom: calc(clamp(12px, 3.5cqw, 16px) + env(safe-area-inset-bottom));
  }
}

/* ---------- 抖音风格侧边栏（点赞/评论/分享） ---------- */
.action-bar {
  position: absolute;
  right: clamp(8px, 3cqw, 12px);
  bottom: clamp(12px, 4cqw, 20px);
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(12px, 4cqw, 18px);
}

.action-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.action-icon {
  width: clamp(36px, 11cqw, 44px);
  height: clamp(36px, 11cqw, 44px);
  border-radius: 50%;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, background 0.2s ease;
}

.action-item:active .action-icon {
  transform: scale(0.85);
}

.action-icon svg {
  width: clamp(20px, 6cqw, 24px);
  height: clamp(20px, 6cqw, 24px);
  color: #fff;
}

.action-icon.liked svg {
  color: #ff3b5c;
}

.action-icon.liked {
  background: rgba(255,59,92,0.15);
}

.action-count {
  font-size: clamp(10px, 2.5cqw, 12px);
  color: #fff;
  font-weight: 600;
  text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

/* ---------- 分享面板 ---------- */
.share-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: #fff;
  border-radius: clamp(16px, 4cqw, 20px) clamp(16px, 4cqw, 20px) 0 0;
  z-index: 40;
  padding: clamp(16px, 4cqw, 20px);
  padding-bottom: calc(clamp(16px, 4cqw, 20px) + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

.share-panel.show {
  transform: translateY(0);
}

.share-panel-title {
  font-size: clamp(13px, 3.5cqw, 15px);
  color: #999;
  text-align: center;
  margin-bottom: clamp(12px, 3cqw, 16px);
}

.share-grid {
  display: flex;
  justify-content: space-around;
  gap: clamp(8px, 2cqw, 12px);
}

.share-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(6px, 1.5cqw, 8px);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.share-item-icon {
  width: clamp(44px, 12cqw, 52px);
  height: clamp(44px, 12cqw, 52px);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
}

.share-item:active .share-item-icon {
  transform: scale(0.9);
}

.share-item-icon svg {
  width: clamp(22px, 6cqw, 26px);
  height: clamp(22px, 6cqw, 26px);
  color: #fff;
}

.share-item-label {
  font-size: clamp(10px, 2.5cqw, 12px);
  color: #333;
}

.share-cancel {
  margin-top: clamp(12px, 3cqw, 16px);
  width: 100%;
  padding: clamp(10px, 3cqw, 12px) 0;
  text-align: center;
  font-size: clamp(14px, 3.5cqw, 16px);
  color: #666;
  background: #f5f5f5;
  border-radius: clamp(10px, 3cqw, 12px);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.share-panel-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 35;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.share-panel-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

/* ============================================================
   微信引导遮罩（新增）：微信内点击下载 → 引导"在浏览器打开"
   ============================================================ */
.wechat-mask {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.82);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  display: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.wechat-mask.show {
  display: block;
  opacity: 1;
}

/* 右上角三个点箭头 + 文字 */
.wx-mask-arrow {
  position: absolute;
  top: 10px;
  right: 16px;
  top: calc(10px + env(safe-area-inset-top));
  z-index: 201;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  animation: wx-arrow-bounce 1.4s ease-in-out infinite;
  pointer-events: none;
}
@keyframes wx-arrow-bounce {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50%      { transform: translateY(-8px) rotate(4deg); }
}
.wx-mask-arrow svg {
  width: 90px;
  height: 110px;
  filter: drop-shadow(0 4px 10px rgba(34,197,94,0.5));
}
.wx-mask-arrow-label {
  background: #22c55e;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 10px;
  text-align: center;
  line-height: 1.4;
  box-shadow: 0 4px 14px rgba(34,197,94,0.45);
}

/* 引导卡片 */
.wx-mask-card {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.94);
  width: calc(100% - 40px);
  max-width: 380px;
  background: #fff;
  border-radius: 22px;
  padding: 24px 22px 22px;
  box-shadow:
    0 20px 60px rgba(0,0,0,0.5),
    0 0 0 1px rgba(255,255,255,0.06) inset;
  animation: wx-card-in 0.35s cubic-bezier(0.32, 0.72, 0, 1) 0.05s both;
}
@keyframes wx-card-in {
  from { opacity: 0; transform: translate(-50%, calc(-50% + 20px)) scale(0.94); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.wx-mask-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}
.wx-mask-title-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  color: #22c55e;
}
.wx-mask-title > span {
  flex: 1;
  min-width: 0;
  font-size: 17px;
  font-weight: 800;
  color: #111827;
  line-height: 1.4;
}

/* 3步引导 */
.wx-mask-steps {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 16px;
}
.wx-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.wx-step-num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 8px rgba(59,130,246,0.4);
}
.wx-step-text {
  flex: 1;
  min-width: 0;
  padding-top: 4px;
  font-size: 15px;
  line-height: 1.5;
  color: #1f2937;
  font-weight: 600;
}
.wx-step-text b {
  color: #dc2626;
  background: #fef2f2;
  padding: 2px 6px;
  border-radius: 6px;
  font-weight: 800;
  margin: 0 1px;
}

/* 灰色说明条 */
.wx-mask-tip {
  background: #f3f4f6;
  color: #6b7280;
  font-size: 12px;
  line-height: 1.6;
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-weight: 500;
}

/* 关闭按钮 */
.wx-mask-close {
  width: 100%;
  padding: 13px 0;
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: #fff;
  border: none;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 8px 20px rgba(59,130,246,0.4);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.wx-mask-close:active {
  transform: translateY(1px) scale(0.985);
  box-shadow: 0 4px 10px rgba(59,130,246,0.35);
}
.wx-mask-close svg {
  width: 16px;
  height: 16px;
  opacity: 0.9;
}

/* PC 端把遮罩限制在容器内（和 .app-container 一样的范围） */
@media (min-width: 768px) {
  .wechat-mask {
    position: absolute;
    max-width: 430px;
    max-height: 900px;
    height: 90vh;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    border-radius: 24px;
    overflow: hidden;
  }
  .wx-mask-card {
    transform: translate(-50%, -50%) scale(0.94);
  }
  .wx-mask-arrow {
    top: 10px;
    right: 16px;
  }
}
