/**
 * Structural styling for the FAB + panel widget itself (not the
 * accessibility effects applied to page content - see a11y-effects.css).
 *
 * Deliberately self-contained: fixed font sizes/colors, no reliance on the
 * active theme, so the widget stays legible no matter what a11y-effects.css
 * or the theme itself is doing to #wp-a11y-content-wrap.
 */

#wp-a11y-fab,
#wp-a11y-panel {
	all: initial;
	box-sizing: border-box;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.4;
	color: #1f2937;
}

#wp-a11y-fab *,
#wp-a11y-panel *,
#wp-a11y-fab *::before,
#wp-a11y-panel *::before,
#wp-a11y-fab *::after,
#wp-a11y-panel *::after {
	box-sizing: border-box;
}

/* ---------------------------------------------------------------------- */
/* FAB                                                                     */
/* ---------------------------------------------------------------------- */

#wp-a11y-fab {
	position: fixed;
	z-index: 999998;
	width: 56px;
	height: 56px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var( --wp-a11y-accent, #3b82f6 );
	color: #fff;
	border: none;
	cursor: pointer;
	box-shadow: 0 4px 14px rgba( 0, 0, 0, 0.25 );
}

#wp-a11y-fab .dashicons {
	font-size: 28px;
	width: 28px;
	height: 28px;
}

/*
 * Qualified with #wp-a11y-fab (not bare `.wp-a11y-fab--*`) so these beat the
 * `all: initial` reset above on specificity (1,1,0) vs (1,0,0) - a plain
 * class selector has LOWER specificity than that ID selector and would
 * silently lose the cascade for any property `all: initial` also touches
 * (which is every property, including position offsets/border-radius).
 */
#wp-a11y-fab.wp-a11y-fab--circle { border-radius: 50%; }
#wp-a11y-fab.wp-a11y-fab--square { border-radius: 12px; }

#wp-a11y-fab.wp-a11y-fab--bottom-right { right: 20px; bottom: 20px; }
#wp-a11y-fab.wp-a11y-fab--bottom-left { left: 20px; bottom: 20px; }
#wp-a11y-fab.wp-a11y-fab--middle-right { right: 20px; top: 50%; transform: translateY( -50% ); }
#wp-a11y-fab.wp-a11y-fab--middle-left { left: 20px; top: 50%; transform: translateY( -50% ); }

#wp-a11y-fab:focus-visible {
	outline: 3px solid #fff;
	outline-offset: 2px;
}

.wp-a11y-fab__badge {
	position: absolute;
	top: -4px;
	right: -4px;
	min-width: 20px;
	height: 20px;
	padding: 0 4px;
	border-radius: 10px;
	background: #dc2626;
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	display: flex;
	align-items: center;
	justify-content: center;
	line-height: 1;
}

.screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect( 1px, 1px, 1px, 1px );
	white-space: nowrap;
}

/* ---------------------------------------------------------------------- */
/* Panel shell                                                             */
/* ---------------------------------------------------------------------- */

#wp-a11y-panel {
	position: fixed;
	z-index: 999999;
	background: #fff;
	color: #1f2937;
	box-shadow: 0 12px 40px rgba( 0, 0, 0, 0.3 );
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

#wp-a11y-panel[hidden] { display: none; }

/* popover: anchored near the FAB, bottom-right by default */
.wp-a11y-panel--popover {
	right: 20px;
	bottom: 88px;
	width: min( 380px, calc( 100vw - 40px ) );
	max-height: min( 640px, calc( 100vh - 120px ) );
	border-radius: 16px;
}

/* drawer: slides from the right edge, full height */
.wp-a11y-panel--drawer {
	top: 0;
	right: 0;
	bottom: 0;
	width: min( 380px, 100vw );
	max-height: 100vh;
	border-radius: 0;
}

/* modal: centered dialog */
.wp-a11y-panel--modal {
	top: 50%;
	left: 50%;
	transform: translate( -50%, -50% );
	width: min( 480px, calc( 100vw - 40px ) );
	max-height: min( 680px, calc( 100vh - 80px ) );
	border-radius: 16px;
}

/* small screens always behave like a drawer, regardless of panelformat */
@media ( max-width: 640px ) {
	#wp-a11y-panel {
		top: 0;
		right: 0;
		left: auto;
		bottom: 0;
		transform: none;
		width: min( 340px, 100vw );
		max-height: 100vh;
		border-radius: 0;
	}
}

.wp-a11y-panel--compact { font-size: 13px; }
.wp-a11y-panel--comfortable { font-size: 16px; }

/* ---------------------------------------------------------------------- */
/* Header / search / footer                                                */
/* ---------------------------------------------------------------------- */

.wp-a11y-panel__header {
	padding: 16px 16px 8px;
	border-bottom: 1px solid #e5e7eb;
	flex: 0 0 auto;
}

.wp-a11y-panel__title-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.wp-a11y-panel__title-row h2 {
	all: unset;
	font-size: 1.15em;
	font-weight: 700;
}

