/* An address in a field of several, with the cross that takes it out: the
   chips the `email-chips` controller draws into the client invitations and
   a client's email field. Zero specificity, so a block's own size wins. */

@layer components {
  :where(.chip) {
    align-items: center;
    background: var(--color-surface-tint);
    border-radius: var(--radius-pill);
    display: inline-flex;
    font-size: 0.875rem;
    font-weight: 600;
    gap: 0.25rem;
    max-inline-size: 100%;
    padding: 0.25rem 0.375rem 0.25rem 0.75rem;
  }

  :where(.chip.is-invalid) {
    background: var(--color-negative-tint);
    color: var(--color-negative);
  }

  :where(.chip__label) {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  :where(.chip__remove) {
    align-items: center;
    background: none;
    block-size: 1.25rem;
    border: none;
    border-radius: 50%;
    color: inherit;
    cursor: pointer;
    display: flex;
    flex: none;
    inline-size: 1.25rem;
    justify-content: center;

    &:hover {
      background: oklch(from var(--color-ink) l c h / 10%);
    }
  }

  /* ─── A client's addresses ──────────────── */

  /* The chips laid into a field the way the text field next to it is
     drawn, with the input for the next address after them; the field lights
     up as the input takes the focus. */
  .address-chips__field {
    align-items: center;
    cursor: text;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    min-block-size: var(--inv-input-height);
    padding-block: 0.25rem;
    padding-inline: 0.375rem;

    &:focus-within {
      border-color: var(--color-brand);
      box-shadow: var(--shadow-focus);
    }
  }

  /* A document past changing, or a seat that may only look, disables the
     field's controls with the fieldset around it: the addresses stay, read
     only, without the crosses and the input that would do nothing. */
  .address-chips__field:has(.address-chips__input:disabled) {
    color: var(--color-ink-muted);
    cursor: default;

    .chip__remove,
    .address-chips__input {
      display: none;
    }
  }

  .address-chips__chip {
    font-size: 0.8125rem;
    font-weight: 500;
    padding-block: 0.125rem;
  }

  .address-chips__input {
    background: none;
    border: none;
    color: var(--color-ink);
    flex: 1;
    font: inherit;
    font-size: 0.875rem;
    min-inline-size: 8rem;
    outline: none;
    padding-block: 0.25rem;
    padding-inline: 0.375rem;
  }
}
