/**
 * Accessibility Styles for HMA Theme
 * WCAG 2.1 Level AA Compliance
 *
 * @package HMA Theme
 * @since 1.1.0
 */

/* ==========================================================================
   Skip Links (WCAG 2.1 - 2.4.1)
   ========================================================================== */

.skip-links {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	z-index: 100000;
}

.skip-link {
	position: absolute;
	top: -100px;
	left: 50%;
	transform: translateX(-50%);
	background-color: #225778;
	color: #ffffff;
	padding: 12px 24px;
	font-size: 16px;
	font-weight: 600;
	text-decoration: none;
	border-radius: 0 0 4px 4px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
	transition: top 0.2s ease-in-out;
	z-index: 100001;
}

.skip-link:focus,
.skip-link:focus-visible {
	top: 0 !important;
	outline: 3px solid #ffc107 !important;
	outline-offset: 2px !important;
	color: #ffffff !important;
	text-decoration: none !important;
}

.skip-link:hover {
	background-color: #1a4560;
	color: #ffffff;
	text-decoration: none;
}

/* ==========================================================================
   Link Distinguishability (WCAG 2.1 - 1.4.1)
   Links must be distinguishable from surrounding text without relying on color alone
   ========================================================================== */

/* Content area links - always underlined */
#maincontainer a,
.entry-content a,
.woocommerce-product-details__short-description a,
article a {
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 2px;
}

#maincontainer a:hover,
.entry-content a:hover,
.woocommerce-product-details__short-description a:hover,
article a:hover {
	text-decoration: underline;
	text-decoration-thickness: 2px;
}

/* Exclude buttons and navigation from underline */
#maincontainer a.btn,
#maincontainer a.button,
#maincontainer a.wp-block-button__link,
#maincontainer .woocommerce a.button,
#maincontainer .woocommerce a.added_to_cart,
.navigation a,
.nav-links a,
.menu a,
.breadcrumb a,
.woocommerce-breadcrumb a,
.product-categories a,
.widget a,
.social-icons a {
	text-decoration: none;
}

/* Header top bar links (phone, email) - WCAG 1.4.1 */
#topbar a,
.topbar_ctmzr a,
.topbar a,
.top-bar a,
.header-top a,
.bp_topbar a {
	text-decoration: underline !important;
	text-decoration-thickness: 1px;
	text-underline-offset: 2px;
}

#topbar a:hover,
.topbar_ctmzr a:hover,
.topbar a:hover,
.top-bar a:hover,
.header-top a:hover,
.bp_topbar a:hover {
	text-decoration: underline !important;
	text-decoration-thickness: 2px;
}

/* Footer links - WCAG 1.4.1 */
#footer a,
.footer a,
.widgets_footer a,
.footer-widgets a,
.site-footer a,
.footer-area a,
.footer-section a,
footer a {
	text-decoration: underline !important;
	text-decoration-thickness: 1px;
	text-underline-offset: 2px;
}

#footer a:hover,
.footer a:hover,
.widgets_footer a:hover,
.footer-widgets a:hover,
.site-footer a:hover,
.footer-area a:hover,
footer a:hover {
	text-decoration: underline !important;
	text-decoration-thickness: 2px;
}

/* Email and phone links anywhere - WCAG 1.4.1 */
a[href^="mailto:"],
a[href^="tel:"] {
	text-decoration: underline !important;
	text-decoration-thickness: 1px;
	text-underline-offset: 2px;
}

a[href^="mailto:"]:hover,
a[href^="tel:"]:hover {
	text-decoration: underline !important;
	text-decoration-thickness: 2px;
}

/* ==========================================================================
   Focus Indicators (WCAG 2.1 - 2.4.7)
   All interactive elements must have visible focus indicators
   ========================================================================== */

/* Base focus styles for all interactive elements */
a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus,
[role="button"]:focus,
[tabindex]:focus {
	outline: 3px solid #225778;
	outline-offset: 2px;
}

