/**
 * SoftForge Form Protection: make the ALTCHA widget's text pass WCAG AAA (7:1).
 *
 * The ALTCHA widget (Akeeba ALTCHA 2.1.x, ALTCHA library 2.x) draws its text in whatever colour the
 * page happens to hand it (often a mid grey) and then fades the "Protected by ALTCHA" footer and the
 * logo with opacity .7. On a white page that is rgb(88,88,88) text, 3.45:1 for the link. This sheet
 * gives the widget its own text colours, footer link colour and background, through the custom
 * properties the widget itself reads (--altcha-color-*), and takes the opacity off. No opacity, no grey.
 *
 * The widget sits in the page (no shadow DOM), so these selectors reach it. Theme: the widget never
 * follows the visitor's operating-system setting on its own, because a light-only page would then get a
 * dark box. It uses the dark palette only when the page itself signals dark: data-theme="dark" or
 * data-bs-theme="dark" on an ancestor, the YOOtheme .uk-light class, or a .dark, .dark-mode or .theme-dark
 * ancestor class. Otherwise it uses the light palette. The widget carries its own background in both
 * palettes so the text is measured against a colour this sheet knows, not against whatever the page
 * happens to be.
 *
 * Ratios (WCAG 2 relative luminance):
 *   light  text #1a1a2e on #ffffff 17.06  link #16568e on #ffffff 7.62  error #a30000 on #ffffff 8.21
 *   dark   text #ffffff on #0d0d1a 19.27  link #7ab3ff on #0d0d1a 8.92  error #ff9b9b on #0d0d1a >8.4
 *
 * @copyright  (C) 2026 SoftForge Ltd
 * @license    GNU General Public License version 2 or later
 */

/* The palette values live on the themed element and are inherited, so the nearest themed ancestor wins.
 * The default is light. There is deliberately no prefers-color-scheme rule: the page decides. */
:root {
	--sf-altcha-base: #ffffff;
	--sf-altcha-text: #1a1a2e;
	--sf-altcha-link: #16568e;
	--sf-altcha-error: #a30000;
	--sf-altcha-border: #6b6b8a;
}

/* An explicit light theme on the page. */
[data-theme="light"],
[data-bs-theme="light"],
.uk-dark {
	--sf-altcha-base: #ffffff;
	--sf-altcha-text: #1a1a2e;
	--sf-altcha-link: #16568e;
	--sf-altcha-error: #a30000;
	--sf-altcha-border: #6b6b8a;
}

/* The page signals dark. Later in the file, so it wins a tie with the rules above. */
[data-theme="dark"],
[data-bs-theme="dark"],
.uk-light,
.dark,
.dark-mode,
.theme-dark {
	--sf-altcha-base: #0d0d1a;
	--sf-altcha-text: #ffffff;
	--sf-altcha-link: #7ab3ff;
	--sf-altcha-error: #ff9b9b;
	--sf-altcha-border: #9a9ab8;
}

/* The widget's own properties, read by the widget's stylesheet. */
altcha-widget {
	--altcha-color-base: var(--sf-altcha-base);
	--altcha-color-text: var(--sf-altcha-text);
	--altcha-color-border: var(--sf-altcha-border);
	--altcha-color-border-focus: var(--sf-altcha-text);
	--altcha-color-error-text: var(--sf-altcha-error);
	--altcha-color-footer-bg: transparent;
}

/* The widget fades the footer and the logo with opacity .7: the text must not be faded. */
altcha-widget .altcha-footer,
altcha-widget .altcha-logo {
	opacity: 1;
}

altcha-widget .altcha-footer a {
	color: var(--sf-altcha-link);
	text-decoration: underline;
}

/* The modal (overlay) form of the widget moves the widget inside .altcha-overlay and puts a close button
 * above it, outside the widget, over a half-transparent black backdrop. The widget's own sheet fades the
 * button to .7 and gives it the page colour, which cannot reach 7:1 over a mid-grey backdrop. Give it the
 * palette's own opaque background and text colour at full opacity (17:1 inside the button). */
.altcha-overlay .altcha-overlay-close-button {
	background: var(--sf-altcha-base);
	color: var(--sf-altcha-text);
	border: 1px solid var(--sf-altcha-border);
	opacity: 1;
}
