/* =========================================================================
   BioEvidenceHub — single post

   The reading experience. Everything here serves one goal: making a long
   evidence review comfortable to read from top to bottom.

   The article sets in Source Serif rather than the interface sans. That is
   the deliberate split — sans for chrome, serif for reading — and it is the
   single change that most makes the site read as a publication rather than a
   theme. The homepage stays entirely on the sans, as it is today.
   ========================================================================= */

/* -------------------------------------------------------------------------
   1. Reading progress
   ---------------------------------------------------------------------- */

.beh-progress {
	position: fixed;
	inset-block-start: var(--beh-admin-bar);
	inset-inline: 0;
	z-index: var(--beh-z-toast);
	block-size: 3px;
	background: transparent;
	pointer-events: none;
	/* Hidden until the reader is a full viewport in. Above the hero the bar
	   would sit at zero and report nothing, which is just visual noise. */
	opacity: 0;
	transition: opacity var(--beh-dur) var(--beh-ease);
}

.beh-progress.is-active {
	opacity: 1;
}

.beh-progress__bar {
	display: block;
	block-size: 100%;
	inline-size: 0;
	background: var(--beh-primary);
	transform-origin: inset-inline-start;
}

/* -------------------------------------------------------------------------
   2. Article header
   ---------------------------------------------------------------------- */

.beh-article-head {
	padding-block: var(--beh-s-10) 0;
	background:
		radial-gradient(52rem 18rem at 20% -10%, var(--beh-pale), transparent 70%),
		var(--beh-surface);
}

.beh-article-head__inner {
	max-inline-size: 50rem;
}

.beh-article-head__cat {
	display: inline-block;
	margin-block-end: var(--beh-s-4);
}

.beh-article-head__cat:hover {
	color: var(--beh-primary-700);
}

.beh-article__title {
	font-family: var(--beh-font-editorial);
	/* Serif display faces carry weight optically, so 600 here reads as heavy
	   as 800 does in Inter — going higher would make it look shouty. */
	font-weight: 600;
	font-size: clamp(2.125rem, 4.6vw, 3.5rem);
	line-height: 1.08;
	letter-spacing: -0.025em;
	margin-block-end: var(--beh-s-5);
}

.beh-article__standfirst {
	font-family: var(--beh-font-editorial);
	font-size: clamp(1.125rem, 1.7vw, 1.375rem);
	line-height: 1.55;
	color: var(--beh-muted);
	max-inline-size: 42rem;
	margin-block-end: var(--beh-s-8);
}

/* ---- Byline ---- */

.beh-byline {
	display: flex;
	align-items: center;
	gap: var(--beh-s-3);
	padding-block: var(--beh-s-5);
	border-block: 1px solid var(--beh-line);
}

.beh-byline__avatar img {
	inline-size: 2.75rem;
	block-size: 2.75rem;
	border-radius: 50%;
}

.beh-byline__text {
	display: flex;
	flex-direction: column;
	gap: 0.125rem;
	min-inline-size: 0;
}

.beh-byline__author {
	font-size: var(--beh-fs-base);
	color: var(--beh-muted);
}

.beh-byline__author a {
	color: var(--beh-navy);
	font-weight: 750;
}

.beh-byline__author a:hover {
	color: var(--beh-primary);
}

.beh-byline__dates {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.4375rem;
	font-size: var(--beh-fs-sm);
	color: var(--beh-muted);
	font-variant-numeric: tabular-nums;
}

.beh-byline__updated,
.beh-byline__reading {
	display: inline-flex;
	align-items: center;
	gap: 0.3125rem;
}

/* A visible last-reviewed date is one of the strongest trust signals a
   health publication has, so it is tinted rather than left grey. */
.beh-byline__updated {
	color: var(--beh-accent);
	font-weight: 700;
}

/* ---- Hero image ---- */

.beh-article__hero {
	margin-block-start: var(--beh-s-10);
}

