/* Collection landing-page hierarchy.
   Keep SEO copy visible and useful without letting it overpower the products. */

.template-collection .spaced-section.spaced-section--full-width {
  margin-top: 0.8rem;
}

.template-collection .collection-hero__inner {
  margin-bottom: 0;
  padding-bottom: clamp(1.2rem, 2vw, 1.7rem);
  border-bottom: 0.1rem solid rgba(var(--color-base-text), 0.08);
}

.template-collection .collection-hero__text-wrapper {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "title sort"
    "description description"
    "center center";
  align-items: start;
  column-gap: 2rem;
  row-gap: 0.7rem;
}

/* Flatten the legacy wrapper so title, app content, and sorting participate in
   one deliberate layout without changing the Liquid/SEO structure. */
.template-collection .collection-hero__text-wrapper > div:first-child {
  display: contents;
}

.template-collection .collection-hero__title {
  grid-area: title;
  max-width: 24ch;
  margin: 0;
  font-family: var(--font-heading-family);
  font-size: clamp(2.35rem, 3.8vw, 3.2rem);
  font-style: var(--font-heading-style);
  font-weight: var(--font-heading-weight);
  line-height: 1.12;
  letter-spacing: -0.025em;
  text-align: left;
  text-wrap: balance;
}

.template-collection .top-wrapper-section {
  grid-area: center;
  min-width: 0;
}

/* Liquid indentation leaves whitespace text nodes, so :empty alone is not
   enough to collapse these optional rows. Modern storefront browsers support
   :has(), which lets us key off the actual rendered controls/content. */
.template-collection .top-wrapper-section:not(:has(*)),
.template-collection .collection-filters:not(:has(.collection-filters__item)) {
  display: none;
}

.template-collection .collection-hero__text-wrapper > .rte {
  grid-area: description;
  max-width: 70ch;
  margin: 0;
  color: rgba(var(--color-base-text), 0.72);
  font-family: var(--font-body-family);
  font-size: 1.3rem;
  font-style: var(--font-body-style);
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: 0.008em;
}

.template-collection .collection-hero__text-wrapper > .rte p,
.template-collection .collection-hero__text-wrapper > .rte ul,
.template-collection .collection-hero__text-wrapper > .rte ol {
  margin-top: 0.3rem;
  margin-bottom: 0.3rem;
}

.template-collection .collection-hero__text-wrapper > .rte strong,
.template-collection .collection-hero__text-wrapper > .rte b {
  color: rgba(var(--color-base-text), 0.9);
  font-weight: 600;
}

.template-collection .collection-hero__text-wrapper > .rte a {
  color: inherit;
  text-decoration-thickness: 0.1rem;
  text-underline-offset: 0.2rem;
}

.template-collection .collection-filters {
  grid-area: sort;
  align-self: center;
  min-width: max-content;
  margin: 0 !important;
}

.template-collection .collection-filters__item {
  align-items: center;
  padding-left: 0;
}

/* compact-spacing.css gives every .select a bottom margin. That is useful in
   forms, but here it made the dropdown sit visibly higher than "Sort by". */
.template-collection .collection-filters__field {
  align-items: center;
  gap: 0.6rem;
}

.template-collection .collection-filters__field .select {
  display: flex;
  align-items: center;
  width: auto;
  margin: 0;
}

.template-collection .collection-filters__label,
.template-collection .collection-filters__sort {
  font-family: var(--font-body-family);
  font-size: 1.25rem;
  font-style: var(--font-body-style);
  font-weight: 400;
  letter-spacing: 0.01em;
}

.template-collection .collection-filters__label {
  display: inline-flex;
  align-items: center;
  min-height: 3.4rem;
  margin: 0;
  color: rgba(var(--color-base-text), 0.58);
  line-height: 1.2;
  white-space: nowrap;
}

.template-collection .collection-filters__sort {
  height: 3.4rem;
  min-height: 3.4rem;
  margin: 0;
  padding-top: 0;
  padding-bottom: 0;
  line-height: 1.2;
  vertical-align: middle;
}

.template-collection #CollectionProductGrid {
  margin-top: clamp(1rem, 1.8vw, 1.6rem);
}

@media screen and (min-width: 750px) {
  .template-collection .collection-hero__text-wrapper > .rte {
    font-size: 1.34rem;
  }
}

@media screen and (max-width: 749px) {
  .template-collection .spaced-section.spaced-section--full-width {
    margin-top: 0.45rem;
  }

  .template-collection .collection-hero__inner {
    padding-bottom: 1.15rem;
  }

  .template-collection .collection-hero__text-wrapper {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "title"
      "description"
      "center"
      "sort";
    row-gap: 0.55rem;
  }

  .template-collection .collection-hero__title {
    max-width: 18ch;
    font-size: clamp(2.1rem, 6.2vw, 2.5rem);
    line-height: 1.12;
    text-align: left !important;
  }

  .template-collection .collection-hero__text-wrapper > .rte {
    max-width: none;
    font-size: 1.18rem;
    line-height: 1.48;
    letter-spacing: 0.006em;
  }

  .template-collection .collection-hero__text-wrapper > .rte p,
  .template-collection .collection-hero__text-wrapper > .rte ul,
  .template-collection .collection-hero__text-wrapper > .rte ol {
    margin-top: 0.25rem;
    margin-bottom: 0.25rem;
  }

  .template-collection .collection-filters:has(.collection-filters__item) {
    width: 100%;
    min-width: 0;
    padding-top: 0.6rem;
    border-top: 0.1rem solid rgba(var(--color-base-text), 0.07);
  }

  .template-collection .collection-filters__item,
  .template-collection .collection-filters__field {
    width: 100%;
  }

  .template-collection .collection-filters__field {
    justify-content: flex-end;
  }

  .template-collection #CollectionProductGrid {
    margin-top: 0.9rem;
  }
}
