/*
 * Wagtail-style tag pills for multi-select tag fields (TagPillSelectMultiple).
 * Admin-only styling; not part of the public styleguide2.
 */

.tagpill-widget {
  max-width: 40rem;
}

.tagpill-filter {
  width: 100%;
  max-width: 24rem;
  margin-bottom: 0.75rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--w-color-border-field-default, #929292);
  border-radius: 0.3rem;
  background: var(--w-color-surface-field, #fff);
  color: var(--w-color-text-context, #1a1a1a);
  font-size: 0.95rem;
}

.tagpill-filter:focus {
  outline: none;
  border-color: var(--w-color-focus, #007d7e);
  box-shadow: 0 0 0 2px var(--w-color-focus, #007d7e);
}

.tagpill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tagpill-item {
  margin: 0;
  padding: 0;
}

/* The pill itself. The real checkbox is visually hidden inside the label. */
.tagpill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  padding: 0.35rem 0.85rem;
  border: 1px solid var(--w-color-border-field-default, #929292);
  border-radius: 999px;
  background: var(--w-color-surface-field, #fff);
  color: var(--w-color-text-context, #1a1a1a);
  font-size: 0.9rem;
  line-height: 1.2;
  cursor: pointer;
  transition: background-color 0.1s ease, border-color 0.1s ease,
    color 0.1s ease;
  user-select: none;
}

.tagpill input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.tagpill__label::before {
  content: "+";
  display: inline-block;
  margin-right: 0.3rem;
  font-weight: 700;
  opacity: 0.6;
}

.tagpill:hover {
  border-color: var(--w-color-focus, #007d7e);
}

/* Selected state. */
.tagpill:has(input:checked) {
  background: var(--w-color-secondary, #007d7e);
  border-color: var(--w-color-secondary, #007d7e);
  color: var(--w-color-white, #fff);
}

.tagpill:has(input:checked) .tagpill__label::before {
  content: "\2713"; /* check mark */
  opacity: 1;
}

/* Keyboard focus on the hidden checkbox highlights the pill. */
.tagpill:has(input:focus-visible) {
  outline: 2px solid var(--w-color-focus, #007d7e);
  outline-offset: 1px;
}

.tagpill-empty {
  margin: 0.5rem 0 0;
  color: var(--w-color-text-meta, #5b5b5b);
  font-style: italic;
}
