/* ==========================================================================
   cover.css · 封面图系统（十一层结构 + 光点动画 + 降级）
   topfootballers.com · B01-31/68
   类别：C3 户外/生活
   比例：全站统一 16:9（1200×675 基准）
   颜色：HSL 格式，通过 CSS 变量注入
   ========================================================================== */

/* ==========================================================================
   1. 封面图容器
   ========================================================================== */

.cover {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: hsl(var(--cover-bg-h), var(--cover-bg-s), var(--cover-bg-l));
  isolation: isolate;
}

.cover svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* ==========================================================================
   2. 十一层结构视觉控制
   每一层由 SVG 内部的 g 元素实现，此处通过 CSS 控制透明度和动画
   ========================================================================== */

.cover-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* 第一层：背景色（由容器背景承载） */
.cover-layer-1-background { opacity: 1; }

/* 第二层：纹理层 */
.cover-layer-2-texture { opacity: 0.08; }

/* 第三层：自然 */
.cover-layer-3-nature { opacity: 0.3; }

/* 第四层：树木 */
.cover-layer-4-trees { opacity: 0.4; }

/* 第五层：建筑 */
.cover-layer-5-architecture { opacity: 0.35; }

/* 第六层：光影 */
.cover-layer-6-light { opacity: 0.15; }

/* 第七层：鲜花（30% 概率出现，由 SVG 控制是否输出） */
.cover-layer-7-flowers { opacity: 0.4; }

/* 第八层：流水（20% 概率出现，由 SVG 控制是否输出） */
.cover-layer-8-water { opacity: 0.35; }

/* 第九层：行业元素 */
.cover-layer-9-industry { opacity: 0.45; }

/* 第十层：产品主体 */
.cover-layer-10-subject { opacity: 1; }

/* 第十一层：闪烁光点 */
.cover-layer-11-dots { opacity: 1; }

/* ==========================================================================
   3. 产品主体光晕（第十层增强）
   ========================================================================== */

.cover-subject-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 60%;
  height: 60%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(
    circle,
    hsl(var(--cover-accent-h), var(--cover-accent-s), 70%, 0.35) 0%,
    hsl(var(--cover-accent-h), var(--cover-accent-s), 60%, 0.15) 40%,
    transparent 70%
  );
  pointer-events: none;
  z-index: 1;
  animation: cover-glow-pulse 4s ease-in-out infinite;
}

@keyframes cover-glow-pulse {
  0%, 100% { opacity: 0.8; transform: translate(-50%, -50%) scale(1); }
  50%      { opacity: 1;   transform: translate(-50%, -50%) scale(1.05); }
}

/* ==========================================================================
   4. 闪烁光点（第十一层，CSS 动画）
   每个光点独立闪烁，节奏不同（由内联 --dot-delay 控制）
   只用 opacity 变化
   ========================================================================== */

.cover-light-dot {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: hsl(var(--cover-accent-h), 85%, 75%);
  box-shadow:
    0 0 8px hsl(var(--cover-accent-h), 85%, 65%, 0.8),
    0 0 16px hsl(var(--cover-accent-h), 85%, 60%, 0.5);
  animation: cover-dot-twinkle 3s ease-in-out infinite;
  animation-delay: var(--dot-delay, 0s);
  pointer-events: none;
  z-index: 2;
}

@keyframes cover-dot-twinkle {
  0%, 100% { opacity: 0.3; }
  50%      { opacity: 1; }
}

/* 光点位置（围绕主体分布） */
.cover-light-dot:nth-child(1) { top: 20%; left: 25%; }
.cover-light-dot:nth-child(2) { top: 30%; left: 75%; animation-delay: 0.4s; }
.cover-light-dot:nth-child(3) { top: 65%; left: 18%; animation-delay: 0.9s; }
.cover-light-dot:nth-child(4) { top: 75%; left: 82%; animation-delay: 1.3s; }
.cover-light-dot:nth-child(5) { top: 45%; left: 12%; animation-delay: 0.6s; }
.cover-light-dot:nth-child(6) { top: 55%; left: 88%; animation-delay: 1.7s; }
.cover-light-dot:nth-child(7) { top: 15%; left: 50%; animation-delay: 2.1s; }
.cover-light-dot:nth-child(8) { top: 85%; left: 40%; animation-delay: 1.1s; }

