/* =====================================================================
   Accessibility widget for the LiteSites marketing pages.
   Paired with assets/a11y-widget.js; port of the customer-site widget.

   Two halves:
   1. The preferences, driven by data-a11y-* attributes on <html>.
   2. The widget chrome, in LiteSites brand colours.

   The marketing pages size everything in px, not rem, so the customer
   widget's root font-size trick would do nothing here. Text size uses
   CSS zoom on the page content instead, the way browser zoom does.
   ===================================================================== */

/* --- 1. preferences ------------------------------------------------- */

/* Text size. Everything in <body> except the widget itself, so the panel
   never grows past the screen while you use it.

   Unlike browser zoom, CSS zoom also scales viewport units inside the
   zoomed element: a `100vh` box becomes 140% of the screen. The factor is
   published as --a11y-zoom so a page rule that must fit the screen can
   divide by it, e.g. `calc(100vh / var(--a11y-zoom, 1))`. */
html[data-a11y-font='1'] { --a11y-zoom: 1.125; }
html[data-a11y-font='2'] { --a11y-zoom: 1.25; }
html[data-a11y-font='3'] { --a11y-zoom: 1.4; }
html[data-a11y-font] body > :not(.lsa11y-root) { zoom: var(--a11y-zoom); }

/* Line and letter spacing, on text-bearing elements only. A blanket `*`
   would stretch buttons and icon rows out of shape. */
html[data-a11y-line='1'] :where(p, li, dd, dt, blockquote, figcaption, td, th, h1, h2, h3, h4, h5, h6) {
	line-height: 1.9 !important;
}
html[data-a11y-line='2'] :where(p, li, dd, dt, blockquote, figcaption, td, th, h1, h2, h3, h4, h5, h6) {
	line-height: 2.3 !important;
}
html[data-a11y-letter='1'] :where(p, li, dd, dt, blockquote, figcaption, td, th, h1, h2, h3, h4, h5, h6, a, span, button, label) {
	letter-spacing: 0.06em !important;
}
html[data-a11y-letter='2'] :where(p, li, dd, dt, blockquote, figcaption, td, th, h1, h2, h3, h4, h5, h6, a, span, button, label) {
	letter-spacing: 0.12em !important;
}

/* High contrast. Re-points the marketing tokens every page already paints
   from: the home page (shell/head.html), /vs/ (vs.css) and the legal pages
   (legal/_head.html) share these names. Grounds go pure white, all text
   pure black, the accent text a deeper teal. */
html[data-a11y-contrast='high'] {
	--paper: #ffffff !important;
	--cream: #ffffff !important;
	--tint: #ffffff !important;
	--ink: #000000 !important;
	--ink-soft: #000000 !important;
	--accent-ink: #004b5f !important;
	--rule: #000000 !important;
	--no: #000000 !important;
	--on-char: #ffffff !important;
	--on-char-soft: #ffffff !important;
}
html[data-a11y-contrast='high'] body {
	color: #000000;
}

/* Grayscale and inversion. Never a `filter` on <html> or a wrapper: a
   filtered element becomes the containing block for its fixed and sticky
   children, which would unpin the header. A fixed, click-through overlay
   filters everything painted beneath it instead. */
html[data-a11y-grayscale='on'] { --lsa11y-backdrop: grayscale(1); }
html[data-a11y-contrast='invert'] { --lsa11y-backdrop: invert(1) hue-rotate(180deg); }
html[data-a11y-grayscale='on'][data-a11y-contrast='invert'] { --lsa11y-backdrop: grayscale(1) invert(1); }
html[data-a11y-grayscale='on'] body::after,
html[data-a11y-contrast='invert'] body::after {
	content: '';
	position: fixed;
	inset: 0;
	pointer-events: none;
	z-index: 2147483000;
	-webkit-backdrop-filter: var(--lsa11y-backdrop);
	backdrop-filter: var(--lsa11y-backdrop);
}

/* Link emphasis. */
html[data-a11y-underline='on'] a {
	text-decoration: underline !important;
	text-underline-offset: 0.2em !important;
}

/* Readable typeface. Arial ships everywhere and its Hebrew is plain. */
html[data-a11y-readable='on'] {
	--font-text: Arial, 'Helvetica Neue', Helvetica, sans-serif !important;
	--font-display: Arial, 'Helvetica Neue', Helvetica, sans-serif !important;
}
html[data-a11y-readable='on'] :where(body, p, li, a, span, h1, h2, h3, h4, h5, h6, button, input, select, textarea, label, td, th, dt, dd) {
	font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif !important;
}

