/* ——— Страница «Шаблоны» (каталог) ——— */

.shell-page--templates {
  --templates-gutter: 1rem;
  max-width: none;
  padding: 0 var(--templates-gutter) 2rem;
}

@media (min-width: 768px) {
  .shell-page--templates {
    --templates-gutter: 1.25rem;
  }
}

@media (min-width: 1200px) {
  .shell-page--templates {
    --templates-gutter: 1.5rem;
  }
}

.catalog-filters-bar {
  padding: 0.65rem 0 0;
  border-bottom: 1px solid #1a1a1a;
}

.catalog-filters {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.5rem;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0 0 0.7rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.catalog-filters::-webkit-scrollbar {
  display: none;
}

.catalog-filters-sep {
  flex-shrink: 0;
  width: 1px;
  height: 1rem;
  margin: 0 0.15rem;
  background: #2a2a2a;
}

.catalog-filter-pill {
  flex-shrink: 0;
  border: none;
  border-radius: 6px;
  padding: 0.35rem 0.7rem;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.2;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}

.catalog-filter-pill:hover {
  color: #fff;
}

.catalog-filter-pill.active {
  background: #3a3a3a;
  color: #fff;
}

.catalog-filter-pill.active:hover {
  color: #fff;
}

/* Masonry: вплотную, между карточками — 1px чёрная линия */
.templates-masonry {
  column-count: 2;
  column-gap: 1px;
  background: #000;
  line-height: 0;
}

@media (min-width: 576px) {
  .templates-masonry {
    column-count: 3;
  }
}

@media (min-width: 992px) {
  .templates-masonry {
    column-count: 4;
  }
}

@media (min-width: 1400px) {
  .templates-masonry {
    column-count: 5;
  }
}

.template-card {
  display: block;
  position: relative;
  border-radius: 0;
  overflow: hidden;
  margin-bottom: 1px;
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  text-decoration: none;
  color: inherit;
  background: #0a0a0a;
}

.template-card:focus-visible {
  outline: 2px solid #7c3aed;
  outline-offset: 0;
  z-index: 1;
}

.template-card picture {
  display: block;
  width: 100%;
}

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

.template-card--empty .template-card-img-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 140px;
  aspect-ratio: 4 / 5;
  background: linear-gradient(145deg, #2d3140 0%, #1a1d24 50%, #3d2a4a 100%);
  color: rgba(255, 255, 255, 0.35);
  font-size: 1.75rem;
}

.template-card-overlay {
  position: absolute;
  inset: auto 0 0;
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  min-height: 42%;
  padding: 0.55rem 0.5rem 0.5rem;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.92) 0%,
    rgba(0, 0, 0, 0.5) 55%,
    transparent 100%
  );
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.template-card-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.12rem;
  text-align: left;
  max-width: 100%;
}

.template-card:hover .template-card-overlay,
.template-card:focus-visible .template-card-overlay {
  opacity: 1;
}

.template-card-title {
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.2;
  color: #fff;
  margin: 0;
}

.template-card-desc {
  font-size: 0.6875rem;
  font-weight: 400;
  line-height: 1.3;
  color: rgba(255, 255, 255, 0.88);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.catalog-empty {
  color: var(--shell-muted, #9ca3af);
  font-size: 0.875rem;
  padding: 2rem 0;
  text-align: center;
}

.catalog-pagination-wrap {
  margin-top: 1.25rem;
}

/* ——— Страница пресета (hero и карточки) ——— */

.preset-card-thumb {
  position: relative;
  overflow: hidden;
  background: linear-gradient(145deg, #2d3140 0%, #1a1d24 50%, #3d2a4a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.35);
  font-size: 2rem;
}

.preset-card-thumb-link {
  display: block;
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  color: inherit;
  text-decoration: none;
}

.preset-card-thumb:not(.preset-card-thumb-hero) {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.preset-card-thumb img.preset-card-thumb-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.preset-card-thumb-hero {
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  margin-inline: auto;
  aspect-ratio: 4 / 5;
  max-height: min(72vh, 520px);
  font-size: 2.5rem;
}

@media (min-width: 992px) {
  .preset-preset-header-card .preset-hero-col {
    align-self: stretch;
    justify-content: center;
  }
}

#preset-result {
  scroll-margin-top: calc(4.5rem + env(safe-area-inset-top, 0px));
}

@media (min-width: 992px) {
  #preset-result {
    scroll-margin-top: 1.25rem;
  }
}

.preset-card {
  display: block;
  border-radius: 12px;
  overflow: hidden;
  background: var(--shell-surface, #1a1a1a);
  border: 1px solid var(--shell-border, #2a2a2a);
}

.preset-card-body {
  padding: 0.85rem 1rem 1rem;
}

.preset-card-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.35rem;
  line-height: 1.3;
  color: var(--shell-text, #f5f5f5);
}

.preset-card-desc {
  font-size: 0.8rem;
  color: var(--shell-muted, #9ca3af);
  line-height: 1.35;
}
