/* ==========================================================================
   WP Koumbit Accessibility — Toolbar & Panel Styles
   The toolbar itself must be accessible by default. High contrast,
   large touch targets, visible focus indicators are non-negotiable.
   ========================================================================== */

:root {
	--wka-primary:        var(--wka-button-color, #1a56db);
	--wka-primary-dark:   #1140a8;
	--wka-white:          #ffffff;
	--wka-bg:             #0f172a;
	--wka-bg-secondary:   #1e293b;
	--wka-border:         #334155;
	--wka-text:           #f1f5f9;
	--wka-text-muted:     #94a3b8;
	--wka-accent:         #60a5fa;
	--wka-success:        #34d399;
	--wka-warning:        #fbbf24;
	--wka-radius:         8px;
	--wka-panel-width:    380px;
	--wka-trigger-size:   3.5em;
	--wka-z:              999999;
	--wka-anim:           0.2s ease;
	--wka-focus-ring:     0 0 0 3px #fff, 0 0 0 5px var(--wka-primary);
}

/* ---- Reset within our scope ---- */
/* :where() keeps specificity at 0 so class-level rules (padding, margin on
   .wka-row, .wka-section-header, etc.) can override without needing !important. */
:where(#wka-root) *,
:where(#wka-root) *::before,
:where(#wka-root) *::after {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

/* ---- Trigger button ---- */
/* Scale icon proportionally so it stays centred in all three button sizes */
#wka-trigger svg {
	width: 50%;
	height: 50%;
	flex-shrink: 0;
}

/* When a text label is shown the parent width is auto (shrink-to-fit), so 50%
   on the SVG has no well-defined parent to resolve against. Use explicit em
   values (half the trigger height) so the button can compute its own width. */
#wka-trigger[data-has-label] svg {
	width: 1.75em;
	height: 1.75em;
}

#wka-trigger {
	font-size: inherit; /* browsers don't inherit font-size on <button> by default */
	position: fixed;
	z-index: var(--wka-z);
	width:  var(--wka-trigger-size);
	height: var(--wka-trigger-size);
	border-radius: 50%;
	border: 3px solid var(--wka-white);
	background-color: var(--wka-primary);
	color: var(--wka-white);
	cursor: grab;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4), 0 0 0 2px var(--wka-primary);
	transition: transform var(--wka-anim), box-shadow var(--wka-anim);
	/* Position set by JS via data-attribute / CSS custom property */
	touch-action: none;
}

#wka-trigger.wka-dragging {
	cursor: grabbing;
	transform: scale(1.05);
	transition: none;
}

#wka-trigger:hover {
	transform: scale(1.08);
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5), 0 0 0 2px var(--wka-primary);
}

#wka-trigger:focus-visible {
	outline: none;
	box-shadow: var(--wka-focus-ring);
}

/* Position variants — applied by JS */
#wka-trigger[data-pos="bottom-right"] { bottom: 24px; right: 24px; }
#wka-trigger[data-pos="bottom-left"]  { bottom: 24px; left:  24px; }
#wka-trigger[data-pos="top-right"]    { top: 24px;    right: 24px; }
#wka-trigger[data-pos="top-left"]     { top: 24px;    left:  24px; }

/* Corner snap classes — applied on drag end if near a corner */
#wka-trigger.wka-corner-bottom-right { bottom: 24px; right: 24px; position: fixed; }
#wka-trigger.wka-corner-bottom-left  { bottom: 24px; left:  24px; position: fixed; }
#wka-trigger.wka-corner-top-right    { top: 24px;    right: 24px; position: fixed; }
#wka-trigger.wka-corner-top-left     { top: 24px;    left:  24px; position: fixed; }

/* Large size variant */
#wka-trigger[data-size="large"] {
	width:  4.5em;
	height: 4.5em;
}

/* Extra-large — for users with significant motor or low-vision needs */
#wka-trigger[data-size="xlarge"] {
	width:  5.5em;
	height: 5.5em;
}

