/*
  One badge for every key:value tag. Secondary fill for metadata, outline for a choice
  that is off, ink fill when that choice is on. Keys are not color-coded.
*/

.tag-badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.tag-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  max-width: 100%;
  min-height: 1.75rem;
  padding: 0 var(--space-2);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: var(--bg-sunken);
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: 500;
  line-height: var(--text-xs-lh);
  color: var(--ink);
  text-align: start;
  text-decoration: none;
  text-wrap: pretty;
  overflow-wrap: anywhere;
  transition: background-color var(--duration-ui) var(--easing-ui);
}

.tag-badge__face {
  display: inline;
}

.tag-badge__face .tag-badge__value {
  margin-inline-start: var(--space-1);
}

a.tag-badge,
button.tag-badge,
label.tag-badge {
  cursor: pointer;
}

a.tag-badge:hover,
button.tag-badge:hover {
  background: var(--border);
  color: var(--ink);
}

.tag-badge--choice {
  background: transparent;
  border-color: var(--border);
}

label.tag-badge--choice:hover {
  background: var(--bg-sunken);
  color: var(--ink);
}

a.tag-badge--selected,
button.tag-badge--selected,
a.tag-badge--selected:hover,
button.tag-badge--selected:hover,
.tag-badge--selected,
.tag-badge--selected:hover,
label.tag-badge--choice:has(:checked),
label.tag-badge--choice:has(:checked):hover {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.tag-badge > input {
  margin: 0;
  accent-color: var(--ink);
}

.tag-badge--choice:has(:checked) > input {
  accent-color: var(--paper);
}

.tag-badge--field {
  padding: 0 var(--space-1) 0 var(--space-2);
  gap: var(--space-1);
}

.tag-badge__remove {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--ink);
  font-size: var(--text-sm);
  line-height: 1;
  cursor: pointer;
}

.tag-badge__remove:hover,
.tag-badge__remove:focus-visible {
  color: var(--ink);
}

@media (max-width: 48rem) {
  a.tag-badge,
  button.tag-badge,
  label.tag-badge {
    min-height: 2.75rem;
    padding-inline: var(--space-3);
    font-size: var(--text-sm);
  }
}

@media (prefers-reduced-motion: reduce) {
  .tag-badge {
    transition: none;
  }
}
