/**
 * BFSG Accessibility Helper - Frontend Styles
 */

/* Skip Links */
.bfsg-skip-links {
	position: absolute;
	left: -9999px;
	top: 0;
	z-index: 999999;
}

.skip-link {
	background: #fff;
	color: #000;
	padding: 10px 15px;
	text-decoration: none;
	border: 2px solid #000;
	display: inline-block;
	font-weight: 600;
}

.skip-link:focus {
	position: absolute;
	left: 6px;
	top: 7px;
	z-index: 999999;
	outline: 3px solid #0073aa !important;
	outline-offset: 2px !important;
}

/* Screen Reader Text */
.screen-reader-text {
	clip: rect(1px, 1px, 1px, 1px);
	position: absolute !important;
	height: 1px;
	width: 1px;
	overflow: hidden;
	word-wrap: normal !important;
}

.screen-reader-text:focus {
	background-color: #f1f1f1;
	border-radius: 3px;
	box-shadow: 0 0 2px 2px rgba(0, 0, 0, 0.6);
	clip: auto !important;
	color: #21759b;
	display: block;
	font-size: 14px;
	font-weight: 600;
	height: auto;
	left: 5px;
	line-height: normal;
	padding: 15px 23px 14px;
	text-decoration: none;
	top: 5px;
	width: auto;
	z-index: 100000;
	outline: 3px solid #0073aa !important;
	outline-offset: 2px !important;
}

/* Accessibility Toolbar */
.bfsg-toolbar {
	position: fixed;
	right: 8px;
	bottom: 30px;
	z-index: 9999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.bfsg-toggle {
	background: var(--wp--preset--color--foreground);
	color: #fff;
	border: none;
	border-radius: 50%;
	width: 56px;
	height: 56px;
	cursor: pointer;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
	transition: all 0.3s ease;
	display: flex;
	align-items: center;
	justify-content: center;
}

.bfsg-toggle:hover {
	background: var(--wp--preset--color--primary);
	transform: scale(1.1);
}

.bfsg-toggle:focus {
	outline: 3px solid #005a87;
	outline-offset: 3px;
}

/* Bei Maus-Navigation kein Fokus-Ring für Toggle */
body.bfsg-mouse-navigation .bfsg-toggle:focus {
	outline: none;
}

.bfsg-toggle .dashicons {
	font-size: 28px;
	width: 28px;
	height: 28px;
}

.bfsg-toolbar-content {
	position: absolute;
	right: 0;
	background: #fff;
	padding: 20px;
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
	min-width: 280px;
	display: flex;
	flex-direction: column;
	z-index: -1 !important;
	border-top: 2px solid var(--wp--preset--color--secondary);
}

.bfsg-toolbar-content[hidden] {
	display: none;
	transform: translateY(-100vh);
}

.bfsg-tool {
	margin-bottom: 15px;
	padding-bottom: 15px;
}

.bfsg-tool:last-child {
	margin-bottom: 0;
	padding-bottom: 0;
	border-bottom: none;
}

.bfsg-tool label {
	display: block;
	font-weight: 600;
	margin-bottom: 8px;
	color: #333;
	font-size: 14px;
}

.bfsg-tool button {
	background: var(--wp--preset--color--lightgrey);
	border: none;
	padding: 8px 12px;
	margin-right: 5px;
	cursor: pointer;
	border-radius: 4px;
	font-size: 14px;
	transition: all 0.2s ease;
	display: inline-flex;
	gap: 0.5em;
	align-items: center;
}

.bfsg-tool button:not(.inline) {
	display: flex;
	width: 100%;
}

.bfsg-tool button:hover {
	background: #e0e0e0;
	border-color: #bbb;
}

.bfsg-tool button:focus {
	outline: 2px solid #0073aa;
	outline-offset: 2px;
}

/* Bei Maus-Navigation kein Fokus-Ring für Toolbar-Buttons */
body.bfsg-mouse-navigation .bfsg-tool button:focus {
	outline: none;
}

.bfsg-font-decrease,
.bfsg-font-reset,
.bfsg-font-increase {
	min-width: 35px;
	font-weight: 600;
}

.bfsg-reset-all {
	display: block;
	width: 100%;
	margin-top: 5px;
}

.bfsg-contrast-toggle.active {
	background: #333;
	color: #fff;
	border-color: #333;
}

/* High Contrast Mode */
body.bfsg-high-contrast {
	background: #000 !important;
	color: #fff !important;
}

body.bfsg-high-contrast * {
	background: #000 !important;
	color: #fff !important;
	border-color: #fff !important;
}

body.bfsg-high-contrast a {
	color: #ffff00 !important;
	text-decoration: underline !important;
}

body.bfsg-high-contrast a:hover,
body.bfsg-high-contrast a:focus {
	color: #ffffff !important;
	background: #0073aa !important;
}

body.bfsg-high-contrast button,
body.bfsg-high-contrast input[type="submit"],
body.bfsg-high-contrast input[type="button"] {
	background: #fff !important;
	color: #000 !important;
	border: 2px solid #fff !important;
}

body.bfsg-high-contrast img {
	opacity: 0.8 !important;
	border: 1px solid #fff !important;
}

/* Focus Improvements - nur bei Tastaturnavigation */
/* Standard: Kein Fokus-Ring */
*:focus {
	outline: none !important;
}

/* Fokus nur bei Keyboard-Navigation zeigen */
body.bfsg-keyboard-navigation *:focus:not(.bfsg-no-focus-outline) {
	outline: 3px solid #0073aa !important;
	outline-offset: 2px !important;
	box-shadow: 0 0 0 6px rgba(0, 115, 170, 0.1) !important;
}

/* Explizit kein Fokus bei Maus-Navigation */
body.bfsg-mouse-navigation *:focus,
.bfsg-no-focus-outline:focus {
	outline: none !important;
	box-shadow: none !important;
}

/* Focus-visible als Fallback für moderne Browser */
*:focus-visible {
	outline: 3px solid #0073aa !important;
	outline-offset: 2px !important;
}

/* Pointer-Input Klasse - alternativer Ansatz */
body.pointer-input *:focus {
	outline: none !important;
}

body:not(.pointer-input) *:focus {
	outline: 3px solid #0073aa !important;
	outline-offset: 2px !important;
}

/* Spezielle Elemente die immer Fokus zeigen sollten */
.skip-link:focus,
.bfsg-toolbar button:focus,
input:focus,
textarea:focus,
select:focus {
	/* Diese behalten den Fokus-Ring auch bei Mausklick für bessere Usability */
}

/* Tab-optimierte Seite - verstärkter Fokus bei Keyboard */
body.bfsg-tab-optimized.bfsg-keyboard-navigation *:focus {
	outline: 3px solid #0073aa !important;
	outline-offset: 2px !important;
	box-shadow: 0 0 0 6px rgba(0, 115, 170, 0.1) !important;
	transition: outline 0.2s, box-shadow 0.2s;
}

/* Keyboard Navigation Indicators - nur bei Tab-Navigation */
body.bfsg-keyboard-navigation a:focus,
body.bfsg-keyboard-navigation button:focus,
body.bfsg-keyboard-navigation input:focus,
body.bfsg-keyboard-navigation select:focus,
body.bfsg-keyboard-navigation textarea:focus {
	box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.5) !important;
}