/* Use :focus-visible for keyboard-only focus (modern browsers) */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[role="button"]:focus-visible,
[tabindex]:focus-visible {
	outline: 3px solid #225778;
	outline-offset: 2px;
}

/* Remove outline on mouse focus (if :focus-visible is supported) */
@supports selector(:focus-visible) {
	a:focus:not(:focus-visible),
	button:focus:not(:focus-visible),
	[role="button"]:focus:not(:focus-visible),
	[tabindex]:focus:not(:focus-visible) {
		outline: none;
	}
}

/* Enhanced focus for navigation items */
.menu a:focus-visible,
.nav-menu a:focus-visible,
.main-navigation a:focus-visible {
	outline: 3px solid #ffc107;
	outline-offset: 2px;
	background-color: rgba(34, 87, 120, 0.1);
}

/* Focus styles for buttons */
.btn:focus-visible,
.button:focus-visible,
input[type="submit"]:focus-visible,
input[type="button"]:focus-visible,
.woocommerce a.button:focus-visible,
.woocommerce button.button:focus-visible {
	outline: 3px solid #ffc107;
	outline-offset: 2px;
	box-shadow: 0 0 0 4px rgba(255, 193, 7, 0.3);
}

/* Focus styles for form inputs */
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="tel"]:focus,
input[type="number"]:focus,
input[type="search"]:focus,
textarea:focus,
select:focus {
	outline: 2px solid #225778;
	outline-offset: 0;
	border-color: #225778;
	box-shadow: 0 0 0 3px rgba(34, 87, 120, 0.2);
}

/* Focus for checkboxes and radio buttons */
input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
	outline: 3px solid #225778;
	outline-offset: 2px;
}

/* WooCommerce product focus */
.products .product:focus-within {
	outline: 2px solid #225778;
	outline-offset: 4px;
}

/* Back to top button focus */
#back-to-top:focus-visible {
	outline: 3px solid #ffc107;
	outline-offset: 2px;
}

/* ==========================================================================
   Color Contrast Fixes (WCAG 2.1 - 1.4.3)
   Minimum contrast ratio: 4.5:1 for normal text, 3:1 for large text
   ========================================================================== */

/*
 * Color Reference (contrast ratios on white #ffffff):
 * #225778 (primary blue): 5.8:1 - PASS AA
 * #333333 (dark gray): 12.6:1 - PASS AAA
 * #555555 (medium gray): 7.5:1 - PASS AA
 * #666666 (lighter gray): 5.7:1 - PASS AA
 * #767676 (minimum gray): 4.5:1 - PASS AA (borderline)
 * #999999: 3.0:1 - FAIL for normal text
 */

/* Fix light gray text to meet minimum contrast */
.text-muted,
.text-secondary,
small,
.small,
.meta,
.post-meta,
.entry-meta,
time,
.date,
figcaption,
.wp-caption-text {
	color: #666666 !important; /* 5.7:1 contrast ratio */
}

/* Form placeholders - must have 4.5:1 contrast */
::placeholder {
	color: #767676; /* Exactly 4.5:1 - minimum required */
	opacity: 1;
}

:-ms-input-placeholder {
	color: #767676;
}

::-ms-input-placeholder {
	color: #767676;
}

/* Form labels */
label,
.form-label,
.woocommerce form .form-row label {
	color: #333333; /* High contrast for form labels */
}

/* Footer text - ensure readable on dark backgrounds */
.footer-widgets,
.site-footer,
footer {
	/* Assuming dark footer background, ensure white text */
}

/* Light text on dark backgrounds */
.footer-widgets,
.footer-widgets p,
.footer-widgets li,
.site-footer,
.site-footer p {
	color: #ffffff; /* White on dark background */
}

.footer-widgets a,
.site-footer a {
	color: #ffffff;
}

.footer-widgets a:hover,
.site-footer a:hover {
	color: #ffc107; /* Yellow for hover contrast */
}

