/**
 * Accessibility Assistant — frontend toolbar styles
 * Uses CSS custom properties for all theme-able values.
 * Zero !important overrides except where semantically required.
 */

/* ============================================================
   Custom properties — override these to theme the toolbar
   ============================================================ */

:root {
	--aa-z:              999999;
	--aa-trigger-size:   52px;
	--aa-trigger-bg:     #2a2a2a;
	--aa-trigger-color:  #ffffff;
	--aa-trigger-radius: 50%;
	--aa-panel-bg:       #ffffff;
	--aa-panel-border:   #d0d0d0;
	--aa-panel-shadow:   0 4px 24px rgba(0, 0, 0, 0.18);
	--aa-panel-radius:   12px;
	--aa-panel-width:    280px;
	--aa-text-primary:   #1a1a1a;
	--aa-text-muted:     #555555;
	--aa-btn-bg:         #f4f4f4;
	--aa-btn-bg-active:  #2a2a2a;
	--aa-btn-color:      #1a1a1a;
	--aa-btn-color-active: #ffffff;
	--aa-btn-border:     #cccccc;
	--aa-accent:         #4a9eff;
	--aa-gap:            8px;
	--aa-font-scale:     1;
	--aa-guide-color:    rgba(74, 158, 255, 0.25);
	--aa-guide-height:   32px;
	--aa-focus-color:    #0000ff;
}

/* ============================================================
   Toolbar container
   ============================================================ */

.aa-toolbar {
	position: fixed;
	bottom: 20px;
	z-index: var(--aa-z);
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 8px;
}

.aa-toolbar.aa-pos-bottom-right {
	right: 20px;
	align-items: flex-end;
}

.aa-toolbar.aa-pos-bottom-left {
	left: 20px;
	align-items: flex-start;
}

/* ============================================================
   Trigger button
   ============================================================ */

.aa-trigger {
	display: flex;
	align-items: center;
	gap: 8px;
	min-width: var(--aa-trigger-size);
	min-height: var(--aa-trigger-size);
	padding: 0 16px;
	background: var(--aa-trigger-bg);
	color: var(--aa-trigger-color);
	border: none;
	border-radius: 26px;
	cursor: pointer;
	font-size: 14px;
	font-weight: 600;
	font-family: inherit;
	line-height: 1;
	white-space: nowrap;
	transition: transform 0.15s ease, box-shadow 0.15s ease;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

.aa-trigger:hover {
	transform: translateY(-1px);
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}

.aa-trigger:focus-visible {
	outline: 3px solid var(--aa-accent);
	outline-offset: 3px;
}

.aa-trigger-icon {
	flex-shrink: 0;
	color: var(--aa-trigger-color);
}

.aa-trigger-label {
	font-size: 14px;
	font-weight: 600;
}

/* ============================================================
   Panel
   ============================================================ */

.aa-panel {
	background: var(--aa-panel-bg);
	border: 1px solid var(--aa-panel-border);
	border-radius: var(--aa-panel-radius);
	box-shadow: var(--aa-panel-shadow);
	width: var(--aa-panel-width);
	max-height: 70vh;
	overflow-y: auto;
	overscroll-behavior: contain;
}

/* Hide via [hidden] attribute — no JS inline styles for visibility */
.aa-panel[hidden] {
	display: none;
}

.aa-panel-inner {
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 12px;
}

/* ============================================================
   Groups (fieldset/legend)
   ============================================================ */

.aa-group {
	border: none;
	margin: 0;
	padding: 0;
}

.aa-group-legend {
	font-size: 11px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--aa-text-muted);
	margin-bottom: 6px;
	padding: 0;
	width: 100%;
}

.aa-group-controls {
	display: flex;
	flex-wrap: wrap;
	gap: var(--aa-gap);
}

.aa-toggle-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: var(--aa-gap);
}

/* ============================================================
   Buttons
   ============================================================ */

.aa-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 5px;
	background: var(--aa-btn-bg);
	color: var(--aa-btn-color);
	border: 1px solid var(--aa-btn-border);
	border-radius: 6px;
	padding: 7px 10px;
	font-size: 12px;
	font-family: inherit;
	font-weight: 500;
	cursor: pointer;
	line-height: 1.3;
	text-align: center;
	transition: background 0.1s, color 0.1s;
}

.aa-btn:hover {
	background: #e8e8e8;
}

.aa-btn:focus-visible {
	outline: 3px solid var(--aa-accent);
	outline-offset: 2px;
}

/* Toggle active state */
.aa-toggle[aria-pressed="true"] {
	background: var(--aa-btn-bg-active);
	color: var(--aa-btn-color-active);
	border-color: var(--aa-btn-bg-active);
}

/* Icon-only size buttons */
.aa-btn-icon {
	width: 36px;
	height: 36px;
	padding: 0;
	flex-shrink: 0;
}

