/*
 * Canadensys accessibility CSS (target: WCAG 2.1 AA).
 *
 * Accessibility fixes only. Layout CSS (header bar height, dropdown width,
 * mobile menu alignment) stays in the Divi module's own Custom CSS.
 * Colours use the Divi global variables, with the hex value as a fallback
 * for pages that don't emit the variable.
 */

/*
 * WCAG 1.3.1 Info and Relationships and 2.4.6 Headings and Labels: text that
 * screen readers announce but sighted users don't need, such as "Canadensys "
 * in the home H1, whose visible part is the "AEROSPACE" wordmark beside the logo.
 * Standard WordPress visually-hidden pattern; it stays in the accessibility tree.
 */
.screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip-path: inset(50%);
	border: 0;
	white-space: nowrap;
	word-wrap: normal !important;
}

/*
 * WCAG 2.4.7 Focus Visible: Divi removes keyboard focus site-wide with a reset
 * rule, a global ":focus { outline: 0 }" and "outline: none" on its audio-player
 * and lightbox buttons. "html body" outranks all of them whatever order the
 * stylesheets load in. :focus-visible keeps the ring off mouse clicks.
 * No hex fallback (light-mode rule): the global header uses cds-accent, so Divi
 * prints the variable on every page. If it were ever missing, the outline would
 * fall back to currentColor and stay visible.
 */
html body :focus-visible,
html body .et_audio_container .mejs-controls .mejs-button button:focus-visible {
	outline: 2px solid var(--gcid-cds-accent);
	outline-offset: 2px;
}

/*
 * WCAG 2.1.1 Keyboard: Divi menu dropdowns are visibility:hidden until mouse
 * hover, so Tab skips every dropdown link. Open a dropdown while keyboard focus
 * is inside its parent item. :focus-visible, not :focus-within, so a mouse
 * click on an in-page item doesn't hold the panel open over the content after
 * the pointer leaves (pixel plan chunk 02, GLOBAL-N01). Browsers without
 * :has() keep the :focus-within rule. header.css repeats the open state for the
 * header's sliding panels.
 */
.et_pb_menu .et-menu-nav li:has(:focus-visible) > ul.sub-menu {
	visibility: visible;
	opacity: 1;
}

@supports not selector(:has(*)) {
	.et_pb_menu .et-menu-nav li:focus-within > ul.sub-menu {
		visibility: visible;
		opacity: 1;
	}
}

/*
 * WCAG 4.1.2 Name, Role, Value: Divi draws the dropdown chevron as an icon-font
 * "3" glyph, which screen readers read as part of the link name
 * ("Exploration 3"). Same glyph, with empty alt text. Browsers without support
 * for the alt-text syntax ignore the rule and keep Divi's glyph.
 */
.et_pb_menu .et-menu .menu-item-has-children > a:first-child::after {
	content: "3" / "";
}

/*
 * WCAG 4.1.2 Name, Role, Value: the social icon-font glyph becomes each link's
 * accessible name and hides its "Follow on ..." title. Same glyphs, with empty
 * alt text, so the title names the link. Add a line here when a network is added.
 */
.et_pb_social_media_follow .et-social-linkedin a.icon::before {
	content: "\e09d" / "";
}

.et_pb_social_media_follow .et-social-instagram a.icon::before {
	content: "\e09a" / "";
}

.et_pb_social_media_follow .et-social-twitter a.icon::before {
	content: "\e094" / "";
}

/*
 * WCAG 2.4.3 Focus Order and 1.3.1 Info and Relationships: when a section turns
 * sticky, Divi inserts a full copy of it (.et_pb_sticky_placeholder) hidden
 * only with opacity: 0. Its links stay in the tab order and the accessibility
 * tree, so keyboard and screen reader users get the whole header twice.
 * visibility: hidden removes the copy from both and keeps the space it holds.
 * Descendants need it too, with !important: Divi sets "visibility: visible" on
 * the mobile menu (and "!important" on its submenus), which would show them
 * inside a hidden parent. The doubled class outranks Divi's !important rule.
 */
.et_pb_section.et_pb_sticky_placeholder,
html body .et_pb_section.et_pb_section.et_pb_sticky_placeholder * {
	visibility: hidden !important;
}

/*
 * WCAG 2.4.1 Bypass Blocks: the "Skip to content" Text module (CSS class
 * cds-skip-link, first module in the global header) sits out of the layout and
 * stays visually hidden until it receives keyboard focus.
 */
/*
 * WCAG 2.4.1 Bypass Blocks (paired with a11y.js): the skip link's target gets
 * tabindex="-1" and focus so the next Tab starts in the content. It isn't a
 * control, so it doesn't draw a focus ring around the whole content area.
 */
