/* ==========================================================================
   Bay Four – Design ideas R1
   Palette taken from the design deck (6 Aug 2026).

   Layouts (the same conditions are used in early.js):
   - Phone: up to 768px wide, or a phone held sideways (up to 1024px wide,
     500px tall, touch screen). Menu in a drawer, header scrolls away.
   - Desktop/tablet: everything else. Menu always visible, blue bar pinned.
   ========================================================================== */

:root {
	--b4-brand: #58879a;        /* header, footer, chat bubble */
	--b4-brand-dark: #3d6b7d;   /* links, current topic (white text 5.8:1) */
	--b4-brand-deep: #2f5565;   /* text on tinted backgrounds */
	--b4-tint: #e3ebee;         /* topic lists, chapters opened with the arrow */
	--b4-tint-strong: #c7dbe2;  /* the chapter you are in */
	--b4-sidebar-bg: #f6f8f9;
	--b4-sidebar-w: 260px;
	/* Header sizes. early.js measures the real ones before the first paint; these
	   match the usual layout so the page still lines up if scripts are delayed. */
	--b4-header-h: 141px;
	--b4-infobar-h: 55px;
	--b4-sidebar-top: var(--b4-header-h);   /* early.js sets it on the menu itself */
	--b4-gutter: 21px;         /* left edge of the side-menu text (18px padding + 3px bar) */
}

/* A new page width (rotating, resizing) should not animate anything across the
   page: the menu, the search box, or the theme's links and fields, which animate
   every change (the title and article links grew and shrank for 0.2s). early.js
   sets this for two frames. */