/* Bei Maus-Navigation keine zusätzlichen Effekte */
body.bfsg-mouse-navigation a:focus,
body.bfsg-mouse-navigation button:focus {
	box-shadow: none !important;
}

/* Link Underlines for Better Visibility */
.bfsg-underline-links a {
	text-decoration: underline !important;
}

/* Content Warnings for Editors */
.bfsg-content-warnings {
	margin: 20px 0;
	padding: 15px;
	background: #fff3cd;
	border: 1px solid #ffc107;
	border-radius: 4px;
}

.bfsg-content-warnings strong {
	color: #856404;
	display: block;
	margin-bottom: 10px;
}

.bfsg-content-warnings ul {
	margin: 10px 0 0 20px;
	color: #856404;
}

/* Image Alt Text Warning */
img[data-bfsg-warning] {
	border: 3px solid #ff0000 !important;
	animation: bfsg-pulse 2s infinite;
}

@keyframes bfsg-pulse {
	0% {
		box-shadow: 0 0 0 0 rgba(255, 0, 0, 0.7);
	}
	70% {
		box-shadow: 0 0 0 10px rgba(255, 0, 0, 0);
	}
	100% {
		box-shadow: 0 0 0 0 rgba(255, 0, 0, 0);
	}
}

/* Alt-Text Warning Tooltip */
img[data-bfsg-warning]:hover::after {
	content: attr(data-bfsg-warning);
	position: absolute;
	background: #ff0000;
	color: white;
	padding: 5px 10px;
	border-radius: 4px;
	font-size: 12px;
	white-space: nowrap;
	z-index: 10000;
	bottom: 100%;
	left: 50%;
	transform: translateX(-50%);
	margin-bottom: 5px;
}

/* Admin Bar - Von Tab-Reihenfolge ausschließen */
#wpadminbar,
#wpadminbar * {
	/* Visueller Hinweis dass Admin-Bar nicht in Tab-Reihenfolge ist */
}

/* Admin-Bar Fokus nur bei Keyboard-Navigation */
body.bfsg-keyboard-navigation #wpadminbar *:focus {
	/* Fokus-Stil für Admin-Bar falls doch fokussiert */
	outline: 2px dashed #999 !important;
	outline-offset: -2px !important;
}

