/* Canonical field focus. Load last, after page styles and light/dark themes.
   Only focus paint changes: existing borders keep their width and layout. */
:root {
  --field-focus-color:#be00fd;
  --field-focus-shadow:inset 0 0 0 1px var(--field-focus-color);
  --field-focus-outline:none;
}

/* A field's 1 px border plus 1 px inset produces a 2 px inward focus edge.
   Explicit overrides unify legacy dark themes, ID selectors and focus-visible
   rules without changing the field's background, text, padding or dimensions. */
:root :where(
  input:not([type="hidden" i]):not([type="checkbox" i]):not([type="radio" i]):not([type="range" i]):not([type="color" i]):not([type="file" i]):not([type="button" i]):not([type="submit" i]):not([type="reset" i]):not([type="image" i]),
  textarea,
  select
):focus,
:root :is(
  .single-trigger,
  .split-picker-trigger,
  .reporting-date-button,
  [data-field-trigger]
):is(:focus,[aria-expanded="true"]),
:root :is(
  .community-search-form,
  .opportunities-search,
  .support-chat-composer,
  .course-search,
  .global-search,
  .assignee-control,
  .tag-control,
  [data-field-control]
):focus-within {
  border-color:var(--field-focus-color)!important;
  box-shadow:var(--field-focus-shadow)!important;
  outline:var(--field-focus-outline)!important;
  outline-offset:-2px!important;
}

/* These compounds already own their border. Their borderless input must not
   create a second rectangle inside the focused wrapper. Embedded action
   buttons (send, clear, remove) retain their own keyboard focus treatment. */
:root :is(
  .community-search-form,
  .opportunities-search,
  .support-chat-composer,
  .course-search,
  .global-search,
  .assignee-control,
  .tag-control,
  [data-field-control]
) :where(input:not([type="hidden" i],[type="checkbox" i],[type="radio" i],[type="range" i],[type="color" i],[type="file" i],[type="button" i],[type="submit" i],[type="reset" i],[type="image" i]),textarea,select):focus,
:root :is(.assignee-control,.tag-control) > :is(.assignee-trigger,.tag-toggle):focus {
  border-color:transparent!important;
  box-shadow:none!important;
  outline:none!important;
}

/* High-contrast mode may suppress shadows. Keep a visible inward edge using
   the user's system highlight, with no external halo or layout shift. */
@media(forced-colors:active) {
  :root {
    --field-focus-color:Highlight;
    --field-focus-shadow:none;
    --field-focus-outline:2px solid Highlight;
  }
}
