/* Un seul repère de focus, commun à toutes les pages. */
:root {
  --emi-focus-ink: #7c705c;
  --emi-focus-halo: #e6e0d4;
}

html[data-theme="dark"] {
  --emi-focus-ink: #d1c4aa;
  --emi-focus-halo: #655d4f;
}

/* Les actions restent repérables au clavier sans encadrement superposé. */
:root :is(a, button, summary, [role="button"], [tabindex]):focus-visible {
  outline: none;
  outline-offset: 0;
  box-shadow: inset 0 -2px 0 currentColor;
}

:root a[href]:focus-visible {
  box-shadow: none;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
}

/* Les champs soulignent leur propre bord, sans second rectangle intérieur. */
:root :is(input, textarea, select, [contenteditable="true"]):focus {
  outline: none;
  outline-offset: 0;
  border-color: var(--emi-focus-ink);
  box-shadow: inset 0 -1px 0 var(--emi-focus-ink);
}

:root .brand-select .brand-select__trigger:focus-visible {
  outline: none;
  border-color: var(--emi-focus-ink);
  box-shadow: inset 0 -1px 0 var(--emi-focus-ink);
}

/* Dans une barre composée, le repère appartient à l’ensemble du champ. */
:root :is(.search-form, .science-search, .forum-search):has(input:focus) {
  border-color: var(--emi-focus-ink);
  box-shadow: inset 0 -1px 0 var(--emi-focus-ink);
}

:root :is(.search-form, .science-search, .forum-search) input:focus {
  outline: none;
  box-shadow: none;
}

:root input:is([type="checkbox"], [type="radio"]):focus-visible {
  box-shadow: 0 0 0 2px var(--emi-focus-halo);
  outline: 1px solid var(--emi-focus-ink);
  outline-offset: 1px;
}

:root input:is([type="range"], [type="file"]):focus-visible {
  box-shadow: 0 2px 0 var(--emi-focus-ink);
}

/* Les couleurs système conservent un repère dans le mode de contraste forcé. */
@media (forced-colors: active) {
  :root :is(a, button, input, textarea, select, summary, [role="button"], [tabindex]):focus-visible:focus {
    outline: 2px solid Highlight;
    outline-offset: 2px;
    box-shadow: none;
  }
}