.beh-article__hero .beh-media {
	aspect-ratio: 16 / 9;
	border-radius: var(--beh-r-lg);
}

.beh-article__hero figcaption {
	margin-block-start: var(--beh-s-3);
	font-size: var(--beh-fs-sm);
	color: var(--beh-muted);
}

/* -------------------------------------------------------------------------
   3. Article layout
   ---------------------------------------------------------------------- */

.beh-article__layout {
	padding-block: var(--beh-s-14) var(--beh-s-20);
}

/*
 * Three tracks: table-of-contents rail, article, share rail.
 *
 * The article column is centred by giving the two rails equal-width tracks,
 * so the text sits optically centred in the page whether or not a table of
 * contents exists — rather than drifting left when one is present.
 */
.beh-article__grid {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: var(--beh-s-10);
}

@media (min-width: 1100px) {
	.beh-article__grid {
		grid-template-columns: 15.5rem minmax(0, 1fr) 3.5rem;
		column-gap: var(--beh-s-12);
		align-items: start;
	}

	/* With no table of contents the first track narrows to a plain spacer
	   (single.php always renders three children, so the track count never
	   changes) and the article is centred in what is left. */
	.beh-article__layout:not(.has-toc) .beh-article__grid {
		grid-template-columns: 3.5rem minmax(0, 1fr) 3.5rem;
	}

	.beh-article__layout:not(.has-toc) .beh-article__body {
		margin-inline: auto;
	}
}

.beh-article__body {
	min-inline-size: 0;
	/* Wider than the reading measure on purpose: the text itself is
	   capped by --beh-measure inside .beh-prose, while tables, wide
	   figures and embeds get this full width to spread into. */
	max-inline-size: 52rem;
}

/* Occupies the table-of-contents track when there is nothing to put in it. */
.beh-toc-spacer {
	display: none;
}

@media (min-width: 1100px) {
	.beh-toc-spacer {
		display: block;
	}
}

/* -------------------------------------------------------------------------
   4. Table of contents rail
   ---------------------------------------------------------------------- */

/*
 * Easy Table of Contents brings its own visual identity: a grey or blue
 * bordered box, its own font stack, its own font sizes set INLINE from the
 * plugin's settings screen, bullet markers and an auto-numbering counter.
 * Dropped into this design it reads as a widget borrowed from another site.
 *
 * Everything below re-skins it to the theme: the interface sans at the theme's
 * own sizes, the theme's muted/primary colours, no bullets, no counters. The
 * plugin keeps full ownership of WHICH headings appear and in what order —
 * only the appearance is taken over.
 *
 * The plugin's own rules are specific (#id plus theme class) and some sizes
 * are inline, so a number of these declarations have to be !important. Each
 * one below is overriding something the plugin sets, not defensive noise.
 */

/* Neutralise the plugin's colour themes wherever they are applied. */
.beh-toc #ez-toc-container,
.beh-toc #ez-toc-container.ez-toc-grey,
.beh-toc #ez-toc-container.ez-toc-blue,
.beh-toc #ez-toc-container.ez-toc-white,
.beh-toc #ez-toc-container.ez-toc-black,
.beh-toc #ez-toc-container.ez-toc-transparent {
	background: transparent !important;
	border: 0 !important;
	border-radius: 0 !important;
	box-shadow: none !important;
	padding: 0 !important;
	margin: 0 !important;
	inline-size: 100% !important;
	max-inline-size: none !important;
	font-family: var(--beh-font-ui) !important;
	font-size: var(--beh-fs-sm) !important;
	line-height: 1.45;
	display: block !important;
}

/* The plugin wraps the list in <nav> in newer versions. */
.beh-toc #ez-toc-container nav {
	display: block;
	inline-size: 100%;
}

/* ---- Heading ---- */

.beh-toc .ez-toc-title-container {
	display: block;
	margin: 0 0 var(--beh-s-4);
	padding: 0;
}

