/* ==========================================================================
   BBI - Global Header (0.4.2; rebuilt on native Divi modules, 0.5.0; 0.5.1
   adds section 7, below)
   Reusable layer. Contains no page copy — the brand link comes entirely
   from the Website Profile options page via the [bbi_header_brand]
   shortcode (inc/global-header.php), pasted into one Divi Text module.
   "Insights" and "Talk to John" are a native Divi Menu module — this file
   no longer styles them; see the Menu module's own Design settings/Preset
   in the Theme Builder, and the one targeted override in section 4 below
   for the "Talk to John" item's CTA underline, which Divi's Menu module
   has no per-item control for.

   Required hooks:
     .bbi-header[data-bbi-header]   the Theme Builder header Row, via
                                     Divi's own Advanced → CSS ID & Classes
     .bbi-header__brand             logo + trading name, links to home
                                     (still custom markup via the shortcode
                                     above — Divi's Text module has no flex-
                                     row control for an <img> + <span> pair)

   Black background, white text, true orange accents, Overpass — the same
   tokens as the hero and footer. Sticky site-wide since the Global header
   task (16 Nov 2026) via Divi's own Sticky Position setting on the header
   Row in the Theme Builder, not a rule in this file — nothing here needed
   to change for that. bbi-chapters.css/.js, referenced below, are not in
   use on the current home page (it rebuilt its chapters as a native Divi
   Accordion module); section 7 below is the real fix for that stickiness
   reaching those anchors.

   Height is pinned to --bbi-hero-header-zone, the same token the hero
   reserves as its own top padding (assets/css/bbi-hero.css), so the header
   and the space the hero leaves for it always agree — one source of truth
   instead of two numbers that can drift apart. That token is set at :root,
   not scoped to .bbi-hero--editorial, specifically so this file — which
   loads on every page, not just the one with a hero — can read it too.
   Tokens otherwise fall back to the hero's own values when bbi-hero.css is
   absent, so this file works standalone on any page that only carries the
   global header.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */

.bbi-header {
	--bbi-header-black: var(--bbi-black, #050505);
	--bbi-header-white: var(--bbi-white, #f5f4f1);
	--bbi-header-orange: var(--bbi-orange, #ff5a00);
	--bbi-header-font: var(
		--bbi-font,
		"Overpass",
		"Overpass Variable",
		-apple-system,
		BlinkMacSystemFont,
		"Segoe UI",
		Roboto,
		"Helvetica Neue",
		Arial,
		sans-serif
	);
	--bbi-header-zone: var(--bbi-hero-header-zone, 106px);
	--bbi-header-inset: var(--bbi-hero-inset, 76px);
}

/* --------------------------------------------------------------------------
   2. Root and layout — in normal flow, not fixed/sticky/overlaid. The
      hero's own top padding already reserves exactly this height, so the
      header simply takes its place above it; nothing needs to overlap.
   -------------------------------------------------------------------------- */

.bbi-header {
	position: relative;
	height: var(--bbi-header-zone);
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 24px;
	padding-inline: var(--bbi-header-inset);
	background: var(--bbi-header-black);
	color: var(--bbi-header-white);
	font-family: var(--bbi-header-font);
	box-sizing: border-box;
	overflow: hidden;
}

.bbi-header * {
	box-sizing: border-box;
}

/* Divi wraps the header in its own .et_pb_section/.et_pb_row/.et_pb_column
   chrome, each carrying default padding, margin or a max-width. Neutralise
   all three so the rendered header is exactly --bbi-header-zone tall with
   no extra Divi padding above or below it; left unfixed, that padding opens
   a gap between the header and the hero below it even though both already
   agree on the same height token. This covers .bbi-header as a descendant
   div — the old shortcode-only header, superseded but kept for rollback. */
.et_pb_section:has(.bbi-header),
.et_pb_row:has(.bbi-header),
.et_pb_column:has(.bbi-header) {
	width: 100%;
	max-width: none;
	padding: 0;
	margin: 0;
}

/* .bbi-header assigned directly to the Row itself via Divi's own CSS ID &
   Classes (the native-module header, 0.5.0 — a Row flexing its Text-module
   brand and Menu-module nav side by side). No padding reset here: unlike the
   nested-wrapper case above, .bbi-header's own padding-inline (section 2)
   IS the Row's padding in this structure — zeroing it here would specificity-
   win over that rule (two classes beats one) and collapse the header's
   insets to flush against the viewport edge, which is what shipped broken
   until this was caught on the live front end. */
.et_pb_row.bbi-header,
.et_pb_column.bbi-header {
	width: 100%;
	max-width: none;
	margin: 0;
}

.bbi-header :focus-visible {
	outline: 2px solid var(--bbi-header-orange);
	outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   3. Brand — the name's typography (bold, 13px, uppercase, letter-spaced)
      is the Eyebrow Text Preset (Order of Work step 1), assigned to this
      module in the Theme Builder, not set here. This file only lays the
      element out (truncation, flex sizing) and colours it on hover/focus.
   -------------------------------------------------------------------------- */

.bbi-header__brand {
	display: inline-flex;
	align-items: center;
	gap: 12px;
	min-width: 0;
	color: var(--bbi-header-white);
	text-decoration: none;
}

.bbi-header__logo {
	display: block;
	flex: 0 0 auto;
	width: 36px;
	height: 36px;
}

.bbi-header__brand-name {
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.bbi-header__brand:hover .bbi-header__brand-name,
.bbi-header__brand:focus-visible .bbi-header__brand-name {
	color: var(--bbi-header-orange);
}

/* --------------------------------------------------------------------------
   4. Nav CTA underline — the Menu module (Design settings/Preset) owns all
      base nav styling now. This is the one thing Divi's Menu module has no
      per-item control for: giving just "Talk to John" the same orange
      underline as the hero CTA, matching the approved language (never a
      filled button, see bbi-hero.css section 6), while "Insights" stays a
      plain link. The menu item itself carries this class via its own
      "CSS Classes" field in Appearance → Menus — not generated here.
   -------------------------------------------------------------------------- */

.bbi-header__cta-item > a {
	padding-bottom: 4px;
	border-bottom: 2px solid var(--bbi-header-orange);
}

/* --------------------------------------------------------------------------
   5. Narrow viewports — same 24px/32px gutters as the hero (bbi-hero.css
      section 7-8), so the brand and the hero's own content line up under
      it instead of sitting at two different insets.
   -------------------------------------------------------------------------- */

@media (max-width: 479px) {
	.bbi-header {
		padding-inline: 24px;
		gap: 16px;
	}
}

@media (min-width: 480px) and (max-width: 989px) {
	.bbi-header {
		padding-inline: 32px;
	}
}

/* --------------------------------------------------------------------------
   5b. Mobile drawer fix (6/8 Nov Codey brief, item 1). Diagnosed live by Lil
       Bro, 5 Nov: section 2's `overflow: hidden` on .bbi-header clips the
       Menu module's drawer, and the drawer itself renders only as wide as
       the 54px hamburger-toggle column it's nested in — "the drawer is only
       as wide as the 54px hamburger column" (Build Control, 6 Nov).

       Two fixes, both scoped to <=767px so desktop (which never shows this
       drawer) is untouched:
       1. Allow the drawer to paint outside .bbi-header's box.
       2. Take the drawer out of normal flow with `position: fixed` rather
          than `absolute`. Fixed positioning is relative to the viewport, not
          any ancestor — so it reliably spans edge-to-edge regardless of
          which column Divi happens to nest it in, without needing to know
          that nesting (no browser access this session to inspect the live
          DOM and confirm the exact ancestor chain). --bbi-header-zone is the
          same token the header's own height already uses (section 1), so
          the drawer always starts exactly where the header ends, including
          at the 88px mobile header height set in bbi-hero.css section 8. */
@media (max-width: 767px) {
	.bbi-header {
		overflow: visible;
	}

	.bbi-header .et_mobile_menu {
		position: fixed;
		top: var(--bbi-header-zone);
		left: 0;
		right: 0;
		width: 100%;
		max-width: 100%;
		z-index: 9999;
	}
}

/* --------------------------------------------------------------------------
   6. Reduced motion / forced colors — no animation is used here, but keep
      the focus ring solid and opaque regardless of forced-colors mode.
   -------------------------------------------------------------------------- */

@media (forced-colors: active) {
	.bbi-header :focus-visible {
		outline-color: Highlight;
	}
}

/* --------------------------------------------------------------------------
   7. Anchor clearance sitewide (Global header task defect, 16 Nov 2026).
      Now that the header sticks on every page (section intro, above), a
      direct link to an in-page anchor with no scroll handling of its own
      lands clipped under it. Checked live: the home page's numbered
      chapters (now a native Divi Accordion, one id per item) land exactly
      this way — #about-john landed at y=32, hidden under the header, which
      ends around y=138 with the admin bar showing. The glossary's own
      terms already clear correctly (bbi-glossary.js computes its own
      scroll position for its manual open-and-scroll); this plain
      scroll-margin-top is for everything that relies on the browser's own
      anchor jump instead, and is harmless alongside that script.
   -------------------------------------------------------------------------- */

.et_pb_accordion_item[id] {
	scroll-margin-top: calc(88px + var(--wp-admin--admin-bar--height, 0px) + 16px);
}

@media (min-width: 981px) {
	.et_pb_accordion_item[id] {
		scroll-margin-top: calc(106px + var(--wp-admin--admin-bar--height, 0px) + 16px);
	}
}