.b4-no-transition *,
.b4-no-transition *::before,
.b4-no-transition *::after {
	transition: none !important;
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */

/* The header rows were pulled together with negative margins, which made them
   overlap and left a gap on the right-hand side. Lay them out normally. */
.elementor-location-header .elementor-element.elementor-element-7b54d19,
.elementor-location-header .elementor-element.elementor-element-c1f6c38 {
	margin: 0 !important;
	width: 100% !important;
	--margin-top: 0px; --margin-right: 0px; --margin-bottom: 0px; --margin-left: 0px;
}

.elementor-location-header .elementor-element.elementor-element-7b54d19,
.elementor-location-header .elementor-element.elementor-element-c1f6c38,
.elementor-location-header .elementor-element-7b54d19 > .elementor-motion-effects-container > .elementor-motion-effects-layer,
.elementor-location-header .elementor-element-c1f6c38 > .elementor-motion-effects-container > .elementor-motion-effects-layer {
	background-color: var(--b4-brand) !important;
}
/* Behind the two blue rows the header is blue too (white only behind the info bar),
   so where their edges fall between device pixels (125% and 175% scaling, many
   phones) no light line shows through between or under them. */
.elementor-location-header {
	background: linear-gradient(#fff 0 var(--b4-infobar-h, 0px), var(--b4-brand) 0);
}

/* Brand row: burger (phones) | Bay Four ............................ search */
.elementor-location-header .elementor-element.elementor-element-7b54d19 {
	padding: 6px 12px 0 !important;
}
.elementor-location-header .elementor-element.elementor-element-191fb33 {
	width: 100% !important;
	flex-wrap: nowrap !important;
	align-items: center !important;
	gap: 0 !important;
	padding: 0 !important;
}
.elementor-location-header .header-hamburger {
	flex: 0 0 auto !important;
	width: 40px !important;
	margin: 0 !important;
	align-self: center !important;
}
.elementor-location-header .header-hamburger .elementor-icon-wrapper,
.elementor-location-header .header-hamburger .elementor-icon {
	display: flex !important;
	align-items: center;
}
/* Line the burger up with the capitals of "Bay Four" and the search icon. */
.elementor-location-header .header-hamburger .elementor-icon-wrapper {
	position: relative;
	top: -3px;
}
.elementor-location-header .header-hamburger,
.elementor-location-header .header-search-toggle {
	cursor: pointer;
}
.elementor-location-header .elementor-element.elementor-element-2d9f4ea {
	flex: 0 0 auto !important;
	margin: 0 !important;
	padding: 0 !important;
	align-self: center !important;
}
.elementor-location-header .elementor-element-2d9f4ea .elementor-heading-title {
	line-height: 1.1 !important;
}
.elementor-location-header .elementor-element-2d9f4ea .elementor-heading-title a {
	color: #fff !important;
}

/* Search panel + icon pushed to the right edge; panel slides open to the left. */
.elementor-location-header .elementor-element.elementor-element-c7f9264 {
	order: 3;
	margin-left: auto !important;
	width: auto !important;
}
.elementor-location-header .elementor-element.elementor-element-8ed7994 {
	order: 4;
	flex: 0 0 auto !important;
	align-self: center !important;
	padding: 10px !important;
	margin: 0 0 0 4px !important;
}
.elementor-location-header .elementor-element-8ed7994 .elementor-icon {
	font-size: 20px !important;
}
.elementor-location-header .elementor-element-8ed7994 .elementor-icon svg {
	width: 20px !important;
	height: 20px !important;
}
/* While closed, the search box is out of the keyboard order too (after it slides shut). */
.elementor-location-header .header-search-panel {
	visibility: hidden;
	transition: width .25s ease, opacity .2s ease, margin-left .2s ease, visibility 0s linear .25s !important;
}
.elementor-location-header .header-search-panel.search-open {
	visibility: visible;
	transition: width .25s ease, opacity .2s ease, margin-left .2s ease, visibility 0s linear 0s !important;
}

/* Subtitle aligned with "Bay Four" (burger width + row padding on phones) and raised. */
.elementor-location-header .elementor-element.elementor-element-c1f6c38 {
	padding: 0 12px 10px calc(12px + 40px) !important;
}
.elementor-location-header .elementor-element-c1f6c38 h2,
.elementor-location-header .elementor-element-c1f6c38 .e-heading-base {
	margin: 0 !important;
	padding: 0 !important;
	line-height: 1.2 !important;
	text-align: left !important;
	color: #fff !important;
}

/* Top information bar: quieter social icons, links in the brand colour. */
.elementor-location-header .elementor-element.elementor-element-1929cc6 {
	align-items: center !important;
	padding: 4px 12px !important;
	border-bottom: 1px solid #e6ecef;
}
.elementor-location-header .elementor-element-b9aad82 .elementor-social-icons-wrapper {
	display: flex;
	gap: 8px;
}
.elementor-location-header .elementor-element-b9aad82 .elementor-social-icon,
.b4-footer .elementor-social-icon {
	--icon-size: 13px !important;
	--icon-padding: 0.55em !important;
	border-radius: 50% !important;
	background-color: var(--b4-brand) !important;
	transition: background-color .15s ease, transform .15s ease;
}
.elementor-location-header .elementor-element-b9aad82 .elementor-social-icon:hover {
	background-color: var(--b4-brand-dark) !important;
}
.elementor-location-header .elementor-element-b9aad82 .elementor-social-icon svg,
.b4-footer .elementor-social-icon svg {
	fill: #fff !important;
}
.elementor-location-header .elementor-element-bd0e7cf .elementor-nav-menu--main .elementor-item {
	color: var(--b4-brand-dark) !important;
	fill: var(--b4-brand-dark) !important;
	padding-top: 6px !important;
	padding-bottom: 6px !important;
}
.elementor-location-header .elementor-element-bd0e7cf .elementor-nav-menu--main .elementor-item:hover,
.elementor-location-header .elementor-element-bd0e7cf .elementor-nav-menu--main .elementor-item.elementor-item-active {
	color: var(--b4-brand-deep) !important;
	text-decoration: underline;
	text-underline-offset: 4px;
}
.elementor-location-header .elementor-element-bd0e7cf {
	--e-nav-menu-divider-color: #c9d6dc !important;
}

/* Search box accents */
.header-search-panel input[type="search"]:focus,
.header-search-dropdown input[type="search"]:focus {
	border-color: var(--b4-brand) !important;
	box-shadow: 0 0 0 3px rgba(88, 135, 154, .25) !important;
}
.header-search-dropdown button[type="submit"] {
	background: var(--b4-brand-dark) !important;
}
/* The field's own focus colour is the bar's colour, so add a dark ring inside it. */
.elementor-location-header .header-search-panel input[type="search"]:focus-visible {
	outline: 2px solid var(--b4-brand-dark) !important;
	outline-offset: -2px !important;
}

/* Keyboard focus: white rings on the blue bar, slate rings on the white bar. */
.elementor-location-header .elementor-element-7b54d19 a:focus-visible,
.elementor-location-header .elementor-element-c1f6c38 a:focus-visible,
.elementor-location-header .header-hamburger:focus-visible,
.elementor-location-header .header-search-toggle:focus-visible {
	outline: 2px solid #fff !important;
	outline-offset: 2px;
	border-radius: 4px;
}
.elementor-location-header .elementor-element-1929cc6 a:focus-visible {
	outline: 2px solid var(--b4-brand-dark) !important;
	outline-offset: 2px;
}
.skip-link.screen-reader-text:focus {
	top: 8px !important;
	left: 8px !important;
	z-index: 100000 !important;
	background: #fff !important;
	color: var(--b4-brand-deep) !important;
	outline: 2px solid var(--b4-brand-dark) !important;
	box-shadow: 0 2px 10px rgba(47, 85, 101, .25);
}

/* --------------------------------------------------------------------------
   Side menu
   -------------------------------------------------------------------------- */

html body #mr-sidebar {
	top: var(--b4-sidebar-top) !important;
	bottom: 0 !important;
	height: auto !important;
	width: var(--b4-sidebar-w) !important;
	background: var(--b4-sidebar-bg) !important;
	border-right: 1px solid #dde5e9 !important;
	padding-bottom: 32px !important;
	overscroll-behavior: contain;
	/* The menu keeps its own scroll position (early.js, design.js). The browser's
	   "scroll anchoring" would otherwise move it by a whole topic list when a
	   chapter is re-opened, leaving the topics out of view above. */
	overflow-anchor: none;
	/* Rows reached with the keyboard are scrolled clear of the pinned chapter
	   heading, and of whatever part of the menu is out of sight below (early.js). */
	scroll-padding-top: 48px;
	scroll-padding-bottom: calc(var(--b4-hidden-bottom, 0px) + 12px);
	scrollbar-width: thin;
	scrollbar-color: #b9cad1 transparent;
}
/* The browser can paint the menu a frame before early.js has scrolled it to the
   current topic. Keep its rows transparent until then (the menu's background
   still shows), so they appear in place instead of jumping. If the script never
   gets that far they are shown after 2s anyway; without JavaScript the rule never
   applies. Opacity, not visibility, so the closed phone drawer stays hidden. */
.b4-js #mr-sidebar:not(.b4-placed) > * {
	opacity: 0;
	animation: b4-show 0s linear 2s forwards;
}
@keyframes b4-show {
	to { opacity: 1; }
}
#mr-sidebar::-webkit-scrollbar { width: 8px; }
#mr-sidebar::-webkit-scrollbar-track { background: transparent; }
#mr-sidebar::-webkit-scrollbar-thumb {
	background: #b9cad1;
	border-radius: 8px;
	border: 2px solid var(--b4-sidebar-bg);
}
#mr-sidebar a,
#mr-sidebar .mr-chapter-arrow {
	-webkit-tap-highlight-color: transparent;
}
/* Astra's dotted outline also showed on taps and clicks; keep rings for keyboard use. */
#mr-sidebar a:focus:not(:focus-visible) {
	outline: none;
}

