/* ==========================================================================
   home.css —— 首页（选择模板）
   移动端数值逐条对照原实现计算样式；类名与原型保持一致（tag-4-item / tag_icon /
   tag_name / tag2-selected / item / item-zhutu / btnWrap / goods-name / btn-create）
   768px 以上为可用性适配
   ========================================================================== */

/* ---------- 页头：渐变背景 + 搜索 + 一级分类 ---------- */
.page-top {
  background: linear-gradient(180deg, var(--c-header-1), var(--c-header-2));
}

.search-bar { padding: 20px 10px 10px; }

.search {
  height: 37px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 15px;
  color: #666;
  margin-bottom: 10px;
  background-color: #fff;
}

.search .input-box { flex: 1; height: 100%; margin-left: 8px; }

.search .input_txt {
  height: 100%;
  width: 100%;
  outline: none;
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
}

.search input::placeholder { color: gray; font-weight: normal; }

.search_img { height: 22px; width: 22px; margin-left: 8px; }

/* 原实现 .search-btn 的 background 简写最终落到 #66f（覆盖了前面的橙色渐变） */
.search-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 31px;
  width: 66px;
  margin-left: 15px;
  margin-right: 3px;
  border-radius: 16px;
  background: var(--c-accent);
  box-shadow: var(--shadow-btn);
  cursor: pointer;
  user-select: none;
}

.search-btn:active { opacity: .85; }
.search-btn-text { color: #fff; font-size: 14px; }

/* ---------- 一级分类（图标横排，可横向滚动） ---------- */
#tag-list {
  padding: 0 6px;
  display: flex;
  align-items: center;
  text-align: center;
  overflow-x: auto;
  white-space: nowrap;
  --local-width: 21%;
  --local-margin: calc(8% / 4);
}

.tag-4-item {
  width: var(--local-width);
  height: var(--local-width);
  margin-right: var(--local-margin);
  flex: 0 0 auto;
  text-align: center;
  border-radius: var(--radius-tag);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  user-select: none;
  cursor: pointer;
}

.tag_icon {
  width: 60%;
  height: 60%;
  line-height: 60%;
  margin: 0 auto;
  display: grid;
  justify-items: center;
  align-items: center;
  border-radius: 8px;
  overflow: hidden;
}

.tag_icon img { width: 100%; height: 100%; object-fit: contain; }

.tag_name {
  height: 24px;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: scale(.9);
}

.tag-4-item.tag-selected {
  background: linear-gradient(180deg, #fff6c6, #fff);
  box-shadow: var(--shadow-tag);
}

/* ---------- 二级分类（胶囊） ---------- */
.page-content {
  padding-left: 5px;
  padding-right: 8px;
  background: #fff;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
}

#tag2-list {
  padding: 15px 0 5px;
  line-height: 24px;
  overflow-x: auto;
  white-space: nowrap;
}

#tag2-list a {
  display: inline-block;
  margin-right: 2px;
  margin-bottom: 8px;
  padding: 0 10px;
  background-color: var(--c-pill-bg);
  color: var(--c-text-sub);
  font-size: 12px;
  border-radius: 4px;
  cursor: pointer;
  transform: scale(.9);
  user-select: none;
  text-decoration: none;
}

#tag2-list a.tag2-selected { background-color: var(--c-accent); color: #fff; }

/* ---------- 主区域 ---------- */
.main-region { display: block; }

.cate-sidebar { display: none; }

#tpl-list {
  padding-bottom: 10px;
  overflow: hidden;
  background: #fff;
  min-height: 70vh;
}

/* 瀑布流：按「较短列优先」投放，这里保留同一算法，列数随断点变化 */
.wf { display: flex; align-items: flex-start; }

.wf-col { overflow: hidden; flex: 0 0 auto; }

.item {
  background-color: #fff;
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  cursor: pointer;
}

.item .element {
  padding: 0;
  break-inside: avoid;
  position: relative;
}

.item-thumb-wrap { position: relative; }

.item-zhutu {
  width: 100%;
  display: block;
  object-fit: contain;
  background: #f2f2f2;
}

.item-zhutu.is-loaded { background: transparent; }

/* 播放角标按 media_type 命名（原实现 item-icon-{img|video|download}），img 类型隐藏 */
.item-icon-img { display: none; }