/* Enlarged cursor. */
html[data-a11y-cursor='on'],
html[data-a11y-cursor='on'] * {
	cursor:
		url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 24 24'%3E%3Cpath d='M5 2l14 10.5-6.2.7 3.4 7.1-2.9 1.4-3.4-7.2L5 19z' fill='%23fff' stroke='%23000' stroke-width='1.5' stroke-linejoin='round'/%3E%3C/svg%3E")
			4 2,
		auto !important;
}
html[data-a11y-cursor='on'] a,
html[data-a11y-cursor='on'] button,
html[data-a11y-cursor='on'] [role='button'],
html[data-a11y-cursor='on'] label,
html[data-a11y-cursor='on'] summary {
	cursor:
		url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 24 24'%3E%3Cpath d='M9 3.5a1.6 1.6 0 013.2 0V10h.6V8.2a1.6 1.6 0 013.2 0V11h.6V9.6a1.6 1.6 0 013.2 0v5.6c0 3.4-2.3 6.3-5.8 6.3h-1.7c-2 0-3.3-.9-4.3-2.5l-2.6-4.3a1.6 1.6 0 012.5-2l1.1 1.2z' fill='%23fff' stroke='%23000' stroke-width='1.4' stroke-linejoin='round'/%3E%3C/svg%3E")
			12 2,
		pointer !important;
}

/* Stop animations. The same rule the pages use for the system's reduced-
   motion setting: every animation and transition declaration is nulled.
   The marketing pages are authored so the un-animated base state is the
   finished one, and `animation: none` also stops the scroll-driven
   animations, which a shortened duration does not. The hero's JavaScript
   animation listens for the change event instead. */
html[data-a11y-motion='off'] {
	scroll-behavior: auto !important;
}
html[data-a11y-motion='off'] *,
html[data-a11y-motion='off'] *::before,
html[data-a11y-motion='off'] *::after {
	animation: none !important;
	transition: none !important;
}

/* Keyboard focus emphasis. A bright core inside a black halo reads on a
   light band and on the charcoal one. */
html[data-a11y-focus='on'] :focus-visible {
	outline: 3px solid #65d1ec !important;
	outline-offset: 2px !important;
	box-shadow: 0 0 0 6px #000000 !important;
	border-radius: 2px;
}

/* --- 2. widget chrome ----------------------------------------------- */

/* Own tokens, hard values. The pages disagree on what --line means, and
   the panel has to look the same on all of them and survive the visitor's
   own contrast setting. Light only, like the rest of the site. */
.lsa11y-root {
	--lsa11y-navy: #092a3a;
	--lsa11y-accent: #65d1ec;
	--lsa11y-accent-ink: #0f7490;
	--lsa11y-tint: #dff4fb;
	--lsa11y-ink: #1a1a1a;
	--lsa11y-ink-soft: #56514c;
	--lsa11y-rule: #928e89;
	--lsa11y-white: #ffffff;

	position: fixed;
	z-index: 2147483001;
	display: flex;
	flex-direction: column;
	gap: 12px;
	font-family: 'Rubik', Arial, 'Helvetica Neue', Helvetica, sans-serif;
	font-size: 16px;
	line-height: 1.4;
	color: var(--lsa11y-ink);
	-webkit-text-size-adjust: 100%;
}
.lsa11y-root *,
.lsa11y-root *::before,
.lsa11y-root *::after {
	box-sizing: border-box;
}
.lsa11y-root [hidden] {
	display: none !important;
}

.lsa11y-trigger {
	position: relative;
	display: grid;
	place-items: center;
	width: 52px;
	height: 52px;
	padding: 0;
	border: 2px solid var(--lsa11y-white);
	border-radius: 999px;
	background: var(--lsa11y-navy);
	color: var(--lsa11y-accent);
	cursor: pointer;
	box-shadow: 0 8px 22px rgba(9, 42, 58, 0.28), 0 1px 3px rgba(9, 42, 58, 0.2);
	transition: transform 160ms ease, background-color 160ms ease;
}
.lsa11y-trigger:hover {
	background: #0e3a50;
	transform: translateY(-1px);
}
.lsa11y-trigger[aria-expanded='true'] {
	background: var(--lsa11y-accent);
	color: var(--lsa11y-navy);
	border-color: var(--lsa11y-navy);
}

.lsa11y-ico {
	width: 18px;
	height: 18px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}
.lsa11y-ico-lg { width: 28px; height: 28px; stroke-width: 2.2; }
.lsa11y-ico-sm { width: 15px; height: 15px; }
.lsa11y-trigger .lsa11y-ico-lg circle { fill: currentColor; }

.lsa11y-badge {
	position: absolute;
	top: -4px;
	inset-inline-end: -4px;
	min-width: 20px;
	height: 20px;
	padding-inline: 4px;
	border-radius: 999px;
	background: var(--lsa11y-accent);
	color: var(--lsa11y-navy);
	border: 2px solid var(--lsa11y-navy);
	font-size: 11px;
	font-weight: 800;
	line-height: 16px;
	text-align: center;
}

