/*
 * A field whose value is a list of short words: regions, CPV codes, word stems, markers in a buyer's name.
 *
 * The value is carried by an ordinary textarea — comma-separated, submitted as is, readable without any script.
 * Once the script runs the textarea hides and the words stand as pills in a control of the field's own
 * geometry: each pill removes itself with its cross, the input at the end adds a word on Enter, a comma or on
 * leaving the field. A list written as text had to be read word by word to find one item; as pills the eye
 * counts them and finds the odd one out.
 */
.fs-tag-field {
  display: grid;
  min-width: 0;
}

.fs-tag-field.is-ready > .fs-tag-field__source {
  display: none;
}

.fs-tag-field__box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  box-sizing: border-box;
  min-height: var(--fs-control-height);
  padding: 5px 6px;
  background: var(--fs-color-field);
  border: 1px solid var(--fs-color-field-line);
  border-radius: var(--fs-radius-sm);
  cursor: text;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.fs-tag-field.is-disabled > .fs-tag-field__box {
  border-color: var(--fs-color-border);
  cursor: default;
}

@media (hover: hover) {
  .fs-tag-field:not(.is-disabled) > .fs-tag-field__box:hover {
    border-color: var(--fs-color-primary);
  }
}

.fs-tag-field:not(.is-disabled) > .fs-tag-field__box:focus-within {
  border-color: var(--fs-color-primary);
  box-shadow: var(--fs-focus-ring);
}

.fs-tag-field__tag {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  max-width: 100%;
  min-height: 26px;
  padding: 2px 4px 2px 10px;
  color: var(--fs-color-text);
  background: var(--fs-color-surface);
  border: 1px solid var(--fs-color-border);
  border-radius: var(--fs-radius-pill);
  font-size: var(--fs-text-sm);
  line-height: 1.3;
}

.fs-tag-field.is-disabled .fs-tag-field__tag {
  padding-right: 10px;
  color: var(--fs-color-text-secondary);
}

.fs-tag-field__tag > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The cross of a pill: a masked glyph, grey until it is pointed at. */
.fs-tag-field__remove {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  padding: 0;
  color: var(--fs-color-text-muted);
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

.fs-tag-field__remove::before {
  width: 12px;
  height: 12px;
  background: currentcolor;
  mask: url("/stoneware/icons/close.svg") center / contain no-repeat;
  content: "";
}

@media (hover: hover) {
  .fs-tag-field__remove:hover {
    color: var(--fs-color-danger);
    background: var(--fs-color-surface-hover);
  }
}

.fs-tag-field__remove:focus-visible {
  outline: 0;
  box-shadow: var(--fs-focus-ring);
}

/* The input is part of the box, so it carries none of a control's own frame. */
.fs-field .fs-tag-field__input,
.fs-tag-field__input {
  flex: 1 1 120px;
  width: auto;
  min-width: 120px;
  min-height: 28px;
  padding: 2px 6px;
  color: var(--fs-color-text);
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  font: inherit;
  font-size: var(--fs-control-font-size);
  outline: none;
}

.fs-tag-field__input::placeholder {
  color: var(--fs-color-text-muted);
}