/* Chapters */
.mr-chapter-item { align-items: stretch !important; }
.mr-chapter-item > .mr-chapter-link {
	color: #1f2d36 !important;
}
@media (hover: hover) {
	.mr-chapter-item > .mr-chapter-link:hover,
	.mr-chapter-arrow:hover {
		background: var(--b4-tint) !important;
	}
}
/* A chapter opened with its arrow: the same light tint as its topic list. */
.mr-chapter-item.open > .mr-chapter-link,
.mr-chapter-item.open > .mr-chapter-arrow {
	background: var(--b4-tint) !important;
}
/* The chapter you are in: stronger tint and the dark bar, whether open or not. */
.mr-chapter-item.active > .mr-chapter-link,
.mr-chapter-item.active > .mr-chapter-arrow {
	background: var(--b4-tint-strong) !important;
	color: var(--b4-brand-deep) !important;
}
.mr-chapter-item.active > .mr-chapter-link {
	border-left-color: var(--b4-brand-dark) !important;
}
@media (hover: hover) {
	.mr-chapter-item.open > .mr-chapter-arrow:hover {
		background: var(--b4-tint-strong) !important;
	}
	.mr-chapter-item.active > .mr-chapter-arrow:hover {
		background: #b6cfd8 !important;
	}
}
/* An open chapter's heading (and its arrow, to close it again) stays at the top of
   the menu while you scroll through its topics. */
html body #mr-sidebar .mr-chapter-item.active > .mr-chapter-link,
html body #mr-sidebar .mr-chapter-item.active > .mr-chapter-arrow,
html body #mr-sidebar .mr-chapter-item.open > .mr-chapter-link,
html body #mr-sidebar .mr-chapter-item.open > .mr-chapter-arrow {
	position: sticky;
	top: 0;
	z-index: 2;
}
/* A chapter opened with its arrow has the same tint as its topics: an edge under
   its heading shows where the topics slide under it. */
html body #mr-sidebar .mr-chapter-item.open:not(.active) > .mr-chapter-link,
html body #mr-sidebar .mr-chapter-item.open:not(.active) > .mr-chapter-arrow {
	box-shadow: 0 1px 0 #c9d6dc;
}

/* Arrows. Astra rotated the whole arrow box 90deg, knocking it out of line. */
.mr-chapter-item.active > .mr-chapter-arrow { transform: none !important; }
.mr-chapter-arrow {
	align-self: stretch;
	display: flex !important;
	align-items: center;
	color: var(--b4-brand) !important;   /* 3.7:1 on the menu background */
	user-select: none;
}
.mr-chapter-item.open > .mr-chapter-arrow {
	color: var(--b4-brand-deep) !important;
}
/* The arrow opens and closes every chapter, including the one you are in
   (design.js). Closed chapters get .b4-collapsed, which beats Astra's
   "current chapter is always open" rule. */
html body #mr-sidebar .mr-chapter-item.b4-collapsed > .mr-topic-list {
	display: none !important;
}

/* Topics */
.mr-topic-list {
	background: var(--b4-tint) !important;
}
.mr-topic-list li a {
	color: #34505d !important;
}
@media (hover: hover) {
	.mr-topic-list li a:hover {
		background: rgba(255, 255, 255, .6) !important;
		color: var(--b4-brand-deep) !important;
	}
}
/* A topic you have just tapped, while its page loads. */
html body #mr-sidebar .mr-topic-list li > a.b4-pending {
	background: var(--b4-tint-strong) !important;
	border-left-color: var(--b4-brand) !important;
	color: var(--b4-brand-deep) !important;
}
/* The topic you are reading. The menu marks it with li.mr-topic-active
   (the theme's old a.current rule never matched anything). */
html body #mr-sidebar .mr-topic-list li.mr-topic-active > a,
html body #mr-sidebar .mr-topic-list li > a[aria-current="page"] {
	background: var(--b4-brand-dark) !important;
	border-left-color: var(--b4-brand-deep) !important;
	color: #fff !important;
	font-weight: 600 !important;
}

/* Keyboard focus in the menu */
html body #mr-sidebar .mr-chapter-link:focus-visible,
html body #mr-sidebar .mr-topic-list li > a:focus-visible,
.mr-chapter-arrow:focus-visible {
	outline: 2px solid var(--b4-brand-dark) !important;
	outline-offset: -2px;
}
html body #mr-sidebar .mr-topic-list li.mr-topic-active > a:focus-visible,
html body #mr-sidebar .mr-topic-list li > a[aria-current="page"]:focus-visible {
	outline: 2px solid #fff !important;
	outline-offset: -4px;
}

/* End-of-menu spacer used by design.js while a chapter is being closed. */
.b4-menu-spacer { flex: none; }

/* --------------------------------------------------------------------------
   Content area
   -------------------------------------------------------------------------- */

/* Content used to start 240px in but be (100% - 20px) wide, so it ran ~220px off
   the right-hand edge and text was cut off. Sit it beside the menu instead. */
