/* ============================================================================
   COREVO Accessibility Panel
   ============================================================================ */

/* Visually hidden but readable by screen readers */
.corevo-a11y-sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* --------------------------------------------------------------------------
   Trigger button (fixed, bottom-left corner)
   -------------------------------------------------------------------------- */

.corevo-a11y-trigger {
	position: fixed;
	bottom: 24px;
	left: 24px;
	z-index: 9999;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 48px;
	padding: 0;
	border: 2px solid transparent;
	border-radius: 50%;
	background-color: #1a1a2e;
	color: #fff;
	cursor: pointer;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
	transition: background-color 0.2s, transform 0.2s;
}

.corevo-a11y-trigger:hover {
	background-color: #16213e;
	transform: scale(1.05);
}

.corevo-a11y-trigger:focus-visible {
	outline: 3px solid #ffbf00;
	outline-offset: 3px;
}

/* --------------------------------------------------------------------------
   Panel container
   -------------------------------------------------------------------------- */

.corevo-a11y-panel {
	position: fixed;
	bottom: 84px;
	left: 24px;
	z-index: 9998;
	width: 320px;
	max-width: calc(100vw - 48px);
	max-height: calc(100vh - 110px);
	display: flex;
	flex-direction: column;
	background-color: #fff;
	border: 1px solid #d0d0d0;
	border-radius: 8px;
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
	overflow: hidden;
	font-size: 14px;
	line-height: 1.4;
}

.corevo-a11y-panel-header,
.corevo-a11y-panel-footer {
	flex-shrink: 0;
}

.corevo-a11y-panel[hidden] {
	display: none;
}

/* --------------------------------------------------------------------------
   Panel header
   -------------------------------------------------------------------------- */

.corevo-a11y-panel-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 16px;
	background-color: #1a1a2e;
	color: #fff;
}

.corevo-a11y-panel-title {
	margin: 0;
	font-size: 14px;
	font-weight: 600;
	color: #fff;
}

.corevo-a11y-close {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 2px solid transparent;
	border-radius: 4px;
	background: transparent;
	color: #fff;
	cursor: pointer;
	flex-shrink: 0;
}

.corevo-a11y-close:hover {
	background-color: rgba(255, 255, 255, 0.15);
}

.corevo-a11y-close:focus-visible {
	outline: 3px solid #ffbf00;
	outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Controls area
   -------------------------------------------------------------------------- */

.corevo-a11y-panel-controls {
	display: flex;
	flex-direction: column;
	gap: 12px;
	padding: 12px 16px;
	overflow-y: auto;
	min-height: 0;
}

.corevo-a11y-group-label {
	display: block;
	margin-bottom: 6px;
	color: #444;
	font-size: 12px;
	font-weight: 600;
}

/* Steppers: [ - ] 120% [ + ] */
.corevo-a11y-stepper-row {
	display: flex;
	align-items: stretch;
	gap: 6px;
}

.corevo-a11y-stepper-row .corevo-a11y-action {
	flex: 1;
}

.corevo-a11y-stepper-value {
	display: flex;
	align-items: center;
	justify-content: center;
	min-width: 48px;
	color: #1a1a2e;
	font-size: 14px;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
	direction: ltr;
	unicode-bidi: isolate;
}

.corevo-a11y-toggle-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 6px;
}

/* Action buttons (Increase / Decrease text size) */
.corevo-a11y-action {
	padding: 8px 10px;
	border: 1px solid #c0c0c0;
	border-radius: 4px;
	background-color: #f5f5f5;
	color: #1a1a2e;
	font-size: 13px;
	cursor: pointer;
	text-align: center;
	transition: background-color 0.15s;
}

.corevo-a11y-action:hover:not(:disabled):not([aria-disabled="true"]) {
	background-color: #e8e8e8;
}

.corevo-a11y-action:focus-visible {
	outline: 3px solid #ffbf00;
	outline-offset: 2px;
}