.beh-toc .ez-toc-title {
	display: block;
	margin: 0;
	padding: 0;
	font-family: var(--beh-font-ui) !important;
	font-size: var(--beh-fs-xs) !important;
	font-weight: 800 !important;
	line-height: 1.3 !important;
	letter-spacing: var(--beh-tracking-label);
	text-transform: uppercase;
	color: var(--beh-muted) !important;
}

/* The expand/collapse control is meaningless in an always-visible rail. */
.beh-toc .ez-toc-title-toggle,
.beh-toc .ez-toc-js-icon-con,
.beh-toc .ez-toc-toggle {
	display: none !important;
}

/* ---- List ---- */

.beh-toc #ez-toc-container :is(ul, ol) {
	margin: 0 !important;
	padding: 0 !important;
	list-style: none !important;
	/* The plugin's "counter-hierarchy" mode numbers every entry. In a rail
	   the indentation already carries the hierarchy, and the numbers compete
	   with the article's own headings. */
	counter-reset: none !important;
}

.beh-toc #ez-toc-container li {
	margin: 0 !important;
	padding: 0 !important;
	list-style: none !important;
	background: none !important;
}

.beh-toc #ez-toc-container li::before,
.beh-toc #ez-toc-container li::marker,
.beh-toc #ez-toc-container a::before {
	content: none !important;
	counter-increment: none !important;
	display: none !important;
}

/* ---- Links ---- */

.beh-toc #ez-toc-container a,
.beh-toc #ez-toc-container a.ez-toc-link,
.beh-toc #ez-toc-container a:visited {
	display: block;
	padding: 0.4375rem 0 0.4375rem var(--beh-s-4);
	/* The active marker sits in this border, so every row reserves the space
	   and nothing shifts when the marker moves. */
	border: 0 !important;
	border-inline-start: 2px solid transparent !important;
	margin-inline-start: -2px;
	font-family: var(--beh-font-ui) !important;
	font-size: var(--beh-fs-sm) !important;
	font-weight: 600 !important;
	line-height: 1.4 !important;
	color: var(--beh-muted) !important;
	text-decoration: none !important;
	text-shadow: none !important;
	background: none !important;
	transition: color var(--beh-dur-fast) var(--beh-ease),
		border-color var(--beh-dur-fast) var(--beh-ease);
}

.beh-toc #ez-toc-container a:hover {
	color: var(--beh-primary) !important;
	border-inline-start-color: var(--beh-primary-200) !important;
}

/* Nested (h3 and deeper) entries indent and drop a step in size. */
.beh-toc #ez-toc-container :is(ul, ol) :is(ul, ol) a {
	padding-inline-start: var(--beh-s-7);
	font-size: var(--beh-fs-xs) !important;
	font-weight: 500 !important;
}

/*
 * The heading currently on screen. `is-current` is set by article.js with an
 * IntersectionObserver; `.active` is the plugin's own class, matched too so
 * the highlight is right even if the script has not run yet.
 */
.beh-toc #ez-toc-container a.is-current,
.beh-toc #ez-toc-container a.active {
	color: var(--beh-primary) !important;
	font-weight: 750 !important;
	border-inline-start-color: var(--beh-primary) !important;
}

.beh-toc__inner {
	position: relative;
}

/* -------------------------------------------------------------------------
   4b. Table of contents — placement

   Below the three-column breakpoint the rail cannot exist, but the table of
   contents still has to. It was previously hidden outright, which meant every
   phone reader lost it entirely — the plugin's box had been lifted out of the
   content and then displayed nowhere. It now renders as an ordinary bordered
   panel above the article.
   ---------------------------------------------------------------------- */

.beh-toc {
	/* Mobile and tablet: a normal block at the top of the article. The grid's
	   own row gap supplies the space below it — adding a margin here as well
	   left a conspicuous hole between the panel and the first paragraph. */
	order: -1;
	padding: var(--beh-s-5) var(--beh-s-6);
	background: var(--beh-surface-soft);
	border: 1px solid var(--beh-line);
	border-radius: var(--beh-r-lg);
}

