/* Catalogo /templates — layout marketplace (palette stage) */
body.body-stage.body-stage-templates-marketplace {
  --tpl-bg: #ffffff;
  --tpl-surface: #f6f6f6;
  --tpl-surface-2: #f2f2f0;
  --tpl-text: #141414;
  --tpl-muted: #5e5e5e;
  --tpl-border: #d8d8d8;
  --tpl-primary: #136ef5;
  --tpl-primary-hover: #0f58c4;
  --tpl-primary-dark: #0b4293;
  --tpl-info-bg: #e7f0fe;
  --tpl-radius-control: 8px;
  --tpl-radius-preview: 16px;
  --tpl-container: 1200px;
  background: var(--tpl-bg);
  color: var(--tpl-text);
}

/* Come altre hero stage: offset navbar + respiro sotto header (80px / 48px mobile) */
body.body-stage-templates-marketplace .tpl-mkt {
  padding-top: calc(80px + var(--stage-navbar-height, 4.25rem));
  padding-bottom: 64px;
}

@media (max-width: 48rem) {
  body.body-stage-templates-marketplace .tpl-mkt {
    padding-top: calc(48px + var(--stage-navbar-height, 4.25rem));
  }
}

body.body-stage-templates-marketplace .tpl-mkt__container {
  max-width: var(--tpl-container);
  margin: 0 auto;
  padding: 0 30px;
}

@media (max-width: 48rem) {
  body.body-stage-templates-marketplace .tpl-mkt__container {
    padding: 0 16px;
  }
}

body.body-stage-templates-marketplace .tpl-mkt__title {
  margin: 0;
  font-family: var(--stage-font-primary, Inter, system-ui, sans-serif);
  font-size: var(--fs-h1-page);
  font-weight: var(--fw-h1-page);
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--tpl-text);
}

@media (max-width: 48rem) {
  body.body-stage-templates-marketplace .tpl-mkt__title {
    font-size: 28px;
  }
}

body.body-stage-templates-marketplace .tpl-mkt__subtitle {
  margin: 20px 0 0;
  max-width: 520px;
  font-size: 16px;
  line-height: 1.4;
  color: var(--tpl-muted);
}

body.body-stage-templates-marketplace .tpl-mkt__header-cta {
  margin: 20px 0 0;
}

body.body-stage-templates-marketplace .tpl-mkt__directory {
  margin-top: 40px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 24px 20px;
}

@media (min-width: 75rem) {
  body.body-stage-templates-marketplace .tpl-mkt__directory {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 40px;
  }
}

@media (max-width: 48rem) {
  body.body-stage-templates-marketplace .tpl-mkt__directory {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }

  body.body-stage-templates-marketplace .tpl-mkt__directory-list {
    display: none !important;
  }
}

body.body-stage-templates-marketplace .tpl-mkt__directory-title {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: 14px;
  font-weight: 500;
  color: var(--tpl-text);
  text-decoration: none;
}

body.body-stage-templates-marketplace .tpl-mkt__directory-title.is-active,
body.body-stage-templates-marketplace .tpl-mkt__directory-title:hover {
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

body.body-stage-templates-marketplace .tpl-mkt__directory-title:focus-visible {
  outline: 2px solid var(--tpl-primary);
  outline-offset: 2px;
  border-radius: 4px;
}

body.body-stage-templates-marketplace .tpl-mkt__directory-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

body.body-stage-templates-marketplace .tpl-mkt__directory-link {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 2px 0;
  font-size: 14px;
  line-height: 1.35;
  color: var(--tpl-muted);
  text-decoration: none;
}

body.body-stage-templates-marketplace .tpl-mkt__directory-link:hover {
  color: var(--tpl-text);
  text-decoration: underline;
}

body.body-stage-templates-marketplace .tpl-mkt__directory-link:focus-visible {
  outline: 2px solid var(--tpl-primary);
  outline-offset: 2px;
}

body.body-stage-templates-marketplace .tpl-mkt__toolbar {
  margin-top: 32px;
  margin-bottom: 24px;
}

body.body-stage-templates-marketplace .tpl-mkt__grid-section {
  margin: 0;
}

body.body-stage-templates-marketplace .tpl-mkt__toolbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

body.body-stage-templates-marketplace .tpl-mkt__segmented {
  display: inline-flex;
  align-items: stretch;
  border-radius: var(--tpl-radius-control);
  overflow: hidden;
  background: var(--tpl-bg);
}

body.body-stage-templates-marketplace .tpl-mkt__segmented-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  font-size: 14px;
  color: var(--tpl-muted);
  text-decoration: none;
  border-radius: var(--tpl-radius-control);
}

body.body-stage-templates-marketplace .tpl-mkt__segmented-btn.is-active {
  background: var(--tpl-surface-2);
  color: var(--tpl-text);
  font-weight: 500;
}

