/**
 * Article page.
 *
 * Loaded for single posts only, after afrobeatswire.css and brand.css, so it
 * can correct the two homepage rules the old article template inherited:
 * the `--has-shadow` mask that faded the end of every story to nothing, and
 * the rule that hid the share links inside a big-image topper.
 *
 * Everything here is namespaced `afw-` and scoped to `.afw-article`, except
 * the two explicit overrides at the top. It reuses the theme's own tokens
 * (--space-*, --font-*, --afw-purple) rather than introducing new values, so
 * the page stays on the same scale as the rest of the site.
 */

/* ------------------------------------------------------------------ *
 * Corrections to inherited rules
 * ------------------------------------------------------------------ */

/* The teaser fade must never apply to a full article. Kept as a defensive
   rule: the template no longer sets the modifier, but any editor or block
   that reintroduces it would silently make the story unreadable again. */
.afw-article .c-content--has-shadow,
.post-template .c-content--has-shadow {
	-webkit-mask-image: none;
	mask-image: none;
}

/* ------------------------------------------------------------------ *
 * Scale
 * ------------------------------------------------------------------ */

.afw-article {
	--afw-measure: 720px;   /* the spine: header and prose share this width */
	--afw-figure: 1080px;   /* the picture is allowed to be wider           */
	--afw-rail: 56px;
	/* Clears the sticky site header; below this the rail's label slides under
	   the navigation. */
	--afw-sticky-top: 132px;

	margin: 0 auto;
	padding: 0 var(--grid-margin, 20px);
	max-width: var(--afw-figure);
}

/* ------------------------------------------------------------------ *
 * Reading progress
 * ------------------------------------------------------------------ */

.afw-progress {
	position: fixed;
	inset: 0 0 auto 0;
	height: 2px;
	z-index: 60;
	background: transparent;
	pointer-events: none;
}