body.bfsg-mouse-navigation #wpadminbar *:focus {
	outline: none !important;
}

/* Tab Order Optimization - nur bei Keyboard */
body.bfsg-keyboard-navigation .bfsg-tab-focus {
	outline: 3px solid #0073aa !important;
	outline-offset: 3px !important;
	z-index: 9999;
}

/* Bei Maus kein spezieller Tab-Fokus */
body.bfsg-mouse-navigation .bfsg-tab-focus {
	outline: none !important;
}

/* Tab Order Visualizer */
.bfsg-tab-order-indicator {
	position: absolute;
	background: #ff0000;
	color: #fff;
	font-size: 11px;
	font-weight: bold;
	padding: 2px 5px;
	border-radius: 10px;
	z-index: 99999;
	pointer-events: none;
	box-shadow: 0 2px 4px rgba(0,0,0,0.3);
	min-width: 20px;
	text-align: center;
	line-height: 1;
	font-family: monospace;
}

.bfsg-tab-order-indicator.current {
	background: #00a32a;
	animation: pulse 1s infinite;
}

@keyframes pulse {
	0% { transform: scale(1); }
	50% { transform: scale(1.1); }
	100% { transform: scale(1); }
}

/* Tab Visualizer Toggle Button */
.bfsg-tab-visualizer-toggle {
	position: fixed;
	bottom: 100px;
	right: 20px;
	z-index: 99999;
	background: #0073aa;
	color: #fff;
	padding: 8px 12px;
	border-radius: 4px;
	border: none;
	cursor: pointer;
	font-size: 12px;
	box-shadow: 0 2px 5px rgba(0,0,0,0.2);
	transition: all 0.3s ease;
}