.aa-btn-text-sm {
	font-size: 11px;
	padding: 6px 10px;
}

/* Text size controls row */
.aa-text-size-controls {
	align-items: center;
	flex-wrap: nowrap;
}

.aa-text-scale-display {
	font-size: 12px;
	color: var(--aa-text-muted);
	min-width: 36px;
	text-align: center;
	flex-shrink: 0;
}

/* Reset all button */
.aa-reset-row {
	padding-top: 4px;
	border-top: 1px solid var(--aa-panel-border);
}

.aa-btn-reset-all {
	width: 100%;
	justify-content: center;
	font-size: 12px;
	color: var(--aa-text-muted);
	background: transparent;
	border: 1px solid var(--aa-btn-border);
}

.aa-btn-reset-all:hover {
	background: #f8f8f8;
	color: var(--aa-text-primary);
}

/* ============================================================
   Reading guide bar
   ============================================================ */

#aa-reading-guide-bar {
	position: fixed;
	left: 0;
	width: 100%;
	height: var(--aa-guide-height);
	background: var(--aa-guide-color);
	border-top: 1px solid rgba(74, 158, 255, 0.4);
	border-bottom: 1px solid rgba(74, 158, 255, 0.4);
	pointer-events: none;
	z-index: calc(var(--aa-z) - 1);
	transform: translateY(-50%);
}

/* ============================================================
   High contrast mode
   ============================================================ */

html.aa-high-contrast body {
	background: #000000 !important;
	color: #ffffff !important;
}

html.aa-high-contrast a {
	color: #ffff00 !important;
}

/* Bug 1: Top header bar has an orange background — white is readable there, yellow is not */
html.aa-high-contrast #top-header a,
html.aa-high-contrast #top-header {
	color: #ffffff !important;
}

/* Bug 2: Footer area keeps a light background that Divi's inline styles protect.
   Use black + underline for links on light backgrounds in high-contrast mode. */
html.aa-high-contrast #main-footer a,
html.aa-high-contrast #footer-widgets a {
	color: #000000 !important;
	text-decoration: underline !important;
}

html.aa-high-contrast button,
html.aa-high-contrast input,
html.aa-high-contrast select,
html.aa-high-contrast textarea {
	background: #000000 !important;
	color: #ffffff !important;
	border: 2px solid #ffffff !important;
}

/* Bug 3: Placeholder text is a separate pseudo-element — must be targeted explicitly */
html.aa-high-contrast input::placeholder,
html.aa-high-contrast textarea::placeholder {
	color: #ffffff !important;
	opacity: 1 !important;
}

html.aa-high-contrast img {
	filter: contrast(1.3);
}

/* Keep the toolbar readable in high-contrast mode */
html.aa-high-contrast .aa-trigger {
	background: #ffff00 !important;
	color: #000000 !important;
}

html.aa-high-contrast .aa-panel {
	background: #000000 !important;
	border-color: #ffffff !important;
	color: #ffffff !important;
}

html.aa-high-contrast .aa-btn {
	background: #000000 !important;
	color: #ffffff !important;
	border-color: #ffffff !important;
}

html.aa-high-contrast .aa-toggle[aria-pressed="true"] {
	background: #ffff00 !important;
	color: #000000 !important;
}

html.aa-high-contrast .aa-group-legend {
	color: #cccccc !important;
}

/* ============================================================
   Dark mode
   ============================================================ */

/* Page-level elements — body + Divi's structural wrappers.
   Doubled-class selectors (.et_pb_section.et_pb_section) give specificity (0,3,0)
   which beats Divi's (0,2,0) generated rules even when both use !important. */
html.aa-dark-mode body,
html.aa-dark-mode .et_pb_section.et_pb_section,
html.aa-dark-mode .et_pb_row.et_pb_row,
html.aa-dark-mode .et_pb_column.et_pb_column,
html.aa-dark-mode .et_pb_module.et_pb_module,
html.aa-dark-mode .et-l,
html.aa-dark-mode .et-l--header,
html.aa-dark-mode .et-l--footer,
html.aa-dark-mode [data-et-multi-view] {
	background-color: #121212 !important;
	color: #e8e8e8 !important;
}

/* Bug 4A: .ptcc case example cards — CSS fix is more reliable than JS for Divi-deferred timing */
html.aa-dark-mode .ptcc {
	background-color: #1e1e1e !important;
	color: #e8e8e8 !important;
}
html.aa-dark-mode .ptcc * {
	color: #e8e8e8 !important;
}

/* Text-bearing elements */
html.aa-dark-mode h1,
html.aa-dark-mode h2,
html.aa-dark-mode h3,
html.aa-dark-mode h4,
html.aa-dark-mode h5,
html.aa-dark-mode h6,
html.aa-dark-mode p,
html.aa-dark-mode li,
html.aa-dark-mode td,
html.aa-dark-mode th,
html.aa-dark-mode span,
html.aa-dark-mode div,
html.aa-dark-mode label {
	color: #e8e8e8 !important;
}