.item-tips {
  position: absolute;
  color: #fff;
  bottom: 6px;
  right: 5px;
  height: 22px;
  line-height: 20px;
  display: inline-block;
  border-radius: 6px;
  padding: 0 4px;
  background: rgba(0, 0, 0, .4);
  border: 1px solid hsla(0, 0%, 100%, .16);
  font-size: 12px;
}

.item-tips:empty { padding: 0; border: none; }

.item .btnWrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 44px;
  overflow: hidden;
}

.item .goods-name {
  flex: 1;
  min-width: 0;
  padding: 6px 5px;
  background-color: #fff;
  font-size: 12px;
  color: #000;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.item .btn-create {
  flex: 0 0 auto;
  color: #fff;
  padding: 3px 3px 5px 5px;
  background-color: var(--c-accent);
  border-top-left-radius: 5px;
  border-bottom-left-radius: 5px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

/* ---------- 搜索结果条 ---------- */
.search-banner {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 10px 8px 0;
  padding: 8px 12px;
  background: #fff7e6;
  border: 1px solid #ffe0a8;
  border-radius: 8px;
  font-size: 12px;
  color: #8a5a00;
}

.search-banner.is-on { display: flex; }
.search-banner button {
  border: 0;
  background: transparent;
  color: var(--c-accent);
  font-size: 12px;
  cursor: pointer;
}

/* ---------- 空状态 ---------- */
.empty {
  min-height: 40vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--c-text-gray);
  font-size: 13px;
}

.empty .big { font-size: 15px; color: #666; }

/* ==========================================================================
   移动端：严格对齐数值（< 768px）
   ========================================================================== */
@media (max-width: 767px) {
  .wf-col { width: 50%; }
  .wf-col:nth-child(odd) .wf-item { margin-left: 3.3vw; }
  .wf-col:nth-child(even) .wf-item { margin-left: 1.6vw; }
  .wf-item { width: 45vw; margin-bottom: 3vw; }
}

/* ==========================================================================
   平板：3 列（768px - 1279px）
   ========================================================================== */
@media (min-width: 768px) and (max-width: 1279px) {
  .wf { padding: 12px 12px 0; gap: 12px; }
  .wf-col { width: auto; flex: 1 1 0; }
  .wf-item { width: 100%; margin-bottom: 12px; }

  .search-bar { max-width: 640px; margin: 0 auto; }
  #tag-list { padding: 0 16px; }
  .page-content { padding: 0 12px; }
}

/* ==========================================================================
   桌面：左侧分类栏 + 4 列（>= 1280px）
   ========================================================================== */
@media (min-width: 1280px) {
  .search-bar { max-width: 760px; margin: 0 auto; }

  /* 横向图标条在桌面端让位给左侧栏 */
  #tag-list { display: none; }

  .page-top { padding-bottom: 6px; }

  .page-content { padding: 0; border-radius: 0; background: transparent; }
  #tag2-list {
    padding: 14px 22px 2px;
    background: #fff;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    margin-left: var(--sidebar-w);
  }

  .main-region {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    background: #fff;
    align-items: start;
  }

  .cate-sidebar {
    display: block;
    position: sticky;
    top: 0;
    align-self: start;
    padding: 8px 8px 40px;
    border-right: 1px solid #f0f0f0;
    min-height: 60vh;
  }

  .cate-sidebar-title {
    padding: 10px 8px 8px;
    font-size: 14px;
    font-weight: 700;
    color: #333;
  }

  .side-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    border-radius: 10px;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    user-select: none;
  }

  .side-item:hover { background: #f5f5f8; }

  .side-item.is-selected {
    background: linear-gradient(180deg, #fff6c6, #fff);
    box-shadow: var(--shadow-tag);
    color: #000;
    font-weight: 600;
  }

  .side-item img { width: 26px; height: 26px; object-fit: contain; flex: 0 0 auto; }
  .side-item span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .wf { padding: 12px 22px 0; gap: 12px; }
  .wf-col { width: auto; flex: 1 1 0; }
  .wf-item { width: 100%; margin-bottom: 12px; }

  #tpl-list { min-height: 60vh; }
}

/* 自制模板角标（home.js buildItem 里按 id 段判断） */
.item-own {
  position: absolute;
  left: 6px;
  top: 6px;
  z-index: 3;
  padding: 1px 6px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .94);
  color: #e75718;
  font-size: 11px;
  line-height: 16px;
  font-weight: 700;
  letter-spacing: .5px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .15);
  pointer-events: none;
}