.afw-progress__bar {
	display: block;
	height: 100%;
	width: 100%;
	transform: scaleX(0);
	transform-origin: 0 50%;
	background: var(--afw-purple, #7C5CFC);
	will-change: transform;
}

/* ------------------------------------------------------------------ *
 * Header
 * ------------------------------------------------------------------ */

.afw-article__head {
	max-width: var(--afw-measure);
	margin: var(--space-40, 40px) auto var(--space-32, 32px);
}

.afw-crumbs {
	display: flex;
	align-items: center;
	gap: var(--space-8, 8px);
	margin-bottom: var(--space-20, 20px);
	font-family: var(--font-family-sansSerif);
	font-size: var(--font-size-scale-0, 12px);
	letter-spacing: var(--font-letter-spacing-small, 1.2px);
	text-transform: uppercase;
	opacity: .75;
}

.afw-crumbs a {
	color: inherit;
	text-decoration: none;
}

.afw-crumbs a:last-of-type {
	color: var(--afw-purple, #7C5CFC);
}

.afw-crumbs a:is(:hover, :focus-visible) {
	text-decoration: underline;
	text-underline-offset: 3px;
}

.afw-article__headline {
	margin: 0;
	font-family: var(--font-family-serif);
	font-weight: 400;
	/* Was a flat 60px sitting on the photograph. Fluid, and never larger than
	   the line it has to fit. */
	font-size: clamp(34px, 5.2vw, 54px);
	line-height: 1.08;
	letter-spacing: var(--font-letter-spacing-negative, -.5px);
	text-wrap: balance;
}

.afw-article__standfirst {
	margin: var(--space-20, 20px) 0 0;
	max-width: 60ch;
	font-family: var(--font-family-sansSerif);
	font-size: var(--font-size-scale-4, 20px);
	line-height: 1.5;
	opacity: .78;
}

.afw-article__meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: var(--space-20, 20px);
	margin-top: var(--space-32, 32px);
	padding-top: var(--space-20, 20px);
	border-top: 1px solid rgba(255, 255, 255, .12);
}

.afw-article__author {
	display: flex;
	align-items: center;
	gap: var(--space-12, 12px);
	min-width: 0;
}

.afw-article__avatar {
	width: 44px;
	height: 44px;
	border-radius: 50%;
	flex: 0 0 auto;
	object-fit: cover;
}

.afw-article__authorText {
	min-width: 0;
}

.afw-article__byline {
	font-family: var(--font-family-sansSerif);
	font-size: var(--font-size-scale-2, 16px);
	line-height: 1.3;
}

.afw-article__byline a {
	color: inherit;
	text-decoration: none;
}

.afw-article__byline a:is(:hover, :focus-visible) {
	text-decoration: underline;
	text-underline-offset: 3px;
}

.afw-article__dates {
	display: flex;
	align-items: center;
	gap: var(--space-8, 8px);
	margin-top: 2px;
	font-family: var(--font-family-sansSerif);
	font-size: var(--font-size-scale-1, 14px);
	opacity: .6;
}

/* ------------------------------------------------------------------ *
 * Feature image
 * ------------------------------------------------------------------ */

.afw-article__figure {
	margin: 0 0 var(--space-40, 40px);
}

.afw-article__image {
	display: block;
	width: 100%;
	height: auto;
	border-radius: var(--border-radius, 4px);
}

.afw-article__caption {
	margin-top: var(--space-12, 12px);
	font-family: var(--font-family-sansSerif);
	font-size: var(--font-size-scale-1, 14px);
	line-height: 1.45;
	opacity: .6;
}

/* ------------------------------------------------------------------ *
 * Body: prose on the spine, share rail in the margin
 * ------------------------------------------------------------------ */

.afw-article__body {
	display: grid;
	grid-template-columns:
		minmax(0, 1fr)
		min(var(--afw-measure), 100%)
		minmax(0, 1fr);
	column-gap: var(--space-32, 32px);
}

.afw-article__rail {
	grid-column: 1;
	grid-row: 1;
	justify-self: end;
	position: sticky;
	top: var(--afw-sticky-top);
	align-self: start;
	height: max-content;
}

.afw-article__prose,
.afw-article__foot {
	grid-column: 2;
}

.afw-article__prose {
	grid-row: 1;
}

/* Explicit second row. A sticky element can only travel inside its own grid
   area, so keeping the foot out of row 1 is what stops the rail from riding
   down alongside the tags and the author card — which already carry their own
   share row. */
.afw-article__foot {
	grid-row: 2;
}

/* .c-content is display:flex/column with `> * { min-width: 100% }`; the prose
   only needs its measure constrained, which the grid track already does. */
.afw-article__prose > * {
	max-width: 100%;
}

/* ------------------------------------------------------------------ *
 * Share
 * ------------------------------------------------------------------ */

.afw-share {
	display: flex;
	gap: var(--space-8, 8px);
}

/* The copy-link control is a <button>; strip the UA styling so it sits in the
   same row as the anchors. */
button.afw-share__link {
	background: none;
	padding: 0;
	font: inherit;
	cursor: pointer;
}

.afw-share__link.is-copied {
	background: var(--afw-mint, #39D98A);
	border-color: var(--afw-mint, #39D98A);
	color: #111;
}

.afw-share__link {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 38px;
	height: 38px;
	border-radius: 50%;
	color: inherit;
	border: 1px solid rgba(255, 255, 255, .18);
	transition: background-color var(--motion-duration-fast, .25s) ease,
	            border-color var(--motion-duration-fast, .25s) ease,
	            color var(--motion-duration-fast, .25s) ease;
}

.afw-share__link:is(:hover, :focus-visible) {
	background: var(--afw-purple, #7C5CFC);
	border-color: var(--afw-purple, #7C5CFC);
	color: #fff;
}

.afw-share--rail {
	flex-direction: column;
}

.afw-share--rail .afw-share__label {
	writing-mode: vertical-rl;
	font-family: var(--font-family-sansSerif);
	font-size: var(--font-size-scale-0, 12px);
	letter-spacing: var(--font-letter-spacing-small, 1.2px);
	text-transform: uppercase;
	opacity: .5;
	margin-bottom: var(--space-8, 8px);
	align-self: center;
}

.afw-share__copied {
	position: absolute;
	opacity: 0;
	pointer-events: none;
}

/* ------------------------------------------------------------------ *
 * Footer of the article: tags, share, author
 * ------------------------------------------------------------------ */

.afw-article__foot {
	margin-top: var(--space-48, 48px);
}

.afw-tags {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-8, 8px);
	margin: 0 0 var(--space-32, 32px);
	padding: 0;
	list-style: none;
}

.afw-tags a {
	display: inline-block;
	padding: 6px 12px;
	border-radius: 999px;
	border: 1px solid rgba(255, 255, 255, .18);
	font-family: var(--font-family-sansSerif);
	font-size: var(--font-size-scale-1, 14px);
	text-decoration: none;
	color: inherit;
	transition: background-color var(--motion-duration-fast, .25s) ease,
	            border-color var(--motion-duration-fast, .25s) ease;
}

.afw-tags a:is(:hover, :focus-visible) {
	background: rgba(124, 92, 252, .16);
	border-color: var(--afw-purple, #7C5CFC);
}

.afw-article__shareFoot {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--space-16, 16px);
	padding: var(--space-24, 24px) 0;
	border-top: 1px solid rgba(255, 255, 255, .12);
	border-bottom: 1px solid rgba(255, 255, 255, .12);
}

.afw-article__shareLabel {
	font-family: var(--font-family-sansSerif);
	font-size: var(--font-size-scale-0, 12px);
	letter-spacing: var(--font-letter-spacing-small, 1.2px);
	text-transform: uppercase;
	opacity: .6;
}

.afw-author {
	display: flex;
	gap: var(--space-20, 20px);
	margin-top: var(--space-40, 40px);
	padding: var(--space-24, 24px);
	border-radius: var(--border-radius, 4px);
	background: rgba(255, 255, 255, .04);
}

.afw-author__avatar {
	width: 64px;
	height: 64px;
	border-radius: 50%;
	flex: 0 0 auto;
	object-fit: cover;
}

.afw-author__text {
	min-width: 0;
}

.afw-author__kicker {
	margin: 0 0 2px;
	font-family: var(--font-family-sansSerif);
	font-size: var(--font-size-scale-0, 12px);
	letter-spacing: var(--font-letter-spacing-small, 1.2px);
	text-transform: uppercase;
	opacity: .5;
}

.afw-author__name {
	margin: 0 0 var(--space-8, 8px);
	font-family: var(--font-family-serif);
	font-weight: 400;
	font-size: var(--font-size-scale-5, 24px);
	line-height: 1.2;
}

.afw-author__name a {
	color: inherit;
	text-decoration: none;
}

.afw-author__name a:is(:hover, :focus-visible) {
	text-decoration: underline;
	text-underline-offset: 3px;
}

.afw-author__bio {
	margin: 0;
	font-family: var(--font-family-sansSerif);
	font-size: var(--font-size-scale-2, 16px);
	line-height: 1.55;
	opacity: .75;
}

.afw-author__more {
	display: inline-block;
	margin-top: var(--space-12, 12px);
	font-family: var(--font-family-sansSerif);
	font-size: var(--font-size-scale-1, 14px);
	color: var(--afw-purple, #7C5CFC);
	text-decoration: none;
}

.afw-author__more:is(:hover, :focus-visible) {
	text-decoration: underline;
	text-underline-offset: 3px;
}

/* ------------------------------------------------------------------ *
 * Newsletter band + comments
 * ------------------------------------------------------------------ */

.afw-article__cta {
	margin: var(--space-64, 64px) auto 0;
	padding: 0 var(--grid-margin, 20px);
	max-width: var(--afw-figure, 1080px);
}

.afw-article__comments {
	max-width: var(--afw-measure, 720px);
	margin: 0 auto;
}

/* ------------------------------------------------------------------ *
 * Narrow screens
 * ------------------------------------------------------------------ */

/* Below this the margins are too tight to hold a rail, so it becomes a row
   above the story. */
@media (max-width: 1024px) {
	.afw-article__body {
		grid-template-columns: minmax(0, 1fr);
	}

	.afw-article__rail {
		grid-column: 1;
		grid-row: auto;
		position: static;
		justify-self: start;
		margin-bottom: var(--space-24, 24px);
	}

	.afw-share--rail {
		flex-direction: row;
		align-items: center;
	}

	.afw-share--rail .afw-share__label {
		writing-mode: horizontal-tb;
		margin: 0 var(--space-4, 4px) 0 0;
	}

	.afw-article__prose,
	.afw-article__foot {
		grid-column: 1;
	}

	/* Both rows must go back to auto together. Leaving the foot pinned to row 2
	   while the prose auto-places would put the two in the same cell, stacking
	   the author card on top of the last paragraphs. */
	.afw-article__prose,
	.afw-article__foot {
		grid-row: auto;
	}
}

@media (max-width: 640px) {
	.afw-article__head {
		margin-top: var(--space-24, 24px);
	}

	.afw-article__meta {
		align-items: flex-start;
		flex-direction: column;
		gap: var(--space-16, 16px);
	}

	.afw-article__figure {
		/* Full-bleed on a phone: the padding around a news photograph costs
		   more than it gives. */
		margin-inline: calc(var(--grid-margin, 20px) * -1);
	}

	.afw-article__image {
		border-radius: 0;
	}

	.afw-article__caption {
		padding-inline: var(--grid-margin, 20px);
	}

	.afw-author {
		flex-direction: column;
		gap: var(--space-16, 16px);
	}
}

@media (prefers-reduced-motion: reduce) {
	.afw-share__link {
		transition: none;
	}
}
