Improve colour contrast to meet WCAG 2.1 AA

Bring the SVG board and the text-mode faces up to WCAG 2.1 AA contrast.
Two oppositions drove the changes: no single ring colour meets 3:1 on
both a near-white card face and the dark-green felt, and no single
fixed suit/marker colour meets 4.5:1 on both a light and a dark Emacs
theme.  The rings therefore become haloed (bright core plus dark edge,
readable on either ground) and the theme-sensitive faces gain
light/dark variants.  Ratios are computed from the sRGB
relative-luminance formula.

* card-games-svg.el (card-games-svg-card): Draw the cursor highlight
as a haloed ring (dark edge, bright core) so it clears 3:1 on both a
card face and the felt; the old single gold ring was 1.63:1 on a card.
Draw the hint as a haloed dashed ring for the same reason, keeping the
dash pattern so it stays distinct by shape, not colour alone.
(card-games-svg-club-color): #1a8a3c -> #166534; four-colour clubs
were 4.35:1 on the card face, now 7.00:1.
(card-games-svg-hint-color): #27ae60 -> #7cf59a; 2.36:1 -> 4.97:1 on
felt.
(card-games-svg-gap-color): #95a5a6 -> #cbd5e1; 2.65:1 -> 4.57:1 on
felt (empty slots carry meaning in Gaps and Montana).

* card-games-core.el (card-games-red-suit): Add a dark-theme variant
(card-games-hint): Give light/dark variants (#207a3f on light, green3
bold on dark); green3 was 2.16:1 on white, now 5.36:1.
(card-games-gap): Give light/dark variants (#595959 light, #a6a6a6
dark); gray50 failed both themes, now about 7:1 light and 6:1 dark.

The card border and faint panel divider are left unchanged -- the card
face already contrasts the felt at 6.67:1, so card edges read
regardless -- and the SVG board's lack of an accessible name is covered
by the text/UNICODE rendering, the intended accessible alternative.

Assisted-by: Claude:claude-opus-4-8
This commit is contained in:
Corwin Brust 2026-08-04 09:45:56 -05:00
parent 99cf31930b
commit ff7a9f6e49
2 changed files with 29 additions and 9 deletions

View file

@ -254,16 +254,22 @@ With no seed the order is unpredictable (system `random')."
;;;; Shared faces
(defface card-games-red-suit '((t :foreground "red3"))
(defface card-games-red-suit
'((((background dark)) :foreground "#ff7961")
(t :foreground "red3"))
"Face for red-suited cards." :group 'card-games)
(defface card-games-cursor '((t :inverse-video t))
"Face for the cell or card under the cursor." :group 'card-games)
(defface card-games-gap '((t :foreground "gray50"))
(defface card-games-gap
'((((background dark)) :foreground "#a6a6a6")
(t :foreground "#595959"))
"Face for an empty slot." :group 'card-games)
(defface card-games-hint '((t :foreground "green3" :weight bold))
(defface card-games-hint
'((((background dark)) :foreground "green3" :weight bold)
(t :foreground "#207a3f" :weight bold))
"Face for a valid move target (a fillable gap)." :group 'card-games)
(defun card-games-color (face attribute fallback)