.corevo-a11y-action:disabled,
.corevo-a11y-action[aria-disabled="true"] {
	opacity: 0.4;
	cursor: not-allowed;
}

/* Toggle buttons */
.corevo-a11y-toggle {
	padding: 8px 12px;
	border: 2px solid #c0c0c0;
	border-radius: 4px;
	background-color: #f5f5f5;
	color: #1a1a2e;
	font-size: 13px;
	text-align: start;
	cursor: pointer;
	transition: background-color 0.15s, border-color 0.15s;
}

.corevo-a11y-toggle:hover {
	background-color: #e8e8e8;
}

.corevo-a11y-toggle:focus-visible {
	outline: 3px solid #ffbf00;
	outline-offset: 2px;
}

/* Active state — non-color cue: border + background change (WCAG 1.4.1) */
.corevo-a11y-toggle[aria-pressed="true"] {
	border-color: #1a1a2e;
	background-color: #1a1a2e;
	color: #fff;
	font-weight: 600;
}

/* --------------------------------------------------------------------------
   Panel footer
   -------------------------------------------------------------------------- */

.corevo-a11y-panel-footer {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 10px 16px;
	border-top: 1px solid #e0e0e0;
	background-color: #fafafa;
	flex-wrap: wrap;
}

.corevo-a11y-reset {
	padding: 6px 10px;
	border: 1px solid #c0c0c0;
	border-radius: 4px;
	background-color: #fff;
	color: #555;
	font-size: 13px;
	cursor: pointer;
	transition: background-color 0.15s;
}

.corevo-a11y-reset:hover {
	background-color: #f0f0f0;
}

.corevo-a11y-reset:focus-visible {
	outline: 3px solid #ffbf00;
	outline-offset: 2px;
}

.corevo-a11y-statement-link {
	font-size: 13px;
	color: #1a1a2e;
	text-decoration: underline;
}

