/* Shared states of text fields on every page (index.html and the editor pages), docs/UI-RULES.md.
   Linked right after tokens.css, so page styles can still restyle a field; they keep these two rules:

   1. Focus: one indicator. The field's own border turns accent and gets a soft 3px halo; no outline drawn outside
      it (an outline plus the field's border reads as two frames). Buttons and links keep the outline ring
      (community.css / style.css button:focus-visible).
   2. Autofill: Chrome paints autofilled fields light blue over our colours. A full-size inset shadow in the
      field's own background (--fc-field-bg, default surface) paints it back. A field with another background
      sets --fc-field-bg next to its background (and again for :focus if that changes it). */

:is(
  input:not([type]),
  input[type='text'],
  input[type='email'],
  input[type='password'],
  input[type='search'],
  input[type='url'],
  input[type='tel'],
  input[type='number'],
  input[type='date'],
  input[type='datetime-local'],
  input[type='time'],
  textarea,
  select
):focus-visible {
  outline: none;
  border-color: var(--fc-color-accent);
  box-shadow: 0 0 0 3px
    var(
      --fc-field-halo,
      color-mix(in srgb, var(--fc-color-accent) 22%, transparent)
    );
}

/* Separate rules: a browser that does not know one of the two pseudo-classes drops only that rule. */
input:-webkit-autofill,
textarea:-webkit-autofill,
select:-webkit-autofill {
  -webkit-text-fill-color: var(--fc-color-text);
  caret-color: var(--fc-color-text);
  box-shadow: inset 0 0 0 1000px var(--fc-field-bg, var(--fc-color-surface));
}
input:autofill,
textarea:autofill,
select:autofill {
  -webkit-text-fill-color: var(--fc-color-text);
  caret-color: var(--fc-color-text);
  box-shadow: inset 0 0 0 1000px var(--fc-field-bg, var(--fc-color-surface));
}
input:-webkit-autofill:focus-visible,
textarea:-webkit-autofill:focus-visible {
  box-shadow:
    inset 0 0 0 1000px var(--fc-field-bg, var(--fc-color-surface)),
    0 0 0 3px
      var(
        --fc-field-halo,
        color-mix(in srgb, var(--fc-color-accent) 22%, transparent)
      );
}
input:autofill:focus-visible,
textarea:autofill:focus-visible {
  box-shadow:
    inset 0 0 0 1000px var(--fc-field-bg, var(--fc-color-surface)),
    0 0 0 3px
      var(
        --fc-field-halo,
        color-mix(in srgb, var(--fc-color-accent) 22%, transparent)
      );
}
