/* ==========================================================================
   BBI - Editorial chapter system (Checkpoint C)
   Reusable layer. Contains no page copy.

   Required hooks (supplied by Divi, all inside ONE Code module so the sticky
   navigation and the chapters share a parent):
     .bbi-chapters-section             the Divi section
     .bbi-chapters[data-bbi-chapters]  root  (+ optional data-bbi-default,
                                              data-bbi-explore-label)
     .bbi-chapters__nav                <nav> with an aria-label
     .bbi-chapters__list               <ul> of in-page links
     .bbi-chapters__link               <a href="#chapter-id">
     .bbi-chapter                      <section id="..."> one per principal chapter
     .bbi-chapter__title               its <h2>
     .bbi-chapter__summary             optional always-visible line
     .bbi-chapter__body                collapsible content
     .bbi-band                         always-open section (advisers, invitation)
     .bbi-band--invitation             the final confidential invitation
     .bbi-band__title / __body / __cta

   Everything is scoped under .bbi-chapters so Divi's global ul / p / h2 rules
   cannot out-rank it. Tokens fall back to the hero values when bbi-hero.css is
   absent.
   ========================================================================== */

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

:root {
	--bbi-chapters-max: 1240px;
	--bbi-chapters-gutter: clamp(24px, 5.3vw, 76px);
	--bbi-chapters-measure: 670px;
	--bbi-chapters-sticky-top: 0px;
	--bbi-chapters-nav-height: 64px;
	--bbi-chapters-rule: rgba(245, 244, 241, 0.14);
}

/* Logged-in WordPress admin bar. It stops being fixed below 601px. */
body.admin-bar {
	--bbi-chapters-sticky-top: 32px;
}

@media (max-width: 782px) {
	body.admin-bar {
		--bbi-chapters-sticky-top: 46px;
	}
}

@media (max-width: 600px) {
	body.admin-bar {
		--bbi-chapters-sticky-top: 0px;
	}
}

@media (max-width: 989px) {
	:root {
		--bbi-chapters-nav-height: 56px;
	}
}

/* --------------------------------------------------------------------------
   2. Section shell
   -------------------------------------------------------------------------- */

/* Doubled class: outranks Divi's `.et_pb_section { padding: 4% 0 }` whatever the
   stylesheet order. */
