/*
 * Accessibility fixes. Each block is switched on by a body class that the module prints from its settings
 * (kpco-a11y-focus, -contrast, -dots, -motion) or belongs to markup the module itself adds.
 * Loaded after Flatsome and the child theme.
 */

.kpco-sr-only {
	border: 0;
	clip: rect(0, 0, 0, 0);
	clip-path: inset(50%);
	height: 1px;
	margin: -1px;
	overflow: hidden;
	padding: 0;
	position: absolute !important;
	white-space: nowrap;
	width: 1px;
}

/* 1. Focus ------------------------------------------------------------------------------------------------- */
/* Two tones: a dark ring (13:1 on white) between two white bands (8.5:1 on the site's dark green), so one of
   them always has at least 3:1 against whatever lies behind. Only :focus-visible, so a mouse click on a button or
   link looks as before. */

.kpco-a11y-focus {
	--kpco-focus: #12343a;
	--kpco-focus-halo: #fff;
}

/* The theme sets box-shadow: none !important on text fields, hence the !important here. */
body.kpco-a11y-focus input:focus-visible,
body.kpco-a11y-focus textarea:focus-visible,
body.kpco-a11y-focus select:focus-visible {
	box-shadow: 0 0 0 6px var(--kpco-focus-halo) !important;
	outline: 2px solid var(--kpco-focus);
	outline-offset: 2px;
}

body.kpco-a11y-focus button:focus-visible:not([tabindex="-1"]),
body.kpco-a11y-focus .button:focus-visible,
body.kpco-a11y-focus [role="button"]:focus-visible,
body.kpco-a11y-focus summary:focus-visible,
body.kpco-a11y-focus .nav > li > a:focus-visible,
body.kpco-a11y-focus .nav-dropdown a:focus-visible,
body.kpco-a11y-focus .nav-sidebar a:focus-visible,
body.kpco-a11y-focus .ux-menu-link__link:focus-visible,
body.kpco-a11y-focus .card-slider__arrow:focus-visible,
body.kpco-a11y-focus .card-slider__dot:focus-visible {
	box-shadow: 0 0 0 6px var(--kpco-focus-halo);
	outline: 2px solid var(--kpco-focus);
	outline-offset: 2px;
}

/* Product card: the main link is an empty layer under the image slider and the text, and the card clips what is
   drawn outside it. The ring is therefore drawn inside the card, on top of everything, without taking clicks. */
body.kpco-a11y-focus .product-small .overlay-link:focus-visible {
	outline: 3px solid var(--kpco-focus);
	outline-offset: -3px;
}

@supports selector(:has(a)) {
	body.kpco-a11y-focus .box.product-small:has(> .overlay-link:focus-visible)::after {
		box-shadow: inset 0 0 0 2px var(--kpco-focus-halo), inset 0 0 0 4px var(--kpco-focus), inset 0 0 0 6px var(--kpco-focus-halo);
		content: "";
		inset: 0;
		pointer-events: none;
		position: absolute;
		z-index: 30;
	}
}

/* Sliders that take keyboard focus: drawn inside, their parents clip. */
body.kpco-a11y-focus .flickity-enabled:focus-visible {
	box-shadow: 0 0 0 3px var(--kpco-focus-halo);
	outline: 3px solid var(--kpco-focus);
	outline-offset: -3px;
}

/* The gallery's image link. Flatsome removes its outline with !important, and the link is an inline box one line
   high around a block image, so the ring is drawn on the image and, where :has() exists, in two tones on the slide. */
body.kpco-a11y-focus .woocommerce-product-gallery__image a:focus-visible img {
	outline: 3px solid var(--kpco-focus);
	outline-offset: -3px;
}

@supports selector(:has(a)) {
	/* Flickity positions the slides itself (inline style); this only matters for a gallery with a single image. */
	body.kpco-a11y-focus .woocommerce-product-gallery__image:has(a:focus-visible) {
		position: relative;
	}

	body.kpco-a11y-focus .woocommerce-product-gallery__image:has(a:focus-visible)::after {
		box-shadow: inset 0 0 0 2px var(--kpco-focus-halo), inset 0 0 0 4px var(--kpco-focus), inset 0 0 0 6px var(--kpco-focus-halo);
		content: "";
		inset: 0;
		pointer-events: none;
		position: absolute;
		z-index: 2;
	}
}

