suggest_contrast_fix
Given failing WCAG color pairs, computes the smallest foreground or background adjustment to meet AA or AAA contrast ratios. Provides concrete passing values instead of manual trial.
Instructions
Given failing WCAG color pairs, return the MINIMAL color change that clears the target ratio. For each {fg,bg} pair, computes the smallest foreground adjustment (and an alternative background adjustment) that reaches AA/AAA — with the achieved ratio and direction. Feeds directly from audit_contrast's failing pairs: pass them here to get concrete passing values instead of brute-forcing colors by hand. Pure offline math.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| level | No | WCAG level when targetRatio is not given per-pair. Default AA. | |
| pairs | No | Color pairs to remediate. Each: { selector?, fg, bg, fontPx?, bold?, targetRatio? }. fontPx/bold pick the large-text threshold; targetRatio overrides the level. |