#main-content[tabindex="-1"]:focus {
	outline: none;
}

.et_pb_module.cds-skip-link {
	position: absolute;
	top: 8px;
	left: 8px;
	z-index: 100000;
	margin: 0;
}

.et_pb_module.cds-skip-link a {
	display: inline-block;
	padding: 12px 16px;
	background-color: var(--gcid-cds-bg);
	border: 1px solid var(--gcid-cds-border-2);
}

.et_pb_module.cds-skip-link a:not(:focus) {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	border: 0;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

/*
 * WCAG 2.4.7 Focus Visible (paired with .cds-card-link in layout.css): the
 * whole card is the click target, so show the keyboard focus ring around the
 * card while its link has focus. The card's own outline isn't clipped by the
 * card's overflow: hidden. The link's own small ring is dropped only where
 * :has() is supported, so older browsers keep the ring on the link itself.
 * Keyboard focus also gets the hover response (accent border; no lift since the
 * pixel plan RC-5), so keyboard users see the same feedback as mouse users.
 * :focus-visible, not :focus-within, so a mouse click doesn't trigger it.
 */
@supports selector(:has(*)) {
	html body .cds-card-link:has(a[href]:focus-visible) {
		outline: 2px solid var(--gcid-cds-accent);
		outline-offset: 2px;
		border-color: var(--gcid-cds-accent);
	}

	html body .cds-card-link a[href]:focus-visible {
		outline: none;
	}
}

/*
 * .cds-tap-target (Text module holding a single navigation link)
 * WCAG 2.5.5 Target Size (AAA; 2.5.8 AA already passes): on phone the hero
 * back links and the prev/next links are 15 to 20px tall, so the link gets a
 * hit area of at least 44px. Equal padding and negative margin, so nothing
 * moves visually (decision D5 in docs/remaining-work.md).
 */
@media (max-width: 767px) {
	.et_pb_text.cds-tap-target a {
		display: inline-block;
		min-height: 44px;
		padding-block: 12px;
		margin-block: -12px;
		box-sizing: border-box;
	}
}

/*
 * WCAG 1.4.1 Use of Color: links inside running text are underlined, so they
 * don't rely on colour alone (the accent is under 3:1 against body text in both
 * themes). Scope (pixel plan RC-1, 2026-11-13): post and job bodies (Post Content
 * module; the WP Job Manager single layout's entry content), and page Text
 * modules marked cds-prose (CSS Class field), the only page text with links inside
 * sentences: NISA "Story text", Careers "Join Us body", Accessibility "Feedback
 * and other formats text", Privacy "13. Contact text". Standalone links (back
 * links, pagers, "Explore →", emails on their own line) aren't in a block of text,
 * so 1.4.1 doesn't require an underline there and the prototype has none.
 * Every Divi page sits inside .entry-content, so .entry-content alone matched them all.
 */
.et_pb_post_content :is(p, li) a,
body.single-job_listing .entry-content :is(p, li) a,
.cds-prose :is(p, li) a {
	text-decoration: underline;
	text-underline-offset: 2px;
}

/*
 * WCAG 1.4.10 Reflow: post and job bodies hold pasted copy, and a long email
 * address or URL (the jobs' closing line, careers@canadensys.com, in a heading)
 * can't wrap, so the page scrolls sideways at 320-390px. Let such words break.
 * The Post Content module has no word-wrap setting.
 */
.et_pb_post_content,
.entry-content {
	overflow-wrap: break-word;
}

/*
 * Reduced motion (site motion plan §6). WCAG 2.3.3 Animation from Interactions
 * (AAA, above the site's AA target; honoured as best practice). Divi's front
 * end ignores prefers-reduced-motion, so: entrance animations show at once,
 * parallax backgrounds hold still, hover and focus lifts become colour-only,
 * and the theme switch doesn't fade.
 * The same rules apply to print, so cards never scrolled into view still print.
 * !important: Divi prints its animation and hover transforms with high
 * specificity, and parallax transforms inline.
 */
@media (prefers-reduced-motion: reduce), print {
	html body .et_animated,
	html body .et-waypoint {
		opacity: 1 !important;
		animation: none !important;
		transform: none !important;
	}

	html body [class*="et-pb-parallax-background"] {
		transform: none !important;
	}

	/* Card lift removed site-wide (pixel plan RC-5); kept for any future hover transform. */
	html body .cds-card-link,
	html body .cds-card-link:hover {
		transform: none !important;
	}

	html.cds-theme-fading,
	html.cds-theme-fading * {
		transition: none !important;
	}
}