/* 7. Product cards: 24 × 24 px hit area on the slider dots --------------------------------------------------- */
/* The dots are 24 px wide and 6 px high; the invisible layer adds 9 px above and below. */

.kpco-a11y-dots .card-slider__dot {
	position: relative;
}

.kpco-a11y-dots .card-slider__dot::after {
	bottom: -9px;
	content: "";
	left: 0;
	position: absolute;
	right: 0;
	top: -9px;
}

/* 9. Contrast ---------------------------------------------------------------------------------------------- */
/* Struck-through regular price: Flatsome fades it to 60 % (3.4:1). #566060 gives 6.5:1 on white and 5.1:1 on
   the cards' beige. */

.kpco-a11y-contrast .price del,
.kpco-a11y-contrast .price del span.amount,
.kpco-a11y-contrast .product-card-price del,
.kpco-a11y-contrast .product-card-price del span.amount {
	color: #566060;
	opacity: 1;
}

.kpco-a11y-contrast .dark .price del,
.kpco-a11y-contrast .dark .price del span.amount {
	color: #fff;
	opacity: 0.85;
}

/* Field borders: #ddd is 1.4:1 on white, #8a8a8a is 3.4:1. :where() keeps the specificity equal to Flatsome's
   base rule, so deliberate variants with a more specific rule (.form-flat) keep their own border. */
:where(body.kpco-a11y-contrast) input[type="date"],
:where(body.kpco-a11y-contrast) input[type="email"],
:where(body.kpco-a11y-contrast) input[type="number"],
:where(body.kpco-a11y-contrast) input[type="password"],
:where(body.kpco-a11y-contrast) input[type="search"],
:where(body.kpco-a11y-contrast) input[type="tel"],
:where(body.kpco-a11y-contrast) input[type="text"],
:where(body.kpco-a11y-contrast) input[type="url"],
:where(body.kpco-a11y-contrast) select,
:where(body.kpco-a11y-contrast) textarea {
	border-color: #8a8a8a;
}

.kpco-a11y-contrast .quantity input[type="button"].is-form,
.kpco-a11y-contrast .quantity button.is-form {
	border-color: #8a8a8a;
}

/* 3. Motion ------------------------------------------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
	.kpco-a11y-motion .bg-effect {
		animation: none !important;
		display: none;
	}
}

[data-kpco-motion="paused"] .bg-effect {
	animation-play-state: paused !important;
}

.kpco-a11y-motion-host {
	position: relative;
}

.kpco-a11y-motion-btn,
.kpco-a11y-motion-btn:hover {
	align-items: center;
	background: rgba(0, 0, 0, 0.78);
	border: 2px solid #fff;
	border-radius: 50%;
	bottom: 12px;
	color: #fff;
	display: flex;
	height: 44px;
	justify-content: center;
	line-height: 1;
	margin: 0;
	min-height: 44px;
	min-width: 44px;
	opacity: 1;
	padding: 0;
	position: absolute;
	right: 12px;
	width: 44px;
	z-index: 21;
}

.kpco-a11y-motion-btn svg {
	display: block;
	fill: currentColor;
	height: 18px;
	width: 18px;
}

.kpco-a11y-motion-btn[data-kpco-state="paused"] .kpco-a11y-icon-pause,
.kpco-a11y-motion-btn[data-kpco-state="playing"] .kpco-a11y-icon-play {
	display: none;
}

.kpco-a11y-motion-btn:focus-visible {
	box-shadow: 0 0 0 6px #fff;
	outline: 2px solid #12343a;
	outline-offset: 2px;
}

/* 8. Tables ------------------------------------------------------------------------------------------------ */

.kpco-table-scroll {
	max-width: 100%;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

.kpco-table-scroll:focus-visible {
	outline: 2px solid #12343a;
	outline-offset: -2px;
}

/* 2. Contact Form 7 ---------------------------------------------------------------------------------------- */
/* The child theme hides every label in these forms (.wpcf7 label { display: none !important }); the labels this
   module adds are shown. Font, weight and colour come from Flatsome's own label rules, white in dark sections. */

.wpcf7 label.kpco-a11y-label {
	display: block !important;
	margin: 0 0 0.4em;
	visibility: visible;
}

.wpcf7 .kpco-a11y-form-note {
	display: block;
	font-size: 0.9em;
	margin: 0 0 1em;
}