html body .ast-page-builder-template .entry-content-wrap,
html body .site-content,
html body #content.site-content {
	margin-left: var(--b4-sidebar-w) !important;
	width: auto !important;
	max-width: none !important;
	/* The old layout slid the article sideways when the menu column came or went.
	   Here that only happens on rotating or resizing, and it reflowed the whole
	   article for a quarter of a second, losing the reader's place. */
	transition: none !important;
}
html, body { overflow-x: clip; }

/* Links in the page text use the colours set in Appearance > Customize > Colors >
   Links (Normal and Hover), which bayfour-design.php passes in as --b4-link and
   --b4-link-hover. Without Astra they fall back to the header blue. */
.entry-content a,
.entry-content a:visited {
	color: var(--b4-link, var(--b4-brand-dark));
	text-decoration-color: rgba(61, 107, 125, .45);
	text-decoration-color: color-mix(in srgb, currentColor 45%, transparent);
	text-underline-offset: 2px;
}
.entry-content a:hover,
.entry-content a:focus {
	color: var(--b4-link-hover, var(--b4-brand-deep));
	text-decoration-color: currentColor;
}
h1.entry-title {
	border-bottom-color: #dfe7eb !important;
}

/* Breathing room after the last line of a page before the footer. */
html body .ast-article-single .entry-content {
	padding-bottom: 72px !important;
}

/* Wide screens: pages written with blocks (front page, About) keep Astra's 1200px
   text column, but start it under the page title instead of centring it. Centred
   blocks and full/wide-width blocks are left as they are. */
@media (min-width: 1500px) {
	html body .entry-content[data-ast-blocks-layout] > :is(p, h1, h2, h3, h4, h5, h6, ul, ol, dl, blockquote, .wp-block-group, .wp-block-table, .wp-block-quote, .wp-block-list):not(.aligncenter):not(.alignwide):not(.alignfull):not(.has-text-align-center) {
		margin-left: 0;
	}
}

/* --------------------------------------------------------------------------
   Search results / archive heading box
   -------------------------------------------------------------------------- */

/* Astra caps this box at 1200px while the results grid below uses the full
   width, so on large screens it stopped short. Match the grid. */
html body .ast-archive-description {
	max-width: none !important;
}
/* Astra lines the result cards up with the box only above 922px wide; do it at
   every width. */
html body.ast-separate-container .ast-blog-layout-4-grid .ast-row {
	margin-left: -1em !important;
	margin-right: -1em !important;
}
/* Narrow phones: that -1em would poke past the screen edges, and with one column
   there is no gutter to line up, so the cards simply fill the row. */
@media (max-width: 544px) {
	html body.ast-separate-container .ast-blog-layout-4-grid .ast-row {
		margin-left: 0 !important;
		margin-right: 0 !important;
	}
	html body.ast-separate-container .ast-blog-layout-4-grid .ast-article-post {
		padding-left: 0 !important;
		padding-right: 0 !important;
	}
}
/* Each result card ends with an empty content box, which the theme pads like a
   page (a blank band of up to 42px). The excerpt above it is the card's text. */
html body .ast-article-post .ast-excerpt-container ~ .entry-content {
	display: none !important;
}
/* The card's author/date line is hidden (Additional CSS), but its empty box kept
   the theme's top padding: a bigger gap under the title on phones. */
