/**
 * Blog / article experience: the posts index (home.php), category/tag/author
 * archives (archive.php), single posts (single.php) and the "Article" page
 * template (page-templates/article.php). Tokens only, from main.css.
 *
 * @package BB_Theme
 */

/* ============================== Category chips ============================== */
.bb-blog-chips { margin: 0 0 24px; }
.bb-blog-chips__list {
	display: flex;
	gap: 8px;
	list-style: none;
	margin: 0;
	padding: 2px 0 10px;
	overflow-x: auto;
	scrollbar-width: none;
}
.bb-blog-chips__list::-webkit-scrollbar { display: none; }
.bb-blog-chips__list > li { flex: none; }

/* ============================== Blog index grid ============================== */
.bb-blog-grid {
	display: grid;
	grid-template-columns: repeat( 3, minmax( 0, 1fr ) );
	gap: var( --bb-gap );
	margin-bottom: var( --bb-section );
}
.bb-blogcard--featured { grid-column: 1 / -1; }
.bb-blogcard--featured .bb-blogcard__media { aspect-ratio: 16 / 7; }
.bb-blogcard--featured .bb-blogcard__title { font-size: 1.5rem; }

@media ( max-width: 1024px ) {
	.bb-blog-grid { grid-template-columns: repeat( 2, minmax( 0, 1fr ) ); }
}
@media ( max-width: 600px ) {
	.bb-blog-grid { grid-template-columns: minmax( 0, 1fr ); }
	.bb-blogcard--featured .bb-blogcard__media { aspect-ratio: 16 / 9; }
}