body.body-stage-templates-marketplace .tpl-mkt__segmented-btn:focus-visible {
  outline: 2px solid var(--tpl-primary);
  outline-offset: 2px;
  z-index: 1;
}

@media (max-width: 48rem) {
  body.body-stage-templates-marketplace .tpl-mkt__segmented-btn {
    min-height: 44px;
  }
}

body.body-stage-templates-marketplace .tpl-mkt__toolbar-filters-desktop {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

@media (max-width: 48rem) {
  body.body-stage-templates-marketplace .tpl-mkt__toolbar-filters-desktop {
    display: none;
  }
}

body.body-stage-templates-marketplace .tpl-mkt__search-input {
  width: 240px;
  height: 36px;
  padding: 0 12px;
  font-size: 14px;
  border: 1px solid var(--tpl-border);
  border-radius: var(--tpl-radius-control);
  background: var(--tpl-bg);
  color: var(--tpl-text);
}

body.body-stage-templates-marketplace .tpl-mkt__search-input:focus-visible {
  outline: 2px solid var(--tpl-primary);
  outline-offset: 1px;
  border-color: var(--tpl-primary);
}

body.body-stage-templates-marketplace .tpl-mkt__dropdown {
  position: relative;
}

body.body-stage-templates-marketplace .tpl-mkt__dropdown-trigger {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  font-size: 14px;
  border: 1px solid var(--tpl-border);
  border-radius: var(--tpl-radius-control);
  background: var(--tpl-bg);
  color: var(--tpl-text);
  cursor: pointer;
}

body.body-stage-templates-marketplace .tpl-mkt__dropdown-trigger:focus-visible {
  outline: 2px solid var(--tpl-primary);
  outline-offset: 2px;
}

body.body-stage-templates-marketplace .tpl-mkt__dropdown-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 40;
  min-width: 200px;
  max-height: 280px;
  overflow: auto;
  padding: 8px;
  background: var(--tpl-bg);
  border: 1px solid var(--tpl-border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(20, 20, 20, 0.08);
}

body.body-stage-templates-marketplace .tpl-mkt__dropdown-search {
  width: 100%;
  height: 36px;
  margin-bottom: 6px;
  padding: 0 10px;
  font-size: 14px;
  border: 1px solid var(--tpl-border);
  border-radius: var(--tpl-radius-control);
}

body.body-stage-templates-marketplace .tpl-mkt__dropdown-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

body.body-stage-templates-marketplace .tpl-mkt__dropdown-option {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 10px;
  font-size: 14px;
  color: var(--tpl-text);
  text-decoration: none;
  border-radius: var(--tpl-radius-control);
}

body.body-stage-templates-marketplace .tpl-mkt__dropdown-option.is-active,
body.body-stage-templates-marketplace .tpl-mkt__dropdown-option:hover {
  background: var(--tpl-surface-2);
}

body.body-stage-templates-marketplace .tpl-mkt__toolbar-mobile {
  display: none;
  width: 100%;
  gap: 10px;
  align-items: center;
}

@media (max-width: 48rem) {
  body.body-stage-templates-marketplace .tpl-mkt__toolbar-mobile {
    display: flex;
  }

  body.body-stage-templates-marketplace .tpl-mkt__segmented {
    width: 100%;
    justify-content: stretch;
  }

  body.body-stage-templates-marketplace .tpl-mkt__segmented-btn {
    flex: 1;
  }

  body.body-stage-templates-marketplace .tpl-mkt__search--mobile {
    flex: 1;
  }

  body.body-stage-templates-marketplace .tpl-mkt__search--mobile .tpl-mkt__search-input {
    width: 100%;
    height: 44px;
    font-size: 16px;
  }
}

body.body-stage-templates-marketplace .tpl-mkt__filters-btn {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--tpl-border);
  border-radius: var(--tpl-radius-control);
  background: var(--tpl-bg);
  color: var(--tpl-text);
  cursor: pointer;
}

body.body-stage-templates-marketplace .tpl-mkt__filters-btn:focus-visible {
  outline: 2px solid var(--tpl-primary);
  outline-offset: 2px;
}

body.body-stage-templates-marketplace .tpl-mkt__grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  column-gap: 20px;
  row-gap: 32px;
}

@media (max-width: 64rem) {
  body.body-stage-templates-marketplace .tpl-mkt__grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 48rem) {
  body.body-stage-templates-marketplace .tpl-mkt__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 16px;
    row-gap: 24px;
  }
}

@media (max-width: 24.375rem) {
  body.body-stage-templates-marketplace .tpl-mkt__grid {
    column-gap: 12px;
  }
}

body.body-stage-templates-marketplace .tpl-mkt__card {
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  transition: transform 0.16s ease;
}

body.body-stage-templates-marketplace .tpl-mkt__card-link {
  display: block;
  color: inherit;
  text-decoration: none;
}

