/* 案例模板 /templates — 列表页：筛选 + 多图案例卡 */

.templates-page .home-section {
  row-gap: 28px;
  padding: 36px 0 60px;
  border-top-color: transparent;
}

.templates-page.wa-index-page:not(.wa-index-page--blocks) .home-section {
  /* 顶距收掉：列表直接贴 Hero 底线 */
  padding: 0 0 60px;
}

.templates-page.wa-index-page:not(.wa-index-page--blocks) .wa-index-catalog {
  padding-bottom: 0;
}

.templates-page.wa-index-page:not(.wa-index-page--blocks) .home-section:not(:first-child)::before {
  display: none;
}

/* —— Hero —— */
.templates-page .templates-hero.wa-comp-index__head {
  position: relative;
  /* visible：勿裁剪 shell 通栏 ::after（100vw）；光晕由 .wa-fx-ribbon-glow 自身 overflow 裁切 */
  overflow: visible;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0;
  max-width: none;
  width: 100%;
  min-height: 0;
  margin: 0;
  padding: clamp(64px, 8vw, 96px) var(--wa-content-pad-x, 32px) clamp(48px, 6vw, 72px);
  border-bottom: 1px solid var(--wa-index-rail, var(--wa-color-border));
  background: var(--wa-color-surface);
  color: var(--wa-color-text);
  text-align: center;
}

.templates-page.wa-index-page:not(.wa-index-page--blocks) .templates-hero.wa-comp-index__head {
  width: calc(100% + 64px);
  margin: -28px -32px 0;
  padding: clamp(64px, 8vw, 96px) 32px clamp(48px, 6vw, 72px);
  border-bottom: 0;
}

/* 光晕铺满整块 Hero，筛选标签也落在同一背景上 */
.templates-page .templates-hero .home-hero__glow.wa-fx-ribbon-glow {
  inset: 0;
  height: auto;
  z-index: 0;
}

.templates-hero::before {
  content: none;
}

.templates-hero__inner {
  position: relative;
  z-index: 1;
  max-width: 40em;
  margin: 0 auto;
}

.templates-hero__badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  margin: 0 0 12px;
  padding: 6px 12px 6px 10px;
  border: 1px solid var(--wa-color-border);
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
  color: var(--wa-color-text);
}

.templates-hero__title {
  margin: 0 0 12px;
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.templates-hero__lead {
  margin: 0;
  font-size: clamp(0.9375rem, 1.35vw, 1.05rem);
  line-height: 1.55;
  color: var(--wa-color-text-secondary, var(--wa-color-muted));
}

/* —— Surface 筛选（Hero 内） —— */
.templates-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 36px 0 0;
}

.templates-filters__btn {
  appearance: none;
  margin: 0;
  padding: 8px 14px;
  border: 1px solid var(--wa-color-border);
  border-radius: 9999px;
  background: transparent;
  color: var(--wa-color-text-secondary, var(--wa-color-muted));
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease;
}

.templates-filters__btn:hover {
  border-color: var(--wa-btn-outline-muted-bd, var(--wa-color-primary));
  color: var(--wa-color-text);
}

.templates-filters__btn.is-active {
  border-color: var(--wa-color-primary);
  background: var(--wa-color-primary-soft);
  color: var(--wa-color-primary);
}

.templates-filters__btn:focus-visible {
  outline: 2px solid var(--wa-color-primary);
  outline-offset: 2px;
}

/* —— 案例卡：左文案 / 右截图 —— */
.templates-list {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.templates-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 0.4fr);
  grid-template-areas: "media body";
  align-items: stretch;
  overflow: hidden;
  border: var(--wa-border-card, 1px solid var(--wa-color-border));
  border-radius: var(--wa-radius-lg, var(--wa-radius));
  background: var(--wa-color-surface);
}

/* 默认版式：无卡外边框；列表贴版心竖轨；块间底线含末项 */
.templates-page.wa-index-page:not(.wa-index-page--blocks) .templates-list {
  gap: 0;
  margin-inline: calc(-1 * var(--wa-index-stage-pad-x, 32px));
}

.templates-page.wa-index-page:not(.wa-index-page--blocks) .templates-card {
  position: relative;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: transparent;
  min-height: 300px;
}

.templates-page.wa-index-page:not(.wa-index-page--blocks) .templates-card:not([hidden])::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--wa-index-rail, var(--wa-color-border));
  pointer-events: none;
  z-index: 1;
}

