/* The catalog moves its existing controls into the results bar after rendering. */
#filterResultsBar > #marketMore {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 5px;
  white-space: nowrap;
}

#filterResultsBar > #marketMore[aria-expanded="true"] {
  background: var(--storefront-accent-soft, #eaf4fa);
  color: var(--storefront-accent-ink, #135879);
  border-color: var(--cx-accent, #0877b3);
}

#listings #ocListingTools.catalog-options:not([hidden]) {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 0;
  box-sizing: border-box;
  width: min(100%, 18rem);
  min-width: 0;
  height: auto;
  margin: 0 0 10px auto;
  padding: 6px;
  background: var(--theme-surface, #fff);
  border: 1px solid var(--theme-border, #dce5ed);
  border-radius: 12px;
  box-shadow: 0 7px 24px rgb(20 37 54 / 12%);
  color: var(--theme-text, #26394b);
  text-align: start;
}

#listings #ocListingTools[hidden] { display: none !important; }

#ocListingTools.catalog-options :is(a, button):not([hidden]) {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 42px;
  height: auto;
  margin: 0;
  padding: 9px 12px;
  border: 0;
  border-radius: 7px;
  box-shadow: none;
  background: transparent;
  color: var(--theme-text, #26394b);
  font: inherit;
  font-size: 14px;
  line-height: 1.35;
  font-weight: 500;
  text-align: start;
  text-decoration: none;
  white-space: normal;
  overflow-wrap: anywhere;
  cursor: pointer;
}

#ocListingTools.catalog-options :is([data-oc-action="compare"], #wantBrowse, #openMatches)::after {
  content: "";
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  margin-inline: auto 3px;
  border: solid currentColor;
  border-width: 1.5px 1.5px 0 0;
  opacity: .55;
  transform: rotate(45deg);
}

#ocListingTools.catalog-options .results-menu-footer {
  order: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid var(--theme-border, #dce5ed);
}

#ocListingTools.catalog-options .results-menu-footer > :is(a, button) {
  width: auto;
  font-size: 13px;
}

#ocListingTools.catalog-options .results-menu-footer > a { color: var(--storefront-accent-ink, #135879); }
#ocListingTools.catalog-options .results-menu-footer > button { color: var(--muted, #586370); }

#ocListingTools.catalog-options button[aria-pressed]::after {
  content: "";
  flex: 0 0 16px;
  box-sizing: border-box;
  width: 16px;
  height: 16px;
  margin-inline-start: auto;
  border: 1px solid currentColor;
  border-radius: 4px;
  opacity: .65;
}

#ocListingTools.catalog-options button[aria-pressed="true"]::after {
  content: "✓";
  border-color: #08699f;
  background: #08699f;
  color: white;
  opacity: 1;
  font-size: 12px;
  line-height: 14px;
  text-align: center;
}

#ocListingTools.catalog-options :is(a, button):focus-visible,
#filterResultsBar > #marketMore:focus-visible {
  outline: 2px solid var(--cx-accent, #0877b3);
  outline-offset: -2px;
}

@media (hover: hover) {
  #ocListingTools.catalog-options :is(a, button):not([hidden]):hover {
    background: var(--storefront-accent-soft, #eaf4fa);
    color: var(--storefront-accent-ink, #135879);
  }
}

@media (min-width: 769px) {
  @supports (anchor-name: --ollo-more) and (top: anchor(bottom)) {
    #filterResultsBar > #marketMore { anchor-name: --ollo-more; }
    #listings #filterResultsBar + #ocListingTools.catalog-options:not([hidden]) {
      position: absolute;
      position-anchor: --ollo-more;
      inset: auto anchor(right) auto auto;
      top: anchor(bottom);
      z-index: 15;
      margin: 5px 0 0;
    }
  }
}

@media (max-width: 768px) {
  #listings #filterResultsBar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, auto) auto;
    gap: 5px;
    align-items: center;
  }
  #filterResultsBar > #browseStatus { min-width: 0; }
  #filterResultsBar > #sortButton,
  #filterResultsBar > #marketMore {
    min-width: 44px;
    min-height: 44px;
    width: auto;
    padding-inline: 8px;
  }
  #listings #ocListingTools.catalog-options:not([hidden]) {
    position: static;
    width: 100%;
    margin: 0 0 10px;
    box-shadow: none;
  }
  #ocListingTools.catalog-options :is(.mobile-secondary-tools, .market-part-actions):not([hidden]) {
    display: contents;
  }
  #listings #ocListingTools .mobile-secondary-tools button:not([hidden]) {
    display: flex !important;
  }
  #listings #ocListingTools .mobile-secondary-tools .market-part-actions:has(button:not([hidden])):not([hidden]) {
    display: contents !important;
  }
  #ocListingTools.catalog-options :is(a, button):not([hidden]) { min-height: 44px; }
}

@media (max-width: 480px) {
  #listings #filterResultsBar {
    grid-template-columns: auto minmax(0, 1fr) auto;
    row-gap: 5px;
  }
  #listings #filterResultsBar > #browseStatus {
    grid-column: 1 / -1;
    width: 100%;
    white-space: normal;
  }
  #listings #filterResultsBar > #sortButton {
    width: 100%;
    max-width: none;
    justify-content: center;
    flex-wrap: nowrap;
    white-space: nowrap;
  }
  #listings #filterResultsBar > #sortButton [data-i18n] {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