body.body-stage-templates-marketplace .tpl-mkt__card-media {
  aspect-ratio: 4 / 3;
  border: none;
  border-radius: var(--tpl-radius-preview);
  overflow: hidden;
  background: var(--tpl-surface);
}

body.body-stage-templates-marketplace .tpl-mkt__card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
  transition: transform 0.16s ease;
}

@media (hover: hover) and (pointer: fine) {
  body.body-stage-templates-marketplace .tpl-mkt__card:hover {
    transform: translateY(-2px);
    transition: transform 0.16s ease;
  }

  body.body-stage-templates-marketplace .tpl-mkt__card:hover .tpl-mkt__card-img {
    animation: tpl-mkt-preview-pan 6s ease-in-out forwards;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.body-stage-templates-marketplace .tpl-mkt__card:hover .tpl-mkt__card-img {
    animation: none;
  }

  body.body-stage-templates-marketplace .tpl-mkt__card:hover {
    transform: none;
  }
}

@keyframes tpl-mkt-preview-pan {
  from {
    object-position: top center;
  }
  to {
    object-position: center 85%;
  }
}

body.body-stage-templates-marketplace .tpl-mkt__card-meta {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}

body.body-stage-templates-marketplace .tpl-mkt__card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--tpl-text);
}

body.body-stage-templates-marketplace .tpl-mkt__card-category {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--tpl-muted);
}

@media (max-width: 48rem) {
  body.body-stage-templates-marketplace .tpl-mkt__card-category {
    display: none;
  }
}

body.body-stage-templates-marketplace .tpl-mkt__price {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
  border-radius: var(--tpl-radius-control);
  background: var(--tpl-surface-2);
  color: var(--tpl-text);
}

body.body-stage-templates-marketplace .tpl-mkt__price--is-paid,
body.body-stage-templates-marketplace .tpl-mkt__price--is-plan {
  background: var(--tpl-info-bg);
  color: var(--tpl-primary-dark);
}

body.body-stage-templates-marketplace .tpl-mkt__load-more {
  margin-top: 32px;
  text-align: center;
}

body.body-stage-templates-marketplace .tpl-mkt__load-more-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--tpl-text);
  text-decoration: none;
  border: 1px solid var(--tpl-border);
  border-radius: var(--tpl-radius-control);
  background: var(--tpl-bg);
}

body.body-stage-templates-marketplace .tpl-mkt__load-more-btn:focus-visible {
  outline: 2px solid var(--tpl-primary);
  outline-offset: 2px;
}

body.body-stage-templates-marketplace .tpl-mkt__cta {
  margin-top: 48px;
  padding: 32px;
  border: none;
  border-radius: var(--tpl-radius-preview);
  background: var(--tpl-surface);
}

body.body-stage-templates-marketplace .tpl-mkt__cta-title {
  margin: 0;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.02em;
}

body.body-stage-templates-marketplace .tpl-mkt__cta-text {
  margin: 12px 0 20px;
  max-width: 520px;
  font-size: 16px;
  line-height: 1.45;
  color: var(--tpl-muted);
}

body.body-stage-templates-marketplace .tpl-mkt__empty {
  padding: 40px 0;
}

body.body-stage-templates-marketplace .tpl-mkt__empty-title {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 500;
}

body.body-stage-templates-marketplace .tpl-mkt__empty-reset {
  font-size: 14px;
  color: var(--tpl-primary);
  text-decoration: underline;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

body.body-stage-templates-marketplace .tpl-mkt__filters-dialog {
  border: none;
  border-radius: 16px;
  padding: 0;
  max-width: min(100vw - 32px, 400px);
}

body.body-stage-templates-marketplace .tpl-mkt__filters-dialog::backdrop {
  background: rgba(20, 20, 20, 0.4);
}

body.body-stage-templates-marketplace .tpl-mkt__filters-dialog-form {
  padding: 20px;
}

body.body-stage-templates-marketplace .tpl-mkt__filters-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

body.body-stage-templates-marketplace .tpl-mkt__filters-dialog-title {
  margin: 0;
  font-size: 18px;
  font-weight: 500;
}

body.body-stage-templates-marketplace .tpl-mkt__filters-close {
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

body.body-stage-templates-marketplace .tpl-mkt__filters-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

body.body-stage-templates-marketplace .tpl-mkt__chip {
  cursor: pointer;
}

body.body-stage-templates-marketplace .tpl-mkt__chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

body.body-stage-templates-marketplace .tpl-mkt__chip span {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  font-size: 14px;
  border: 1px solid var(--tpl-border);
  border-radius: var(--tpl-radius-control);
  background: var(--tpl-bg);
}

body.body-stage-templates-marketplace .tpl-mkt__chip input:checked + span {
  background: var(--tpl-surface-2);
  border-color: var(--tpl-text);
}

body.body-stage-templates-marketplace .tpl-mkt__filters-apply {
  width: 100%;
  min-height: 44px;
  margin-top: 16px;
}

body.body-stage-templates-marketplace .visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