/* 左侧缩略图井底铺满至版心左边；加高块内边距 */
.templates-page.wa-index-page:not(.wa-index-page--blocks) .templates-card__media {
  padding: clamp(28px, 3.2vw, 44px) clamp(18px, 2vw, 28px) clamp(28px, 3.2vw, 44px)
    var(--wa-index-stage-pad-x, 32px);
}

.templates-page.wa-index-page:not(.wa-index-page--blocks) .templates-card__body {
  padding: clamp(32px, 3.5vw, 48px) var(--wa-index-stage-pad-x, 32px) clamp(32px, 3.5vw, 48px)
    clamp(22px, 2.3vw, 30px);
}

.templates-card[hidden] {
  display: none;
}

.templates-card__body {
  grid-area: body;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  padding: clamp(24px, 2.6vw, 32px) clamp(22px, 2.3vw, 30px);
  border-left: 1px solid var(--wa-color-border);
}

.templates-card__title {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: clamp(1.25rem, 2vw, 1.5rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: var(--wa-color-text);
}

.templates-card__title-text {
  flex: 1 1 auto;
  min-width: 0;
}

/* Pro 角标：与设计资源 .wa-tier-pro 同款（本页不挂 design-resources.css） */
.templates-card__title .wa-tier-pro {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  margin-left: auto;
  padding: 0 4px;
  border-radius: 3px;
  border: 1px solid #e74c3c;
  font-size: 9px;
  font-weight: 650;
  line-height: 1.4;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #e74c3c;
  background: color-mix(in srgb, #e74c3c 10%, transparent);
  font-family: inherit;
}

html[data-theme="dark"] .templates-card__title .wa-tier-pro {
  background: color-mix(in srgb, #e74c3c 16%, transparent);
}

.templates-card__actions .wa-btn {
  gap: 6px;
  min-height: 36px;
  padding: 0 14px;
  font-size: 0.8125rem;
  font-weight: 500;
}

.templates-card__desc {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  margin: 0;
  font-size: 15px;
  line-height: 1.65;
  color: var(--wa-color-text-secondary, var(--wa-color-muted));
}

.templates-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 2px 0 0;
  padding: 0;
  list-style: none;
}

.templates-card__tags li {
  margin: 0;
  padding: 2px 8px;
  border: 1px solid var(--wa-color-border);
  border-radius: 9999px;
  background: transparent;
  color: var(--wa-color-text-secondary, var(--wa-color-muted));
  font-size: 11px;
  font-weight: 500;
  line-height: 16px;
}

.templates-card__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding-top: 22px;
}

/* 未登录锁态：图标换锁即可，字色与次按钮正文一致，避免比「查看演示」弱一截 */
.templates-card__actions .wa-btn--secondary.is-locked {
  color: var(--wa-color-text);
}

/* 使用说明：右对齐 ⓘ +「说明」，12px，无外框 / 无门禁 */
.templates-card__info {
  appearance: none;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex: 0 0 auto;
  margin: 0 0 0 auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--wa-color-text-secondary, var(--wa-color-muted));
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s ease;
}

.templates-card__info:hover,
.templates-card__info:focus-visible {
  color: var(--wa-color-text);
  outline: none;
}

.templates-card__info:focus:not(:focus-visible) {
  outline: none;
}

.templates-card__info i {
  font-size: 12px;
  line-height: 1;
}

.templates-card__media {
  grid-area: media;
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  padding: clamp(16px, 1.8vw, 22px);
  /* 缩略图井底：介于 fill-1 与卡片面之间 */
  background: color-mix(in srgb, var(--wa-color-fill-1) 55%, var(--wa-color-surface));
  container-type: inline-size;
  container-name: wa-dr-stage-card;
}

