/**
 * FUSIO Accessibility Fixes - styles.
 * Each block matches an entry in the plugin's README.md.
 */

/*
 * Fix 5 - CookieYes "Consent Preferences" trigger on the privacy pages.
 * The PHP side turns <a class="cky-banner-element"> into a <button>. These
 * rules keep the look of the original link (CookieYes only styles
 * a.cky-banner-element) and beat Astra's global button, hover and focus styles.
 * Text colour #5b6064 instead of CookieYes' #858a8f: 6.03:1 on #f8f9fa
 * (was 3.30:1, needs 4.5:1).
 */
button.cky-banner-element.cky-banner-element,
button.cky-banner-element.cky-banner-element:hover,
button.cky-banner-element.cky-banner-element:focus {
	display: inline-block;
	/* An inline-block grows the line; this keeps the spacing of the original inline link. */
	margin: -5px 0;
	padding: 8px 30px;
	font: inherit;
	line-height: 1.2;
	color: #5b6064;
	background: #f8f9fa;
	border: 1px solid #dee2e6;
	border-radius: 2px;
	box-shadow: none;
	text-transform: none;
	text-decoration: underline;
	letter-spacing: inherit;
	cursor: pointer;
	vertical-align: baseline;
}

/* Astra removes the outline from focused buttons; give keyboard users one back. */
button.cky-banner-element.cky-banner-element:focus-visible {
	outline: 2px solid #156082;
	outline-offset: 2px;
}

/* Same contrast fix if the link version is used again somewhere. */
a.cky-banner-element.cky-banner-element {
	color: #5b6064;
}

/*
 * Fix 10 - CookieYes banner text reported as contrast "needs review".
 * axe checks contrast line by line and lists every element under each line,
 * including the page content behind the fixed banner. When two lines of the
 * banner text sit over different page elements, axe gives up
 * ("elmPartiallyObscuring"), even though the banner's white background covers
 * them: #212121 on #ffffff = 16.10:1. ValioQ counted it as serious on 44 pages.
 * axe gives each scroll container its own layer and compares the lines only
 * inside it. So the banner's content wrapper becomes a scroll container that
 * can scroll by 1px (an empty 1px pseudo-element just below it), with the
 * scrollbar hidden. Nothing moves on screen (checked at 375-1440px), and the
 * wrapper holds the banner buttons, so the scroll area stays keyboard
 * reachable (no "scrollable-region-focusable" issue).
 * Relies on how axe-core 4.x builds its grid: if that changes, the
 * "needs review" comes back, and nothing else breaks.
 */
.cky-consent-container .cky-notice-content-wrapper {
	position: relative;
	overflow-y: auto;
	scrollbar-width: none;
}

.cky-consent-container .cky-notice-content-wrapper::-webkit-scrollbar {
	display: none;
}

.cky-consent-container .cky-notice-content-wrapper::after {
	content: "";
	position: absolute;
	bottom: -1px;
	left: 0;
	width: 1px;
	height: 1px;
}

/*
 * Fix 6 - Brand green #7faf9e with too little contrast (2.46:1, needs 3:1 for
 * these large bold headings). Only the elements reported by the scan change,
 * to #5a7c70 (4.61:1 against white); the green stays the same everywhere else.
 * The selectors use Spectra block IDs: if one of these blocks is recreated in
 * the editor its ID changes, and the colour must then be set in the block.
 * !important is needed because the page's own CSS sets some of these
 * backgrounds with !important.
 */

/* Green headings on white: "Completing the Survey: Video" and "About the Commission: Video" (EN/GA). */
.wp-block-uagb-advanced-heading.uagb-block-4b345f75 .uagb-heading-text,
.wp-block-uagb-advanced-heading.uagb-block-6d89a36d .uagb-heading-text {
	color: #5a7c70 !important;
}

/* Green boxes with white headings on "Our Work - At a Glance" (EN/GA). */
.wp-block-uagb-container.uagb-block-179f7f3c,
.wp-block-uagb-container.uagb-block-6fc52898,
.wp-block-uagb-container.uagb-block-16c473d8,
.wp-block-uagb-advanced-heading.uagb-block-f0eab238 {
	background-color: #5a7c70 !important;
}

/*
 * Fix 7 - Card headings under the Spectra link overlay.
 * In a linked Spectra container the whole card is covered by a transparent
 * <a class="spectra-container-link-overlay"> (z-index 10). Contrast checkers
 * cannot read the background of text under another element, so every card
 * heading was reported as "needs review" (the real ratio is 6.93:1).
 * The heading now sits above the overlay, and pointer-events: none lets
 * clicks go through it to the overlay link, so the card works as before.
 * Nothing changes on screen. Browsers without :has() simply 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 - Text cut off on "If You are Worried About a Child's Safety Now".
 * This page alone has its main Spectra container set to "Full width"
 * (alignfull). The negative margins assume a centred parent, but the parent
 * column is narrower and off centre, so the text started up to 132px
 * outside the screen at 768-1440px. Without the full-width margins the page
 * gets the same layout as /support and the other content pages.
 * Better fix: set the container width back to the default in the editor;
 * this rule then stops matching.
 */
.entry-content > .wp-block-uagb-container.alignfull.uagb-block-d38abf4a {
	width: auto;
	max-width: 100%;
	margin-left: 0;
	margin-right: 0;
	padding-left: 0;
	padding-right: 0;
}

/*
 * Fix 9 (part 1) - Full-width video blocks inside text pages.
 * Same cause as Fix 8: the video sections of /about-the-commission,
 * /taking-part, /taking-part/survey and /ga/maidir-leis-an-gcoimisiun are
 * "Full width" containers, so at 768px the player started up to 195px
 * outside the screen. Without the full-width margins the video lines up with
 * the text of the page (at 1440px it stays where it was, 762 instead of
 * 768px wide). Any full-width block that holds an iframe and shares the page
 * with other content gets this. Video-only pages are fixed in the JS file.
 */
.entry-content > .wp-block-uagb-container.alignfull:not(:only-child):has(iframe) {
	width: auto;
	max-width: 100%;
	margin-left: 0;
	margin-right: 0;
}

/*
 * Fix 11 - Pages with the side menu squeezed to the width of their content.
 * The FUSIO plugin "Astra Container to Main" prints
 * <main class="site-content ast-container"> with auto side margins inside
 * Astra's #page, which is a flex column. In that combination <main> no longer
 * stretches: it is only as wide as its content. On a page with little text
 * (/about-the-commission/parts-of-the-commission) the whole layout shrank to
 * 515px at 1440px, the side menu box to 94px, and the menu links ran up to
 * 29px outside the box (axe "needs review" on the menu).
 * Full width (still capped by .ast-container's max-width) gives these pages
 * the same layout as the other pages with the side menu. Only pages whose
 * side menu has links get it: /contact and the video-only pages print an
 * empty menu, and there it would change an approved layout without fixing
 * anything.
 */
#page > main.site-content.ast-container:has(.hierarchical-side-menu a) {
	width: 100%;
}
