/**
 * FUSIO Custom Codes - accessibility styles.
 * Each block matches a numbered fix in ../../README.md.
 */

/*
 * Fix 1 - Cookiebot 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 two lines of the banner text
 * sit over different page elements it gives up ("elmPartiallyObscuring"),
 * even though the banner's own white background is behind it: #141414 on
 * #ffffff = 18.42:1. ValioQ counted it as serious on 110 of 112 pages.
 *
 * axe gives each scroll container its own layer and compares the lines only
 * inside it. The block that holds the banner title and text
 * (#CybotCookiebotDialogBodyContent, already overflow-y: auto) becomes a
 * container that can scroll by 1px (an empty 1px pseudo-element just below
 * it), with the scrollbar hidden. It holds no buttons or switches, so no
 * focus ring can be cut, and axe ignores scroll areas this small for
 * "scrollable-region-focusable".
 * Only while the banner is in its first state (.CybotEdge; "Show details"
 * removes that class and scrolls a different panel), and from 400px wide:
 * below that the text really scrolls and Cookiebot's fade must stay where it
 * is. "body" and the class beat Cookiebot's own rule for this block.
 * Checked at 414x896, 768x1024, 1024x768, 1280x1024, 1440x900 and
 * 1920x1080: the text passes, no element moves on screen (only Cookiebot's
 * invisible fade layer, opacity 0, is re-anchored).
 * Relies on how axe-core 4.x builds its grid: if that changes, the "needs
 * review" comes back, and nothing else breaks.
 */
@media (min-width: 400px) {
	body #CybotCookiebotDialog.CybotEdge #CybotCookiebotDialogBodyContent {
		position: relative;
		overflow-y: auto;
		scrollbar-width: none;
	}

	body #CybotCookiebotDialog.CybotEdge #CybotCookiebotDialogBodyContent::-webkit-scrollbar {
		display: none;
	}

	body #CybotCookiebotDialog.CybotEdge #CybotCookiebotDialogBodyContent::after {
		content: "";
		position: absolute;
		bottom: -1px;
		left: 0;
		width: 1px;
		height: 1px;
	}
}

/*
 * Fix 2 - Skip link inside the header.
 * The JS file moves "Skip to content" into the site header (#masthead).
 * There Astra's ".site .skip-link" rules apply to it and change its font
 * (Montserrat bold) and its place (1-2px). These rules put back the look it
 * had as the first element of <body>; all 31 measured properties and its
 * position are identical at 375 and 1440px.
 */
#masthead > a.skip-link.screen-reader-text {
	font-family: inherit;
	font-weight: 400;
}

#masthead > a.skip-link.screen-reader-text:focus {
	left: 5px;
	top: 5px;
}

/*
 * Fix 3 - Text under the transparent link of Spectra cards.
 * A Spectra container with a link gets an empty
 * <a class="spectra-container-link-overlay"> (z-index 10) stretched over it.
 * On the home page the six purple cards and the six news cards use it, so
 * their titles and dates sit under that link, and contrast checkers cannot
 * read text covered by another element ("needs review" on 18 elements; real
 * ratios: #ffffff on #562583 = 10.56:1, #1c3154 on #ffffff = 12.98:1).
 * The text blocks now sit above the link, and pointer-events: none lets
 * clicks go through them to the link, so the cards work 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 8 - Submenu toggles too small (WCAG 2.5.8 Target Size, axe:
 * target-size).
 * The arrow that opens each submenu of the desktop menu is 17.8 x 30px and
 * sits inside the menu link, so it has no spacing to make up for it; the
 * minimum is 24 x 24px. It now reaches 24.3px wide by growing 6.5px to the
 * right, into the link's own 10px padding, and a negative margin of the same
 * size keeps the layout as it was: the arrow and every menu item stay in
 * exactly the same place (measured at 1024 and 1440px).
 */
.main-header-menu .menu-link > .dropdown-menu-toggle.ast-header-navigation-arrow {
	padding-right: 6.5px;
	margin-right: -6.5px;
}