html body .ast-article-post .entry-header.ast-blog-meta-container {
	padding-top: 0 !important;
}
.ast-archive-description .ast-archive-title,
.ast-archive-description h1,
.ast-archive-description .ast-breadcrumbs {
	overflow-wrap: anywhere;   /* long one-word search terms */
}
.ast-archive-description a,
.ast-archive-description a:visited {
	color: var(--b4-link, var(--b4-brand-dark)) !important;
}
html body .ast-archive-description a:hover,
html body .ast-archive-description a:focus {
	color: var(--b4-link-hover, var(--b4-brand-deep)) !important;
	text-decoration: underline;
	text-underline-offset: 3px;
}
/* Page numbers (search results) in the Links colours, like the links in the text. */
html body .ast-pagination .page-numbers.current {
	background-color: var(--b4-link, var(--b4-brand-dark)) !important;
	border-color: var(--b4-link, var(--b4-brand-dark)) !important;
	color: #fff !important;
}
html body .ast-pagination a.page-numbers:hover,
html body .ast-pagination a.page-numbers:focus {
	color: var(--b4-link-hover, var(--b4-brand-deep)) !important;
	border-color: var(--b4-link-hover, var(--b4-brand-deep)) !important;
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

/* Old Elementor footer (phone only, outdated icons) replaced by .b4-footer. */
.elementor-location-footer { display: none !important; }

.b4-footer {
	position: relative;
	z-index: 950;               /* above the fixed side menu */
	background: var(--b4-brand);
	color: #fff;
	font-size: 13px;
}
.b4-footer__inner {
	display: grid;
	grid-template-columns: auto 1fr auto;
	align-items: center;
	gap: 16px 32px;
	padding: 28px 112px 28px 40px; /* right: room for the chat bubble */
}
.b4-footer__social .elementor-social-icons-wrapper {
	display: flex;
	gap: 10px;
}
.b4-footer .elementor-social-icon {
	--icon-size: 16px !important;
	background-color: rgba(255, 255, 255, .16) !important;
}
.b4-footer .elementor-social-icon:hover {
	background-color: rgba(255, 255, 255, .3) !important;
}
/* The links flow like words, so where they wrap the browser can balance the rows
   (4 + 4 rather than 7 + 1). */
.b4-footer__links {
	list-style: none;
	margin: 0;
	padding: 0;
	text-align: center;
	text-wrap: balance;
	font-size: 0;               /* no stray word spaces between the links */
}
.b4-footer__links li {
	display: inline-block;
	margin: 2px 0;
	font-size: 13px;
	line-height: 1.6;
}
/* Separators are drawn, not typed, so screen readers don't read out "|". */
.b4-footer__links li + li::before {
	content: "";
	display: inline-block;
	height: .9em;
	margin: 0 9px 0 10px;
	border-left: 1px solid currentColor;
	opacity: .5;
	vertical-align: -.1em;
}
/* Safety net: if a row ever wraps, it doesn't start with a separator (design.js).
   It keeps its width so the row doesn't re-wrap. */
.b4-footer__links li.b4-row-start::before {
	visibility: hidden;
}
.b4-footer__links a,
.b4-footer__links a:visited {
	color: #fff;
	text-decoration: none;
}
.b4-footer__links a:hover,
.b4-footer__links a:focus {
	text-decoration: underline;
	text-underline-offset: 3px;
}
.b4-footer a:focus-visible {
	outline: 2px solid #fff !important;
	outline-offset: 3px;
}
.b4-footer__copy {
	margin: 0;
	white-space: nowrap;
}
/* Where the links can't fit on one line, space them out instead of using "|". */
@media (max-width: 1099px) {
	.b4-footer__links li { margin: 3px 8px; }
	.b4-footer__links li + li::before { content: none; }
}

/* --------------------------------------------------------------------------
   Chat / error-report bubble
   -------------------------------------------------------------------------- */

#mr-error-btn {
	background: var(--b4-brand) !important;
	box-shadow: 0 4px 14px rgba(47, 85, 101, .35) !important;
	transition: background .2s, transform .2s, box-shadow .2s !important;
}
#mr-error-btn:hover {
	background: var(--b4-brand-dark) !important;
}
#mr-error-btn:focus-visible {
	outline: 3px solid var(--b4-brand-deep) !important;
	outline-offset: 3px;
}
/* Over the blue footer it turns white (lighter), matching the scroll-to-top. */
body.b4-footer-in-view #mr-error-btn {
	background: #fff !important;
	box-shadow: 0 0 0 1px var(--b4-tint-strong), 0 2px 10px rgba(47, 85, 101, .25) !important;
}
body.b4-footer-in-view #mr-error-btn svg {
	stroke: var(--b4-brand-dark) !important;
}
body.b4-footer-in-view #mr-error-btn:hover {
	background: var(--b4-tint) !important;
}
body.b4-footer-in-view #mr-error-btn:focus-visible {
	outline-color: #fff !important;
}
#mr-error-form button[type="submit"],
#mr-error-modal button[type="submit"] {
	background: var(--b4-brand-dark) !important;
}
#mr-error-modal h3,
#mr-error-modal label span {
	color: var(--b4-brand-dark) !important;
}
/* The green "Thank you!" and its Close button, dark enough to read (5.1:1). */
#mr-error-modal #mr-error-success h3 {
	color: #1e7e46 !important;
}
#mr-error-modal #mr-error-success button {
	background: #1e7e46 !important;
}
#mr-error-modal textarea:focus-visible,
#mr-error-modal input:focus-visible,
#mr-error-modal button:focus-visible {
	outline: 2px solid var(--b4-brand-dark) !important;
	outline-offset: 1px;
}
/* The dialog box and the "Thank you!" heading take focus only so that keyboard
   focus stays in the dialog; they need no ring. */
#mr-error-modal:focus,
#mr-error-modal #mr-error-success h3:focus {
	outline: none;
}
/* The close button picked up the theme's button padding and shadow (a 69 x 50
   box over the heading); a round 40px target in the corner instead, level with
   the heading's first line. */
#mr-error-close {
	top: 23px !important;
	right: 6px !important;
	width: 40px;
	height: 40px;
	padding: 0 !important;
	display: flex;
	align-items: center;
	justify-content: center;
	line-height: 1 !important;
	border-radius: 50% !important;
	box-shadow: none !important;
	color: var(--b4-brand-dark) !important;   /* was light grey (2.9:1) */
}
@media (hover: hover) {
	#mr-error-close:hover {
		background: var(--b4-tint) !important;
	}
}
/* Room beside the title for the close button, so on narrow screens the title
   wraps before it instead of running underneath. */
#mr-error-form-inner h3 {
	padding-right: 24px;
}
/* Focus moved by the dialog's own Tab handling is keyboard focus: Safari showed no
   ring on the close button when a click in the dialog came first (design.js). */
#mr-error-modal.b4-kbd button:focus {
	outline: 2px solid var(--b4-brand-dark) !important;
	outline-offset: 1px;
}
/* "Thank you!" level with the close button, as the form's title is. */
#mr-error-modal #mr-error-success {
	padding-top: 0;
}
/* While the dialog is open the page behind it stays put (Safari and Firefox
   scrolled it underneath). design.js sets these. While it or the phone drawer is
   open, the scrollbar's space is kept where the system shows one (design.js,
   early.js), so the page doesn't shift sideways. */
html.b4-dialog-open {
	overflow: hidden !important;
}
html.b4-keep-gutter {
	scrollbar-gutter: stable;
}
#mr-error-modal input[type="email"],
#mr-error-modal textarea {
	border-color: #7f8f97 !important;         /* field edges visible (3.3:1) */
}
/* Phones held sideways are shorter than the dialog: let it scroll inside the
   dimmed backdrop instead of cutting off its top and bottom. */
