/*
 * Ekhaa 2026 — accessibility controls.
 *
 * Built against WCAG 2.1 level AA. Each control below names the success
 * criterion it serves, so the reason it exists survives the next redesign.
 *
 * A toolbar is an addition, not a substitute: the page must already be usable
 * before anyone opens it. Contrast, focus order, keyboard operation and
 * markup semantics are handled in the page itself.
 */

/* ==========================================================================
   The launcher and panel
   ========================================================================== */

.a11y {
	position: fixed;
	inset-block-start: 50%;
	inset-inline-start: 0;
	transform: translateY(-50%);
	z-index: 97;
	font-family: var(--wp--preset--font-family--body, "Tajawal", sans-serif);
}

.a11y__toggle {
	display: grid;
	place-items: center;
	width: 52px;
	height: 52px;
	border: 2px solid var(--ink);
	border-start-end-radius: 16px;
	border-end-end-radius: 16px;
	border-inline-start: 0;
	background: var(--ink);
	color: #fff;
	cursor: pointer;
	font-size: 1.4rem;
	line-height: 1;
}
.a11y__toggle:hover { background: var(--clay-deep); border-color: var(--clay-deep); }

.a11y__panel {
	position: absolute;
	inset-block-start: 50%;
	inset-inline-start: calc(100% + 10px);
	transform: translateY(-50%);
	width: min(310px, calc(100vw - 80px));
	background: #fff;
	border: 1px solid var(--line);
	border-radius: 18px;
	box-shadow: var(--shadow-lift);
	padding: 1.1rem;
	display: grid;
	gap: .9rem;
}
.a11y__panel[hidden] { display: none; }

.a11y__panel h2 {
	font-size: 1.05rem;
	margin: 0;
	color: var(--ink);
}

.a11y__group { display: grid; gap: .4rem; }
.a11y__group > p { margin: 0; font-size: .82rem; color: var(--muted); font-weight: 700; }

.a11y__row { display: flex; gap: .35rem; flex-wrap: wrap; }

.a11y__btn {
	flex: 1 1 auto;
	min-height: 44px;
	padding: .5rem .8rem;
	border: 1px solid var(--line);
	border-radius: 11px;
	background: #fff;
	color: var(--ink);
	font: inherit;
	font-size: .88rem;
	cursor: pointer;
	text-align: center;
}
.a11y__btn:hover { background: var(--cream); }
.a11y__btn[aria-pressed="true"] {
	background: var(--ink);
	border-color: var(--ink);
	color: #fff;
	font-weight: 700;
}

.a11y__reset {
	min-height: 44px;
	border: 0;
	border-radius: 11px;
	background: var(--cream);
	color: var(--clay-deep);
	font: inherit;
	font-weight: 700;
	cursor: pointer;
}

@media (max-width: 760px) {
	.a11y { inset-block-start: auto; inset-block-end: 5.2rem; transform: none; }
	.a11y__panel { inset-block-start: auto; inset-block-end: 0; transform: none; }
}

/* ==========================================================================
   What the controls actually do
   ========================================================================== */

/* 1.4.4 Resize text — up to 200% without loss of content or function. */
:root[data-a11y-size="large"] { font-size: 118%; }
:root[data-a11y-size="xlarge"] { font-size: 140%; }

/* 1.4.12 Text spacing — loosens lines and words for dyslexic readers. */
:root[data-a11y-spacing="on"] body,
:root[data-a11y-spacing="on"] p,
:root[data-a11y-spacing="on"] li {
	line-height: 2.1 !important;
	letter-spacing: .055em !important;
	word-spacing: .14em !important;
}
:root[data-a11y-spacing="on"] p { margin-bottom: 1.6em !important; }

/* 1.4.1 Use of colour — links must not rely on colour alone. */
:root[data-a11y-links="on"] a:not(.ekhaa-btn):not(.a11y__btn) {
	text-decoration: underline !important;
	text-decoration-thickness: 2px !important;
	text-underline-offset: .2em;
}

/* 1.4.6 Contrast (enhanced) — a high-contrast rendering on demand. */
:root[data-a11y-contrast="on"] {
	--paper: #ffffff;
	--cream: #ffffff;
	--ink: #000000;
	--ink-2: #000000;
	--muted: #1a1a1a;
	--line: #000000;
	--clay-deep: #000000;
	--blue-deep: #00309c;
	--sand: #000000;
	/* The button tokens. Setting these is what actually reaches the buttons;
	   an !important rule on .ekhaa-btn did not, for reasons the cascade never
	   made visible, so the design now routes every button colour through here. */
	--btn-cta-bg: #000000;
	--btn-cta-ink: #ffffff;
	--btn-quiet-bg: #ffffff;
	--btn-quiet-ink: #000000;
	--btn-quiet-border: #000000;
}
:root[data-a11y-contrast="on"] body { background-image: none; }
:root[data-a11y-contrast="on"] .ekhaa-card,
:root[data-a11y-contrast="on"] .ekhaa-chip { border-width: 2px; }
/* The hero and the cream sections are LIGHT in this design, so high contrast
   makes them white-on-black text, not a black panel. Turning them black while
   their text still used the dark ink produced 1:1 — text invisible against its
   own background. Only the pledge and the footer stay inverted. */
:root[data-a11y-contrast="on"] .ekhaa-hero,
:root[data-a11y-contrast="on"] .ekhaa-section--cream,
:root[data-a11y-contrast="on"] .ekhaa-section--ink:not(.pledge) {
	background: #fff !important;
	color: #000 !important;
}
:root[data-a11y-contrast="on"] .ekhaa-hero h1,
:root[data-a11y-contrast="on"] .ekhaa-hero h1 em,
:root[data-a11y-contrast="on"] .ekhaa-hero__lede,
:root[data-a11y-contrast="on"] .ekhaa-hero .ekhaa-eyebrow,
:root[data-a11y-contrast="on"] .ekhaa-section--ink:not(.pledge) h2,
:root[data-a11y-contrast="on"] .ekhaa-section--ink:not(.pledge) h3,
:root[data-a11y-contrast="on"] .ekhaa-section--ink:not(.pledge) p,
:root[data-a11y-contrast="on"] .ekhaa-section--ink:not(.pledge) .ekhaa-eyebrow,
:root[data-a11y-contrast="on"] .impact__num,
:root[data-a11y-contrast="on"] .impact__label,
:root[data-a11y-contrast="on"] .stat__num,
:root[data-a11y-contrast="on"] .stat__label {
	-webkit-text-fill-color: #000 !important;
	color: #000 !important;
	background: none !important;
	animation: none !important;
}

/* The two inverted panels. */
:root[data-a11y-contrast="on"] .pledge,
:root[data-a11y-contrast="on"] .ekhaa-footer { background: #000 !important; color: #fff !important; }
:root[data-a11y-contrast="on"] .pledge blockquote,
:root[data-a11y-contrast="on"] .ekhaa-footer h2 { color: #fff !important; }
:root[data-a11y-contrast="on"] .pledge cite,
:root[data-a11y-contrast="on"] .pledge .ekhaa-eyebrow,
:root[data-a11y-contrast="on"] .ekhaa-footer a { color: #ffe9a8 !important; }

/* Buttons need their own treatment: a transparent or tinted button on white
   leaves its label unreadable once the palette collapses to black and white.
   That treatment is the --btn-* tokens near the top of this file rather than
   rules down here — sector.css reads them for every button, so overriding the
   tokens reaches all of them at once. An !important rule on .ekhaa-btn was
   tried first and never applied; the tokens demonstrably do. Nothing is
   missing below this line. */