/* When panel is open, indicate active state */
#wka-trigger[aria-expanded="true"] {
	background-color: var(--wka-primary-dark);
}

/* ---- Panel overlay (mobile) ---- */
#wka-panel-overlay {
	display: none;
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.5);
	z-index: calc(var(--wka-z) + 1);
}
#wka-panel-overlay.wka-visible {
	display: block;
}

/* ---- Panel ---- */
#wka-panel {
	position: fixed;
	top: 0;
	bottom: 0;
	right: 0;
	width: var(--wka-panel-width);
	max-width: 100vw;
	z-index: calc(var(--wka-z) + 2);
	background: var(--wka-bg);
	color: var(--wka-text);
	display: flex;
	flex-direction: column;
	transform: translateX(100%);
	transition: transform var(--wka-anim);
	overflow: hidden;
	/* display:flex overrides the UA-sheet [hidden]{display:none}, so use
	   visibility + pointer-events to keep the panel keyboard- and AT-inert
	   when closed while still allowing the transform slide animation. */
	visibility: hidden;
	pointer-events: none;
}

#wka-panel:not([hidden]) {
	transform: translateX(0);
	visibility: visible;
	pointer-events: auto;
}

/* Left-side positioning */
body.wka-pos-left #wka-panel {
	right: auto;
	left: 0;
	transform: translateX(-100%);
}
body.wka-pos-left #wka-panel:not([hidden]) {
	transform: translateX(0);
}

#wka-panel-inner {
	display: flex;
	flex-direction: column;
	height: 100%;
	overflow: hidden;
}

/* ---- Panel header ---- */
#wka-panel-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 16px 22px;
	background: var(--wka-bg-secondary);
	border-bottom: 1px solid var(--wka-border);
	flex-shrink: 0;
}

#wka-panel-title {
	font-size: 1em;
	font-weight: 600;
	color: var(--wka-text);
	flex: 1;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

#wka-panel-header-actions {
	display: flex;
	align-items: center;
	gap: 8px;
}

#wka-lang-select {
	background: var(--wka-bg);
	color: var(--wka-text);
	border: 1px solid var(--wka-border);
	border-radius: 4px;
	padding: 4px 8px;
	font-size: 0.8em;
	cursor: pointer;
}

#wka-lang-select:focus-visible {
	outline: none;
	box-shadow: var(--wka-focus-ring);
}

#wka-close {
	background: transparent;
	border: 1px solid var(--wka-border);
	color: var(--wka-text);
	width: 36px;
	height: 36px;
	border-radius: 4px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: background var(--wka-anim);
}

#wka-close:hover { background: var(--wka-bg-secondary); }
#wka-close:focus-visible {
	outline: none;
	box-shadow: var(--wka-focus-ring);
}

/* ---- Panel body (scrollable) ---- */
#wka-panel-body {
	flex: 1;
	overflow-y: auto;
	overflow-x: hidden;
	padding: 12px 0;
	scroll-behavior: smooth;
}

/* Firefox scrollbar */
#wka-panel-body { scrollbar-width: thin; scrollbar-color: var(--wka-border) transparent; }

/* ---- Feature sections ---- */
.wka-section {
	padding: 6px 0;
	border-bottom: 1px solid var(--wka-border);
}

.wka-section:last-child { border-bottom: none; }

.wka-section-header {
	width: 100%;
	background: none;
	border: none;
	color: var(--wka-text-muted);
	font-size: 0.72em;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	padding: 8px 22px 6px;
	text-align: left;
	cursor: default;
	display: flex;
	align-items: center;
	gap: 8px;
}

.wka-section-icon { font-size: 1em; }

/* ---- Toggle row ---- */
.wka-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 10px 22px;
	transition: background var(--wka-anim);
}

.wka-row:hover { background: var(--wka-bg-secondary); }