#mr-error-overlay {
	overflow-x: hidden;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 12px;
	box-sizing: border-box;
}
#mr-error-modal {
	margin: auto;               /* centred when it fits, from the top when it doesn't */
	max-width: 100% !important;
	box-sizing: border-box;
}
@media (max-height: 500px) {
	#mr-error-overlay { padding: 8px; }
	#mr-error-modal { padding: 14px 20px 12px !important; }
	#mr-error-close { top: 6px !important; }
	#mr-error-modal h3 { margin-bottom: 4px !important; }
	#mr-error-modal p.sub { margin-bottom: 8px !important; }
	#mr-error-modal .mr-page-url-box,
	#mr-error-modal input[type="email"],
	#mr-error-modal textarea { margin-bottom: 8px !important; }
	#mr-error-modal .mr-page-url-box { padding-top: 4px !important; padding-bottom: 4px !important; }
	/* Not !important, so dragging the field's corner to make it taller still works. */
	html body #mr-error-modal textarea { height: 56px; }
	#mr-error-modal button[type="submit"] { padding-top: 8px !important; padding-bottom: 8px !important; }
}

/* Scroll-to-top (Astra) was hidden underneath the chat bubble and behind the
   footer. Stack it just above the bubble, centred on it. Astra shows and hides
   it with an inline display style, so display is left alone here. */
html body #ast-scroll-top {
	--b4-top-size: 40px;
	z-index: 990 !important;     /* above the footer (950), below lightboxes and the bubble */
	right: calc(24px + (60px - var(--b4-top-size)) / 2) !important;
	bottom: calc(24px + 60px + 12px) !important;
	width: var(--b4-top-size) !important;
	height: var(--b4-top-size) !important;
	padding: 0 !important;
	border: 1px solid var(--b4-tint-strong) !important;
	border-radius: 50% !important;
	/* Colours from Appearance > Customize > Scroll To Top, when set there
	   (bayfour-design.php passes them in); otherwise white with a blue arrow. */
	background: var(--b4-top-bg, #fff) !important;
	color: var(--b4-top-icon, var(--b4-brand-dark)) !important;
	box-shadow: 0 2px 10px rgba(47, 85, 101, .25) !important;
	line-height: 1 !important;
	transition: background .2s, box-shadow .2s;
}
html body #ast-scroll-top:hover {
	background: var(--b4-top-bg-hover, var(--b4-tint)) !important;
	color: var(--b4-top-icon-hover, var(--b4-top-icon, var(--b4-brand-dark))) !important;
}
/* Two-tone ring so focus shows over white content and the blue footer alike. The
   transparent outline is what Windows High Contrast draws instead. */
html body #ast-scroll-top:focus-visible {
	outline: 2px solid transparent !important;
	outline-offset: 2px;
	box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--b4-brand-dark) !important;
}
html body #ast-scroll-top .ast-icon.icon-arrow {
	display: flex !important;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
}
html body #ast-scroll-top .ast-icon.icon-arrow svg {
	width: 16px !important;
	height: 16px !important;
	margin: 0 !important;
	fill: currentColor !important;
	transform: rotate(180deg) !important;   /* Astra also nudged it up 20%, off-centre */
}

/* ==========================================================================
   Desktop & tablet: header stays put, menu sits beneath it
   (768.02px rather than 769px so zoomed/scaled windows never fall between the
   phone and desktop rules; phones held sideways use the phone layout.)
   ========================================================================== */
@media (min-width: 1024.02px), (min-width: 768.02px) and (min-height: 500.02px), (min-width: 768.02px) and (pointer: fine), (min-width: 768.02px) and (pointer: none) {
	.elementor-location-header {
		position: sticky;
		/* White info bar scrolls away, blue bar stays (under the admin bar when logged in). */
		top: calc(var(--wp-admin--admin-bar--height, 0px) - var(--b4-infobar-h, 0px));
		z-index: 1000;
	}

	/* In-page links, the skip link and keyboard focus land below the pinned bar:
	   the article keeps that much room above whatever is scrolled into view in it.
	   Not the page as a whole (scroll-padding): the bar's own contents sit in that
	   band, so Chrome and Safari scrolled the article by up to a screen to "reveal"
	   anything in the bar that was focused or found (opening search, tabbing to it,
	   find in page). early.js handles keyboard focus on a link that is already on
	   screen under the bar, which browsers leave where it is. */
	#content,
	#primary,
	#primary * {
		scroll-margin-top: calc(var(--wp-admin--admin-bar--height, 0px) + var(--b4-header-h) - var(--b4-infobar-h, 0px) + 16px);
	}

	html body #mr-overlay { display: none !important; }

	/* While the white info bar scrolls away, the menu moves up with the header.
	   Where the browser supports scroll-driven animations this happens on the
	   compositor, in step with the header: the menu's box stays where it starts
	   (under the whole header) and is drawn up to --b4-follow higher. Elsewhere
	   early.js moves its top from a scroll listener, which can trail the header by
	   a frame. */
	@supports (animation-timeline: scroll()) {
		html body #mr-sidebar {
			--b4-follow: var(--b4-infobar-h);
			top: calc(var(--wp-admin--admin-bar--height, 0px) + var(--b4-header-h)) !important;
			animation-name: b4-follow-header;
			animation-duration: auto;
			animation-timing-function: linear;
			animation-fill-mode: both;
			animation-timeline: scroll(root block);
			animation-range: 0px var(--b4-follow);
		}
	}

	/* The menu's box reaches --b4-follow below the window, so however far it is
	   drawn up its bottom edge never comes up short, and nothing about it has to
	   change while the page scrolls. The footer is drawn over the end of the menu,
	   so there is never a gap between them either. The end padding grows by the
	   same amounts (early.js sets the footer's share), so the last row can still be
	   scrolled into view.
	   A band of menu colour above and below the menu (hidden behind the header and
	   footer) covers any sub-pixel seam. */
	html body #mr-sidebar {
		bottom: calc(-1 * var(--b4-follow, 0px)) !important;
		padding-bottom: calc(32px + var(--b4-follow, 0px) + var(--b4-footer-overlap, 0px)) !important;
		box-shadow: 0 -160px 0 0 var(--b4-sidebar-bg), 0 160px 0 0 var(--b4-sidebar-bg) !important;
	}

	/* No rubber-band bounce at either end of the page: it pulled the header and the
	   footer away from the menu, which stays where it is. (Phones keep it, and
	   pull-to-refresh.) */
	html {
		overscroll-behavior-y: none;
	}

	/* The menu column is painted into the page background too, so it doesn't blink
	   white for a frame while the next page loads (the header paints first). */
	html body {
		background-image: linear-gradient(var(--b4-sidebar-bg), var(--b4-sidebar-bg)) !important;
		background-repeat: no-repeat !important;
		background-position: left top !important;
		background-size: var(--b4-sidebar-w) 100% !important;
	}

	/* The side menu is always on screen here, so the burger did nothing. */
	.elementor-location-header .header-hamburger {
		display: none !important;
	}
	/* Without the burger, "Bay Four" and the subtitle line up with the
	   side-menu text below them. */
	.elementor-location-header .elementor-element.elementor-element-7b54d19 {
		padding-left: var(--b4-gutter) !important;
	}
	.elementor-location-header .elementor-element.elementor-element-c1f6c38 {
		padding-left: var(--b4-gutter) !important;
	}
}