.bfsg-tab-visualizer-toggle:hover {
	background: #005a87;
	transform: translateY(-2px);
	box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

/* Improved Focus Indicators for Tab Navigation - nur bei Keyboard */
body.bfsg-tab-optimized.bfsg-keyboard-navigation *:focus {
	outline: 3px solid #0073aa !important;
	outline-offset: 2px !important;
	box-shadow: 0 0 0 6px rgba(0, 115, 170, 0.1) !important;
	transition: outline 0.2s, box-shadow 0.2s;
}

/* Bei Maus keine Animation/Transition */
body.bfsg-tab-optimized.bfsg-mouse-navigation *:focus {
	outline: none !important;
	box-shadow: none !important;
	transition: none !important;
}

/* Skip Link Improvements - immer sichtbar bei Fokus */
.skip-link:focus,
.skip-to-content:focus {
	position: fixed !important;
	top: 10px !important;
	left: 10px !important;
	z-index: 100000 !important;
	padding: 15px 20px !important;
	background: #0073aa !important;
	color: #fff !important;
	text-decoration: none !important;
	border-radius: 4px !important;
	box-shadow: 0 4px 6px rgba(0,0,0,0.1) !important;
	outline: 3px solid #fff !important;
	outline-offset: 2px !important;
}

/* Form Tab Order Indicators - nur bei Keyboard */
body.bfsg-keyboard-navigation form.bfsg-optimized input:focus,
body.bfsg-keyboard-navigation form.bfsg-optimized select:focus,
body.bfsg-keyboard-navigation form.bfsg-optimized textarea:focus {
	outline: 3px solid #0073aa !important;
	outline-offset: 2px !important;
	background-color: #f0f8ff !important;
}

/* Formularfelder behalten immer einen subtilen Fokus für bessere Usability */
input:focus,
select:focus,
textarea:focus {
	border-color: #0073aa !important;
}

/* Bei Maus-Navigation nur subtiler Rahmen */
body.bfsg-mouse-navigation input:focus,
body.bfsg-mouse-navigation select:focus,
body.bfsg-mouse-navigation textarea:focus {
	outline: none !important;
	border-color: #0073aa !important;
}

/* Modal Focus Trap Indicator - nur bei Keyboard */
body.bfsg-keyboard-navigation [role="dialog"]:focus,
body.bfsg-keyboard-navigation .modal:focus {
	outline: 4px dashed #ff6b6b !important;
	outline-offset: 4px !important;
}

body.bfsg-mouse-navigation [role="dialog"]:focus,
body.bfsg-mouse-navigation .modal:focus {
	outline: none !important;
}

/* Navigation Tab Order - nur bei Keyboard */
body.bfsg-keyboard-navigation nav a:focus,
body.bfsg-keyboard-navigation .navigation a:focus,
body.bfsg-keyboard-navigation .menu a:focus {
	background: rgba(0, 115, 170, 0.1) !important;
	outline: 2px solid #0073aa !important;
	outline-offset: 0 !important;
	text-decoration: underline !important;
}

/* Bei Maus-Navigation keine Hervorhebung */
body.bfsg-mouse-navigation nav a:focus,
body.bfsg-mouse-navigation .navigation a:focus,
body.bfsg-mouse-navigation .menu a:focus {
	outline: none !important;
	background: transparent !important;
}

/* Tab Order Debug Mode */
body.bfsg-tab-debug [tabindex] {
	position: relative;
}

body.bfsg-tab-debug [tabindex]::before {
	content: attr(tabindex);
	position: absolute;
	top: -20px;
	left: 0;
	background: #ff0000;
	color: #fff;
	font-size: 10px;
	padding: 2px 4px;
	border-radius: 2px;
	z-index: 10000;
	pointer-events: none;
}

/* Hidden but Focusable (for skip links) */
.visually-hidden-focusable {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	padding: 0 !important;
	margin: -1px !important;
	overflow: hidden !important;
	clip: rect(0,0,0,0) !important;
	white-space: nowrap !important;
	border: 0 !important;
}

.visually-hidden-focusable:focus {
	position: static !important;
	width: auto !important;
	height: auto !important;
	padding: inherit !important;
	margin: inherit !important;
	overflow: visible !important;
	clip: auto !important;
	white-space: normal !important;
	outline: 3px solid #0073aa !important;
	outline-offset: 2px !important;
}

/* Responsive Design */
@media (max-width: 768px) {
	.bfsg-toolbar {
		right: 10px;
		bottom: 10px;
	}
	
	.bfsg-toolbar-content {
		min-width: 250px;
		right: -10px;
	}
}

/* Print Styles */
@media print {
	.bfsg-toolbar,
	.bfsg-skip-links,
	.bfsg-content-warnings {
		display: none !important;
	}
}

/* Animation for Toolbar */
@keyframes slideIn {
	from {
		opacity: 0;
		transform: translateY(20px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.bfsg-toolbar-content {
	animation: slideIn 0.3s ease;
}

/* Ensure Visibility of Important Elements */
.bfsg-force-visible {
	opacity: 1 !important;
	visibility: visible !important;
	display: block !important;
}

/* Grauskala-Modus */
body.bfsg-grayscale {
	filter: grayscale(100%) !important;
	-webkit-filter: grayscale(100%) !important;
	-moz-filter: grayscale(100%) !important;
	-ms-filter: grayscale(100%) !important;
	-o-filter: grayscale(100%) !important;
}

/* Grauskala für alle Bilder und Videos verstärken */
body.bfsg-grayscale img,
body.bfsg-grayscale video,
body.bfsg-grayscale iframe,
body.bfsg-grayscale svg,
body.bfsg-grayscale picture,
body.bfsg-grayscale embed,
body.bfsg-grayscale object {
	filter: grayscale(100%) !important;
	-webkit-filter: grayscale(100%) !important;
}

/* Grauskala-Button aktiv */
.bfsg-grayscale-toggle.active {
	background: #666;
	color: #fff;
	border-color: #666;
}

.bfsg-grayscale-toggle svg {
	width: 20px;
	height: 20px;
	margin-right: 5px;
	vertical-align: middle;
}

/* Smooth Transition für Grauskala */
body {
	transition: filter 0.3s ease;
}

/* Erweiterte Grauskala mit CSS-Variablen für moderne Browser */
body.bfsg-grayscale {
	filter: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg'><filter id='grayscale'><feColorMatrix type='matrix' values='0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0'/></filter></svg>#grayscale") grayscale(100%);
}

/* Fallback für ältere Browser */
body.bfsg-grayscale {
	-webkit-filter: grayscale(1);
	filter: gray;
	filter: grayscale(1);
}

/* Exclude Admin Bar from grayscale */
body.bfsg-grayscale #wpadminbar {
	filter: none !important;
	-webkit-filter: none !important;
}

/* Smooth animation when toggling */
body,
body * {
	transition: filter 0.3s ease-in-out, -webkit-filter 0.3s ease-in-out;
}

/* Print styles - maintain grayscale in print */
@media print {
	body.bfsg-grayscale {
		filter: grayscale(100%) !important;
		-webkit-print-color-adjust: exact;
		color-adjust: exact;
	}
}


/* Link Underlines for Better Visibility */
.bfsg-underline-links a {
	text-decoration: underline !important;
	text-decoration-thickness: 2px !important;
	text-underline-offset: 0.2em !important;
}

.bfsg-underline-links a:hover {
	text-decoration-thickness: 3px !important;
}

/* Links unterstreichen Button aktiv */
.bfsg-underline-toggle.active {
	background: #0073aa;
	color: #fff;
	border-color: #0073aa;
}