.wka-row-label {
	font-size: 0.9em;
	color: var(--wka-text);
	flex: 1;
	min-width: 0;
	line-height: 1.3;
	overflow-wrap: break-word;
}

/* ---- Toggle switch ---- */
.wka-toggle {
	position: relative;
	width: 44px;
	height: 24px;
	flex-shrink: 0;
}

.wka-toggle input {
	opacity: 0;
	width: 0;
	height: 0;
	position: absolute;
}

.wka-toggle-track {
	display: block;
	width: 44px;
	height: 24px;
	background: var(--wka-border);
	border-radius: 12px;
	cursor: pointer;
	transition: background var(--wka-anim);
	position: relative;
}

.wka-toggle-track::after {
	content: '';
	position: absolute;
	top: 3px;
	left: 3px;
	width: 18px;
	height: 18px;
	background: var(--wka-white);
	border-radius: 50%;
	transition: transform var(--wka-anim);
}

.wka-toggle input:checked + .wka-toggle-track {
	background: var(--wka-success);
}

.wka-toggle input:checked + .wka-toggle-track::after {
	transform: translateX(20px);
}

.wka-toggle input:focus-visible + .wka-toggle-track {
	box-shadow: var(--wka-focus-ring);
}

/* ---- Stepper (font size, spacing) ---- */
.wka-stepper {
	display: flex;
	align-items: center;
	gap: 6px;
	flex-shrink: 0;
}

.wka-stepper-btn {
	width: 28px;
	height: 28px;
	border-radius: 4px;
	border: 1px solid var(--wka-border);
	background: var(--wka-bg-secondary);
	color: var(--wka-text);
	font-size: 1.1em;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background var(--wka-anim);
}

.wka-stepper-btn:hover    { background: var(--wka-border); }
.wka-stepper-btn:focus-visible {
	outline: none;
	box-shadow: var(--wka-focus-ring);
}

.wka-stepper-val {
	min-width: 40px;
	text-align: center;
	font-size: 0.85em;
	color: var(--wka-text-muted);
}

/* ---- Panel footer ---- */
#wka-panel-footer {
	padding: 12px 22px;
	border-top: 1px solid var(--wka-border);
	background: var(--wka-bg-secondary);
	flex-shrink: 0;
}

#wka-reset {
	display: flex;
	align-items: center;
	gap: 8px;
	width: 100%;
	padding: 10px 16px;
	background: transparent;
	border: 1px solid var(--wka-border);
	border-radius: var(--wka-radius);
	color: var(--wka-text-muted);
	font-size: 0.875em;
	cursor: pointer;
	justify-content: center;
	transition: border-color var(--wka-anim), color var(--wka-anim);
}

#wka-reset:hover {
	border-color: var(--wka-accent);
	color: var(--wka-text);
}

#wka-reset:focus-visible {
	outline: none;
	box-shadow: var(--wka-focus-ring);
}

#wka-audit-copy-btn {
	display: flex;
	align-items: center;
	gap: 8px;
	width: 100%;
	padding: 10px 16px;
	background: transparent;
	border: 1px solid var(--wka-border);
	border-radius: var(--wka-radius);
	color: var(--wka-text-muted);
	font-size: 0.875em;
	cursor: pointer;
	justify-content: center;
	transition: border-color var(--wka-anim), color var(--wka-anim);
}
#wka-audit-copy-btn:hover {
	border-color: var(--wka-accent);
	color: var(--wka-text);
}
#wka-audit-copy-btn:focus-visible {
	outline: none;
	box-shadow: var(--wka-focus-ring);
}

/* ---- Trigger button text label ---- */
#wka-trigger[data-has-label] {
	width: auto;
	min-width: var(--wka-trigger-size);
	max-width: calc(100vw - 48px);
	border-radius: 1.75em;
	padding: 0 18px 0 14px;
	gap: 8px;
}

.wka-trigger-label {
	font-size: 0.85em;
	font-weight: 600;
	white-space: nowrap;
	color: var(--wka-white);
}