/* Short windows: a pinned bar would take a large share of the height, so let
   it scroll away (and the menu follow it all the way up). */
@media (min-width: 768.02px) and (max-height: 500px) {
	.elementor-location-header {
		position: relative;
		top: auto;
	}
	#content,
	#primary,
	#primary * {
		scroll-margin-top: 0;
	}
}
@supports (animation-timeline: scroll()) {
	@media (min-width: 768.02px) and (max-height: 500px) {
		html body #mr-sidebar { --b4-follow: var(--b4-header-h); }
	}
}

@keyframes b4-follow-header {
	from { transform: none; }
	to { transform: translateY(calc(-1 * var(--b4-follow, 0px))); }
}

@media (max-width: 1024px) {
	:root { --b4-sidebar-w: 230px; }
}

/* Tablet: Elementor gives the info bar fixed widths (300px icons, 500px links)
   and the links 34px of unused padding, which forced them onto two rows. */
@media (min-width: 768.02px) and (max-width: 1024px) {
	.elementor-location-header .elementor-element.elementor-element-74034e2 {
		--width: auto;
		width: auto !important;
		flex: 0 0 auto !important;
	}
	.elementor-location-header .elementor-element.elementor-element-7f95ee3 {
		--width: auto;
		width: auto !important;
		flex: 1 1 auto !important;
		min-width: 0;
	}
	.elementor-location-header .elementor-element.elementor-element-bd0e7cf {
		padding-right: 0 !important;
	}
}
@media (min-width: 768.02px) and (max-width: 888px) {
	.elementor-location-header .elementor-element.elementor-element-bd0e7cf {
		--e-nav-menu-horizontal-menu-item-margin: calc(20px / 2) !important;
	}
	.elementor-location-header .elementor-element-bd0e7cf .elementor-nav-menu--main .elementor-item {
		font-size: 13px !important;
	}
}

/* ==========================================================================
   Phone: maximise reading space
   ========================================================================== */
@media (max-width: 768px), (max-width: 1024px) and (max-height: 500px) and (pointer: coarse) {
	:root {
		--b4-sidebar-w: 0px;
		--b4-header-h: 75px;
		--b4-infobar-h: 0px;
	}

	/* Social icons and info links live in the footer on phones, so the topic
	   text starts straight under the header. */
	.elementor-location-header .elementor-element.elementor-element-1929cc6 {
		display: none !important;
	}

	.elementor-location-header .elementor-element.elementor-element-7b54d19 {
		padding: 4px 4px 0 !important;
	}
	.elementor-location-header .elementor-element-2d9f4ea .elementor-heading-title {
		font-size: 28px !important;
	}
	.elementor-location-header .elementor-element.elementor-element-c1f6c38 {
		padding: 0 12px 8px calc(4px + 40px) !important;
	}
	.elementor-location-header .elementor-element-c1f6c38 h2,
	.elementor-location-header .elementor-element-c1f6c38 .e-heading-base {
		font-size: 13px !important;
	}

	/* Drawer: starts at the bottom of whatever header is still on screen. While
	   closed it is hidden from keyboard and screen readers too (after the slide). */
	html body #mr-sidebar {
		width: min(320px, 85vw) !important;
		transform: translateX(-105%) !important;
		bottom: 0 !important;
		padding-bottom: calc(24px + env(safe-area-inset-bottom)) !important;
		z-index: 1100 !important;
		box-shadow: 2px 0 12px rgba(0, 0, 0, .18) !important;
		visibility: hidden;
		transition: transform .25s ease, visibility 0s linear .25s !important;
	}
	html body #mr-sidebar.mobile-open {
		transform: translateX(0) !important;
		visibility: visible;
		transition: transform .25s ease, visibility 0s linear 0s !important;
	}
	html body #mr-overlay {
		inset: var(--b4-sidebar-top) 0 0 0 !important;
		z-index: 960 !important;   /* above the footer, below the drawer */
	}
	/* Stop the article scrolling behind the open drawer. (The lock has to be on
	   <html>: overflow-x: clip there stops body's overflow reaching the page.) */
	html:has(> body.mr-menu-open) { overflow: hidden !important; }
	body.mr-menu-open { overflow: hidden; }

	html body .ast-page-builder-template .entry-content-wrap,
	html body .site-content,
	html body #content.site-content {
		margin-left: 0 !important;
	}
	html body .ast-article-single .entry-content {
		padding-bottom: 48px !important;
	}

	/* Search results: Astra's search-only padding (3em) is far too much here. */
	html body.search .ast-container section.ast-archive-description {
		padding: 1.5em 1em !important;
	}

	/* Footer as a single centred column. The side padding keeps every link clear
	   of the chat bubble and scroll-to-top at the bottom right. */
	.b4-footer__inner {
		grid-template-columns: 1fr;
		justify-items: center;
		text-align: center;
		gap: 14px;
		padding: 28px 68px calc(28px + env(safe-area-inset-bottom));
	}
	.b4-footer__links li { margin: 5px 8px; }
	.b4-footer__links li + li::before { content: none; }

	/* Smaller bubble so it hides less text. */
	#mr-error-btn {
		width: 48px !important;
		height: 48px !important;
		right: 14px !important;
		bottom: calc(14px + env(safe-area-inset-bottom)) !important;
	}
	#mr-error-btn svg {
		width: 24px !important;
		height: 24px !important;
	}
	html body #ast-scroll-top {
		right: calc(14px + (48px - var(--b4-top-size)) / 2) !important;
		bottom: calc(14px + 48px + 10px + env(safe-area-inset-bottom)) !important;
	}

	/* Floating buttons step aside while the menu drawer is open. */
	body.mr-menu-open #mr-error-btn,
	body.mr-menu-open #ast-scroll-top {
		visibility: hidden !important;
	}
}

