/* QC Keyboard Navigation & Focus (PBI 131054, QC-001).
 *
 * Site-wide globalCSS Client Extension (scope: company) — pairs with
 * qc-a11y-keyboard.js. Purely additive accessibility layer over the existing
 * header/nav/footer fragments and the accessibility-panel / announcement-popup
 * client extensions; it does NOT restyle any component, it only:
 *   - AC-2: a single, brand-coloured, ALWAYS-visible :focus-visible ring that
 *           reads on light, dark, high-contrast and maroon-button surfaces, in
 *           both LTR and RTL;
 *   - Edge: a skip-to-content link that is the first tab stop on every page.
 *
 * Focus-ring colour strategy (why not a single hardcoded colour): the maroon
 * brand primary (#911731) is a fine ring on the light theme's white/gray
 * surfaces, but it disappears against the dark theme's near-black chrome, and a
 * white ring would vanish on light. So the ring colour is a theme-scoped
 * variable — maroon in light, warm gold (#ffc845, high-contrast on every dark
 * surface AND on the maroon search button) in dark — and the ring is drawn as
 * an OUTLINE WITH OFFSET (a gap of page colour separates ring from element) so
 * even a maroon ring around the maroon search button stays visible. */

:root {
	--qc-focus-ring: #911731;
	--qc-focus-ring-width: 2px;
	--qc-focus-ring-offset: 2px;
}

:root[data-theme="dark"] {
	--qc-focus-ring: #ffc845;
}

/* High-contrast mode (accessibility panel toggles .qc-a11y-contrast on <html>):
   thicker, gold ring regardless of theme for maximum salience. */
html.qc-a11y-contrast {
	--qc-focus-ring: #ffc845;
	--qc-focus-ring-width: 3px;
}

/* The universal visible focus indicator. :focus-visible only paints the ring
   for keyboard/AT focus, never for a plain mouse click, so sighted mouse users
   see no change while keyboard users always get a clear indicator (AC-2). */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible,
[role="button"]:focus-visible,
[role="link"]:focus-visible,
[role="menuitem"]:focus-visible,
[role="switch"]:focus-visible,
[role="tab"]:focus-visible,
[contenteditable="true"]:focus-visible,
.qc-nav-link:focus-visible,
.qc-nav-utility-row:focus-visible {
	outline: var(--qc-focus-ring-width, 2px) solid var(--qc-focus-ring, #911731) !important;
	/* outline-offset: var(--qc-focus-ring-offset, 2px) !important; */
	border-radius: var(--qc-focus-ring-radius, 4px);
}

/* Older engines that don't support :focus-visible fall back to :focus — still
   better than an invisible focus. Modern engines ignore this because the
   :focus-visible rule above wins for keyboard focus and this is only :focus. */
@supports not selector(:focus-visible) {
	a:focus,
	button:focus,
	input:focus,
	select:focus,
	textarea:focus,
	[tabindex]:focus {
		outline: 2px solid var(--qc-focus-ring, #911731) !important;
		outline-offset: 2px !important;
	}
}

/* ADO 150987 - a TEXT-ENTRY control is not ringed. A browser reports a text
   field as :focus-visible on a plain mouse click too, so the !important ring
   above was drawn around every field the moment it was clicked - a second red
   box inside the field's own focus state (the Figma border + glow that every
   QC form already draws on the field or on its wrapper, e.g. .qc-input:
   focus-within on Contact Us). The field's own state is the indicator; where a
   field styles none, its border takes the ring colour instead (zero
   specificity, so any component's own focus border still wins). Buttons,
   links, checkboxes, radios and every other control keep the ring. */
input:not([type="checkbox"]):not([type="radio"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="file"]):not([type="range"]):not([type="color"]):not([type="image"]):focus-visible,
textarea:focus-visible,
select:focus-visible {
	outline: none !important;
}

:where(input:not([type="checkbox"]):not([type="radio"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="file"]):not([type="range"]):not([type="color"]):not([type="image"]), textarea, select):focus-visible {
	border-color: var(--qc-focus-ring, #911731);
}

/* ADO 150984 - Clay's own focus indicator is a BLUE double ring (box-shadow
   0 0 0 .125rem #fff, 0 0 0 .25rem #80acff) on a, .btn, badges, breadcrumb
   links and labels, applied on :focus-visible and - once Clay has added
   .c-prefers-focus to the page - on every :focus, i.e. right after a click,
   so a button still under the pointer read as "highlighted in blue on
   hover". The brand ring above is the one focus indicator on this site, so
   Clay's blue one is removed. */
:is(a, button, .btn, [role="button"], .badge, .breadcrumb-link, .label):is(:focus, :focus-visible, .focus) {
	box-shadow: none !important;
}

/* ADO 150984 - Liferay's own portlet "back" arrow takes Clay's blue link
   colour on hover; it keeps its own colour. */
a.portlet-icon-back:hover,
a.portlet-icon-back:focus {
	color: inherit;
	text-decoration: none;
}

/* Never let a component's own reset hide the ring while it is keyboard-focused. */
*:focus-visible {
	outline-color: var(--qc-focus-ring, #911731);
}

/* ---- skip-to-content link (Edge scenario) ----
   In the DOM it is the very first child of <body> (JS prepends it), so it is
   the first Tab stop on every page and lets a keyboard user jump straight past
   the header chrome to the main content. Off-screen until focused, then it
   slides into the top-inline-start corner. Logical properties => mirrors in
   RTL automatically. */

.qc-skip-link {
	background: var(--qc-focus-ring, #911731);
	border-radius: 0 0 6px 6px;
	color: #fff;
	font-family: var(--qc-font-family-base, 'Cairo', sans-serif);
	font-size: 0.95rem;
	font-weight: 600;
	inset-block-start: 0;
	inset-inline-start: 1rem;
	padding: 0.65rem 1.25rem;
	position: fixed;
	text-decoration: none;
	transform: translateY(-150%);
	transition: transform 0.15s ease;
	z-index: 10000;
}

.qc-skip-link:focus,
.qc-skip-link:focus-visible {
	outline: 3px solid #fff !important;
	outline-offset: -6px !important;
	transform: translateY(0);
}

:root[data-theme="dark"] .qc-skip-link {
	color: #1d1d1b;
}

/* Programmatic focus target (main content) must not itself paint a ring when
   we move focus to it via the skip link — it is a container, not a control. */
[data-qc-main-target]:focus {
	outline: none !important;
}

/* When the mobile nav drawer or a modal panel traps focus, prevent the page
   body behind it from scrolling under keyboard focus movement. Applied by JS
   via .qc-a11y-scroll-locked to avoid fighting other scripts. */
html.qc-a11y-scroll-locked,
html.qc-a11y-scroll-locked body {
	overflow: hidden;
}
