/* Community sorting only. Keep the original select/options/change handler.
   Desktop enhancement uses the native customizable picker, not a div menu:
   https://developer.chrome.com/blog/a-customizable-select
   Touch, unsupported engines and forced colors keep the platform picker. */
#typewriterWorkshop .cw-community-page .cd-sort select {
  padding-inline: 12px;
  font-family: var(--cw-community-font-ui);
  font-weight: 500;
}
#typewriterWorkshop .cw-community-page .cd-sort select:focus-visible {
  outline: 2px solid var(--cw-community-focus);
  outline-offset: 3px;
  box-shadow: none;
}

@supports (appearance: base-select) {
  @media (hover: hover) and (pointer: fine) and (forced-colors: none) {
    #typewriterWorkshop .cw-community-page .cd-sort select,
    #typewriterWorkshop .cw-community-page .cd-sort select::picker(select) {
      appearance: base-select;
    }
    #typewriterWorkshop .cw-community-page .cd-sort select {
      display: inline-flex;
      align-items: center;
      gap: 10px;
      text-align: start;
    }
    #typewriterWorkshop .cw-community-page .cd-sort select::picker-icon {
      content: "";
      flex: none;
      width: 7px;
      height: 7px;
      margin-left: auto;
      margin-top: -3px;
      border-right: 1.5px solid currentColor;
      border-bottom: 1.5px solid currentColor;
      color: var(--cw-community-muted);
      transform: rotate(45deg);
    }
    #typewriterWorkshop .cw-community-page .cd-sort select:open::picker-icon {
      margin-top: 3px;
      transform: rotate(225deg);
    }
    #typewriterWorkshop .cw-community-page .cd-sort select:open {
      border-color: var(--cw-community-ink);
    }
    #typewriterWorkshop .cw-community-page .cd-sort select::picker(select) {
      box-sizing: border-box;
      min-width: 208px;
      max-width: calc(100vw - 24px);
      max-height: min(320px, 60vh);
      margin-top: 6px;
      padding: 6px;
      overflow: auto;
      border: 1px solid var(--cw-community-rule);
      border-radius: var(--cw-community-radius-inner);
      background: var(--cw-community-paper);
      color: var(--cw-community-ink);
      box-shadow: 0 8px 24px rgb(32 33 36 / 10%);
      font: 400 13px/1.4 var(--cw-community-font-ui);
    }
    #typewriterWorkshop .cw-community-page .cd-sort option {
      display: flex;
      align-items: center;
      gap: 10px;
      min-height: 44px;
      padding: 10px;
      border: 0;
      border-radius: 6px;
      background: transparent;
      color: var(--cw-community-ink);
      cursor: pointer;
      white-space: normal;
    }
    #typewriterWorkshop .cw-community-page .cd-sort option:checked {
      background: var(--cw-community-surface, #f0f1f2);
      font-weight: 600;
    }
    #typewriterWorkshop .cw-community-page .cd-sort option:hover {
      background: #eef0f2;
    }
    #typewriterWorkshop .cw-community-page .cd-sort option:focus-visible {
      outline: 2px solid var(--cw-community-focus);
      outline-offset: -2px;
    }
    #typewriterWorkshop .cw-community-page .cd-sort option::checkmark {
      order: 1;
      margin-left: auto;
      color: var(--cw-community-ink);
    }
  }
}