.lsa11y-panel {
	display: flex;
	flex-direction: column;
	width: min(calc(100vw - 32px), 340px);
	max-height: min(80vh, 640px);
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 16px;
	border: 1px solid var(--lsa11y-rule);
	border-radius: 16px;
	background: var(--lsa11y-white);
	box-shadow: 0 18px 50px rgba(9, 42, 58, 0.22), 0 2px 6px rgba(9, 42, 58, 0.12);
	color-scheme: light;
	scrollbar-width: thin;
	scrollbar-color: var(--lsa11y-rule) transparent;
}
.lsa11y-panel:focus { outline: none; }

.lsa11y-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	margin-bottom: 8px;
}
.lsa11y-title {
	margin: 0;
	font-size: 18px;
	font-weight: 700;
	line-height: 1.3;
	color: var(--lsa11y-ink);
}

.lsa11y-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding-block: 6px;
}
.lsa11y-label {
	padding: 0;
	font-size: 15px;
	font-weight: 500;
	color: var(--lsa11y-ink);
}
/* A legend normally sits ON the fieldset's top border. Floated full width,
   it becomes an ordinary heading under the divider. */
legend.lsa11y-label {
	float: inline-start;
	width: 100%;
	margin-bottom: 8px;
}
legend.lsa11y-label + * { clear: both; }

.lsa11y-stepper {
	display: flex;
	flex-shrink: 0;
	align-items: center;
	gap: 4px;
}
.lsa11y-readout {
	min-width: 88px;
	text-align: center;
	font-size: 13px;
	font-weight: 600;
	color: var(--lsa11y-ink-soft);
}

.lsa11y-step,
.lsa11y-icon-btn {
	display: grid;
	place-items: center;
	width: 36px;
	height: 36px;
	padding: 0;
	border-radius: 10px;
	border: 1px solid var(--lsa11y-rule);
	background: var(--lsa11y-white);
	color: var(--lsa11y-ink);
	font: inherit;
	font-size: 18px;
	font-weight: 700;
	line-height: 1;
	cursor: pointer;
}
.lsa11y-icon-btn { border-color: transparent; }
.lsa11y-step:hover:not(:disabled),
.lsa11y-icon-btn:hover {
	background: var(--lsa11y-tint);
}
.lsa11y-step:disabled {
	opacity: 0.4;
	cursor: default;
}

.lsa11y-group {
	margin: 12px 0 0;
	padding: 12px 0 0;
	border: 0;
	border-top: 1px solid var(--lsa11y-rule);
	min-width: 0;
}

.lsa11y-chips {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 6px;
}
.lsa11y-chip {
	min-height: 40px;
	padding: 6px 8px;
	border-radius: 10px;
	border: 1px solid var(--lsa11y-rule);
	background: var(--lsa11y-white);
	color: var(--lsa11y-ink);
	font: inherit;
	font-size: 13px;
	font-weight: 600;
	line-height: 1.3;
	cursor: pointer;
	overflow-wrap: anywhere;
}
.lsa11y-chip:hover { background: var(--lsa11y-tint); }
.lsa11y-chip-on,
.lsa11y-chip-on:hover {
	background: var(--lsa11y-accent);
	border-color: var(--lsa11y-accent-ink);
	color: var(--lsa11y-ink);
}

.lsa11y-toggles {
	display: flex;
	flex-direction: column;
	gap: 2px;
}
.lsa11y-toggle {
	display: flex;
	align-items: center;
	gap: 8px;
	width: 100%;
	min-height: 40px;
	padding: 6px 8px;
	border-radius: 10px;
	border: 1px solid transparent;
	background: transparent;
	color: var(--lsa11y-ink);
	font: inherit;
	font-size: 15px;
	font-weight: 500;
	text-align: start;
	cursor: pointer;
}
.lsa11y-toggle:hover { background: var(--lsa11y-tint); }
.lsa11y-toggle-label { flex: 1; }

/* A switch drawn in CSS that reads aria-pressed through its parent's class,
   so the picture and the semantics cannot disagree. */
.lsa11y-switch {
	position: relative;
	flex: none;
	width: 36px;
	height: 20px;
	border-radius: 999px;
	background: var(--lsa11y-rule);
	transition: background-color 150ms ease;
}
.lsa11y-switch::after {
	content: '';
	position: absolute;
	top: 3px;
	inset-inline-start: 3px;
	width: 14px;
	height: 14px;
	border-radius: 999px;
	background: var(--lsa11y-white);
	transition: translate 150ms ease;
}
.lsa11y-toggle-on .lsa11y-switch { background: var(--lsa11y-accent-ink); }
/* The knob travels toward the inline end, which is left in RTL. */
.lsa11y-toggle-on .lsa11y-switch::after { translate: -16px 0; }

