/* --- Chips (js/components/chips.js) ------------------------------------------------------------ */

/* One small pill, four uses: a link chip (a genre on an album), a filter chip
   (button.chip[aria-pressed]), a removable chip in an editor, and a badge ("Admin",
   "No genre", "2 discs"). Lay them out in a .chip-row, a div or a list (ul > li).

   A chip's text is tag text as often as not (a genre can be in any script, and as long
   as a tag allows), so it is set in the content face and wraps rather than running out
   of the pill; a badge's fixed words are in the chrome face. */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}
.chip-row > li { min-width: 0; max-width: 100%; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  max-width: 100%;
  min-height: 1.75rem;
  padding: .25rem .625rem;
  background: var(--surface-3);
  color: var(--fg);
  border: 0;
  border-radius: var(--radius-pill);
  font: 500 var(--text-sm)/1.2 var(--font-ui);
  text-decoration: none;
  overflow-wrap: anywhere;
}

/* Link chip. */
a.chip { transition: background-color var(--motion-fast) var(--ease); }
a.chip:hover { background: rgba(255, 255, 255, .14); }

/* Filter chip: brass when on, which is also said by aria-pressed and the edge. */
button.chip { cursor: pointer; transition: background-color var(--motion-fast) var(--ease), color var(--motion-fast) var(--ease); }
button.chip:hover:not(:disabled) { background: rgba(255, 255, 255, .14); }
button.chip[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

/* Removable chip: the label, then a small close button named "Remove <label>". */
.chip-removable { min-height: 2rem; padding-top: 0; padding-bottom: 0; padding-right: 0; }
.chip-label { min-width: 0; }
.chip-remove.icon-btn-sm { position: relative; width: 2rem; height: 2rem; color: var(--fg-muted); }
.chip-remove.icon-btn-sm .icon { width: .875rem; height: .875rem; }

/* Badge: smaller, not interactive. Tones for the admin badge and a problem value. */
.chip-badge { min-height: 1.375rem; padding: .125rem .5rem; font-family: var(--font-chrome); font-size: var(--text-xs); }
.chip-accent { background: var(--accent-soft); color: var(--accent); }
.chip-danger { background: var(--danger-soft); color: var(--danger); }

/* A finger: interactive chips are taller and further apart; the remove button keeps a
   44px hit area through ::after without making the chip that tall. */
@media (pointer: coarse) {
  .chip-row { gap: var(--space-3); }
  a.chip, button.chip, .chip-removable { min-height: 2.25rem; }
  .chip-remove.icon-btn-sm { width: 2.25rem; height: 2.25rem; }
  .chip-remove.icon-btn-sm::after { content: ""; position: absolute; inset: -.25rem; }
}