/* 缩略图框：对齐风格卡舞台 — 斜纹底 + 十字参考线，封面落在内框 */
.templates-card__shot {
  /* 模板封面本身偏小，默认比设计资源/首页略收（10；窄卡再 8/6） */
  --templates-shot-guide: 10px;
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  aspect-ratio: 16 / 10;
  border: 1px solid color-mix(in srgb, var(--wa-color-border) 55%, transparent);
  border-radius: var(--wa-radius, 12px);
  background-color: var(--wa-stage-hatch-bg, #fafafa);
  background-image: var(--wa-stage-hatch-tile);
  background-size: var(--wa-stage-hatch-tile-size, 5px) var(--wa-stage-hatch-tile-size, 5px);
  background-repeat: repeat;
  box-shadow: none;
  isolation: isolate;
}

.templates-card__shot::before,
.templates-card__shot::after {
  content: "";
  position: absolute;
  z-index: 2;
  pointer-events: none;
  border-color: color-mix(in srgb, var(--wa-color-border) 70%, transparent);
  border-style: solid;
}

.templates-card__shot::before {
  top: var(--templates-shot-guide);
  right: 0;
  bottom: var(--templates-shot-guide);
  left: 0;
  border-width: 1px 0;
}

.templates-card__shot::after {
  top: 0;
  right: var(--templates-shot-guide);
  bottom: 0;
  left: var(--templates-shot-guide);
  border-width: 0 1px;
}

@container wa-dr-stage-card (max-width: 360px) {
  .templates-card__shot {
    --templates-shot-guide: 8px;
  }
}

@container wa-dr-stage-card (max-width: 280px) {
  .templates-card__shot {
    --templates-shot-guide: 6px;
  }
}

html[data-theme="dark"] .templates-card__shot {
  background-color: var(--wa-stage-hatch-bg, #121214);
  background-image: var(--wa-stage-hatch-tile);
  background-size: var(--wa-stage-hatch-tile-size, 5px) var(--wa-stage-hatch-tile-size, 5px);
  background-repeat: repeat;
}

/* 内框：封面图 */
.templates-card__frame {
  position: absolute;
  z-index: 1;
  inset: var(--templates-shot-guide);
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--wa-color-border) 50%, transparent);
  border-radius: 0;
  background: var(--wa-color-surface);
}

.templates-card__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  transition: filter 0.22s ease;
}

/* 悬停：对齐风格页 — 暗遮罩 + 扫光主钮 */
.templates-card__cta {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: inherit;
  background: color-mix(in srgb, var(--wa-color-text, #1d2129) 46%, transparent);
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.18s ease;
  cursor: pointer;
}

.templates-card__shot:hover .templates-card__cta,
.templates-card__cta:focus-visible {
  opacity: 1;
}

.templates-card__cta-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  isolation: isolate;
  min-height: 36px;
  padding: 0 18px;
  border-radius: 999px;
  background: var(--wa-color-primary);
  color: var(--wa-color-on-primary, #fff);
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  box-shadow: 0 8px 24px color-mix(in srgb, var(--wa-color-primary) 35%, transparent);
}

.templates-card__cta-label {
  position: relative;
  z-index: 1;
}

.templates-card__cta-btn::after {
  content: "";
  position: absolute;
  top: -30%;
  bottom: -30%;
  left: 0;
  width: 2.25rem;
  z-index: 2;
  pointer-events: none;
  background: color-mix(in srgb, #fff 28%, transparent);
  filter: blur(2px);
  transform: translateX(-140%) rotate(20deg);
  transition: transform 0.6s ease-in-out;
  opacity: 0;
}

.templates-card__shot:hover .templates-card__cta-btn::after,
.templates-card__cta:focus-visible .templates-card__cta-btn::after {
  opacity: 1;
  transform: translateX(420%) rotate(20deg);
}

.templates-card__shot:hover .templates-card__img {
  filter: saturate(0.9) brightness(0.96);
}

.templates-empty {
  margin: 24px 0 0;
  text-align: center;
  font-size: 14px;
  color: var(--wa-color-text-secondary, var(--wa-color-muted));
}

.templates-empty[hidden] {
  display: none;
}

/* 脚注上下各约 60px：上 = margin，下 = section padding-bottom */
.templates-footnote {
  margin: 60px 0 0;
  text-align: center;
  font-size: 14px;
  color: var(--wa-color-text-secondary, var(--wa-color-muted));
}

@media (max-width: 900px) {
  .templates-card {
    grid-template-columns: 1fr;
    grid-template-areas:
      "body"
      "media";
  }

  .templates-card__body {
    border-left: 0;
    border-bottom: 1px solid var(--wa-color-border);
  }

  .templates-card__media {
    gap: 10px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }

  .templates-card__shot {
    flex: 0 0 min(72%, 280px);
    scroll-snap-align: start;
  }

  .templates-card__actions .wa-btn {
    width: 100%;
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .templates-filters__btn,
  .templates-card__cta,
  .templates-card__img,
  .templates-card__cta-btn::after {
    transition: none;
  }

  .templates-card__shot:hover .templates-card__cta-btn::after,
  .templates-card__cta:focus-visible .templates-card__cta-btn::after {
    opacity: 0;
    transform: translateX(-140%) rotate(20deg);
  }
}