/* Breadcrumb text */
.breadcrumb,
.woocommerce-breadcrumb {
	color: #666666;
}

.breadcrumb a,
.woocommerce-breadcrumb a {
	color: #225778;
}

/* Price and sale badges */
.woocommerce .price,
.woocommerce-Price-amount {
	color: #333333;
}

.woocommerce span.onsale {
	background-color: #225778;
	color: #ffffff;
}

/* Stock status */
.woocommerce .stock.in-stock {
	color: #0d6a34; /* Dark green - 4.6:1 on white */
}

.woocommerce .stock.out-of-stock {
	color: #b91c1c; /* Dark red - 5.9:1 on white */
}

/* Disabled state - still needs to be readable */
button:disabled,
input:disabled,
.btn:disabled,
.button:disabled {
	color: #767676;
	background-color: #e5e5e5;
}

/* Error messages */
.error,
.woocommerce-error,
.woocommerce-message.error {
	color: #b91c1c;
	border-color: #b91c1c;
}

/* Success messages */
.success,
.woocommerce-message {
	color: #0d6a34;
	border-color: #0d6a34;
}

/* Widget titles */
.widget-title,
.widgettitle {
	color: #333333;
}

/* Table headers */
th,
.woocommerce table th {
	color: #333333;
}

/* ==========================================================================
   Reduced Motion (WCAG 2.1 - 2.3.3)
   Respect user preference for reduced motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
	/* Disable all animations and transitions */
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
		scroll-behavior: auto !important;
	}

	/* Keep skip-link functional but instant */
	.skip-link {
		transition: none;
	}

	/* Disable carousel/slider autoplay indicators */
	.carousel,
	.slider,
	.swiper,
	[class*="carousel"],
	[class*="slider"] {
		animation: none !important;
	}

	/* Disable loading spinners animation */
	.load-icon,
	.loading,
	.spinner,
	[class*="loading"],
	[class*="spinner"] {
		animation: none !important;
	}

	/* Disable parallax effects */
	.parallax,
	[class*="parallax"] {
		transform: none !important;
		position: relative !important;
	}

	/* Disable hover animations */
	a:hover,
	button:hover,
	.btn:hover,
	.button:hover {
		transform: none !important;
	}

	/* Disable scroll animations */
	.animate-on-scroll,
	.aos-animate,
	[data-aos] {
		opacity: 1 !important;
		transform: none !important;
	}

	/* WooCommerce specific */
	.woocommerce .blockUI.blockOverlay,
	.woocommerce .loader {
		animation: none !important;
	}

	/* Back to top - instant scroll */
	html {
		scroll-behavior: auto !important;
	}
}

/* ==========================================================================
   Print Styles (Accessibility Enhancement)
   ========================================================================== */

@media print {
	/* Ensure skip-links don't print */
	.skip-links {
		display: none !important;
	}

	/* Show link URLs in print */
	#maincontainer a[href]::after {
		content: " (" attr(href) ")";
		font-size: 0.8em;
		font-weight: normal;
	}

	/* Don't show URL for internal links or buttons */
	#maincontainer a[href^="#"]::after,
	#maincontainer a[href^="javascript"]::after,
	#maincontainer a.btn::after,
	#maincontainer a.button::after {
		content: none;
	}

	/* Ensure sufficient contrast for printing */
	body {
		color: #000000 !important;
		background: #ffffff !important;
	}

	a {
		color: #000000 !important;
		text-decoration: underline !important;
	}
}

/* ==========================================================================
   Visual Composer / WPBakery Color Contrast Fixes (WCAG 2.1 - 1.4.3)
   ========================================================================== */

/*
 * Original #0088cc has only 3.6:1 contrast on white (FAILS AA)
 * #006699 has 5.5:1 contrast on white (PASSES AA)
 * #ff6600 has only 3.0:1 contrast on white (FAILS AA)
 * #c75000 has 4.6:1 contrast on white (PASSES AA)
 */