html.aa-dark-mode a {
	color: #7eb8ff !important;
}

/* Form controls */
html.aa-dark-mode input,
html.aa-dark-mode textarea,
html.aa-dark-mode select {
	background-color: #1e1e1e !important;
	color: #e8e8e8 !important;
	border-color: #444444 !important;
}

/* Non-toolbar buttons */
html.aa-dark-mode button:not(.aa-btn):not(.aa-trigger) {
	background-color: #2c2c2c !important;
	color: #e8e8e8 !important;
	border-color: #444444 !important;
}

/* ---- Toolbar itself in dark mode ---- */

html.aa-dark-mode .aa-panel {
	background-color: #1e1e1e !important;
	border-color: #3a3a3a !important;
	color: #e8e8e8 !important;
}

html.aa-dark-mode .aa-btn {
	background-color: #2c2c2c !important;
	color: #e8e8e8 !important;
	border-color: #444444 !important;
}

html.aa-dark-mode .aa-btn:hover {
	background-color: #383838 !important;
}

html.aa-dark-mode .aa-toggle[aria-pressed="true"] {
	background-color: #4a9eff !important;
	color: #ffffff !important;
	border-color: #4a9eff !important;
}

html.aa-dark-mode .aa-group-legend {
	color: #999999 !important;
}

html.aa-dark-mode .aa-btn-reset-all {
	border-color: #444444 !important;
	color: #999999 !important;
}

html.aa-dark-mode .aa-text-scale-display {
	color: #999999 !important;
}

html.aa-dark-mode .aa-reset-row {
	border-top-color: #3a3a3a !important;
}

/* ============================================================
   Grayscale
   ============================================================ */

html.aa-grayscale body {
	filter: grayscale(100%) !important;
}

/* Toolbar is moved to <html> by JS when grayscale is active, so it sits
   outside the filtered body and position: fixed works correctly. */

/* ============================================================
   Highlight links
   ============================================================ */

html.aa-highlight-links a {
	text-decoration: underline !important;
	outline: 2px solid currentColor;
	outline-offset: 1px;
	border-radius: 2px;
}

/* ============================================================
   Highlight headings
   ============================================================ */

html.aa-highlight-headings h1,
html.aa-highlight-headings h2,
html.aa-highlight-headings h3,
html.aa-highlight-headings h4,
html.aa-highlight-headings h5,
html.aa-highlight-headings h6 {
	outline: 2px dashed #0066cc;
	outline-offset: 3px;
	background: rgba(0, 102, 204, 0.07);
	border-radius: 2px;
}

/* ============================================================
   Dyslexia-friendly font (system fonts only, no external requests)
   ============================================================ */

html.aa-dyslexia-font,
html.aa-dyslexia-font body,
html.aa-dyslexia-font p,
html.aa-dyslexia-font li,
html.aa-dyslexia-font td,
html.aa-dyslexia-font th,
html.aa-dyslexia-font input,
html.aa-dyslexia-font textarea,
html.aa-dyslexia-font select,
html.aa-dyslexia-font button {
	font-family: "Comic Sans MS", "Comic Sans", "Trebuchet MS", "Arial", sans-serif !important;
	letter-spacing: 0.03em;
	word-spacing: 0.12em;
	line-height: 1.75;
}

/* ============================================================
   Pause animations
   ============================================================ */

html.aa-pause-animations *,
html.aa-pause-animations *::before,
html.aa-pause-animations *::after {
	animation-duration: 0.001ms !important;
	animation-iteration-count: 1 !important;
	transition-duration: 0.001ms !important;
	scroll-behavior: auto !important;
}

/* ============================================================
   Enhanced focus outline
   ============================================================ */

html.aa-enhanced-focus *:focus,
html.aa-enhanced-focus *:focus-visible {
	outline: 3px solid var(--aa-focus-color) !important;
	outline-offset: 2px !important;
}

/* ============================================================
   Mobile / responsive
   ============================================================ */

@media ( max-width: 480px ) {
	.aa-panel {
		width: calc(100vw - 40px);
	}

	.aa-toolbar.aa-pos-bottom-right,
	.aa-toolbar.aa-pos-bottom-left {
		right: 12px;
		left: 12px;
		bottom: 12px;
		align-items: flex-end;
	}

	.aa-trigger-label {
		display: none;
	}

	.aa-trigger {
		width: var(--aa-trigger-size);
		height: var(--aa-trigger-size);
		padding: 0;
		border-radius: 50%;
		justify-content: center;
	}
}

/* ============================================================
   Screen reader only utility (used in server-rendered markup)
   ============================================================ */

.aa-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;
}
