/*
 * Twinkle Trimmings: 定制化产品列表布局 (Layout B)
 *
 * 仅由 [tt_customizer_list] 使用。
 *
 * 结构约定：
 *   .tt-customizer-grid                      网格（1 / 2 / 3 列）
 *     .tt-customizer-card[.has-hover-media]  卡片（上下式）
 *       .tt-card-img                         媒体区（4:3）
 *         button.tt-card-media-toggle        可点击的媒体切换按钮（仅有视频时输出）
 *           img.tt-card-cover                静态封面图
 *           video.tt-card-video              视频层（默认透明，JS 播放后淡入）
 *           span.tt-card-badge               右上角角标
 *       .tt-card-info                        信息区
 *         .tt-card-title > a                 标题（可点击）
 *         .tt-card-desc                      短描述（完整展示，不做行数截断）
 *         a.tt-btn-accent                    按钮（样式在 style.css 里，此处只做布局）
 *
 * 卡片状态类（由 JS 添加，只出现在「有视频」的卡片上）：
 *   .is-loading   视频尚未就绪 → 封面图模糊 + 角标转圈
 *   .is-playing   视频正在播放 → 视频淡入 + 角标变暂停双竖条
 *   两者都不在     → 静态封面图 + 播放三角
 *
 * 列数由内联 CSS 变量 --tt-cols 驱动（简码属性 columns），默认 3 列。
 */

/* ==========================================================================
   1. 网格
   ========================================================================== */
.tt-customizer-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 40px;
}

/* 平板：固定 2 列 */
@media (min-width: 768px) {
  .tt-customizer-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* 桌面：由简码属性 columns 决定，默认 3 列 */
@media (min-width: 1024px) {
  .tt-customizer-grid {
    grid-template-columns: repeat(var(--tt-cols, 3), 1fr);
  }
}

/* ==========================================================================
   2. 卡片外壳（上下式：媒体区在上，信息区在下）
   ========================================================================== */
.tt-customizer-card {
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  padding: 0;
}

/* ==========================================================================
   3. 媒体区（4:3，图片满铺）
   ========================================================================== */
.tt-card-img {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #f5f5f5;
  overflow: hidden;
}

/* 媒体切换按钮：去掉浏览器默认按钮样式，铺满整个媒体区 */
.tt-card-media-toggle {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.tt-card-media-toggle:focus-visible {
  outline: 2px solid var(--tt-accent, #aa440f);
  outline-offset: -2px;
}

/* 静态封面图 */
.tt-card-img img.tt-card-cover,
.tt-card-img .tt-placeholder-img {
  display: block;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
}

.tt-card-img img.tt-card-cover {
  transition:
    filter 0.25s ease,
    transform 0.25s ease;
}

/* 加载态：封面图模糊（轻微放大，避免模糊后边缘露出白边） */
.tt-customizer-card.is-loading .tt-card-img img.tt-card-cover {
  filter: blur(6px);
  transform: scale(1.06);
}

/* 视频层：盖在封面图之上，默认完全透明 */
.tt-card-img video.tt-card-video {
  position: absolute;
  inset: 0;
  display: block;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

/* 只有真正开始播放后才淡入，所以加载过程中看到的一直是封面图 */
.tt-customizer-card.is-playing .tt-card-img video.tt-card-video {
  opacity: 1;
}

/* ==========================================================================
   4. 媒体区右上角角标（播放中切换为暂停图标）
   ========================================================================== */
.tt-card-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  pointer-events: none;
}

/* 默认：三角形播放图标 */
.tt-card-badge::after {
  content: "";
  position: absolute;
  left: 12px;
  top: 9px;
  border-style: solid;
  border-width: 7px 0 7px 11px;
  border-color: transparent transparent transparent #fff;
}

/* 加载中：角标变成转圈（覆盖上面的播放三角） */
.tt-customizer-card.is-loading .tt-card-badge {
  background: rgba(0, 0, 0, 0.45);
}

.tt-customizer-card.is-loading .tt-card-badge::after {
  left: 50%;
  top: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  background: none;
  box-shadow: none;
  animation: tt-card-spin 0.7s linear infinite;
}

@keyframes tt-card-spin {
  to {
    transform: rotate(360deg);
  }
}

/* 播放中：两条竖线（暂停图标） */
.tt-customizer-card.is-playing .tt-card-badge::after {
  left: 11px;
  top: 9px;
  border: none;
  width: 4px;
  height: 14px;
  background: #fff;
  box-shadow: 6px 0 0 #fff;
}

/* ==========================================================================
   5. 信息区
   ========================================================================== */
.tt-card-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px 24px 24px;
}

.tt-customizer-card .tt-card-title {
  font-size: 1.15rem;
  margin: 0 0 10px;
  color: var(--tt-accent);
  line-height: 1.4;
}

/* 标题整块可点击跳转 */
.tt-customizer-card .tt-card-title a {
  color: inherit;
  text-decoration: none;
}

/* 描述：完整展示短描述，不做行数截断 */
.tt-card-desc {
  margin-bottom: 18px;
}

.tt-card-desc p {
  font-size: 0.85rem;
  margin: 0 0 0.6em;
}

.tt-card-desc p:last-child {
  margin-bottom: 0;
}

/* 按钮沉到卡片底部，保证同一行卡片按钮对齐 */
.tt-card-info .tt-btn-accent {
  border-radius: 8px;
  margin-top: auto;
}

/* ==========================================================================
   6. 移动端微调
   ========================================================================== */
@media (max-width: 767px) {
  .tt-customizer-card .tt-card-title {
    font-size: 1rem;
  }
  .tt-customizer-grid {
    gap: 20px;
  }
  .tt-card-info {
    padding: 16px 18px 20px;
  }
  .tt-card-badge {
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
  }
  .tt-card-badge::after {
    left: 10px;
    top: 8px;
    border-width: 6px 0 6px 10px;
  }
  .tt-customizer-card.is-playing .tt-card-badge::after {
    left: 10px;
    top: 8px;
    width: 3px;
    height: 12px;
    box-shadow: 5px 0 0 #fff;
  }
  /* 移动端角标更小，转圈也相应收紧 */
  .tt-customizer-card.is-loading .tt-card-badge::after {
    width: 14px;
    height: 14px;
    margin: -7px 0 0 -7px;
  }
}

/* 偏好减少动效时不要淡入动画 */
@media (prefers-reduced-motion: reduce) {
  .tt-card-img video.tt-card-video {
    transition: none;
  }
}
