.template-width {
  width: min(1000px, 100% - var(--site-gutter) * 2);
  margin-inline: auto;
}

.template-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.template-catalog-page {
  --site-page-background: #f7f8fa;
  background: radial-gradient(ellipse 90% 830px at 50% -200px, #fff2d9, #fff);
  background-size: 100% 640px;
  background-repeat: no-repeat;
  background-color: #fff;
}

.template-catalog-content {
  padding-block: 32px 56px;
}

.template-catalog-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  /* 发布入口存在时才生成第二列。 */
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  gap: 32px;
}

.template-catalog-tools > form {
  width: 100%;
  min-width: 0;
}

.template-catalog-heading a:hover {
  color: var(--color-accent);
}

.template-publish-entry {
  position: relative;
  display: flex;
  align-items: center;
}

.template-publish-link {
  display: inline-flex;
  list-style: none;
  cursor: pointer;
  align-items: center;
  min-height: 48px;
  color: #fb9900;
  font-size: 16px;
  white-space: nowrap;
}

.template-publish-choices {
  position: absolute;
  z-index: 4;
  inset: 100% 0 auto auto;
  display: none;
  width: min(288px, 100vw - var(--site-gutter) * 2);
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0;
  padding: 0;
  border-radius: 2px;
  background: #fff;
  box-shadow: 0 2px 8px rgb(0 0 0 / 15%);
  list-style: none;
}

.template-publish-entry[open] .template-publish-choices {
  display: grid;
}

.template-publish-choices a {
  display: grid;
  min-height: 72px;
  justify-items: center;
  align-content: center;
  gap: 6px;
  padding: 6px;
  font-size: 14px;
  text-align: center;
}

.template-publish-choices a:hover {
  background: #fff6e6;
  color: #fb9900;
}

.template-publish-choices a:focus-visible {
  outline-offset: -3px;
}

.template-catalog-filters {
  display: flex;
  align-items: center;
  overflow-x: auto;
  min-height: 44px;
  margin-block: 24px 32px;
  white-space: nowrap;
}

.template-catalog-filters a {
  display: block;
  padding: 8px 16px;
  border-radius: 8px;
  line-height: 24px;
}

.template-catalog-filters a:hover {
  background: #fff6e6;
  color: var(--color-accent);
}

.template-catalog-filters a:focus-visible {
  outline-offset: -3px;
}

.template-catalog-sections {
  display: grid;
  gap: 48px;
}

.template-catalog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.template-catalog-heading h2 {
  margin: 0;
  font-size: 20px;
  line-height: 28px;
}

.template-catalog-heading a {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding-right: 6px;
  color: var(--color-secondary);
  font-size: 14px;
  line-height: 22px;
}

.template-catalog-heading a::after {
  width: 6px;
  height: 6px;
  border-top: 1px solid currentColor;
  border-right: 1px solid currentColor;
  content: "";
  transform: rotate(45deg);
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
}

.template-card {
  display: block;
  min-width: 0;
  overflow: hidden;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #fff;
}

.template-card__media {
  position: relative;
  aspect-ratio: 233 / 131;
  overflow: hidden;
}

.template-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.template-card__media--empty {
  background: #fff6e8;
}

.template-card img.template-card__placeholder {
  position: absolute;
  inset: 0;
  width: min(55%, 120px);
  height: auto;
  margin: auto;
}

.template-card__type {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 2px 8px;
  border-radius: 12px;
  background: rgb(0 0 0 / 52%);
  color: #fff;
  font-size: 12px;
  line-height: 18px;
}

.template-card__actions {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 6px;
  background: rgb(0 0 0 / 58%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.template-card:hover .template-card__actions,
.template-card:focus-within .template-card__actions {
  opacity: 1;
  pointer-events: auto;
}

.template-card__action {
  padding: 5px 12px;
  border-radius: 4px;
  background: #fff;
  color: var(--color-secondary);
  font-size: 14px;
  line-height: 22px;
  text-align: center;
  white-space: nowrap;
}

.template-card__action--use {
  background: var(--color-accent);
  color: #fff;
}

.template-card__title {
  display: block;
  padding: 15px 14px;
  overflow: hidden;
  font-size: 14px;
  line-height: 22px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

a.template-card__title:hover {
  color: var(--color-accent);
}

.template-card__title:focus-visible {
  outline-offset: -3px;
}

.template-collection-strip {
  padding-block: 56px 24px;
  background: var(--site-page-background);
}

.template-more-collections {
  display: grid;
  align-content: center;
  border-radius: 8px;
  background: linear-gradient(164deg, #68757e 4%, #8e806b 38%, #3b444b 62%, #0d1b2a 100%);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  line-height: 24px;
  text-align: center;
}

.template-more-collections:hover {
  filter: brightness(1.12);
}

@media (max-width: 900px) {
  .template-grid {
    gap: 16px;
  }

  .template-card__actions {
    gap: 6px;
  }

  .template-card__action {
    padding-inline: 6px;
    font-size: 13px;
  }
}

@media (max-width: 680px) {
  .template-catalog-content {
    padding-block: 24px 36px;
  }

  .template-catalog-tools {
    gap: 10px;
  }

  .template-publish-link {
    min-height: 42px;
    font-size: 14px;
  }

  .template-publish-link {
    padding-inline: 4px;
  }

  .template-catalog-filters {
    margin-block: 16px 24px;
  }

  .template-catalog-filters a {
    padding-inline: 12px;
  }

  .template-catalog-sections {
    gap: 32px;
  }

  .template-catalog-heading {
    margin-bottom: 16px;
  }

  .template-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .template-card__title {
    padding: 9px 10px;
  }

  .template-collection-strip {
    padding-block: 28px 12px;
  }
}

@media (hover: none) {
  .template-card__actions {
    align-items: end;
    background: linear-gradient(transparent 50%, rgb(0 0 0 / 50%));
    opacity: 1;
    pointer-events: auto;
  }

  .template-card__action {
    padding: 2px 5px;
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .template-card__actions {
    transition: none;
  }
}
