/**
 * Rainz Accessibility — user-selected accessibility modes.
 * Original implementation by Rainz.ai (https://rainz.ai). GPL-2.0-or-later.
 */

/* 1. Keyboard navigation: strong visible focus everywhere (SC 2.4.7) */
body.rnz-keyboard a:focus,
body.rnz-keyboard button:focus,
body.rnz-keyboard input:focus,
body.rnz-keyboard select:focus,
body.rnz-keyboard textarea:focus,
body.rnz-keyboard [role="button"]:focus,
body.rnz-keyboard [tabindex]:focus {
	outline: 3px solid var(--rnz-primary, #100E33) !important;
	outline-offset: 2px !important;
	box-shadow: 0 0 0 6px rgba(255, 255, 255, .9) !important;
}

/* 2. Stop animations, transitions and smooth scrolling (SC 2.2.2 / 2.3.3) */
body.rnz-no-motion *,
body.rnz-no-motion *::before,
body.rnz-no-motion *::after {
	animation: none !important;
	transition: none !important;
	scroll-behavior: auto !important;
}
body.rnz-no-motion marquee { display: none !important; }

/* 3. High contrast: light background, near-black text, clear links (SC 1.4.3+) */
body.rnz-contrast *:not(#rnz-a11y-root):not(#rnz-a11y-root *):not(img):not(video):not(svg):not(svg *):not(iframe) {
	background-color: #FFFFFF !important;
	background-image: none !important;
	color: #0A0A0A !important;
	border-color: #0A0A0A !important;
	text-shadow: none !important;
	box-shadow: none !important;
}
body.rnz-contrast a:not(#rnz-a11y-root a) {
	color: #0000CC !important;
	text-decoration: underline !important;
}
body.rnz-contrast button:not(#rnz-a11y-root button),
body.rnz-contrast input[type="submit"],
body.rnz-contrast input[type="button"] {
	border: 2px solid #0A0A0A !important;
}

/* 4. Readable font (SC 1.4.8 support) */
body.rnz-readable *:not(#rnz-a11y-root):not(#rnz-a11y-root *):not(i):not([class*="icon"]):not([class*="fa-"]) {
	font-family: Arial, Helvetica, sans-serif !important;
	letter-spacing: .02em;
}

/* 5. Highlight headings (SC 2.4.6 support) */
body.rnz-titles h1,
body.rnz-titles h2,
body.rnz-titles h3,
body.rnz-titles h4,
body.rnz-titles h5,
body.rnz-titles h6 {
	background: #FFF3B0 !important;
	color: #0A0A0A !important;
	outline: 2px dashed #8A5A00 !important;
	outline-offset: 2px;
}

/* 6. Highlight links and buttons (SC 1.4.1 support) */
body.rnz-links a:not(#rnz-a11y-root a) {
	text-decoration: underline !important;
	text-underline-offset: 2px;
	outline: 2px solid #0000CC !important;
	outline-offset: 1px;
}
body.rnz-links button:not(#rnz-a11y-root button),
body.rnz-links [role="button"]:not(#rnz-a11y-root [role="button"]),
body.rnz-links input[type="submit"],
body.rnz-links input[type="button"] {
	outline: 2px solid #B00050 !important;
	outline-offset: 1px;
}

/* 7. Color-filter overlay (grayscale / invert) — backdrop-filter layer keeps
      position:fixed elements working, unlike a filter on html/body. */
#rnz-filter-layer {
	position: fixed;
	inset: 0;
	pointer-events: none;
	z-index: 999980; /* below the widget (999990/999991) */
}

/* 7b. Fallback for browsers without backdrop-filter */
html.rnz-fb-gray { filter: grayscale(1) !important; }
html.rnz-fb-invert { filter: invert(1) hue-rotate(180deg) !important; }
html.rnz-fb-gray.rnz-fb-invert { filter: grayscale(1) invert(1) hue-rotate(180deg) !important; }
html.rnz-fb-invert img,
html.rnz-fb-invert video,
html.rnz-fb-invert iframe,
html.rnz-fb-invert svg image {
	filter: invert(1) hue-rotate(180deg) !important; /* counter-invert media */
}

/* 8. Underline links (SC 1.4.1) */
body.rnz-underline a:not(#rnz-a11y-root a) {
	text-decoration: underline !important;
	text-underline-offset: 2px;
}

/* 9. Text spacing per WCAG 2.1 SC 1.4.12 */
body.rnz-spacing *:not(#rnz-a11y-root):not(#rnz-a11y-root *) {
	letter-spacing: .12em !important;
	word-spacing: .16em !important;
	line-height: 1.5 !important;
}
body.rnz-spacing p:not(#rnz-a11y-root p) { margin-bottom: 2em !important; }

/* 10. Big cursor — inline SVG, no external requests */
body.rnz-cursor,
body.rnz-cursor *:not(#rnz-a11y-root):not(#rnz-a11y-root *) {
	cursor: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'%3E%3Cpath d='M11 4 L11 36 L19 29 L24 42 L29 40 L24 27 L34 27 Z' fill='%23100E33' stroke='%23FFFFFF' stroke-width='2.5' stroke-linejoin='round'/%3E%3C/svg%3E") 11 4, auto !important;
}

/* 11. Reading guide bar */
#rnz-read-guide {
	position: fixed;
	left: 0;
	right: 0;
	height: 6px;
	background: var(--rnz-accent, #05D89E);
	border-radius: 3px;
	box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
	pointer-events: none;
	z-index: 999985;
}

/* Respect system-level reduced motion regardless of toggles */
@media (prefers-reduced-motion: reduce) {
	#rnz-a11y-root .rnz-trigger,
	#rnz-a11y-root .rnz-knob,
	#rnz-a11y-root .rnz-switch,
	#rnz-skip-link {
		transition: none !important;
	}
}
