/* !
 * Lavisa Cars — Accessibility polish layer
 *
 * Loads in two contexts:
 *   1. Customizer admin panel (customize.php)  — via Lcr_Polish_Assets::enqueue_admin_a11y
 *   2. Customizer preview iframe + front-end   — via Lcr_Polish_Assets::enqueue_frontend_a11y
 *
 * Only touches Cars-namespace selectors. Never targets shared/hotels/flights.
 *
 * @since 1.0.0 (C-17)
 */

/* ============================================================
 * 1. Focus-visible — settingless control buttons
 * ============================================================
 *
 * Native WP customizer controls already get focus rings from core.
 * Our custom Cars buttons (Lcr_Reset_Control, Lcr_Portability_Control)
 * render plain <button class="button"> elements — these inherit the
 * .button class focus styling but it varies by WP version. Force a
 * predictable, high-contrast outline using :focus-visible (avoids the
 * outline-on-mouse-click anti-pattern).
 */

.lcr-reset-button:focus-visible,
.lcr-export-button:focus-visible,
.lcr-import-button:focus-visible {
	outline: 2px solid #2271b1;       /* WP admin primary blue */
	outline-offset: 2px;
	box-shadow: 0 0 0 1px #fff;       /* contrast halo for dark themes */
}

.lcr-reset-control--destructive .lcr-reset-button:focus-visible {
	outline-color: #d63638;            /* destructive variant uses red */
}

/* ============================================================
 * 2. Reduced-motion — disable cascade animation re-fire
 * ============================================================
 *
 * The cascade's animation engine attaches `is-animating` to elements
 * to trigger CSS keyframes. When admin tweaks animation_entrance/hover
 * in the customizer, lcr-customize-preview.js removes+re-adds the class
 * to re-fire the animation so admin can see the new preset immediately.
 *
 * For users who've set `prefers-reduced-motion: reduce`, we suppress
 * those animations entirely. The CSS-side suppression is layered ON TOP
 * of any JS class-toggle behaviour — even if JS adds is-animating, the
 * @media gate prevents visual motion.
 */

@media (prefers-reduced-motion: reduce) {
	[data-lcr-element].is-animating,
	[data-lcr-element]:hover {
		animation: none !important;
		transition: none !important;
	}
}

/* ============================================================
 * 3. Prefers-contrast: high — strengthen borders + outlines
 * ============================================================
 *
 * The cascade emits user-chosen border colours which may have low
 * contrast against backgrounds. In high-contrast mode we force visible
 * borders on Cars-tagged components. Uses currentColor to pick up the
 * user's text colour, ensuring foreground/background separation.
 */

@media (prefers-contrast: more) {
	[data-lcr-element] {
		border-color: currentColor !important;
	}

	.lcr-reset-button,
	.lcr-export-button,
	.lcr-import-button {
		border: 2px solid currentColor !important;
	}
}

/* ============================================================
 * 4. Forced-colors mode (Windows High Contrast)
 * ============================================================
 *
 * When the user is in Windows High Contrast mode (or similar), the
 * browser overrides colours with system values. Our cascade-emitted
 * background/foreground colours get nullified. Ensure interactive
 * elements remain visually identifiable using system tokens.
 */

@media (forced-colors: active) {
	.lcr-reset-button,
	.lcr-export-button,
	.lcr-import-button {
		border: 1px solid ButtonText;
		background: ButtonFace;
		color: ButtonText;
		forced-color-adjust: none;
	}

	.lcr-reset-button:focus-visible,
	.lcr-export-button:focus-visible,
	.lcr-import-button:focus-visible {
		outline: 2px solid Highlight;
		outline-offset: 2px;
	}
}

/* ============================================================
 * 5. Touch-target minimum size for buttons
 * ============================================================
 *
 * WCAG 2.1 SC 2.5.5 (Target Size) minimum is 44×44 CSS pixels for AA.
 * Default WP .button class meets this on most themes but can render
 * smaller in compact admin layouts. Enforce minimum.
 */

.lcr-reset-button,
.lcr-export-button,
.lcr-import-button {
	min-height: 32px;     /* WP admin convention; AAA is 44px */
	padding: 4px 12px;
}

/* ============================================================
 * 6. Live-region feedback styling
 * ============================================================
 *
 * Lcr_Portability_Control renders a div.lcr-portability-feedback with
 * aria-live="polite". Make sure the feedback is visually distinguishable
 * by status (success/warn/error). The JS sets inline color on text;
 * here we add subtle background tinting for higher contrast.
 */

.lcr-portability-feedback:not(:empty) {
	display: block;
	padding: 6px 8px;
	border-radius: 3px;
	background: rgba( 0, 0, 0, 0.04 );
}
