/* ============================================
   cover.css - 封面图系统 + 光点动画 + 三级降级
   LGBTQ+ Weddings & Elopement Planning
   Design: Crystal Yifei Liu
   ============================================ */

/* ---------- 封面容器 ---------- */
.cover-container {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: var(--bg-off);
  isolation: isolate;
}

/* 列表页/聚合页卡片：16:9 */
.cover-16x9 {
  aspect-ratio: 16 / 9;
}

/* 文章详情页横幅：2:3 */
.cover-2x3 {
  aspect-ratio: 2 / 3;
  max-height: 500px;
}

/* ---------- 封面图 SVG 渲染 ---------- */
.cover-container svg {
  width: 100%;
  height: 100%;
  display: block;
}

.cover-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.5s ease;
}

.cover-container:hover img {
  transform: scale(1.02);
}

/* ---------- 产品主体光晕 ---------- */
.cover-product {
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.18));
  transition: filter 0.3s ease;
}

.cover-container:hover .cover-product {
  filter: drop-shadow(0 12px 32px rgba(0, 0, 0, 0.25));
}

/* 光晕增强层（用于需要更强光晕的产品） */
.cover-product-glow {
  filter: drop-shadow(0 0 40px rgba(200, 155, 90, 0.35))
          drop-shadow(0 8px 24px rgba(0, 0, 0, 0.15));
}

/* ---------- 光点闪烁动画（只用 opacity，不造成 CLS） ---------- */
.cover-sparkle {
  animation: sparkle-float 3s ease-in-out infinite;
  opacity: 0.5;
  transform-origin: center;
}

.cover-sparkle:nth-child(2) {
  animation-duration: 2.4s;
  animation-delay: 0.6s;
}

.cover-sparkle:nth-child(3) {
  animation-duration: 3.6s;
  animation-delay: 1.2s;
}

.cover-sparkle:nth-child(4) {
  animation-duration: 2.8s;
  animation-delay: 0.3s;
}

.cover-sparkle:nth-child(5) {
  animation-duration: 3.2s;
  animation-delay: 1.8s;
}

.cover-sparkle:nth-child(6) {
  animation-duration: 2.2s;
  animation-delay: 0.9s;
}

.cover-sparkle:nth-child(7) {
  animation-duration: 3.8s;
  animation-delay: 1.5s;
}

.cover-sparkle:nth-child(8) {
  animation-duration: 2.6s;
  animation-delay: 0.4s;
}

@keyframes sparkle-float {
  0%, 100% {
    opacity: 0.3;
  }
  25% {
    opacity: 0.8;
  }
  50% {
    opacity: 1;
  }
  75% {
    opacity: 0.6;
  }
}

/* 光点大小变化（使用 transform: scale 不影响布局） */
@keyframes sparkle-pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.3);
  }
}

.cover-sparkle-pulse {
  animation: sparkle-float 3s ease-in-out infinite,
             sparkle-pulse 3s ease-in-out infinite;
  opacity: 0.5;
  transform-origin: center;
}

/* ---------- 三级降级：纯色背景 + 标题 ---------- */
.cover-fallback {
  display: none;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--brand-primary-dark), var(--brand-primary));
  color: #fff;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-4);
  position: absolute;
  top: 0;
  left: 0;
  border-radius: var(--radius-md);
  z-index: 2;
}

.cover-fallback.active {
  display: flex;
}

.cover-fallback .fallback-title {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.4;
  max-width: 80%;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* 降级时的装饰元素 */
.cover-fallback::before {
  content: '';
  position: absolute;
  top: -60px;
  right: -60px;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(200, 155, 90, 0.3) 0%, transparent 70%);
  border-radius: 50%;
}

.cover-fallback::after {
  content: '';
  position: absolute;
  bottom: -40px;
  left: -40px;
  width: 150px;
  height: 150px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
  border-radius: 50%;
}

/* ---------- 封面图加载状态 ---------- */
.cover-loading {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-off);
  z-index: 1;
}

.cover-loading.hidden {
  display: none;
}

.cover-loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--brand-primary-light);
  border-top-color: var(--brand-primary);
  border-radius: 50%;
  animation: cover-spin 0.8s linear infinite;
}

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

/* ---------- 移动端适配 ---------- */
@media (max-width: 768px) {
  .cover-2x3 {
    aspect-ratio: 16 / 9;
    max-height: unset;
  }

  .cover-container .cover-sparkle {
    /* 移动端光点动画时长略微加快 */
    animation-duration: 2.5s;
  }

  .cover-container .cover-sparkle:nth-child(2) {
    animation-duration: 2s;
  }

  .cover-container .cover-sparkle:nth-child(3) {
    animation-duration: 3s;
  }

  .cover-container .cover-sparkle:nth-child(4) {
    animation-duration: 2.3s;
  }

  .cover-container .cover-sparkle:nth-child(5) {
    animation-duration: 2.7s;
  }

  .cover-container .cover-sparkle:nth-child(6) {
    animation-duration: 1.9s;
  }

  .cover-container .cover-sparkle:nth-child(7) {
    animation-duration: 3.2s;
  }

  .cover-container .cover-sparkle:nth-child(8) {
    animation-duration: 2.2s;
  }

  .cover-fallback .fallback-title {
    font-size: 1rem;
  }

  .cover-container:hover img {
    transform: none;
  }

  .cover-container:hover .cover-product {
    filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.18));
  }
}

@media (max-width: 480px) {
  .cover-container {
    border-radius: var(--radius-sm);
  }

  .cover-fallback {
    border-radius: var(--radius-sm);
  }

  .cover-fallback .fallback-title {
    font-size: 0.9rem;
    max-width: 90%;
  }
}

/* ---------- 无障碍：减少动态效果 ---------- */
@media (prefers-reduced-motion: reduce) {
  .cover-sparkle,
  .cover-sparkle-pulse {
    animation: none;
    opacity: 0.7;
  }

  .cover-container img,
  .cover-container:hover img {
    transition: none;
    transform: none;
  }

  .cover-loading-spinner {
    animation-duration: 1.6s;
  }
}