.wp-a11y-icon-button {
	all: unset;
	cursor: pointer;
	width: 32px;
	height: 32px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 8px;
}
.wp-a11y-icon-button:hover,
.wp-a11y-icon-button:focus-visible {
	background: #f1f5f9;
	outline: 2px solid var( --wp-a11y-accent, #3b82f6 );
}

.wp-a11y-panel__status {
	margin: 4px 0 0;
	font-size: 0.85em;
	color: #6b7280;
}

.wp-a11y-panel__actions { margin-top: 8px; }

.wp-a11y-text-button {
	all: unset;
	cursor: pointer;
	color: var( --wp-a11y-accent, #3b82f6 );
	font-weight: 600;
	font-size: 0.85em;
}
.wp-a11y-text-button:hover,
.wp-a11y-text-button:focus-visible {
	text-decoration: underline;
}

.wp-a11y-panel__search {
	padding: 8px 16px;
	border-bottom: 1px solid #e5e7eb;
	flex: 0 0 auto;
}
.wp-a11y-panel__search input {
	width: 100%;
	padding: 8px 10px;
	border: 1px solid #d1d5db;
	border-radius: 8px;
	font-size: 0.95em;
}
.wp-a11y-panel__search input:focus-visible {
	outline: 2px solid var( --wp-a11y-accent, #3b82f6 );
}

.wp-a11y-panel__body {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 8px 16px 16px;
}

.wp-a11y-panel__footer {
	padding: 10px 16px;
	border-top: 1px solid #e5e7eb;
	font-size: 0.8em;
	color: #6b7280;
	flex: 0 0 auto;
}
.wp-a11y-panel__hint { margin: 4px 0 0; }

/* ---------------------------------------------------------------------- */
/* Profiles                                                                */
/* ---------------------------------------------------------------------- */

.wp-a11y-profiles { margin-bottom: 12px; }
.wp-a11y-profiles h3 {
	all: unset;
	display: block;
	font-size: 0.9em;
	font-weight: 700;
	margin-bottom: 8px;
}
.wp-a11y-profiles__grid {
	display: grid;
	grid-template-columns: repeat( 3, 1fr );
	gap: 8px;
}
.wp-a11y-profile {
	all: unset;
	cursor: pointer;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	padding: 8px 4px;
	border-radius: 10px;
	border: 1px solid var( --tone-border, #e5e7eb );
	background: var( --tone-bg, #f8fafc );
	text-align: center;
}
.wp-a11y-profile__swatch {
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: var( --tone-icon, #64748b );
}
.wp-a11y-profile__label {
	font-size: 0.75em;
	font-weight: 600;
	color: var( --tone-text, #334155 );
}
.wp-a11y-profile.is-active {
	outline: 2px solid var( --tone-icon, #64748b );
	outline-offset: 1px;
}
.wp-a11y-profile:focus-visible {
	outline: 2px solid var( --wp-a11y-accent, #3b82f6 );
}

/* ---------------------------------------------------------------------- */
/* Categories                                                              */
/* ---------------------------------------------------------------------- */

.wp-a11y-category { margin-bottom: 8px; border-bottom: 1px solid #f1f5f9; }
.wp-a11y-category h3 { all: unset; display: block; }

.wp-a11y-category__toggle {
	all: unset;
	display: flex;
	align-items: center;
	gap: 8px;
	width: 100%;
	padding: 10px 4px;
	cursor: pointer;
	font-weight: 600;
}
.wp-a11y-category__toggle:focus-visible {
	outline: 2px solid var( --wp-a11y-accent, #3b82f6 );
}
.wp-a11y-category__toggle span:first-child { flex: 1 1 auto; }

.wp-a11y-category__count {
	background: var( --wp-a11y-accent, #3b82f6 );
	color: #fff;
	font-size: 0.7em;
	font-weight: 700;
	border-radius: 10px;
	padding: 1px 7px;
}

.wp-a11y-category__chevron {
	transition: transform 0.15s ease;
}
.wp-a11y-category__toggle[aria-expanded='true'] .wp-a11y-category__chevron {
	transform: rotate( 180deg );
}

.wp-a11y-category__options {
	padding: 0 4px 8px;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

/* ---------------------------------------------------------------------- */
/* Options: toggle switch + stepper                                        */
/* ---------------------------------------------------------------------- */

.wp-a11y-option {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 6px 4px;
}
.wp-a11y-option[hidden] { display: none; }

.wp-a11y-option__label { flex: 1 1 auto; }

.wp-a11y-toggle {
	all: unset;
	cursor: pointer;
	flex: 0 0 auto;
}
.wp-a11y-toggle__track {
	display: block;
	width: 40px;
	height: 22px;
	border-radius: 11px;
	background: #d1d5db;
	position: relative;
	transition: background 0.15s ease;
}
.wp-a11y-toggle__thumb {
	position: absolute;
	top: 2px;
	left: 2px;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: #fff;
	transition: transform 0.15s ease;
}
.wp-a11y-toggle[aria-checked='true'] .wp-a11y-toggle__track {
	background: var( --wp-a11y-accent, #3b82f6 );
}
.wp-a11y-toggle[aria-checked='true'] .wp-a11y-toggle__thumb {
	transform: translateX( 18px );
}
.wp-a11y-toggle:focus-visible .wp-a11y-toggle__track {
	outline: 2px solid var( --wp-a11y-accent, #3b82f6 );
	outline-offset: 2px;
}

.wp-a11y-stepper {
	all: unset;
	cursor: pointer;
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 4px 8px;
	border-radius: 8px;
	border: 1px solid #d1d5db;
}
.wp-a11y-stepper.is-active {
	border-color: var( --wp-a11y-accent, #3b82f6 );
}
.wp-a11y-stepper:focus-visible {
	outline: 2px solid var( --wp-a11y-accent, #3b82f6 );
}
.wp-a11y-stepper__dots { display: flex; gap: 2px; }
.wp-a11y-stepper__dot {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: #d1d5db;
}
.wp-a11y-stepper__dot.is-filled {
	background: var( --wp-a11y-accent, #3b82f6 );
}
.wp-a11y-stepper__value {
	font-size: 0.8em;
	white-space: nowrap;
}