/* ============================== Post card ============================== */
.bb-blogcard {
	background: var( --bb-surface );
	border: 1px solid var( --bb-border );
	border-radius: var( --bb-r-card );
	overflow: hidden;
	display: flex;
	flex-direction: column;
	height: 100%;
}
.bb-blogcard__media {
	display: block;
	aspect-ratio: 16 / 10;
	background: var( --bb-ground );
	overflow: hidden;
}
.bb-blogcard__media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bb-blogcard__media-fallback {
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var( --bb-muted );
}
.bb-blogcard__body { padding: 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.bb-blogcard__meta {
	margin: 0;
	font-size: .75rem;
	font-weight: 600;
	color: var( --bb-muted );
	display: flex;
	align-items: center;
	gap: 6px;
	flex-wrap: wrap;
}
.bb-blogcard__cat { color: var( --bb-ink-2 ); text-decoration: none; }
.bb-blogcard__cat:hover { text-decoration: underline; }
.bb-blogcard__dot { opacity: .6; }
.bb-blogcard__title { margin: 0; font-family: var( --bb-font-display ); font-size: 1.0625rem; line-height: 1.3; }
.bb-blogcard__title a { color: var( --bb-ink ); text-decoration: none; }
.bb-blogcard__title a:hover { text-decoration: underline; }
.bb-blogcard__excerpt {
	margin: 0;
	font-size: .875rem;
	color: var( --bb-body );
	line-height: 1.5;
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* Compact variant: horizontal row, used in the sidebar's "More articles" list. */
.bb-blogcard--compact {
	flex-direction: row;
	border: 0;
	border-radius: 0;
	border-bottom: 1px solid var( --bb-border );
	padding-bottom: 12px;
}
.bb-blogcard--compact .bb-blogcard__media { flex: none; width: 76px; height: 76px; aspect-ratio: auto; border-radius: var( --bb-r-small ); }
.bb-blogcard--compact .bb-blogcard__body { padding: 0 0 0 12px; gap: 4px; }
.bb-blogcard--compact .bb-blogcard__title { font-size: .9375rem; line-height: 1.35; }
.bb-blogcard--compact .bb-blogcard__title a {
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* ============================== Article layout ============================== */
.bb-article-layout {
	display: grid;
	grid-template-columns: minmax( 0, 1fr ) 340px;
	gap: clamp( 24px, 4vw, 56px );
	align-items: start;
}
@media ( max-width: 1024px ) {
	.bb-article-layout { grid-template-columns: minmax( 0, 1fr ); }
}

.bb-article__head { margin-bottom: 16px; max-width: 70ch; }
.bb-article__meta {
	display: flex;
	align-items: center;
	gap: 6px;
	flex-wrap: wrap;
	margin: 0 0 10px;
	font-size: .8125rem;
	font-weight: 600;
	color: var( --bb-muted );
}
.bb-article__meta svg { flex: none; }
.bb-article__cat { color: var( --bb-ink-2 ); text-decoration: none; }
.bb-article__cat:hover { text-decoration: underline; }
.bb-article__dot { opacity: .6; }
.bb-article__date,
.bb-article__read { display: inline-flex; align-items: center; gap: 4px; }
.bb-article__title {
	margin: 0;
	font-family: var( --bb-font-display );
	font-size: clamp( 1.75rem, 3.4vw, 2.625rem );
	line-height: 1.15;
}

.bb-article__hero {
	margin: 20px 0 28px;
	border-radius: var( --bb-r-panel );
	overflow: hidden;
	background: var( --bb-ground );
}
.bb-article__hero img { width: 100%; height: auto; display: block; }

/* ============================== Table of contents ============================== */
.bb-toc {
	background: var( --bb-ground );
	border: 1px solid var( --bb-border );
	border-radius: var( --bb-r-small );
	padding: 14px 16px;
	margin: 0 0 24px;
	max-width: 70ch;
}
.bb-toc__summary {
	display: flex;
	align-items: center;
	gap: 8px;
	cursor: pointer;
	font-weight: 700;
	list-style: none;
	min-height: 28px;
}
.bb-toc__summary::-webkit-details-marker { display: none; }
.bb-toc__summary svg { flex: none; }
.bb-toc__list { margin: 12px 0 0; padding-left: 1.2em; }
.bb-toc__list li { margin: 0 0 6px; }
.bb-toc__list a { color: var( --bb-ink-2 ); text-decoration: none; }
.bb-toc__list a:hover { text-decoration: underline; }

@media ( min-width: 1025px ) {
	/* Not sticky: it sat over the article text while scrolling; the sidebar now follows instead. */
	.bb-toc__summary { cursor: default; pointer-events: none; }
}

/* ============================== Article body (prose) ============================== */
.bb-article__body { max-width: 70ch; font-size: 1.0625rem; line-height: 1.7; color: var( --bb-body ); }
.bb-article__body > :first-child { margin-top: 0; }

.bb-article__body h2,
.bb-article__body h3,
.bb-article__body h4 {
	font-family: var( --bb-font-display );
	color: var( --bb-ink );
	line-height: 1.25;
	scroll-margin-top: 90px;
}
.bb-article__body h2 { font-size: 1.5rem; margin: 2em 0 .6em; }
.bb-article__body h3 { font-size: 1.1875rem; margin: 1.75em 0 .5em; }
.bb-article__body h4 { font-size: 1.0625rem; margin: 1.5em 0 .5em; }

.bb-article__body p { margin: 0 0 1.1em; }

.bb-article__body ul,
.bb-article__body ol { margin: 0 0 1.1em; padding-left: 1.25em; }
.bb-article__body ul { list-style: disc; }
.bb-article__body ol { list-style: decimal; }
.bb-article__body li { margin: 0 0 .4em; }
.bb-article__body li:last-child { margin-bottom: 0; }
.bb-article__body li > p { margin-bottom: .4em; }

.bb-article__body a { color: var( --bb-ink ); text-decoration: underline; text-decoration-color: var( --bb-border-2 ); text-underline-offset: 2px; }
.bb-article__body a:hover { text-decoration-color: currentColor; }

.bb-article__body strong { color: var( --bb-ink ); }

.bb-article__body blockquote {
	margin: 1.4em 0;
	padding: 4px 0 4px 18px;
	border-left: 3px solid var( --bb-yellow );
	font-style: italic;
	color: var( --bb-ink-2 );
}
.bb-article__body blockquote p:last-child { margin-bottom: 0; }

.bb-article__body figure { margin: 1.4em 0; }
.bb-article__body img { max-width: 100%; height: auto; display: block; border-radius: var( --bb-r-small ); }
.bb-article__body figcaption { margin-top: 8px; font-size: .8125rem; color: var( --bb-muted ); text-align: center; }
.bb-article__body figcaption:empty { display: none; }

.bb-article__body table {
	width: 100%;
	border-collapse: collapse;
	font-size: .9375rem;
	margin: 1.4em 0;
	display: block;
	overflow-x: auto;
}
.bb-article__body th,
.bb-article__body td { border: 1px solid var( --bb-border ); padding: 8px 10px; text-align: left; }

.bb-article__body hr { border: 0; border-top: 1px solid var( --bb-border ); margin: 2em 0; }

/* Any iframe/video/embed left un-wrapped still can't overflow the column. */
.bb-article__body iframe,
.bb-article__body video,
.bb-article__body embed,
.bb-article__body object { max-width: 100%; }

/* Responsive 16:9 wrapper for video embeds (used by the cleaned-up "in the
   media" posts - see docs/theme/DEPLOY-CHECKLIST.md for which post IDs). */
.bb-article__body .bb-embed-wrap {
	position: relative;
	width: 100%;
	aspect-ratio: 16 / 9;
	overflow: hidden;
	border-radius: var( --bb-r-panel );
	background: var( --bb-ink );
	margin: 1.4em 0;
}
.bb-article__body .bb-embed-wrap iframe {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
}

/* "Read the full article at ..." press-clip link card (cleaned-up media posts). */
.bb-article__body .bb-press-clip { margin: 1.4em 0; }
.bb-article__body .bb-press-clip__link {
	display: block;
	text-decoration: none;
	border: 1px solid var( --bb-border );
	border-radius: var( --bb-r-panel );
	overflow: hidden;
	background: var( --bb-surface );
}
.bb-article__body .bb-press-clip__link img { border-radius: 0; margin: 0; }
.bb-article__body .bb-press-clip__cta {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 14px 16px;
	font-weight: 700;
	color: var( --bb-ink );
	text-decoration: none;
	border-top: 1px solid var( --bb-border );
}

/* Callout box, same visual language as content.css's .bb-callout (used on
   editorial "Article"-template pages for the key safety points). */
.bb-article__body .bb-callout {
	display: flex;
	gap: 12px;
	align-items: flex-start;
	background: var( --bb-pale-yellow );
	border: 1px solid var( --bb-soft-yellow );
	border-radius: var( --bb-r-small );
	padding: 16px;
	margin: 1.4em 0;
}
.bb-article__body .bb-callout svg { flex: none; margin-top: 2px; }
.bb-article__body .bb-callout p { margin: 0; }
.bb-article__body .bb-callout p + p { margin-top: .5em; }
.bb-article__body .bb-callout strong { display: block; margin-bottom: 2px; }

.bb-article__body .wp-block-button__link {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: var( --bb-touch );
	padding: 0 20px;
	border-radius: var( --bb-r-control );
	background: var( --bb-yellow );
	color: var( --bb-ink );
	font-weight: 700;
	text-decoration: none;
}

/* ============================== Related + CTA ============================== */
.bb-article-related { margin-top: var( --bb-section ); max-width: none; }
.bb-article-related__title { font-family: var( --bb-font-display ); font-size: 1.375rem; margin: 0 0 16px; }
.bb-article-related__scroller {
	display: grid;
	grid-template-columns: repeat( 4, minmax( 0, 1fr ) );
	gap: var( --bb-gap );
	margin-bottom: 20px;
}
.bb-article-related__cta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
}
.bb-article-related__cta-text { margin: 0; max-width: 60ch; }

@media ( max-width: 1024px ) {
	.bb-article-related__scroller { grid-template-columns: repeat( 2, minmax( 0, 1fr ) ); }
}
@media ( max-width: 640px ) {
	.bb-article-related__scroller {
		grid-template-columns: none;
		grid-auto-flow: column;
		grid-auto-columns: 78%;
		overflow-x: auto;
		scroll-snap-type: x mandatory;
		padding-bottom: 4px;
		margin-inline: calc( var( --bb-gutter ) * -1 );
		padding-inline: var( --bb-gutter );
	}
	.bb-article-related__scroller .bb-blogcard { scroll-snap-align: start; }
	.bb-article-related__cta { flex-direction: column; align-items: stretch; text-align: center; }
}

/* ============================== Sidebar ============================== */
.bb-article__sidebar { display: flex; flex-direction: column; gap: 20px; }
.bb-sidebar-block { border-top: 1px solid var( --bb-border ); padding-top: 18px; }
.bb-sidebar-block:first-child { border-top: 0; padding-top: 0; }
.bb-sidebar-block__title { font-family: var( --bb-font-display ); font-size: 1.0625rem; margin: 0 0 12px; }
.bb-sidebar-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.bb-sidebar-list > li:last-child .bb-blogcard--compact { border-bottom: 0; padding-bottom: 0; }

.bb-sidebar-promo { text-align: left; }
.bb-sidebar-promo__label { margin: 0; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; }
.bb-sidebar-promo__figure { margin: 4px 0 0; font-family: var( --bb-font-display ); font-size: 2.25rem; line-height: 1; }
.bb-sidebar-promo__sub { margin: 4px 0 16px; font-size: .875rem; }
.bb-sidebar-promo .bb-btn { margin: 0; }

.bb-sidebar-cats { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.bb-sidebar-cats__count { opacity: .6; font-weight: 400; }

@media ( max-width: 1024px ) {
	.bb-article__sidebar { flex-direction: row; flex-wrap: wrap; margin-top: var( --bb-section ); }
	.bb-sidebar-block { flex: 1 1 260px; border-top: 0; padding-top: 0; }
	.bb-sidebar-list { flex-direction: row; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 4px; }
	.bb-sidebar-list > li { flex: none; width: 260px; scroll-snap-align: start; }
	.bb-blogcard--compact { border-bottom: 0; }
}
@media ( max-width: 600px ) {
	.bb-article__sidebar { flex-direction: column; }
	.bb-sidebar-block { flex: none; }
}

/* ============================== Pagination ============================== */
.bb-blog-index .navigation.pagination,
.bb-blog-index .pagination { margin-top: 8px; }
.bb-blog-index .pagination .nav-links { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.bb-blog-index .pagination .page-numbers {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: var( --bb-touch );
	min-height: var( --bb-touch );
	padding: 0 10px;
	border: 1px solid var( --bb-border );
	border-radius: var( --bb-r-control );
	color: var( --bb-ink-2 );
	text-decoration: none;
	font-weight: 600;
}
.bb-blog-index .pagination .page-numbers.current { background: var( --bb-ink ); border-color: var( --bb-ink ); color: #fff; }
.bb-blog-index .pagination .page-numbers.dots { border: 0; min-width: auto; padding: 0 4px; }

@media ( max-width: 767px ) {
	.bb-article__title { margin-top: 2px; }
	.bb-pagehead__title { font-size: 1.625rem; }
}

/* Grid children must be allowed to shrink below their content (scroll strips inside). */
.bb-article-layout > * { min-width: 0; }
.bb-article__sidebar, .bb-article__sidebar > *, .bb-sidebar-list, .bb-article-related { min-width: 0; max-width: 100%; }

/* Gary: "More articles" follows the reader while scrolling (desktop sidebar). */
@media ( min-width: 1025px ) {
	.bb-article__sidebar {
		position: sticky;
		top: 24px;
		max-height: calc( 100vh - 48px );
		overflow-y: auto;
		overscroll-behavior: contain;
		scrollbar-width: thin;
		padding-right: 4px;
	}
}

/* Press clips without their duplicate image: a clean call-to-action card. */
.bb-article__body .bb-press-lead { font-size: 1.125rem; color: var( --bb-ink-2 ); }
.bb-article__body .bb-press-clip__link:not(:has(img)) .bb-press-clip__cta { border-radius: var( --bb-r-tile ); }

/* FAQ accordions (core/details) inside blog posts - same treatment as content pages. */
/* FAQ-style accordions (core/details). */
.bb-article__body details {
	border-bottom: 1px solid var( --bb-border );
	padding: 14px 0;
}
.bb-article__body details:first-of-type { border-top: 1px solid var( --bb-border ); }
.bb-article__body summary {
	cursor: pointer;
	font-weight: 600;
	list-style: none;
	padding-right: 28px;
	position: relative;
}
.bb-article__body summary::-webkit-details-marker { display: none; }
.bb-article__body summary::after {
	content: "+";
	position: absolute;
	right: 4px;
	top: 0;
	font-weight: 400;
	color: var( --bb-muted );
}
.bb-article__body details[open] summary::after { content: "\2212"; }
.bb-article__body details > :last-child { margin-top: 10px; }