/* Fix blue buttons/links with insufficient contrast */
.vc_btn3-color-info,
.vc_btn3-color-info.vc_btn3-style-flat,
a.vc_btn3-color-info,
.vc_icon_element-color-info .vc_icon_element-icon {
	background-color: #006699 !important;
	color: #ffffff !important;
}

/* Fix outline style buttons - text color needs higher contrast */
.vc_btn3-style-outline,
.vc_btn3-style-outline-custom,
a.vc_btn3-style-outline,
a.vc_btn3-style-outline-custom {
	color: #006699 !important; /* 5.5:1 contrast instead of #0088cc at 3.6:1 */
	border-color: #006699 !important;
}

.vc_btn3-style-outline:hover,
.vc_btn3-style-outline-custom:hover,
a.vc_btn3-style-outline:hover,
a.vc_btn3-style-outline-custom:hover {
	background-color: #006699 !important;
	color: #ffffff !important;
}

.vc_btn3-color-info:hover,
.vc_btn3-color-info:focus,
a.vc_btn3-color-info:hover,
a.vc_btn3-color-info:focus {
	background-color: #004d73 !important;
}

/* Fix orange/warning buttons with insufficient contrast */
.vc_btn3-color-warning,
.vc_btn3-color-warning.vc_btn3-style-flat,
a.vc_btn3-color-warning {
	background-color: #c75000 !important;
	color: #ffffff !important;
}

.vc_btn3-color-warning:hover,
.vc_btn3-color-warning:focus,
a.vc_btn3-color-warning:hover,
a.vc_btn3-color-warning:focus {
	background-color: #a04000 !important;
}

/* Fix any inline styles with problematic colors */
[style*="color: #0088cc"],
[style*="color:#0088cc"] {
	color: #006699 !important;
}

[style*="background-color: #0088cc"],
[style*="background-color:#0088cc"],
[style*="background: #0088cc"],
[style*="background:#0088cc"] {
	background-color: #006699 !important;
}

[style*="color: #ff6600"],
[style*="color:#ff6600"] {
	color: #c75000 !important;
}

/* Fix pure red text (#FF0000) - only 4.0:1 contrast on white, needs 4.5:1 */
[style*="color: red"],
[style*="color:red"],
[style*="color: #ff0000"],
[style*="color:#ff0000"],
[style*="color: #FF0000"],
[style*="color:#FF0000"],
[style*="color: rgb(255, 0, 0)"],
[style*="color:rgb(255, 0, 0)"],
[style*="color: rgb(255,0,0)"],
[style*="color:rgb(255,0,0)"] {
	color: #b91c1c !important; /* Dark red - 5.9:1 contrast on white */
}

/* Also fix content area red text that may be set via editor */
.entry-content span[style*="color"],
.entry-content strong[style*="color"],
.entry-content p[style*="color"] {
	/* Ensure minimum contrast - handled by specific color overrides above */
}

/* VC Icon element text links */
.vc_icon_element-link {
	/* Ensure icon links are distinguishable */
}

/* Slick carousel accessibility fixes */
.slick-slide[aria-hidden="true"] {
	visibility: hidden;
}

.slick-slide[aria-hidden="true"] * {
	visibility: hidden;
}

/* Ensure visible slides are interactive */
.slick-slide[aria-hidden="false"] {
	visibility: visible;
}

.slick-slide[aria-hidden="false"] * {
	visibility: visible;
}

/* ==========================================================================
   Form Accessibility (WCAG 2.1 - 1.3.1, 3.3.1, 3.3.2)
   ========================================================================== */

/* Required field indicator */
.required,
.woocommerce-form-row abbr.required,
label .required,
.nf-field-label .ninja-forms-req-symbol {
	color: #b91c1c !important;
	font-weight: bold;
	text-decoration: none !important;
}