@media (min-width: 1100px) {
	.beh-toc {
		position: sticky;
		inset-block-start: calc(var(--beh-header-h) + var(--beh-admin-bar) + 1.75rem);
		max-block-size: calc(100vh - var(--beh-header-h) - 5rem);
		overflow-y: auto;
		overscroll-behavior: contain;
		/* The rail is a hairline against the text, not a panel. */
		padding: 0 0 0 var(--beh-s-5);
		background: transparent;
		border: 0;
		border-inline-start: 2px solid var(--beh-line);
		border-radius: 0;
	}
}

/* -------------------------------------------------------------------------
   5. Share
   ---------------------------------------------------------------------- */

.beh-share {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: var(--beh-s-4);
	padding-block: var(--beh-s-6);
	margin-block-start: var(--beh-s-10);
	border-block: 1px solid var(--beh-line);
}

.beh-share__label {
	font-size: var(--beh-fs-xs);
	font-weight: 800;
	letter-spacing: var(--beh-tracking-label);
	text-transform: uppercase;
	color: var(--beh-muted);
}

.beh-share__links {
	display: flex;
	gap: 0.4375rem;
}

.beh-share__link {
	display: grid;
	place-items: center;
	inline-size: 2.25rem;
	block-size: 2.25rem;
	border: 1px solid var(--beh-line);
	border-radius: 50%;
	background: var(--beh-surface);
	color: var(--beh-navy);
	transition: background var(--beh-dur-fast) var(--beh-ease),
		border-color var(--beh-dur-fast) var(--beh-ease),
		color var(--beh-dur-fast) var(--beh-ease);
}

.beh-share__link:hover {
	background: var(--beh-primary);
	border-color: var(--beh-primary);
	color: #fff;
}

.beh-share__feedback {
	font-size: var(--beh-fs-sm);
	font-weight: 700;
	color: var(--beh-accent);
}

/* Sticky rail version. */
.beh-article__rail {
	display: none;
}

@media (min-width: 1100px) {
	.beh-article__rail {
		display: block;
		position: sticky;
		inset-block-start: calc(var(--beh-header-h) + var(--beh-admin-bar) + 1.75rem);
	}
}

.beh-share-rail {
	display: flex;
	flex-direction: column;
	gap: 0.4375rem;
}

.beh-share-rail__link {
	display: grid;
	place-items: center;
	inline-size: 2.25rem;
	block-size: 2.25rem;
	border: 1px solid var(--beh-line);
	border-radius: 50%;
	background: var(--beh-surface);
	color: var(--beh-muted);
	transition: background var(--beh-dur-fast) var(--beh-ease),
		border-color var(--beh-dur-fast) var(--beh-ease),
		color var(--beh-dur-fast) var(--beh-ease);
}

.beh-share-rail__link:hover {
	background: var(--beh-primary);
	border-color: var(--beh-primary);
	color: #fff;
}

/* -------------------------------------------------------------------------
   6. Tags
   ---------------------------------------------------------------------- */

.beh-entry-tags {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: var(--beh-s-4);
	margin-block-start: var(--beh-s-10);
}

.beh-entry-tags__label {
	font-size: var(--beh-fs-xs);
	font-weight: 800;
	letter-spacing: var(--beh-tracking-label);
	text-transform: uppercase;
	color: var(--beh-muted);
}

/* -------------------------------------------------------------------------
   7. Author box
   ---------------------------------------------------------------------- */

.beh-authorbox {
	display: grid;
	grid-template-columns: 5rem minmax(0, 1fr);
	gap: var(--beh-s-6);
	padding: var(--beh-s-8);
	margin-block-start: var(--beh-s-12);
	background: var(--beh-surface-soft);
	border: 1px solid var(--beh-line);
	border-radius: var(--beh-r-lg);
}

