Maps the Houses module onto the shared design system: tokens in 00-shared/02
(Design Tokens) and system mapping in 00-shared/04 (Design System Mapping).
The critical module problem: color is a free string stored on the server
(house.schema.ts:15-16) - the client must map it to design tokens safely.
Server stores any string (house.schema.ts:15-16); the client must never trust it
as a valid Color. Resolver order:
Exact match against a known palette table (name or hex) → token colour.
Hex parse (#RRGGBB, #RRGGBBAA) → validated; fall through on failure.
Unknown/named colour not in table → deterministic fallback: hash of code
picks a token from the house palette (stable per house, so lists don't shift).
Missing color → neutral token (surface-variant).
Color resolveHouseColor(String code, String? color) {
if (color != null) {
final hex = _tryParseHex(color);
if (hex != null) return hex;
final named = _palette[color.toLowerCase()];
if (named != null) return named;
}
return _palette.values.elementAt(code.hashCode % _palette.length); // stable fallback
}
Contrast: banner text is always onPrimary over a 24% black scrim - arbitrary
user colours pass AA by construction (00-shared/09).