/* Very narrow phones (under 360px): a little less footer padding, so the links
   still fit in three rows instead of leaving one alone on a row. The bubble and
   scroll-to-top stay clear of them. */
@media (max-width: 359px) {
	.b4-footer__inner {
		padding-left: 52px;
		padding-right: 52px;
	}
}

/* Phones held sideways get the phone layout above, but the theme's phone spacing
   stops at 768px wide, so they had the wider tablet side margins. Use the phone
   ones (keeping the tablet's tighter top spacing). */
@media (min-width: 768.02px) and (max-width: 1024px) and (max-height: 500px) and (pointer: coarse) {
	html body .entry-content,
	html body .entry-header {
		padding-left: 16px !important;
		padding-right: 16px !important;
	}
}
/* Phones held sideways had the theme's roomier spacing above the title and the
   text (up to 768px wide, and again above 921px, as on the largest phones): about
   40px of an already short screen. Start them all as high. */
@media (max-width: 1024px) and (max-height: 500px) and (pointer: coarse) {
	/* Above 921px the theme lays the page out as a row, so this margin no longer
	   folds into the one above it: 10px more. */
	html body #primary {
		margin-top: 0 !important;
	}
	html body .ast-article-single .entry-header {
		padding-top: 5px !important;
	}
	html body .ast-article-single .entry-content {
		padding-top: 0 !important;
	}
}

/* Elementor's phone search field is a fixed 180px, which pushed it under the
   search icon on phones narrower than ~390px. Use what is left of the row. */
@media (max-width: 767px) {
	.elementor-location-header .header-search-panel.search-open {
		width: min(180px, calc(100vw - 214px)) !important;
	}
}

/* ==========================================================================
   Windows High Contrast: backgrounds are dropped and every transparent bar or
   white icon would vanish or be painted, so draw only what means something.
   ========================================================================== */
@media (forced-colors: active) {
	html body #mr-sidebar .mr-chapter-link,
	html body #mr-sidebar .mr-topic-list li > a {
		border-left-color: Canvas !important;
	}
	html body #mr-sidebar .mr-chapter-item.active > .mr-chapter-link {
		border-left-color: Highlight !important;
	}
	html body #mr-sidebar .mr-topic-list li.mr-topic-active > a {
		forced-color-adjust: none;
		background: Highlight !important;
		color: HighlightText !important;
		border-left-color: Highlight !important;
	}
	html body #mr-sidebar .mr-topic-list li.mr-topic-active > a:focus-visible {
		outline-color: HighlightText !important;
	}
	.elementor-location-header .header-hamburger svg,
	.elementor-location-header .header-search-toggle svg {
		fill: ButtonText !important;
	}
	#mr-error-btn {
		border: 2px solid ButtonText !important;
	}
	#mr-error-btn svg,
	html body.b4-footer-in-view #mr-error-btn svg {
		stroke: ButtonText !important;
	}
	/* White icons on coloured circles: the circles are dropped, so draw the icons
	   in the text colour. */
	html body .elementor-location-header .elementor-element-b9aad82 .elementor-social-icon svg,
	html body .b4-footer .elementor-social-icon svg {
		fill: CanvasText !important;
	}
	/* The dialog and its button lose their backgrounds: give them edges. */
	#mr-error-modal {
		border: 1px solid CanvasText;
	}
	/* Mark where the page ends and the footer begins. */
	.b4-footer {
		border-top: 1px solid CanvasText;
	}
	#mr-error-modal button {
		border: 1px solid ButtonText !important;
	}
}

/* ==========================================================================
   Reduced motion
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
	html body #mr-sidebar,
	html body #mr-sidebar.mobile-open,
	.elementor-location-header .header-search-panel,
	.elementor-location-header .header-search-panel.search-open,
	#mr-error-btn,
	html body #ast-scroll-top {
		transition: none !important;
	}
	#mr-error-btn:hover {
		transform: none !important;
	}
}