.beh-authorbox__avatar img {
	inline-size: 5rem;
	block-size: 5rem;
	border-radius: 50%;
}

.beh-authorbox__name {
	font-size: var(--beh-fs-xl);
	margin-block: var(--beh-s-1) var(--beh-s-3);
}

.beh-authorbox__name a {
	color: var(--beh-navy);
}

.beh-authorbox__name a:hover {
	color: var(--beh-primary);
}

.beh-authorbox__bio {
	color: var(--beh-body);
	margin-block-end: var(--beh-s-3);
}

/* -------------------------------------------------------------------------
   8. Previous / next
   ---------------------------------------------------------------------- */

.beh-prevnext {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: var(--beh-s-4);
	margin-block-start: var(--beh-s-12);
}

.beh-prevnext__item {
	display: flex;
	flex-direction: column;
	gap: var(--beh-s-2);
	padding: var(--beh-s-5) var(--beh-s-6);
	border: 1px solid var(--beh-line);
	border-radius: var(--beh-r-md);
	transition: border-color var(--beh-dur) var(--beh-ease),
		background var(--beh-dur) var(--beh-ease);
}

.beh-prevnext__item:hover {
	border-color: var(--beh-primary-200);
	background: var(--beh-surface-soft);
}

/* A lone "next" link sits on the right where a reader expects it, rather
   than sliding into the empty "previous" slot. */
.beh-prevnext__item--next:only-child {
	grid-column: 2;
}

.beh-prevnext__label {
	display: inline-flex;
	align-items: center;
	gap: 0.3125rem;
	font-size: var(--beh-fs-xs);
	font-weight: 800;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--beh-primary);
}

.beh-prevnext__item--prev .beh-i {
	scale: -1 1;
}

[dir='rtl'] .beh-prevnext__item--prev .beh-i {
	scale: 1 1;
}

[dir='rtl'] .beh-prevnext__item--next .beh-i {
	scale: -1 1;
}

.beh-prevnext__item--next {
	text-align: end;
	align-items: flex-end;
}

.beh-prevnext__title {
	font-family: var(--beh-font-editorial);
	font-size: var(--beh-fs-lg);
	font-weight: 600;
	line-height: 1.3;
	color: var(--beh-navy);
}

.beh-font-sans .beh-prevnext__title {
	font-family: var(--beh-font-ui);
	font-weight: 750;
}

/* -------------------------------------------------------------------------
   9. Page links (paginated posts)
   ---------------------------------------------------------------------- */

.beh-page-links {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.375rem;
	margin-block: var(--beh-s-10);
	font-family: var(--beh-font-ui);
	font-size: var(--beh-fs-base);
	font-weight: 700;
}

.beh-page-links :is(a, span) span {
	display: inline-grid;
	place-items: center;
	min-inline-size: 2.25rem;
	block-size: 2.25rem;
	padding-inline: 0.5rem;
	border: 1px solid var(--beh-line);
	border-radius: var(--beh-r-sm);
}

.beh-page-links > span:not(:first-child) > span {
	background: var(--beh-primary);
	border-color: var(--beh-primary);
	color: #fff;
}

/* -------------------------------------------------------------------------
   10. Responsive
   ---------------------------------------------------------------------- */

@media (max-width: 860px) {
	.beh-article-head {
		padding-block-start: var(--beh-s-8);
	}

	.beh-article__layout {
		padding-block: var(--beh-s-10) var(--beh-s-14);
	}

	.beh-authorbox {
		grid-template-columns: 1fr;
		padding: var(--beh-s-6);
	}

	.beh-prevnext {
		grid-template-columns: 1fr;
	}

	.beh-prevnext__item--next:only-child {
		grid-column: 1;
	}

	.beh-prevnext__item--next {
		text-align: start;
		align-items: flex-start;
	}
}
