/* ==========================================================================
   Tag input — type, press Enter or comma, and each value becomes a chip (chip.css):
     <input class="form-control" name="tags" value="design, admin" data-moey-tags>
   moey.js turns the field into chips; the form still sends one comma list
   ("design, admin"), so it works the same without JavaScript.
   ========================================================================== */

/* Tag input ----------------------------------------------------------------------- */
.tag-input {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .375rem;
  padding: .3125rem .375rem;
  cursor: text;
}
.tag-input:focus-within {
  border-color: var(--mo-theme-bg);
  box-shadow: 0 0 0 var(--mo-focus-ring-width) var(--mo-theme-focus-ring);
}
.tag-input > input[data-moey-tags] { display: none; }          /* the original field keeps the value */
.tag-input-field {
  flex: 1 0 6rem;
  min-width: 6rem;
  height: 1.625rem;
  padding: 0 .375rem;
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  outline: 0;
}
/* Inside a colored tag input the chips take its color, lightly */
.tag-input:is([class*="theme-"], [class*="chip-"]) .chip { --_chip-fg: var(--mo-theme-subtle-text); --_chip-bg: var(--mo-theme-subtle); }
.tag-input-field::placeholder { color: var(--mo-control-placeholder); opacity: 1; }
.tag-input .chip.is-armed { --_chip-bg: color-mix(in oklab, var(--mo-fg-body) 18%, transparent); }   /* Backspace once more removes it */
.tag-input .chip.is-duplicate { animation: mo-chip-nudge .4s; }
@keyframes mo-chip-nudge { 25% { translate: -3px 0; } 50% { translate: 3px 0; } 75% { translate: -2px 0; } }
@media (prefers-reduced-motion: reduce) { .tag-input .chip.is-duplicate { animation: none; outline: 2px solid var(--mo-theme-focus-ring); } }

.tag-input.is-full .tag-input-field { flex-basis: 0; min-width: 0; width: 0; padding: 0; }
.tag-input.is-disabled { color: var(--mo-fg-3); cursor: not-allowed; background-color: var(--mo-bg-1); border-color: var(--mo-border-color); }
.tag-input.is-disabled .chip-remove { display: none; }

.tag-input.form-control-sm .chip, .tag-input.form-control-sm .tag-input-field { height: 1.375rem; font-size: .75rem; }
.tag-input.form-control-lg .chip, .tag-input.form-control-lg .tag-input-field { height: 1.875rem; font-size: .875rem; }

/* Touch screens: the typing field stays at 16px at every size (no iPhone zoom) */
@media (pointer: coarse) { .tag-input .tag-input-field { font-size: 1rem; } }
