/**
 * FUSIO Custom Codes - accessibility styles.
 * Each block matches a numbered fix in ../../README.md.
 */

/*
 * Fix 1 - Main landmark.
 * The <main> added around the page content is a child of .wp-site-blocks,
 * where WordPress puts a block gap above every element but the first. The
 * Spectra containers it now wraps had no gap, so the main gets none either:
 * nothing moves (measured at 375-1440px).
 */
.wp-site-blocks > main.fusio-a11y-main {
	margin-block: 0;
}

/*
 * Fix 4 - Site name under the logo link.
 * In the header and footer logo, the text "Child Law Project" sits under the
 * transparent <a class="spectra-container-link-overlay"> (z-index 10) that
 * makes the whole block a link. Contrast checkers cannot read the background
 * of text covered by another element, so it was reported as "needs review"
 * on 175 pages (real ratio: #ffffff on #4e182b = 14.09:1).
 * The heading now sits above the overlay, and pointer-events: none lets
 * clicks go through it to the link, so it works as before. Nothing changes
 * on screen. Browsers without :has() skip the rule.
 */
.wp-block-uagb-container:has(> .spectra-container-link-overlay) > .wp-block-uagb-advanced-heading {
	position: relative;
	z-index: 11;
	pointer-events: none;
}

/*
 * Fix 6 - Complianz banner text reported as contrast "needs review".
 * The banner is fixed over the page. axe checks contrast line by line and
 * lists the page content behind each line; when the banner text covers
 * several page elements it gives up ("elmPartiallyObscuring"), even though
 * the banner's own white background is behind it: #222222 on #ffffff =
 * 15.91:1. ValioQ counted it as serious on 75 pages.
 * axe gives each scroll container its own layer, so the banner body becomes
 * a container that can scroll by 1px (an empty 1px pseudo-element just
 * below it), with the scrollbar hidden. Nothing moves on screen.
 * Only while the preference categories are closed (the banner as first
 * shown, never taller than its limit) and on screens at least 500px high: an
 * expanded banner on a small or zoomed screen can really scroll, and then
 * its scrollbar must stay visible.
 * Relies on how axe-core 4.x builds its grid: if that changes, the "needs
 * review" comes back, and nothing else breaks.
 */
@media (min-height: 500px) {
	.cmplz-cookiebanner:not(.cmplz-categories-visible) .cmplz-body {
		position: relative;
		overflow-y: auto;
		scrollbar-width: none;
	}

	.cmplz-cookiebanner:not(.cmplz-categories-visible) .cmplz-body::-webkit-scrollbar {
		display: none;
	}

	.cmplz-cookiebanner:not(.cmplz-categories-visible) .cmplz-body::after {
		content: "";
		position: absolute;
		bottom: -1px;
		left: 0;
		width: 1px;
		height: 1px;
	}
}

/*
 * Fix 9 - Search & Filter list colours (WCAG 1.4.3).
 * In the Categories and Year lists, white text on the chosen option
 * (#167de4 = 4.13:1) and on the option under the keyboard or mouse (#167de4
 * at 80%, #4597e9 on white = 3.06:1) is below 4.5:1. They now use the teal of
 * the search panel: chosen option #0c525d (8.82:1), highlighted option
 * #106a78 (6.26:1). Approved by FUSIO on 16 Nov 2026 from the comparison
 * image accessibility/colour-proposals/sf-highlight-colours-comparison.png.
 * Same fix without code: Search & Filter > Styles > style 1, selected
 * background colour; this rule can then go.
 */
body .search-filter-style--id-1.search-filter-style--id-1 {
	--search-filter-input-selected-background-color: #0c525d;
	--search-filter-input-selection-background-color: #106a78;
}

/*
 * Fix 10 - "Court Reports Search" title on /cases (contrast "needs review").
 * The title sits on a gradient (maroon above, white below, with a hard edge).
 * Contrast checkers cannot read gradients. The heading block gets the
 * maroon as a plain background; it is always inside the maroon band
 * (checked at 375, 768, 1024 and 1440px), so nothing changes on screen:
 * #ffffff on #4e182b = 14.09:1. The 4px padding, cancelled by negative
 * margins, makes the background cover the whole height of the letters, which
 * the 36px line height does not.
 * The selector uses the Spectra block ID: if the block is recreated in the
 * Site Editor (Cases archive template), update it here. The same block ID is
 * also used by the maroon "Search Court Reports" title on white on the home
 * page, which must not get this background: hence the body class.
 */
body.post-type-archive-cases .wp-block-uagb-advanced-heading.uagb-block-8355935b {
	padding-block: 4px;
	margin-block: -4px;
	background-color: #4e182b;
}

/*
 * Fix 11 - Mobile menu button.
 * The PHP side turns the icon <div> into a <button>. This removes the
 * browser's button styles so it looks and sits exactly like the <div> did
 * (checked at 375px). The focus outline comes from the site's own styles.
 */
button.uagb-modal-trigger {
	appearance: none;
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	line-height: inherit;
	cursor: pointer;
}

/*
 * Fix 12 - Old layout tables wider than the phone screen (WCAG 1.4.10).
 * The case lists on /archive (and other old pages) are layout tables with a
 * fixed width="708". At 375px the whole page scrolled sideways (738px wide).
 * They now never get wider than the content column. Nothing changes at
 * 768px and above, where they already fit.
 */
.wp-block-post-content table[width] {
	max-width: 100%;
}