.lsa11y-hint {
	margin: 8px 0 0;
	font-size: 12px;
	line-height: 1.5;
	color: var(--lsa11y-ink-soft);
}
.lsa11y-group > .lsa11y-hint { margin: 0 0 8px; }

.lsa11y-grid {
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	gap: 6px;
	width: 100%;
	max-width: 180px;
	aspect-ratio: 16 / 10;
	padding: 6px;
	border: 1px solid var(--lsa11y-rule);
	border-radius: 10px;
	background: var(--lsa11y-tint);
}
.lsa11y-grid-row {
	display: flex;
	justify-content: space-between;
}
.lsa11y-dot {
	width: 26px;
	height: 26px;
	padding: 0;
	border-radius: 999px;
	border: 1px solid var(--lsa11y-rule);
	background: var(--lsa11y-white);
	cursor: pointer;
}
.lsa11y-dot:hover { border-color: var(--lsa11y-accent-ink); }
.lsa11y-dot-on {
	background: var(--lsa11y-navy);
	border-color: var(--lsa11y-navy);
	box-shadow: inset 0 0 0 5px var(--lsa11y-navy), inset 0 0 0 9px var(--lsa11y-accent);
}

.lsa11y-foot {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
}
.lsa11y-reset {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	min-height: 36px;
	padding: 6px 12px;
	border-radius: 10px;
	border: 1px solid var(--lsa11y-rule);
	background: var(--lsa11y-white);
	color: var(--lsa11y-ink);
	font: inherit;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
}
.lsa11y-reset:hover:not(:disabled) { background: var(--lsa11y-tint); }
.lsa11y-reset:disabled { opacity: 0.4; cursor: default; }
.lsa11y-link {
	color: var(--lsa11y-accent-ink);
	font-size: 14px;
	font-weight: 600;
	text-decoration: underline;
	text-underline-offset: 3px;
}

/* The widget's own focus ring is always on, whatever the preferences. */
.lsa11y-root :focus-visible {
	outline: 3px solid var(--lsa11y-accent-ink);
	outline-offset: 2px;
}
.lsa11y-trigger:focus-visible {
	outline-color: var(--lsa11y-navy);
	box-shadow: 0 0 0 5px var(--lsa11y-accent);
}

/* --- placement ------------------------------------------------------
   The visitor's choice on <html> beats the default on the root, because
   `html[…] .lsa11y-root` outranks `.lsa11y-root[…]`. Each rule writes both
   ends of its axis so an override fully replaces the default. */
.lsa11y-root[data-a11y-default-pos^='bottom'],
html[data-a11y-pos^='bottom'] .lsa11y-root {
	top: auto;
	bottom: 16px;
	transform: none;
	flex-direction: column;
}
.lsa11y-root[data-a11y-default-pos^='top'],
html[data-a11y-pos^='top'] .lsa11y-root {
	top: 16px;
	bottom: auto;
	transform: none;
	flex-direction: column-reverse;
}
.lsa11y-root[data-a11y-default-pos^='middle'],
html[data-a11y-pos^='middle'] .lsa11y-root {
	top: 50%;
	bottom: auto;
	transform: translateY(-50%);
	flex-direction: column;
}
.lsa11y-root[data-a11y-default-pos$='-start'],
html[data-a11y-pos$='-start'] .lsa11y-root {
	inset-inline-start: 16px;
	inset-inline-end: auto;
	align-items: flex-start;
}
.lsa11y-root[data-a11y-default-pos$='-end'],
html[data-a11y-pos$='-end'] .lsa11y-root {
	inset-inline-start: auto;
	inset-inline-end: 16px;
	align-items: flex-end;
}

/* Phones: top and middle would sit over whatever content is at that height,
   and the screen is too short to spare. Every position pins to the bottom;
   the picker still offers all six, which matter on a wider screen. */
@media (max-width: 767px) {
	.lsa11y-root[data-a11y-default-pos],
	html[data-a11y-pos] .lsa11y-root {
		top: auto;
		bottom: max(12px, env(safe-area-inset-bottom));
		transform: none;
		flex-direction: column;
	}
	.lsa11y-root[data-a11y-default-pos$='-start'],
	html[data-a11y-pos$='-start'] .lsa11y-root { inset-inline-start: 12px; }
	.lsa11y-root[data-a11y-default-pos$='-end'],
	html[data-a11y-pos$='-end'] .lsa11y-root { inset-inline-end: 12px; }
	.lsa11y-trigger { width: 48px; height: 48px; }
	.lsa11y-ico-lg { width: 26px; height: 26px; }
	.lsa11y-panel {
		width: calc(100vw - 24px);
		max-height: calc(100dvh - 96px);
	}
}

@media (prefers-reduced-motion: reduce) {
	.lsa11y-trigger,
	.lsa11y-switch,
	.lsa11y-switch::after {
		transition: none;
	}
	.lsa11y-trigger:hover { transform: none; }
}
