/* 模板展示区排版修复 —— 2026-10-09
 * 目标：取消横向滑动，改为自适应多列 + 上下滚动；一屏看到多个模板；手机兼容。
 * 实现说明：线上 main-*.css 由入口 JS 运行时注入，顺序晚于本文件，
 *          故所有覆盖选择器统一加 body 前缀抬高优先级（0,1,1 > 0,1,0）。
 */

/* ---- 滚动容器：纵向滚动，固定高度上限，不把下方「开始生成」顶走 ---- */
body .showcase-scroll-wrapper {
  overflow-x: hidden;
  overflow-y: auto;
  max-height: 560px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding: 4px 6px 8px 4px;
}

body .showcase-scroll-wrapper::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

body .showcase-scroll-wrapper::-webkit-scrollbar-track {
  background: #f5f5f5;
  border-radius: 4px;
}

body .showcase-scroll-wrapper::-webkit-scrollbar-thumb {
  background: #d9d9d9;
  border-radius: 4px;
}

body .showcase-scroll-wrapper::-webkit-scrollbar-thumb:hover {
  background: #bfbfbf;
}

/* ---- 自适应多列：按卡片最小宽度自动决定列数 ---- */
body .showcase-card-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
  padding: 0;
  align-content: start;
}

body .showcase-card {
  display: flex;
  flex-direction: column;
  width: auto;
  flex: 0 1 auto;
  min-width: 0;
}

/* ---- 文案：两行换行展示，不再单行截断 ---- */
body .showcase-card-info {
  padding: 10px 12px 12px;
  flex: 1 1 auto;
  min-width: 0;
}

body .showcase-card-name {
  line-height: 1.4;
  white-space: normal;
  text-overflow: clip;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

body .showcase-card-desc {
  line-height: 1.5;
  margin-top: 4px;
  white-space: normal;
  text-overflow: clip;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

body .showcase-empty {
  grid-column: 1 / -1;
}

/* ---- 平板 ---- */
@media (max-width: 1200px) and (min-width: 769px) {
  body .showcase-card-row {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}

/* ---- 手机：两列 + 上下滚动（原来是 flex 横滑 + 卡片定宽 280px，一屏只看到一个）---- */
@media (max-width: 768px) {
  body .showcase-scroll-wrapper {
    overflow-x: hidden;
    overflow-y: auto;
    max-height: 62vh;
    padding: 2px 4px 6px 2px;
  }

  body .showcase-card-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(144px, 1fr));
    gap: 10px;
    padding: 0;
  }

  body .showcase-card {
    width: auto;
    flex: 0 1 auto;
    min-width: 0;
  }

  body .showcase-card:hover {
    transform: none;
  }

  /* 触屏没有 hover：整块蒙层改成右下角常驻小播放角标，
     保留「查看完整示例」入口又不挡住预览画面 */
  body .showcase-card-overlay {
    top: auto;
    left: auto;
    right: 6px;
    bottom: 6px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    opacity: 1;
    justify-content: center;
    align-items: center;
    padding-bottom: 0;
    gap: 0;
  }

  body .showcase-play-icon {
    font-size: 17px;
  }

  body .showcase-card-overlay span {
    display: none;
  }

  body .showcase-card-info {
    padding: 8px 9px 10px;
  }

  body .showcase-card-name {
    font-size: 12px;
  }

  body .showcase-card-desc {
    font-size: 10px;
  }

  body .showcase-card-check {
    width: 20px;
    height: 20px;
    font-size: 11px;
    top: 6px;
    right: 6px;
  }
}

/* ---- 超窄屏兜底：避免两列挤到不可读 ---- */
@media (max-width: 330px) {
  body .showcase-card-row {
    grid-template-columns: 1fr;
  }
}

/* ---- 深色主题滚动条 ---- */
[data-theme='dark'] .showcase-scroll-wrapper::-webkit-scrollbar-track {
  background: #262626;
}

[data-theme='dark'] .showcase-scroll-wrapper::-webkit-scrollbar-thumb {
  background: #434343;
}