.bbi-chapters-section.bbi-chapters-section {
	padding: 0;
	background: var(--bbi-black, #050505);
	color: var(--bbi-white, #f5f4f1);
}

/* Same neutralisation as the hero: Divi rows and columns must not impose their
   own width or gutters. `overflow` is never set here or on any ancestor of the
   navigation, because any overflow value other than visible disables sticky. */
.bbi-chapters-section .et_pb_row,
.bbi-chapters-section .et_pb_column {
	width: 100%;
	max-width: none;
	padding: 0;
	margin: 0;
}

.bbi-chapters {
	background: var(--bbi-black, #050505);
	color: var(--bbi-white, #f5f4f1);
	font-family: var(--bbi-font, "Overpass", system-ui, sans-serif);
	font-weight: 400;
}

/* Shared container: 1240px maximum, centred, fluid gutters. */
.bbi-chapters .bbi-chapters__list,
.bbi-chapters .bbi-chapters__explore,
.bbi-chapters .bbi-chapter,
.bbi-chapters .bbi-band {
	box-sizing: border-box;
	width: min(var(--bbi-chapters-max), calc(100% - 2 * var(--bbi-chapters-gutter)));
	margin-inline: auto;
}

.bbi-chapters :focus-visible {
	outline: 2px solid var(--bbi-orange, #ff5a00);
	outline-offset: 4px;
}

/* --------------------------------------------------------------------------
   3. Chapter navigation
   -------------------------------------------------------------------------- */

.bbi-chapters .bbi-chapters__nav {
	position: sticky;
	top: var(--bbi-chapters-sticky-top);
	z-index: 20;
	background: var(--bbi-black, #050505);
	border-bottom: 1px solid var(--bbi-chapters-rule);
}

.bbi-chapters .bbi-chapters__list {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	min-height: var(--bbi-chapters-nav-height);
	margin-block: 0;
	padding: 0;
	list-style: none;
	line-height: 1;
}

.bbi-chapters .bbi-chapters__list > li {
	display: flex;
	align-items: center;
	margin: 0;
	padding: 0;
	list-style: none;
}

.bbi-chapters .bbi-chapters__list > li::before {
	content: none;
}

.bbi-chapters .bbi-chapters__list > li + li::before {
	content: "\00B7" / "";
	margin-inline: 14px;
	color: var(--bbi-orange, #ff5a00);
	font-weight: 700;
}

.bbi-chapters .bbi-chapters__link {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	border-bottom: 2px solid transparent;
	color: var(--bbi-muted, #c5c3bf);
	font-size: 13px;
	font-weight: 700;
	letter-spacing: 0.14em;
	line-height: 1;
	text-decoration: none;
	text-transform: uppercase;
	transition: color 160ms ease, border-color 160ms ease;
}

.bbi-chapters .bbi-chapters__link:hover {
	color: var(--bbi-white, #f5f4f1);
}

.bbi-chapters .bbi-chapters__link[aria-current] {
	border-bottom-color: var(--bbi-orange, #ff5a00);
	color: var(--bbi-white, #f5f4f1);
}

/* Created by the script; never shown on desktop or without JavaScript. */
.bbi-chapters .bbi-chapters__explore {
	display: none;
}

/* --------------------------------------------------------------------------
   4. Chapters
   -------------------------------------------------------------------------- */

.bbi-chapters .bbi-chapter,
.bbi-chapters .bbi-band {
	margin-block: 0;
	padding: 0;
	border-top: 1px solid var(--bbi-chapters-rule);
	/* + 1px for the navigation's bottom rule. */
	scroll-margin-top: calc(var(--bbi-chapters-sticky-top) + var(--bbi-chapters-nav-height) + 1px);
}

.bbi-chapters .bbi-chapter__title,
.bbi-chapters .bbi-band__title {
	margin: 0;
	padding: 40px 0 16px;
	color: var(--bbi-white, #f5f4f1);
	font-family: inherit;
	font-size: clamp(26px, 2.4vw, 36px);
	font-weight: 700;
	letter-spacing: -0.01em;
	line-height: 1.15;
}

/* Enhanced: the button carries the spacing so the whole row is clickable. */
.bbi-chapters[data-bbi-chapters-ready="true"] .bbi-chapter__title {
	padding: 0;
}

.bbi-chapters .bbi-chapter__toggle {
	position: relative;
	display: block;
	box-sizing: border-box;
	width: 100%;
	margin: 0;
	padding: 32px 56px 32px 0;
	border: 0;
	border-radius: 0;
	background: none;
	color: inherit;
	font: inherit;
	letter-spacing: inherit;
	line-height: inherit;
	text-align: left;
	text-transform: none;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
}

.bbi-chapters .bbi-chapter__icon {
	position: absolute;
	top: 50%;
	right: 4px;
	width: 20px;
	height: 20px;
	transform: translateY(-50%);
}

.bbi-chapters .bbi-chapter__icon::before,
.bbi-chapters .bbi-chapter__icon::after {
	content: "";
	position: absolute;
	top: 9px;
	left: 0;
	width: 20px;
	height: 2px;
	background: var(--bbi-orange, #ff5a00);
	transition: transform 200ms ease;
}

.bbi-chapters .bbi-chapter__icon::after {
	transform: rotate(90deg);
}

.bbi-chapters .bbi-chapter__toggle[aria-expanded="true"] .bbi-chapter__icon::after {
	transform: rotate(0deg);
}

.bbi-chapters .bbi-chapter__summary {
	max-width: var(--bbi-chapters-measure);
	margin: -12px 0 32px;
	padding: 0;
	color: var(--bbi-muted, #c5c3bf);
	font-size: 18px;
	line-height: 1.5;
}

/* No padding, border or margin on the body itself: a collapsed body uses
   hidden="until-found", which keeps the box but skips its contents, so any
   spacing here would leave a gap under every closed chapter. */
.bbi-chapters .bbi-chapter__body,
.bbi-chapters .bbi-band__body {
	max-width: var(--bbi-chapters-measure);
	color: var(--bbi-white, #f5f4f1);
	font-size: clamp(18px, 1.25vw, 20px);
	font-weight: 400;
	line-height: 1.55;
}

.bbi-chapters .bbi-chapter__body > :last-child {
	margin-bottom: 48px;
}

/* --------------------------------------------------------------------------
   5. Body typography (generic, so page copy can stay in Divi)
   -------------------------------------------------------------------------- */

.bbi-chapters .bbi-chapter__body p,
.bbi-chapters .bbi-band__body p {
	margin: 0 0 1em;
	padding: 0;
	font-size: inherit;
	line-height: inherit;
}

.bbi-chapters .bbi-chapter__body h3,
.bbi-chapters .bbi-band__body h3 {
	margin: 1.6em 0 0.5em;
	padding: 0;
	color: var(--bbi-white, #f5f4f1);
	font-family: inherit;
	font-size: 20px;
	font-weight: 700;
	line-height: 1.3;
}

.bbi-chapters .bbi-chapter__body a,
.bbi-chapters .bbi-band__body a {
	color: var(--bbi-white, #f5f4f1);
	text-decoration: underline;
	text-decoration-color: var(--bbi-orange, #ff5a00);
	text-decoration-thickness: 2px;
	text-underline-offset: 4px;
}

.bbi-chapters .bbi-chapter__body ul,
.bbi-chapters .bbi-chapter__body ol,
.bbi-chapters .bbi-band__body ul,
.bbi-chapters .bbi-band__body ol {
	margin: 0 0 1em;
	padding: 0;
	list-style: none;
	line-height: inherit;
}

.bbi-chapters .bbi-chapter__body li,
.bbi-chapters .bbi-band__body li {
	position: relative;
	margin: 0 0 0.6em;
	padding: 0 0 0 28px;
}

.bbi-chapters .bbi-chapter__body ul > li::before,
.bbi-chapters .bbi-band__body ul > li::before {
	content: "";
	position: absolute;
	top: 0.75em;
	left: 0;
	width: 12px;
	height: 2px;
	background: var(--bbi-orange, #ff5a00);
}

/* Ordered lists are process steps: orange two-digit numerals. */
.bbi-chapters .bbi-chapter__body ol,
.bbi-chapters .bbi-band__body ol {
	counter-reset: bbi-step;
}

.bbi-chapters .bbi-chapter__body ol > li,
.bbi-chapters .bbi-band__body ol > li {
	padding-left: 48px;
	counter-increment: bbi-step;
}

.bbi-chapters .bbi-chapter__body ol > li::before,
.bbi-chapters .bbi-band__body ol > li::before {
	content: counter(bbi-step, decimal-leading-zero);
	position: absolute;
	top: 0.3em;
	left: 0;
	color: var(--bbi-orange, #ff5a00);
	font-size: 13px;
	font-weight: 700;
	letter-spacing: 0.12em;
	line-height: 1.4;
}

/* Question lists. */
.bbi-chapters .bbi-chapter__body dl {
	margin: 0 0 1em;
	padding: 0;
}

.bbi-chapters .bbi-chapter__body dt {
	margin: 1.4em 0 0.35em;
	padding: 0;
	color: var(--bbi-white, #f5f4f1);
	font-weight: 700;
	scroll-margin-top: calc(var(--bbi-chapters-sticky-top) + var(--bbi-chapters-nav-height) + 16px);
}

.bbi-chapters .bbi-chapter__body dt:first-child {
	margin-top: 0;
}

.bbi-chapters .bbi-chapter__body dd {
	margin: 0 0 1em;
	padding: 0;
	color: var(--bbi-muted, #c5c3bf);
}

/* --------------------------------------------------------------------------
   6. Always-open bands (advisers, confidential invitation)
   -------------------------------------------------------------------------- */

.bbi-chapters .bbi-band {
	padding-bottom: 56px;
}

.bbi-chapters .bbi-band__title {
	padding-bottom: 20px;
}

.bbi-chapters .bbi-band--invitation {
	padding-bottom: 96px;
	border-top: 2px solid var(--bbi-orange, #ff5a00);
}

.bbi-chapters .bbi-band__cta {
	display: inline-flex;
	align-items: center;
	gap: 12px;
	margin-top: 12px;
	padding: 0 0 12px;
	border-bottom: 2px solid var(--bbi-orange, #ff5a00);
	color: var(--bbi-white, #f5f4f1);
	font-size: 15px;
	font-weight: 700;
	letter-spacing: 0.12em;
	line-height: 1;
	text-decoration: none;
	text-transform: uppercase;
}

/* --------------------------------------------------------------------------
   7. Narrow screens (<= 989px, matching the hero breakpoint)
   -------------------------------------------------------------------------- */

@media (max-width: 989px) {
	/* Without JavaScript the list simply wraps and scrolls away with the page. */
	.bbi-chapters:not([data-bbi-chapters-ready="true"]) .bbi-chapters__nav {
		position: static;
	}

	.bbi-chapters:not([data-bbi-chapters-ready="true"]) .bbi-chapters__list {
		padding-block: 10px;
	}

	.bbi-chapters[data-bbi-chapters-ready="true"] .bbi-chapters__explore {
		display: flex;
		align-items: center;
		justify-content: space-between;
		height: var(--bbi-chapters-nav-height);
		padding: 0;
		border: 0;
		border-radius: 0;
		background: none;
		color: var(--bbi-white, #f5f4f1);
		font-family: inherit;
		font-size: 13px;
		font-weight: 700;
		letter-spacing: 0.14em;
		line-height: 1;
		text-transform: uppercase;
		cursor: pointer;
		-webkit-appearance: none;
		appearance: none;
	}

	.bbi-chapters .bbi-chapters__explore-arrow {
		color: var(--bbi-orange, #ff5a00);
		font-size: 16px;
		transition: transform 200ms ease;
	}

	.bbi-chapters .bbi-chapters__explore[aria-expanded="true"] .bbi-chapters__explore-arrow {
		transform: rotate(180deg);
	}

	.bbi-chapters[data-bbi-chapters-ready="true"] .bbi-chapters__list {
		display: none;
	}

	.bbi-chapters[data-bbi-chapters-ready="true"] .bbi-chapters__nav[data-bbi-explore-open] .bbi-chapters__list {
		display: flex;
		flex-direction: column;
		align-items: stretch;
		min-height: 0;
		padding-bottom: 12px;
	}

	.bbi-chapters[data-bbi-chapters-ready="true"] .bbi-chapters__list > li + li::before {
		content: none;
	}

	.bbi-chapters[data-bbi-chapters-ready="true"] .bbi-chapters__link {
		width: 100%;
		border-bottom: 0;
		border-left: 2px solid transparent;
		padding-left: 12px;
	}

	.bbi-chapters[data-bbi-chapters-ready="true"] .bbi-chapters__link[aria-current] {
		border-left-color: var(--bbi-orange, #ff5a00);
	}

	.bbi-chapters .bbi-chapter__title,
	.bbi-chapters .bbi-band__title {
		padding-top: 32px;
	}

	.bbi-chapters .bbi-chapter__toggle {
		padding-block: 26px;
	}
}

/* --------------------------------------------------------------------------
   8. Motion: short, additive reveal on open
   -------------------------------------------------------------------------- */

@keyframes bbi-chapter-in {
	from {
		opacity: 0;
		transform: translateY(8px);
	}

	to {
		opacity: 1;
		transform: none;
	}
}

.bbi-chapters[data-bbi-chapters-ready="true"] .bbi-chapter[data-bbi-open] > .bbi-chapter__body {
	animation: bbi-chapter-in 240ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

@media (prefers-reduced-motion: reduce) {
	.bbi-chapters *,
	.bbi-chapters *::before,
	.bbi-chapters *::after {
		animation: none !important;
		transition: none !important;
	}
}

