/*
	BlogFusion navigation accessibility. (inc/accessibility.php, assets/js/accessibility.js)

	1. Focus indicators       : site-wide two-tone ring (dark outline + light halo) visible on light and dark backgrounds.
	2. Menu / search toggles  : <button> reset (the theme styles every button), header search box.
	3. Submenu toggle         : the caret after each parent link (desktop: chevron / arrow; mobile: round button); open state (.wpi-submenu-open) in css/992.css.
	4. Off-canvas panel       : #wpi-mobile-nav (< 992px), overlay, no-JS fallback.
	5. Mobile menu            : links + large submenu toggles, open / current states.
*/

:root {
	--wpi-focus-ring: #16171a;
	--wpi-focus-halo: #ffffff;
	--wpi-offcanvas-width: min(360px, 88vw);
	--wpi-offcanvas-bg: var(--wp--preset--color--wpi-background, #fff);
	--wpi-offcanvas-text: var(--wp--preset--color--wpi-heading, #222);
	--wpi-offcanvas-line: rgba(0, 0, 0, 0.08);
	--wpi-offcanvas-tint: rgba(0, 0, 0, 0.04);
	}

/* Dark header / menu bar / dark submenus: light ring outside, dark halo inside. */
.is-header-dark:not(.is-menu-bar) .site-header,
.is-menu-dark.is-menu-bar .site-navigation,
.is-submenu-dark .nav-menu ul ul,
.is-header-dark:not(.is-menu-bar) .wpi-offcanvas,
.is-menu-dark.is-menu-bar .wpi-offcanvas {
	--wpi-focus-ring: #ffffff;
	--wpi-focus-halo: #16171a;
	}
.is-header-dark:not(.is-menu-bar) .wpi-offcanvas,
.is-menu-dark.is-menu-bar .wpi-offcanvas {
	--wpi-offcanvas-bg: #181818;
	--wpi-offcanvas-text: #fff;
	--wpi-offcanvas-line: rgba(255, 255, 255, 0.14);
	--wpi-offcanvas-tint: rgba(255, 255, 255, 0.06);
	}


/* 1. FOCUS INDICATORS (keyboard only: :focus-visible), site-wide: links, buttons, form fields
   The theme removes outlines (main.css: a, a:focus, .button, input:focus, checkboxes …); this restores a visible, consistent ring.
   Outline follows each element's own border-radius (pill search fields stay round).
   :is() takes the specificity of its strongest argument ([tabindex]:not(), 0-2-0), so this beats the theme's outline removals
   (.input-text:focus, .button …) and the button resets below. */
:is(a, button, input, select, textarea, summary, .button, .input-text, [tabindex]:not([tabindex="-1"])):focus-visible {
	outline: 3px solid var(--wpi-focus-ring); outline-offset: 2px; box-shadow: 0 0 0 2px var(--wpi-focus-halo);
	transition-property: color, background-color, border-color, opacity, transform; /* The ring appears at once (the theme animates "all"). */
	}
/* The link text carries the menu hover styles; the ring goes on the link box. */
.nav-menu a:focus-visible {
	position: relative; z-index: 1;
	}
/* Search forms whose submit button is an invisible layer over the magnifier icon (search widgets, block search, mobile menu):
   show the button area with the ring while it has keyboard focus. */
.widget_search input.search-submit:focus-visible,
.wp-block-search__button:focus-visible {
	opacity: 1; width: 48px; color: transparent; background: transparent; z-index: 2; transition: none;
	}


/* 2. MENU TOGGLE, HEADER SEARCH TOGGLE (<button>s: reset the theme's button style) */
.site-navigation .menu-toggle,
.site-navigation .search-toggle {
	appearance: none; padding: 0; border: 0; background: none; box-shadow: none; color: inherit; font: inherit; letter-spacing: 0; text-transform: none; line-height: 1;
	}
.site-navigation .search-toggle {
	height: 100%; margin: 0; cursor: pointer;
	}
/* Header search box: visible at once when opened (no visibility transition), so its field can take the focus. */
.is-search-toggled-on .search-container,
.search-container input {
	transition-property: color, background-color, border-color, opacity, transform, filter;
	}


/* 3. SUBMENU TOGGLE (button after each parent link, see assets/js/accessibility.js) */
.wpi-submenu-toggle {
	appearance: none; display: flex; align-items: center; justify-content: center; margin: 0; padding: 0; border: 0; border-radius: 50%; background: none; box-shadow: none; color: inherit; font: inherit; font-size: 12px; letter-spacing: 0; line-height: 1; text-transform: none; cursor: pointer;
	}
.wpi-submenu-toggle:before {
	content: "\f282"; font-family: bootstrap-icons; font-weight: normal; transition: transform 0.2s;
	}
.wpi-submenu-toggle[aria-expanded="true"]:before {
	transform: rotate(180deg);
	}

@media screen and (min-width: 992px) {
	/* Desktop caret: the toggle button after the parent link. Top level: chevron after the link text; submenus: arrow on the right. */
	.nav-menu .wpi-submenu-toggle {
		display: inline-flex; width: 16px; height: 16px; vertical-align: middle; font-size: inherit; opacity: .8; transition: opacity 0.2s; /* 24px target (WCAG 2.5.8); negative margins keep the caret where it was */
		}
	.nav-menu .wpi-submenu-toggle:before {
		font-size: 1em;
		}
	.nav-menu li.has-submenu:hover > .wpi-submenu-toggle,
	.nav-menu li.wpi-submenu-open > .wpi-submenu-toggle,
	.nav-menu .wpi-submenu-toggle:focus-visible {
		opacity: 1;
		}
	.nav-menu ul ul .wpi-submenu-toggle {
		position: absolute; top: 50%; right: 4px; margin: 0; transform: translateY(-50%);
		}
	.nav-menu ul ul .wpi-submenu-toggle:before {
		content: "\f285";
		}
	.nav-menu ul ul .wpi-submenu-toggle[aria-expanded="true"]:before {
		transform: none;
		}
	/* Open by keyboard: visible at once (no visibility transition), so the next Tab can reach the submenu links. */
	.nav-menu li.wpi-submenu-open > ul {
		transition-property: opacity, transform, filter, margin, top, left, right;
		}
	/* Open by keyboard: the parent link keeps a visible marker, not only the dropdown. */
	.nav-menu li.wpi-submenu-open > a .link-text {
		text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 6px;
		}
	/* No JavaScript: submenus open while the keyboard focus is inside. */
	html:not(.wpi-js) .nav-menu ul li:focus-within > ul {
		visibility: visible; opacity: 1; transform: none; transition-property: opacity, transform, filter;
		}

	.wpi-offcanvas,
	.wpi-offcanvas-overlay {
		display: none !important;
		}
}


/* 4. OFF-CANVAS PANEL (mobile) */
.wpi-offcanvas {
	display: none;
	}
@media screen and (max-width: 991px) {
	.wpi-offcanvas {
		display: flex; flex-direction: column; color: var(--wpi-offcanvas-text); background: var(--wpi-offcanvas-bg);
		}

	/* No JavaScript: plain list below the header. */
	html:not(.wpi-js) .wpi-offcanvas {
		border-top: 1px solid var(--wpi-offcanvas-line);
		}
	html:not(.wpi-js) .wpi-offcanvas-header {
		display: none;
		}

	html.wpi-js .wpi-offcanvas {
		position: fixed; top: 0; bottom: 0; left: 0; z-index: 100000; width: var(--wpi-offcanvas-width); max-width: 100%; overflow-y: auto; overscroll-behavior: contain; visibility: hidden; transform: translateX(-100%); transition: transform 0.3s ease, visibility 0s linear 0.3s;
		}
	html.wpi-js .wpi-offcanvas.is-open {
		visibility: visible; transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, 0.25); transition: transform 0.3s ease, visibility 0s;
		}
	.wpi-offcanvas:focus {
		outline: none;
		}
	/* The theme animates every property of links and buttons; an inherited visibility change must not be animated,
	   or the panel content is not focusable in the first frame after opening. */
	.wpi-offcanvas a,
	.wpi-offcanvas button,
	.wpi-offcanvas input {
		transition-property: color, background-color, border-color, opacity, transform;
		}

	.wpi-offcanvas-overlay {
		position: fixed; inset: 0; z-index: 99999; background: rgba(15, 16, 18, 0.55); opacity: 0; visibility: hidden; transition: opacity 0.3s, visibility 0s linear 0.3s;
		}
	.wpi-offcanvas-overlay.is-visible {
		opacity: 1; visibility: visible; transition: opacity 0.3s;
		}

	/* Background does not scroll while the panel is open. */
	html.wpi-offcanvas-open,
	html.wpi-offcanvas-open body {
		overflow: hidden;
		}

	.wpi-offcanvas-header {
		position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 10px 24px; border-bottom: 1px solid var(--wpi-offcanvas-line); background: var(--wpi-offcanvas-bg);
		}
	.wpi-offcanvas-title {
		font-family: var(--wpi-font-base); font-size: 11px; font-weight: 600; letter-spacing: 2px; text-transform: uppercase;
		}
	.wpi-offcanvas-close {
		appearance: none; display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; margin: 0; padding: 0; border: 0; border-radius: 50%; background: none; box-shadow: none; color: inherit; font-size: 18px; line-height: 1; cursor: pointer;
		}
	.wpi-offcanvas-close-icon:before {
		content: "\f659"; font-family: bootstrap-icons;
		}
	.wpi-offcanvas-close:hover {
		background: var(--wpi-offcanvas-tint);
		}

	.wpi-offcanvas-search {
		padding: 20px 24px 8px;
		}
	.wpi-offcanvas-search .search-form {
		margin: 0;
		}
	.wpi-offcanvas-social {
		padding: 12px 24px 28px;
		}


	/* 5. MOBILE MENU */
	.wpi-mobile-menu {
		padding: 4px 0 8px; font-family: var(--wpi-font-base); font-size: 13px; letter-spacing: 1px; text-align: left;
		}
	.is-menu-uppercase .wpi-mobile-menu {
		text-transform: uppercase;
		}
	.wpi-mobile-menu ul {
		margin: 0; padding: 0; list-style: none;
		}
	.wpi-mobile-menu li {
		display: flex; flex-wrap: wrap; align-items: center; margin: 0; padding: 0; border-bottom: 1px solid var(--wpi-offcanvas-line);
		}
	.wpi-mobile-menu li:last-child {
		border-bottom: 0;
		}
	.wpi-mobile-menu li > a {
		flex: 1 1 0; min-width: 0; min-height: 48px; padding: 15px 24px; color: inherit; line-height: 1.4; box-sizing: border-box;
		}
	/* Full-width rows: the focus ring is drawn inside, so the panel edges do not cut it. */
	.wpi-offcanvas .wpi-mobile-menu li > a:focus-visible {
		outline-offset: -3px; box-shadow: inset 0 0 0 5px var(--wpi-focus-halo); border-radius: 0;
		}
	.wpi-mobile-menu li > a:hover {
		color: inherit; background: var(--wpi-offcanvas-tint);
		}
	/* Current page: underline, not colour alone. */
	.wpi-mobile-menu a[aria-current="page"] {
		text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 5px;
		}

	/* Submenus: collapsed until their toggle opens them (all open without JavaScript). */
	.wpi-mobile-menu li > ul {
		display: none; flex-basis: 100%; border-top: 1px solid var(--wpi-offcanvas-line); background: var(--wpi-offcanvas-tint); font-size: 92%;
		}
	.wpi-mobile-menu li.wpi-submenu-open > ul,
	html:not(.wpi-js) .wpi-mobile-menu li > ul {
		display: block;
		}
	.wpi-mobile-menu ul ul a {
		padding-left: 40px;
		}
	.wpi-mobile-menu ul ul ul a {
		padding-left: 56px;
		}
	/* Open parent: bold + side bar, and the toggle arrow points up. */
	.wpi-mobile-menu li.wpi-submenu-open > a {
		font-weight: 600; box-shadow: inset 3px 0 0 currentColor;
		}

	/* Submenu toggle: 44px target, next to the link (the link itself still opens its page). */
	.wpi-mobile-menu .wpi-submenu-toggle {
		flex: 0 0 34px; width: 34px; height: 34px; margin: 2px 10px 2px 0; border: 1px solid var(--wpi-offcanvas-line);
		}
	.wpi-mobile-menu .wpi-submenu-toggle:hover {
		background: var(--wpi-offcanvas-tint);
		}
}

@media (prefers-reduced-motion: reduce) {
	html.wpi-js .wpi-offcanvas,
	html.wpi-js .wpi-offcanvas.is-open,
	.wpi-offcanvas-overlay,
	.wpi-offcanvas-overlay.is-visible,
	.wpi-submenu-toggle:before {
		transition: none;
		}
}