/* Add visual required indicator after label */
label.required::after,
.woocommerce-form-row.validate-required label::after {
	content: " *";
	color: #b91c1c;
	font-weight: bold;
}

/* Screen reader text for required fields */
.woocommerce-form-row.validate-required label abbr[title] {
	border: none;
	text-decoration: none;
}

/* Form field error states */
.woocommerce-invalid input,
.woocommerce-invalid select,
.woocommerce-invalid textarea,
input.error,
select.error,
textarea.error,
.nf-error .ninja-forms-field,
input[aria-invalid="true"],
select[aria-invalid="true"],
textarea[aria-invalid="true"] {
	border-color: #b91c1c !important;
	box-shadow: 0 0 0 2px rgba(185, 28, 28, 0.2) !important;
}

/* Error messages styling */
.woocommerce-error,
.woocommerce-error li,
.nf-error-msg,
.error-message,
[role="alert"] {
	color: #b91c1c !important;
	background-color: #fef2f2 !important;
	border: 1px solid #b91c1c !important;
	border-left-width: 4px !important;
	padding: 12px 16px !important;
	margin-bottom: 16px;
}

/* Success messages */
.woocommerce-message,
.nf-response-msg,
.success-message {
	color: #0d6a34 !important;
	background-color: #f0fdf4 !important;
	border: 1px solid #0d6a34 !important;
	border-left-width: 4px !important;
	padding: 12px 16px !important;
}

/* Form field descriptions/hints */
.description,
.woocommerce-form-row .description,
.nf-field-description,
[id$="-description"] {
	color: #666666;
	font-size: 0.875em;
	margin-top: 4px;
}

/* Ensure form labels are visible and associated */
label,
.nf-field-label label {
	display: block;
	margin-bottom: 4px;
	color: #333333;
	font-weight: 500;
}

/* Fieldset and legend styling */
fieldset {
	border: 1px solid #ccc;
	padding: 16px;
	margin-bottom: 16px;
}

fieldset legend {
	font-weight: bold;
	padding: 0 8px;
	color: #333333;
}

/* Checkbox and radio button accessibility */
input[type="checkbox"],
input[type="radio"] {
	width: 18px;
	height: 18px;
	margin-right: 8px;
	vertical-align: middle;
}

input[type="checkbox"] + label,
input[type="radio"] + label,
label:has(input[type="checkbox"]),
label:has(input[type="radio"]) {
	display: inline;
	font-weight: normal;
}

/* WooCommerce checkout required fields */
.woocommerce form .form-row.validate-required > label::after {
	content: " *";
	color: #b91c1c;
}

/* Ninja Forms accessibility */
.nf-form-content .nf-field-container {
	margin-bottom: 16px;
}

.nf-form-content .nf-field-label {
	margin-bottom: 4px;
}

/* CAPTCHA alternative text */
.wpcf7-recaptcha,
.g-recaptcha {
	margin-bottom: 16px;
}

/* Help text for CAPTCHA */
.captcha-help {
	font-size: 0.875em;
	color: #666666;
	margin-top: 8px;
}

/* ==========================================================================
   Cookie Banner Accessibility (Borlabs Cookie)
   ========================================================================== */

/* Ensure cookie banner is keyboard accessible */
#BorlabsCookieBox {
	/* Focus trap will be handled by JS */
}

#BorlabsCookieBox a:focus,
#BorlabsCookieBox button:focus {
	outline: 3px solid #ffc107 !important;
	outline-offset: 2px !important;
}

/* Improve button contrast in cookie banner */
#BorlabsCookieBox .btn,
#BorlabsCookieBox button,
#BorlabsCookieBox a._brlbs-btn {
	min-height: 44px; /* Touch target size WCAG 2.5.5 */
	padding: 12px 24px;
}

/* Cookie preference checkboxes */
#BorlabsCookieBox input[type="checkbox"] {
	width: 20px;
	height: 20px;
}

#BorlabsCookieBox label {
	cursor: pointer;
}