/* ==========================================================================
   5. 封面图标题（降级模式使用）
   ========================================================================== */

.cover-title-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: var(--space-5) var(--space-6);
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.75) 0%,
    rgba(0, 0, 0, 0.4) 60%,
    transparent 100%
  );
  color: white;
  z-index: 3;
}

.cover-title-overlay h2 {
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  color: white;
  margin: 0;
  line-height: var(--leading-snug);
}

@media (max-width: 768px) {
  .cover-title-overlay {
    padding: var(--space-3) var(--space-4);
  }
  .cover-title-overlay h2 {
    font-size: var(--text-base);
  }
}

/* ==========================================================================
   6. 三级降级机制
   第一级：外部图片（img）
   第二级：SVG 封面图
   第三级：纯色背景 + 标题
   ========================================================================== */

/* 降级到纯色背景 + 标题（终极兜底） */
.cover.is-fallback {
  background: linear-gradient(
    135deg,
    hsl(var(--cover-bg-h), var(--cover-bg-s), var(--cover-bg-l)) 0%,
    hsl(var(--cover-bg-h), calc(var(--cover-bg-s) - 10%), calc(var(--cover-bg-l) + 15%)) 100%
  );
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
}

.cover.is-fallback svg,
.cover.is-fallback img {
  display: none;
}

.cover.is-fallback .cover-fallback-title {
  display: block;
  color: white;
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  text-align: center;
  line-height: var(--leading-snug);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  max-width: 80%;
}

.cover-fallback-title { display: none; }

/* 降级到 SVG 时，隐藏外部图片 */
.cover.is-svg-fallback img { display: none; }

/* ==========================================================================
   7. 封面图在列表/卡片中的使用
   ========================================================================== */

.article-card-cover .cover {
  border-radius: var(--radius-md);
}

.featured-cover .cover {
  border-radius: var(--radius-lg);
}

.hero-cover .cover {
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
}

/* ==========================================================================
   8. 移动端优化
   ========================================================================== */

@media (max-width: 768px) {
  /* 移动端光点数量减半（隐藏奇数位） */
  .cover-light-dot:nth-child(odd) {
    display: none;
  }

  /* 移动端光点尺寸增大，闪烁稍微加快 */
  .cover-light-dot {
    width: 5px;
    height: 5px;
    animation-duration: 2.5s;
  }

  /* 移动端封面占满屏宽 */
  .cover {
    border-radius: var(--radius-sm);
  }

  /* 移动端降低光晕强度 */
  .cover-subject-glow {
    width: 70%;
    height: 70%;
  }

  /* 移动端降级标题字号 */
  .cover.is-fallback .cover-fallback-title {
    font-size: var(--text-lg);
  }
}

/* ==========================================================================
   9. 减少动效偏好
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .cover-light-dot,
  .cover-subject-glow {
    animation: none;
  }
  .cover-light-dot {
    opacity: 0.6;
  }
}

/* ==========================================================================
   10. Mood 适配（HSL 变量动态注入，由 publish.php 实现）
   ========================================================================== */

/* 默认是类别基线色（C3 户外/生活 = 森林绿系） */
/* publish.php 会在文章 <style> 中注入：
   --cover-bg-h / --cover-bg-s / --cover-bg-l
   --cover-accent-h / --cover-accent-s / --cover-accent-l
   这些变量直接覆盖 :root 中的默认值 */

/* ==========================================================================
   11. 骨架屏（图片加载前）
   ========================================================================== */

.cover.is-loading {
  background: linear-gradient(
    90deg,
    hsl(var(--cover-bg-h), 10%, 92%) 0%,
    hsl(var(--cover-bg-h), 15%, 96%) 50%,
    hsl(var(--cover-bg-h), 10%, 92%) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

.cover.is-loading > * {
  opacity: 0;
}
