diff --git a/docs/settings-api.md b/docs/settings-api.md
index 09dec59ea1..997be9cd59 100644
--- a/docs/settings-api.md
+++ b/docs/settings-api.md
@@ -489,6 +489,12 @@ accent as stored. A stored value that is not a `#rgb` or
the web app manifest use it too. The branding document has no default theme
or light-theme logo URLs, and the API has no theme overrides or theme catalog.
+Text in the accent color (`text-primary`) doesn't use the stored value as is.
+The web client lightens the accent just enough to read at 4.5:1 on Cinema
+Dark's lightest surface and on the accent's own 20% tint, with a paler variant
+for high contrast. Fills and borders keep the stored color, as does the focus
+ring outside high contrast.
+
### Retired theme settings
Manifest revision 12 deprecates `ui.theme`, `ui.custom_theme_vars` and
diff --git a/web/docs/design-system.md b/web/docs/design-system.md
index f36e151e0b..bcb7b42db8 100644
--- a/web/docs/design-system.md
+++ b/web/docs/design-system.md
@@ -138,6 +138,7 @@ Colors are organized as semantic layers. `app.css` provides the actual values; c
- `--primary`: primary action color
- `--primary-foreground`: text on primary elements
+- `--primary-text`: the primary color as text, which `text-primary` uses. An admin accent sets it to the accent, lightened only as far as needed to read at 4.5:1 on Cinema Dark's surfaces; without one it is `--primary`. Draw accent-colored text with `text-primary`, never `var(--primary)`
- `--secondary`: secondary element backgrounds
- `--accent`: highlighted and active backgrounds
- `--destructive`: danger and error text, icons, borders, and status dots
diff --git a/web/src/app.css b/web/src/app.css
index 17914688eb..710739911a 100644
--- a/web/src/app.css
+++ b/web/src/app.css
@@ -57,6 +57,10 @@
/* ── Interactive ─────────────────────────────────────────── */
--color-primary: var(--primary);
--color-primary-foreground: var(--primary-foreground);
+ /* Text in the primary color. An admin accent sets --primary-text to a
+ variant that reads on Cinema Dark's surfaces (lib/accentColor.ts); fills,
+ borders, and rings keep the accent itself. */
+ --text-color-primary: var(--primary-text, var(--primary));
--color-secondary: var(--secondary);
--color-secondary-foreground: var(--secondary-foreground);
--color-muted: var(--muted);
diff --git a/web/src/components/admin/libraries/LibraryFormSections.tsx b/web/src/components/admin/libraries/LibraryFormSections.tsx
index 7651aa5726..2feab45ce4 100644
--- a/web/src/components/admin/libraries/LibraryFormSections.tsx
+++ b/web/src/components/admin/libraries/LibraryFormSections.tsx
@@ -331,7 +331,7 @@ function ProviderLevelSection({
type="button"
onClick={() => setCollapsed(!collapsed)}
aria-expanded={!collapsed}
- className="text-primary hover:text-primary/80 mb-1.5 flex min-h-11 items-center gap-1.5 text-start text-xs font-semibold tracking-wider uppercase sm:min-h-0"
+ className="text-primary mb-1.5 flex min-h-11 items-center gap-1.5 text-start text-xs font-semibold tracking-wider uppercase hover:underline sm:min-h-0"
>
{collapsed ? : }
{contentLevelLabel(level)}
diff --git a/web/src/components/watchlist/WatchlistTitlesTab.tsx b/web/src/components/watchlist/WatchlistTitlesTab.tsx
index 13a07de31e..91921ac7e6 100644
--- a/web/src/components/watchlist/WatchlistTitlesTab.tsx
+++ b/web/src/components/watchlist/WatchlistTitlesTab.tsx
@@ -101,7 +101,7 @@ export default function WatchlistTitlesTab({
{watchlistTitlesHint(watchlistRequests)}
{t("web.library.watchlist.findMore")}
diff --git a/web/src/contexts/BrandingProvider.tsx b/web/src/contexts/BrandingProvider.tsx
index c99d8fb750..d49c05ab3c 100644
--- a/web/src/contexts/BrandingProvider.tsx
+++ b/web/src/contexts/BrandingProvider.tsx
@@ -95,7 +95,8 @@ const ACCENT_STYLE_ID = "silo-accent";
* to , so it wins over the theme's layered tokens. That would also beat
* high contrast's boosted focus ring, so a second unlayered rule restores it:
* a dark accent must not hide keyboard focus for someone who asked for high
- * contrast.
+ * contrast. The same rule swaps accent text to the variant that reads on high
+ * contrast's lighter surfaces.
*/
function applyAccent(hex: string | null) {
if (typeof document === "undefined") return;
@@ -103,7 +104,9 @@ function applyAccent(hex: string | null) {
const css = declarations
? `:root {\n${Object.entries(declarations)
.map(([token, value]) => ` --${token}: ${value};`)
- .join("\n")}\n}\nhtml[data-high-contrast="true"] {\n --ring: var(--contrast-boost);\n}`
+ .join(
+ "\n",
+ )}\n}\nhtml[data-high-contrast="true"] {\n --ring: var(--contrast-boost);\n --primary-text: var(--primary-text-high-contrast);\n}`
: "";
let style = document.getElementById(ACCENT_STYLE_ID) as HTMLStyleElement | null;
if (!css) {
diff --git a/web/src/lib/accentColor.test.ts b/web/src/lib/accentColor.test.ts
index 7eb0fd784f..d96b0ac3b2 100644
--- a/web/src/lib/accentColor.test.ts
+++ b/web/src/lib/accentColor.test.ts
@@ -4,6 +4,9 @@ import { accentDeclarations } from "./accentColor";
/** Cinema Dark's labels on primary surfaces, drawn when the accent keeps the dark label. */
const THEME_LABEL = "#141417";
const THEME_SIDEBAR_LABEL = "#0f0f12";
+/** Cinema Dark's lightest surface under text (--surface-raised), and the same under high contrast. */
+const LIGHTEST_SURFACE = "#28282e";
+const LIGHTEST_SURFACE_HIGH_CONTRAST = "#535358";
function luminance(hex: string): number {
const value = parseInt(hex.slice(1), 16);
@@ -14,6 +17,17 @@ function luminance(hex: string): number {
return 0.2126 * channel(16) + 0.7152 * channel(8) + 0.0722 * channel(0);
}
+/** `bg-primary/20` over `surface`: the strongest accent tint text sits on. */
+function tint(accent: string, surface: string): string {
+ const a = parseInt(accent.slice(1), 16);
+ const b = parseInt(surface.slice(1), 16);
+ const channel = (shift: number) =>
+ Math.round(((a >> shift) & 0xff) * 0.2 + ((b >> shift) & 0xff) * 0.8)
+ .toString(16)
+ .padStart(2, "0");
+ return `#${channel(16)}${channel(8)}${channel(0)}`;
+}
+
function contrast(a: string, b: string): number {
const [light, dark] = [luminance(a), luminance(b)].sort((x, y) => y - x);
return (light! + 0.05) / (dark! + 0.05);
@@ -34,4 +48,21 @@ describe("accentDeclarations", () => {
expect(contrast(accent, sidebarLabel)).toBeGreaterThanOrEqual(4.5);
},
);
+
+ // Dark presets that fail as text, one that already reads, and the extremes.
+ it.each(["#4f46e5", "#8b5cf6", "#f59e0b", "#000000", "#ffffff"])(
+ "draws %s as text at 4.5:1 or more on Cinema Dark",
+ (accent) => {
+ const declarations = accentDeclarations(accent)!;
+ const variants: [string | undefined, string][] = [
+ [declarations["primary-text"], LIGHTEST_SURFACE],
+ [declarations["primary-text-high-contrast"], LIGHTEST_SURFACE_HIGH_CONTRAST],
+ ];
+ for (const [text, surface] of variants) {
+ expect(text).toBeDefined();
+ expect(contrast(text!, surface)).toBeGreaterThanOrEqual(4.5);
+ expect(contrast(text!, tint(accent, surface))).toBeGreaterThanOrEqual(4.5);
+ }
+ },
+ );
});
diff --git a/web/src/lib/accentColor.ts b/web/src/lib/accentColor.ts
index 683a64491e..c6dddd2f9f 100644
--- a/web/src/lib/accentColor.ts
+++ b/web/src/lib/accentColor.ts
@@ -49,17 +49,29 @@ function contrastRatio(a: string, b: string): number {
return (light! + 0.05) / (dark! + 0.05);
}
-function mixWithWhite(hex: string, amount: number): string {
- const value = parseInt(hex.slice(1), 16);
+/** Moves `hex` toward `target` by `amount` (0 keeps `hex`, 1 gives `target`). */
+function mixToward(hex: string, target: string, amount: number): string {
+ const from = parseInt(hex.slice(1), 16);
+ const to = parseInt(target.slice(1), 16);
const channel = (shift: number) => {
- const c = (value >> shift) & 0xff;
- return Math.round(c + (255 - c) * amount)
+ const a = (from >> shift) & 0xff;
+ const b = (to >> shift) & 0xff;
+ return Math.round(a + (b - a) * amount)
.toString(16)
.padStart(2, "0");
};
return `#${channel(16)}${channel(8)}${channel(0)}`;
}
+/** The accent mixed toward white in twentieths until `reads` accepts it, or white. */
+function lightenUntil(hex: string, reads: (candidate: string) => boolean): string {
+ for (let step = 0; step <= 20; step++) {
+ const candidate = mixToward(hex, WHITE_LABEL, step / 20);
+ if (reads(candidate)) return candidate;
+ }
+ return WHITE_LABEL;
+}
+
/** The label drawn on an accent: white or Cinema Dark's dark label, whichever reads better. */
function labelOn(hex: string): string {
return prefersWhiteLabel(hex) ? WHITE_LABEL : DARK_LABEL;
@@ -83,16 +95,37 @@ function primaryLabelOn(hex: string): string {
* badge) still reads.
*/
function accentOnDark(hex: string): string {
- for (let step = 0; step <= 20; step++) {
- const candidate = mixWithWhite(hex, step / 20);
- if (
+ return lightenUntil(
+ hex,
+ (candidate) =>
contrastRatio(candidate, PLAYER_PANEL) >= MIN_PLAYER_CONTRAST &&
- contrastRatio(candidate, labelOn(candidate)) >= MIN_PLAYER_CONTRAST
- ) {
- return candidate;
- }
- }
- return WHITE_LABEL;
+ contrastRatio(candidate, labelOn(candidate)) >= MIN_PLAYER_CONTRAST,
+ );
+}
+
+/** Cinema Dark's lightest surface under text, --surface-raised. */
+const LIGHTEST_SURFACE = "#28282e";
+/** High contrast mixes 20% of its white boost into --surface-raised (app.css). */
+const LIGHTEST_SURFACE_HIGH_CONTRAST = mixToward(LIGHTEST_SURFACE, WHITE_LABEL, 0.2);
+/** The strongest accent tint text sits on: `bg-primary/20`. */
+const STRONGEST_TINT = 0.2;
+/** WCAG AA for normal text. */
+const MIN_TEXT_CONTRAST = 4.5;
+
+/**
+ * The accent as text (`text-primary`) on Cinema Dark: unchanged when it
+ * already reads at 4.5:1 on `surface`, the lightest surface text sits on, and
+ * on the accent's own strongest tint over it; otherwise lightened just enough.
+ * Darker surfaces then read at least as well.
+ */
+function accentText(hex: string, surface: string): string {
+ const tint = mixToward(surface, hex, STRONGEST_TINT);
+ return lightenUntil(
+ hex,
+ (candidate) =>
+ contrastRatio(candidate, surface) >= MIN_TEXT_CONTRAST &&
+ contrastRatio(candidate, tint) >= MIN_TEXT_CONTRAST,
+ );
}
/**
@@ -113,6 +146,10 @@ export function accentDeclarations(accent: string): Record | nul
"sidebar-primary": hex,
"accent-on-dark": onDark,
"accent-on-dark-foreground": labelOn(onDark),
+ // app.css maps text-primary to --primary-text; BrandingProvider swaps in
+ // the high contrast value under that setting.
+ "primary-text": accentText(hex, LIGHTEST_SURFACE),
+ "primary-text-high-contrast": accentText(hex, LIGHTEST_SURFACE_HIGH_CONTRAST),
};
const label = primaryLabelOn(hex);
if (label !== DARK_LABEL) {
diff --git a/web/src/lib/upcomingEventPresentation.ts b/web/src/lib/upcomingEventPresentation.ts
index b47f1607bc..f9f163f4f5 100644
--- a/web/src/lib/upcomingEventPresentation.ts
+++ b/web/src/lib/upcomingEventPresentation.ts
@@ -36,7 +36,7 @@ export function upcomingBadgeClass(badge: string): string {
switch (badge) {
case "series_premiere":
case "season_premiere":
- return "border-primary/40 bg-primary/20 text-primary";
+ return "border-primary/40 bg-[color-mix(in_srgb,var(--primary)_12%,var(--background))] text-primary shadow-sm";
case "finale":
return "border-orange-800/55 bg-orange-950/90 text-orange-50 shadow-sm backdrop-blur-none";
case "digital":
diff --git a/web/src/pages/AdminPlaybackHistory.tsx b/web/src/pages/AdminPlaybackHistory.tsx
index 5813550f5b..d267ecee63 100644
--- a/web/src/pages/AdminPlaybackHistory.tsx
+++ b/web/src/pages/AdminPlaybackHistory.tsx
@@ -412,7 +412,7 @@ export default function AdminPlaybackHistory() {
{t("web.admin.activity.row.ffmpegLogs")}
diff --git a/web/src/pages/ItemDetail/components/EpisodeCardCaption.tsx b/web/src/pages/ItemDetail/components/EpisodeCardCaption.tsx
index 5e3b7a32e7..b899f060b2 100644
--- a/web/src/pages/ItemDetail/components/EpisodeCardCaption.tsx
+++ b/web/src/pages/ItemDetail/components/EpisodeCardCaption.tsx
@@ -1,6 +1,7 @@
import type { ReactNode } from "react";
import type { EpisodeListItem } from "@/api/types";
import { useAppLanguage } from "@/i18n";
+import { cn } from "@/lib/utils";
import MachineTranslatedLabel from "./MachineTranslatedLabel";
import { hasMachineTranslation } from "./machineTranslation";
import { episodeCardMetadata, episodeCardSpokenTitle, episodeCardTitle } from "./episodeCardText";
@@ -38,8 +39,10 @@ export default function EpisodeCardCaption({