.corevo-a11y-statement-link:focus-visible {
	outline: 3px solid #ffbf00;
	outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Preference class effects on <html>
   -------------------------------------------------------------------------- */

/* Text size — fluid 100–200% in 10% steps. panel.js measures the theme's real
   root and body font sizes (custom properties *-base) and multiplies them, so
   62.5%-root themes and large body sizes scale up from their own baseline.
   Text the theme sizes in fixed px on other elements does not scale. */
html.corevo-a11y-text-scaled {
	font-size: calc(var(--corevo-a11y-text-scale, 1) * var(--corevo-a11y-root-base, 100%)) !important;
}

html.corevo-a11y-text-scaled.corevo-a11y-measured body {
	font-size: calc(var(--corevo-a11y-text-scale, 1) * var(--corevo-a11y-body-base)) !important;
}

/* Screen size — whole-page zoom; the panel counter-zooms to keep its size */
html.corevo-a11y-zoomed {
	zoom: var(--corevo-a11y-page-zoom, 1);
}

html.corevo-a11y-zoomed .corevo-a11y-trigger,
html.corevo-a11y-zoomed .corevo-a11y-panel,
html.corevo-a11y-zoomed .corevo-a11y-desc-tip {
	zoom: calc(1 / var(--corevo-a11y-page-zoom, 1));
}

/* Colour modes — mutually exclusive (one filter at a time) */
html.corevo-a11y-contrast   { filter: contrast(1.4); }
html.corevo-a11y-monochrome { filter: grayscale(1); }
html.corevo-a11y-sepia      { filter: sepia(1); }
html.corevo-a11y-invert     { filter: invert(1) hue-rotate(180deg); }

html.corevo-a11y-black-yellow body *:not(#corevo-a11y-trigger):not(#corevo-a11y-panel):not(#corevo-a11y-panel *):not(.corevo-a11y-desc-tip) {
	background-color: #000 !important;
	background-image: none !important;
	color: #ff0 !important;
	border-color: #ff0 !important;
}

html.corevo-a11y-black-yellow body {
	background-color: #000 !important;
	color: #ff0 !important;
}

html.corevo-a11y-black-yellow body a:not(#corevo-a11y-panel a) {
	text-decoration: underline !important;
}

/* Highlight links under black-and-yellow: keep the outline visible */
html.corevo-a11y-black-yellow.corevo-a11y-highlight-links a:not(#corevo-a11y-panel a),
html.corevo-a11y-black-yellow.corevo-a11y-highlight-headings :is(h1, h2, h3, h4, h5, h6):not(#corevo-a11y-panel *) {
	outline-color: #ff0 !important;
}

/* Underline all links */
html.corevo-a11y-underline-links a {
	text-decoration: underline !important;
}

/* Highlight links / headings — outline is the non-colour cue (WCAG 1.4.1) */
html.corevo-a11y-highlight-links a:not(#corevo-a11y-panel a) {
	background-color: #ffeb3b !important;
	color: #000 !important;
	outline: 2px solid #000 !important;
	outline-offset: 1px;
	text-decoration: underline !important;
}

html.corevo-a11y-highlight-headings :is(h1, h2, h3, h4, h5, h6):not(#corevo-a11y-panel *) {
	background-color: #ffeb3b !important;
	color: #000 !important;
	outline: 2px solid #000 !important;
	outline-offset: 2px;
}

/* Readable font — text elements only, so icon fonts keep working */
html.corevo-a11y-readable-font :is(body, p, li, a, span, div, h1, h2, h3, h4, h5, h6, td, th, label, input, textarea, select, button, blockquote, figcaption):not(.dashicons):not([class*="icon"]):not([class*="fa-"]):not(#corevo-a11y-panel *) {
	font-family: Arial, Helvetica, "Segoe UI", sans-serif !important;
	letter-spacing: 0.02em;
}

/* Cursors (interactive elements keep the native pointer) */
html.corevo-a11y-big-cursor,
html.corevo-a11y-big-cursor body *:not(a):not(button):not(input):not(select):not(textarea):not(label):not(summary):not([role="button"]) {
	cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 32 32'%3E%3Cpath d='M5 2v23l6-6 4 9 4-2-4-9h8z' fill='%23fff' stroke='%23000' stroke-width='2' stroke-linejoin='round'/%3E%3C/svg%3E") 7 3, auto !important;
}

html.corevo-a11y-black-cursor,
html.corevo-a11y-black-cursor body *:not(a):not(button):not(input):not(select):not(textarea):not(label):not(summary):not([role="button"]) {
	cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cpath d='M5 2v23l6-6 4 9 4-2-4-9h8z' fill='%23000' stroke='%23fff' stroke-width='2' stroke-linejoin='round'/%3E%3C/svg%3E") 5 2, auto !important;
}

html.corevo-a11y-big-cursor.corevo-a11y-black-cursor,
html.corevo-a11y-big-cursor.corevo-a11y-black-cursor body *:not(a):not(button):not(input):not(select):not(textarea):not(label):not(summary):not([role="button"]) {
	cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 32 32'%3E%3Cpath d='M5 2v23l6-6 4 9 4-2-4-9h8z' fill='%23000' stroke='%23fff' stroke-width='2' stroke-linejoin='round'/%3E%3C/svg%3E") 7 3, auto !important;
}

/* Keyboard navigation — strong, always-visible focus indicator */
html.corevo-a11y-keyboard-nav :focus,
html.corevo-a11y-keyboard-nav :focus-visible {
	outline: 4px solid #ffbf00 !important;
	outline-offset: 3px !important;
	box-shadow: 0 0 0 7px #000 !important;
}

/* Description tooltip (hover/focus) and fixed bar */
.corevo-a11y-desc-tip {
	position: fixed;
	z-index: 9997;
	display: none;
	max-width: min(360px, calc(100vw - 16px));
	padding: 8px 12px;
	border: 2px solid #fff;
	border-radius: 4px;
	background-color: #1a1a2e;
	color: #fff;
	font: 600 14px/1.4 Arial, Helvetica, sans-serif;
	pointer-events: none;
	overflow-wrap: anywhere;
}

.corevo-a11y-desc-tip--fixed {
	right: 0;
	bottom: 0;
	left: 0;
	max-width: none;
	border-width: 2px 0 0;
	border-radius: 0;
	text-align: center;
}

/* Reduce motion */
html.corevo-a11y-reduce-motion *,
html.corevo-a11y-reduce-motion *::before,
html.corevo-a11y-reduce-motion *::after {
	animation-duration: 0.001ms !important;
	animation-iteration-count: 1 !important;
	transition-duration: 0.001ms !important;
	scroll-behavior: auto !important;
}

/* --------------------------------------------------------------------------
   Respect native prefers-reduced-motion
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
	* {
		animation-duration: 0.001ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.001ms !important;
		scroll-behavior: auto !important;
	}

	.corevo-a11y-trigger,
	.corevo-a11y-action,
	.corevo-a11y-toggle,
	.corevo-a11y-reset {
		transition: none;
	}
}

/* --------------------------------------------------------------------------
   Contrast mode — ensure panel focus indicators remain visible after filter
   filter: contrast(1.4) is applied to <html>; compensate with a brighter
   outline so the post-filter rendered colour stays above WCAG 1.4.11 3:1.
   -------------------------------------------------------------------------- */

html.corevo-a11y-contrast .corevo-a11y-trigger:focus-visible,
html.corevo-a11y-contrast .corevo-a11y-panel *:focus-visible {
	outline-color: #fff200;
}

/* --------------------------------------------------------------------------
   Position variants
   (bottom-left is the default, covered by base rules above)
   -------------------------------------------------------------------------- */

/* Bottom-right */
.corevo-a11y-trigger.corevo-a11y-pos-bottom-right {
	left: auto;
	right: 24px;
}

.corevo-a11y-panel.corevo-a11y-pos-bottom-right {
	left: auto;
	right: 24px;
}

/* Bottom-left — matches base, declared explicitly for completeness */
.corevo-a11y-trigger.corevo-a11y-pos-bottom-left {
	right: auto;
	left: 24px;
}

.corevo-a11y-panel.corevo-a11y-pos-bottom-left {
	right: auto;
	left: 24px;
}

/* Top-right */
.corevo-a11y-trigger.corevo-a11y-pos-top-right {
	bottom: auto;
	top: 24px;
}

.corevo-a11y-panel.corevo-a11y-pos-top-right {
	bottom: auto;
	top: 80px;
}

/* Top-left */
.corevo-a11y-trigger.corevo-a11y-pos-top-left {
	bottom: auto;
	top: 24px;
	right: auto;
	left: 24px;
}

.corevo-a11y-panel.corevo-a11y-pos-top-left {
	bottom: auto;
	top: 80px;
	right: auto;
	left: 24px;
}

/* --------------------------------------------------------------------------
   RTL support
   -------------------------------------------------------------------------- */

[dir="rtl"] .corevo-a11y-trigger {
	left: auto;
	right: 24px;
}

[dir="rtl"] .corevo-a11y-panel {
	left: auto;
	right: 24px;
}

/* RTL overrides for explicit position variants */
[dir="rtl"] .corevo-a11y-trigger.corevo-a11y-pos-bottom-right,
[dir="rtl"] .corevo-a11y-panel.corevo-a11y-pos-bottom-right {
	right: auto;
	left: 24px;
}

[dir="rtl"] .corevo-a11y-trigger.corevo-a11y-pos-top-right,
[dir="rtl"] .corevo-a11y-panel.corevo-a11y-pos-top-right {
	left: 24px;
	right: auto;
}

[dir="rtl"] .corevo-a11y-trigger.corevo-a11y-pos-top-left,
[dir="rtl"] .corevo-a11y-panel.corevo-a11y-pos-top-left {
	left: auto;
	right: 24px;
}

@media (max-width: 400px) {
	.corevo-a11y-toggle-grid {
		grid-template-columns: 1fr;
	}
}