/* ---- Colour reading overlay ---- */
#wka-colour-overlay {
	display: none;
	position: fixed;
	inset: 0;
	pointer-events: none;
	z-index: calc(var(--wka-z) - 2);
}

/* ---- Reading overlay colour swatches ---- */
.wka-overlay-swatches {
	display: flex;
	gap: 6px;
	flex-shrink: 0;
}

.wka-overlay-swatch {
	width: 24px;
	height: 24px;
	border-radius: 50%;
	border: 2px solid transparent;
	cursor: pointer;
	transition: border-color var(--wka-anim), transform var(--wka-anim);
	flex-shrink: 0;
}

.wka-overlay-swatch:hover {
	transform: scale(1.15);
}

.wka-overlay-swatch--active {
	border-color: var(--wka-white);
	box-shadow: 0 0 0 2px var(--wka-success);
}

.wka-overlay-swatch:focus-visible {
	outline: none;
	box-shadow: var(--wka-focus-ring);
}

/* ---- Reading ruler ---- */
#wka-reading-ruler {
	position: fixed;
	left: 0;
	right: 0;
	height: 32px;
	background: rgba(255, 255, 0, 0.18);
	border-top: 2px solid rgba(255, 200, 0, 0.6);
	border-bottom: 2px solid rgba(255, 200, 0, 0.6);
	pointer-events: none;
	z-index: calc(var(--wka-z) - 1);
	transition: top 0.05s linear;
}

/* ---- Skip link (injected by JS for keyboard nav) ---- */
.wka-skip-to-content {
	position: fixed;
	top: -100%;
	left: 16px;
	z-index: calc(var(--wka-z) + 10);
	background: var(--wka-bg);
	color: var(--wka-text);
	padding: 12px 20px;
	border-radius: 0 0 var(--wka-radius) var(--wka-radius);
	font-weight: 600;
	font-size: 1rem;
	border: 2px solid var(--wka-primary);
	text-decoration: none;
}

.wka-skip-to-content:focus {
	top: 0;
}

.wka-noscript-notice {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
}

/* ---- Reduced motion: respect user system preference ---- */
@media (prefers-reduced-motion: reduce) {
	#wka-trigger,
	#wka-panel,
	.wka-toggle-track,
	.wka-toggle-track::after {
		transition: none;
	}
}

/* ---- Mobile ---- */
@media (max-width: 480px) {
	:root { --wka-panel-width: 100vw; }
}

/* ---- Accessibility profiles ---- */
.wka-profiles-section {
	padding: 14px 22px 10px;
	border-bottom: 1px solid var(--wka-border);
}

.wka-profiles-heading {
	font-size: 0.72em;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: var(--wka-text-muted);
	margin-bottom: 10px;
}

.wka-profiles-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
	gap: 8px;
}

.wka-profile-btn {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	padding: 10px 8px;
	background: var(--wka-bg-secondary);
	border: 2px solid var(--wka-border);
	border-radius: var(--wka-radius);
	color: var(--wka-text);
	cursor: pointer;
	font-size: 0.78em;
	line-height: 1.2;
	text-align: center;
	transition: border-color var(--wka-anim), background var(--wka-anim);
}

.wka-profile-btn:hover {
	border-color: var(--wka-accent);
	background: var(--wka-bg);
}

.wka-profile-btn:focus-visible {
	outline: none;
	box-shadow: var(--wka-focus-ring);
}

.wka-profile-btn--active {
	border-color: var(--wka-success);
	background: rgba(52, 211, 153, 0.08);
}

.wka-profile-icon {
	font-size: 1.4em;
	line-height: 1;
}

.wka-profile-name {
	font-weight: 500;
}

.wka-profile-badge {
	font-size: 0.65em;
	font-weight: 700;
	text-transform: uppercase;
	color: var(--wka-success);
	letter-spacing: 0.05em;
}
