/*
 * CBPA Knowledge Center — P2-05
 *
 * Every colour and face is read from the Elementor global kit with a hard
 * fallback, so a rebrand in Elementor carries into the KB with no code change
 * (plan §3.4, §6.8 — never hard-code #4B7C83).
 *
 * Everything is namespaced .cbpa-kb* and there are NO bare element selectors:
 * this site runs Astra plus four Elementor addon packs (ElementsKit, Essential
 * Addons, Royal, Pojo a11y) and anything unscoped will either leak or be
 * leaked into (plan R6).
 */

.cbpa-kb {
	--cbpa-kb-primary: var(--e-global-color-primary, #4b7c83);
	--cbpa-kb-secondary: var(--e-global-color-secondary, #dfe0e2);
	--cbpa-kb-text: var(--e-global-color-text, #000);
	--cbpa-kb-surface: var(--e-global-color-accent, #fff);
	--cbpa-kb-font: var(--e-global-typography-text-font-family, "Raleway"), system-ui, -apple-system, "Segoe UI", sans-serif;
	--cbpa-kb-gap: 1.25rem;
	--cbpa-kb-radius: 4px;

	font-family: var(--cbpa-kb-font);
	color: var(--cbpa-kb-text);
}

.cbpa-kb *,
.cbpa-kb *::before,
.cbpa-kb *::after {
	box-sizing: border-box;
}

.cbpa-kb__heading {
	margin: 0 0 1rem;
}

/* ---------------------------------------------------------------- filters */

.cbpa-kb__filters {
	margin-bottom: 1.75rem;
}

/* Belt and braces: kb.js removes the [hidden] attribute, but Astra or an addon
   pack setting display on the element would defeat a bare [hidden]. */
.cbpa-kb__filters[hidden] {
	display: none !important;
}

.cbpa-kb__tabs,
.cbpa-kb__chips {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.cbpa-kb__tabs {
	margin-bottom: 0.9rem;
	border-bottom: 2px solid var(--cbpa-kb-secondary);
	padding-bottom: 0.9rem;
}

.cbpa-kb__chips {
	margin-bottom: 0.9rem;
}

.cbpa-kb__tab,
.cbpa-kb__chip {
	font-family: inherit;
	font-size: 0.9375rem;
	line-height: 1.2;
	cursor: pointer;
	border: 1px solid var(--cbpa-kb-secondary);
	background: var(--cbpa-kb-surface);
	color: var(--cbpa-kb-text);
	border-radius: var(--cbpa-kb-radius);
	transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.cbpa-kb__tab {
	padding: 0.55rem 1.1rem;
	font-weight: 600;
}

.cbpa-kb__chip {
	padding: 0.4rem 0.8rem;
	font-size: 0.875rem;
}

/* aria-pressed is the source of truth for state; .is-active only exists so the
   server can paint the default tab before JS runs. */
.cbpa-kb__tab[aria-pressed="true"],
.cbpa-kb__chip[aria-pressed="true"] {
	background: var(--cbpa-kb-primary);
	border-color: var(--cbpa-kb-primary);
	color: #fff;
}

/* Tabs and hub chips both preview the selected state on hover: the same fill
   as aria-pressed above — keep the two blocks in step.
   Gated on (hover: hover) because now that hover and selected look identical,
   a touch device latching :hover after a tap would leave an UNSELECTED control
   looking like the current filter. Equal specificity to the rule above
   (0,0,2,0), so source order decides: this sits after it, and hovering an
   already-selected tab or chip is a no-op because the declarations match. */
@media (hover: hover) {
	.cbpa-kb__tab:hover,
	.cbpa-kb__chip:hover {
		background: var(--cbpa-kb-primary);
		border-color: var(--cbpa-kb-primary);
		color: #fff;
	}
}

/* Visible focus ring — Astra suppresses outlines on buttons (plan P5-04). */
.cbpa-kb__tab:focus-visible,
.cbpa-kb__chip:focus-visible,
.cbpa-kb__search-input:focus-visible,
.cbpa-kb-card__summary:focus-visible,
.cbpa-kb-card__q a:focus-visible {
	outline: 2px solid var(--cbpa-kb-primary);
	outline-offset: 2px;
}

.cbpa-kb__chip[hidden] {
	display: none !important;
}

.cbpa-kb__search-input {
	width: 100%;
	max-width: 24rem;
	padding: 0.55rem 0.8rem;
	font-family: inherit;
	font-size: 1rem;
	border: 1px solid var(--cbpa-kb-secondary);
	border-radius: var(--cbpa-kb-radius);
	background: var(--cbpa-kb-surface);
	color: var(--cbpa-kb-text);
}

.cbpa-kb__count {
	margin: 0.6rem 0 0;
	font-size: 0.875rem;
	opacity: 0.75;
}

.cbpa-kb__noscript ul {
	margin: 0 0 0 1.1rem;
}

/* ------------------------------------------------------------------- grid */

/*
 * Two layout modes, and the handoff between them is where Shuffle grids
 * usually break.
 *
 *   :not(.is-ready) — before Shuffle initialises, and permanently if Shuffle
 *   fails to load from the CDN or JS is off. Plain CSS grid, cards visible and
 *   in flow. This is the no-JS guarantee from plan §3.4.
 *
 *   .is-ready — Shuffle owns positioning and sets position:absolute on each
 *   item, so the container becomes display:block with explicit item widths.
 *
 * kb.js adds .is-ready BEFORE constructing Shuffle so the first measurement is
 * taken against the mode Shuffle will actually lay out in.
 */

.cbpa-kb__grid {
	position: relative;
}

.cbpa-kb__grid:not(.is-ready) {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(17.5rem, 1fr));
	gap: var(--cbpa-kb-gap);
}

/* The sizer is Shuffle's column-width probe. It must not occupy a grid cell
   before init, and must be measurable (height 0, not display:none) after. */
.cbpa-kb__grid:not(.is-ready) .cbpa-kb__sizer {
	display: none;
}

.cbpa-kb__grid.is-ready {
	display: block;
}

.cbpa-kb__grid.is-ready .cbpa-kb__sizer {
	height: 0;
	margin: 0;
	padding: 0;
	border: 0;
}

.cbpa-kb__grid.is-ready .cbpa-kb__sizer,
.cbpa-kb__grid.is-ready .cbpa-kb-card {
	width: 100%;
}

@media (min-width: 40rem) {
	.cbpa-kb__grid.is-ready .cbpa-kb__sizer,
	.cbpa-kb__grid.is-ready .cbpa-kb-card {
		width: calc(50% - (var(--cbpa-kb-gap) / 2));
	}
}

@media (min-width: 64rem) {
	.cbpa-kb__grid.is-ready .cbpa-kb__sizer,
	.cbpa-kb__grid.is-ready .cbpa-kb-card {
		width: calc(33.333% - (var(--cbpa-kb-gap) * 2 / 3));
	}
}

.cbpa-kb__grid.is-ready .cbpa-kb-card {
	margin-bottom: var(--cbpa-kb-gap);
}

/* ------------------------------------------------------------------ cards */

.cbpa-kb-card__inner {
	height: 100%;
	display: flex;
	flex-direction: column;
	gap: 0.6rem;
	padding: 1.1rem 1.15rem 1.2rem;
	background: var(--cbpa-kb-surface);
	border: 1px solid var(--cbpa-kb-secondary);
	border-left: 3px solid var(--cbpa-kb-primary);
	border-radius: var(--cbpa-kb-radius);
}

.cbpa-kb-card__chip {
	align-self: flex-start;
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	text-decoration: none;
	color: var(--cbpa-kb-primary);
}

.cbpa-kb-card__chip:hover {
	text-decoration: underline;
}

.cbpa-kb-card__q {
	margin: 0;
	font-size: 1.0625rem;
	line-height: 1.35;
	font-weight: 600;
}

.cbpa-kb-card__q a {
	color: inherit;
	text-decoration: none;
}

.cbpa-kb-card__q a:hover {
	color: var(--cbpa-kb-primary);
	text-decoration: underline;
}

.cbpa-kb-card__details {
	margin-top: auto;
}

.cbpa-kb-card__summary {
	cursor: pointer;
	font-size: 0.875rem;
	font-weight: 600;
	color: var(--cbpa-kb-primary);
	list-style: none;
}

.cbpa-kb-card__summary::-webkit-details-marker {
	display: none;
}

.cbpa-kb-card__summary::before {
	content: "+ ";
	font-weight: 700;
}

.cbpa-kb-card__details[open] .cbpa-kb-card__summary::before {
	content: "– ";
}

.cbpa-kb-card__answer {
	padding-top: 0.5rem;
	font-size: 0.9375rem;
	line-height: 1.6;
}

.cbpa-kb-card__answer p {
	margin: 0 0 0.6rem;
}

.cbpa-kb-card__more {
	font-size: 0.875rem;
	font-weight: 600;
	color: var(--cbpa-kb-primary);
}

.cbpa-kb__noresults {
	padding: 1.5rem 0;
	font-size: 1rem;
}

.cbpa-kb__noresults[hidden] {
	display: none !important;
}

/* --------------------------------------------- theme byline suppression */

/*
 * Astra prints its own "By <wp-user> / <publish date>" meta in the entry
 * header. On a legal Q&A that is actively WRONG: it attributes the content to
 * the WordPress account that ran the import (literally "By admin"), directly
 * above the real attorney byline we render ourselves. Found on a real Astra
 * install in P3-02.
 *
 * The PROPER fix is Astra's Customizer, which can turn post meta off per post
 * type, and that should be done on the live site (plan P4-06). This rule is
 * the safety net so the wrong byline can never ship if nobody gets to that
 * setting — scoped to the single Q&A body class so it cannot touch posts,
 * pages or any other archive.
 */
body.single-cbpa_kb .entry-header .entry-meta {
	display: none;
}

/* ----------------------------------------------------------- single Q&A */

.cbpa-kb-single {
	--cbpa-kb-primary: var(--e-global-color-primary, #4b7c83);
	--cbpa-kb-secondary: var(--e-global-color-secondary, #dfe0e2);
	--cbpa-kb-radius: 4px;
	margin-top: 2rem;
}

.cbpa-kb-single__block {
	margin: 0 0 1.5rem;
	padding-top: 1.25rem;
	border-top: 1px solid var(--cbpa-kb-secondary);
}

.cbpa-kb-single__label {
	margin: 0 0 0.35rem;
	font-size: 0.75rem;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	opacity: 0.7;
}

.cbpa-kb-single__authority {
	margin: 0 0 0.4rem;
	line-height: 1.6;
}

.cbpa-kb-single__note {
	margin: 0;
	font-size: 0.9375rem;
	opacity: 0.85;
}

.cbpa-kb-single__byline {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem 1.25rem;
	font-size: 0.9375rem;
}

.cbpa-kb-single__related {
	margin: 0;
	padding-left: 1.15rem;
}

.cbpa-kb-single__related li {
	margin-bottom: 0.4rem;
}

.cbpa-kb-single__cta {
	display: inline-block;
	margin-top: 0.5rem;
	padding: 0.7rem 1.4rem;
	font-weight: 600;
	text-decoration: none;
	color: #fff;
	background: var(--cbpa-kb-primary);
	border-radius: var(--cbpa-kb-radius);
}

.cbpa-kb-single__cta:hover,
.cbpa-kb-single__cta:focus {
	color: #fff;
	filter: brightness(0.92);
}

.cbpa-kb-single__disclaimer {
	margin: 0;
	padding: 1rem 1.15rem;
	font-size: 0.8125rem;
	line-height: 1.6;
	background: var(--cbpa-kb-secondary);
	border-radius: var(--cbpa-kb-radius);
	opacity: 0.95;
}

@media (max-width: 30rem) {
	.cbpa-kb__tab,
	.cbpa-kb__chip {
		font-size: 0.8125rem;
	}

	.cbpa-kb-card__inner {
		padding: 0.9rem 1rem 1rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.cbpa-kb__tab,
	.cbpa-kb__chip {
		transition: none;
	}
}

/* ------------------------------------------------------- archive wrapper */

/*
 * P5-04 (live QA, 2026-11-02). templates/cbpa-kb-index.php renders
 * <main id="primary" class="site-main cbpa-kb-archive"> into Astra's #content,
 * and that wrapper carried no styling at all. Against the live theme it broke
 * two ways, both invisible locally:
 *
 *   1. Astra runs its "Page Builder" container layout site-wide
 *      (body.ast-page-builder-template), which strips every scrap of theme
 *      padding. Elementor-built pages substitute their own section padding;
 *      our template has no sections, so the index ran edge to edge.
 *   2. The site header OVERLAYS the content instead of occupying flow space —
 *      #content starts at y=0 while the header paints down over it. Elementor
 *      pages clear it with a hero section's top padding. We had none, so the
 *      <h1> and the pillar tabs rendered underneath the site nav.
 *
 * The spacing lives on an inner wrapper we own outright, NOT on the <main>.
 * Astra ships
 *     .ast-page-builder-template .site .site-content #primary { padding: 0 }
 * at specificity (0,1,3,0), which beats any class selector we could put on the
 * <main> itself. Measured on the live site: max-width applied, padding was
 * silently dropped, and the collision survived the "fix". Do not move these
 * declarations back onto .cbpa-kb-archive.
 *
 * The clearance is a custom property (inherited by the inner wrapper) so kb.js
 * can measure the real header and set it exactly. The value here is the no-JS
 * fallback and is deliberately generous: surplus whitespace degrades far
 * better than a collision.
 */

.cbpa-kb-archive {
	--cbpa-kb-header-offset: 110px;
	--cbpa-kb-measure: 1240px;
}

.cbpa-kb-archive__inner {
	max-width: var(--cbpa-kb-measure);
	margin-inline: auto;
	padding: calc(var(--cbpa-kb-header-offset) + 1.5rem) 1.25rem 3.5rem;
}

@media (max-width: 921px) {
	.cbpa-kb-archive {
		--cbpa-kb-header-offset: 80px;
	}
}

.cbpa-kb-archive__header {
	margin-bottom: 1.5rem;
}

.cbpa-kb-archive__title {
	margin: 0 0 0.5rem;
}

.cbpa-kb-archive__description {
	margin: 0;
	max-width: 70ch;
}

/* ---------------------------------------------- single: content container */

/*
 * P5-04 (live QA). Astra applies a DIFFERENT container layout per post type.
 * Ordinary posts get `ast-separate-container` — a 1240px `.ast-container` with
 * text measuring ~760px. The Knowledge Center CPT instead lands on
 * `ast-page-builder-template`, whose `.ast-container` is `max-width: 100%`, so
 * the Q&A answers ran the full width of the viewport (1400px at a 1440px
 * window): unreadable for prose, and the title was already capped at 1240px,
 * so heading and body did not even share an edge.
 *
 * Fixed here rather than in the Customizer so it travels with the plugin and
 * cannot be lost to a theme-settings change.
 *
 * Scoped to `body.single-cbpa_kb` so it cannot reach any other post type.
 *
 * The doubled class is a deliberate specificity bump, not a typo. Astra ships
 *     .single.ast-page-builder-template .entry-header { max-width: 1240px }
 * at (0,0,3,0). A plain `body.single-cbpa_kb .entry-header` is (0,0,2,1) —
 * THREE classes beat two-classes-plus-an-element, so Astra wins outright and
 * source order never gets a say. Measured: the body constrained to 780px while
 * the <h1> stayed at 1240px. Repeating the class makes it (0,0,3,1), which
 * clears Astra while staying overridable later — `!important` would not.
 *
 * --cbpa-kb-single-measure is the single number to change. 780px matches the
 * reading measure of the site's own article pages; 1240px would instead match
 * the site's outer container.
 */

body.single-cbpa_kb {
	--cbpa-kb-single-measure: 780px;
}

body.single-cbpa_kb .entry-header.entry-header,
body.single-cbpa_kb .entry-content.entry-content {
	max-width: var(--cbpa-kb-single-measure);
	margin-inline: auto;
}
