/**
 * One blog article.
 *
 * Figma: PAC-Page-Designs
 *   with a photograph  2216:4558 (desktop), 2221:4664 (tablet), 2221:6273 (phone)
 *   without one        2224:2639 (desktop), 2224:2720 (tablet), 2224:2800 (phone)
 *
 * Heights are checked by check-templates.mjs in the fidelity harness, which
 * names the frame behind every number it compares against.
 *
 * THE BODY IS THE EDITOR'S
 *
 * Everything between the headline and the similar articles is blocks that an
 * editor assembled, so this styles what they produce rather than markup of
 * ours. Two column widths run through it: ordinary blocks stop at 960, and
 * an image marked wide runs to 1312 - which is what makes a picture feel
 * like a picture rather than another paragraph.
 */


/* ------------------------------------------------------------
   The headline, and the photograph that hangs off it
   Figma nodes 2218:3089 and 2224:2642.
   ------------------------------------------------------------ */

.pchs-article-hero {
	/*
	 * The gold band's own padding. In variables because the no-image variant
	 * has to reuse the top value for the bottom, at whatever breakpoint - see
	 * the rule below. The media queries at the foot of the file change the
	 * first two; nothing changes the third.
	 */
	--pchs-hero-px: var(--wp--preset--spacing--20);
	--pchs-hero-pt: var(--wp--preset--spacing--40);
	--pchs-hero-pb: 120px;

	padding-bottom: var(--wp--preset--spacing--40); /* 40px below the picture */
}

/*
 * Without a photograph the band closes up symmetrically, and the space that
 * was inside it moves below it.
 *
 * The 120 above is not spacing - it is clearance for the picture, which
 * covers the last 80 of the band. With no picture there is nothing to clear,
 * so the bottom goes back to matching the top: 40 on a phone, 64 on a tablet,
 * 80 on a desktop. Frames 2224:2803 (390 x 382), 2224:2723 (768 x 438) and
 * 2224:2642 (1440 x 414) all pad their Info box that way, and all three then
 * leave white below the band before the article body.
 */
.pchs-article-hero--no-image {
	--pchs-hero-pb: var(--pchs-hero-pt);
}

.pchs-article-hero__band {
	position: relative;
	background-color: var(--wp--preset--color--yellow-500);
	background-image: linear-gradient(
		90.48deg,
		var(--wp--preset--color--yellow-300) 0%,
		var(--wp--preset--color--yellow-500) 100%
	);
}

/*
 * The same ginkgo drawing as the blog listing's header, at a little over
 * half strength.
 *
 * It is sized two different ways, which is easy to miss because the artwork
 * is the same file at every width. On a phone the frame fills the band with
 * it (`object-cover`, centred), so it is large and runs off both edges. From
 * 768 up the frame contains it against the right-hand edge instead, where it
 * sits beside the headline rather than behind it. Using the wide treatment
 * on a phone leaves the band visibly paler, because a contained drawing
 * covers about a third of the area a cover-sized one does.
 *
 * Frames: 2221:6276 (390), 2221:4667 (768), 2218:3089 (1440).
 */
.pchs-article-hero__band::after {
	position: absolute;
	content: "";
	inset: 0;
	opacity: 0.6;
	background-image: url("../../images/blog/hero-pattern.png");
	background-repeat: no-repeat;
	background-position: center;
	background-size: cover;
	pointer-events: none;
}

.pchs-article-hero__inner {
	position: relative;
	z-index: 1;
	display: flex;
	width: 100%;
	max-width: var(--wp--custom--breakpoint--max-page); /* 1440px */
	flex-direction: column;
	align-items: flex-start;
	margin-inline: auto;

	/*
	 * 120 at the bottom at every width - far more than the words need,
	 * because the photograph is about to cover most of it. The picture
	 * overlaps the band by 80 at every width, so 40 of gold shows below the
	 * byline.
	 *
	 * An article with no photograph overrides the bottom one. The three are
	 * declared on .pchs-article-hero above.
	 */
	padding: var(--pchs-hero-pt) var(--pchs-hero-px) var(--pchs-hero-pb);
}

.pchs-article-hero__meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--wp--preset--spacing--8);
	margin: 0;
}

.pchs-article-hero__meta .pchs-tag {
	text-decoration: none;
}

/*
 * 12 to the headline and 20 from it to the byline - the badges belong to the
 * headline, the byline is a separate thought. Figma: the band is 390 tall at
 * 80 and 120 of padding, and 22 + 12 + 112 + 20 + 24 is the 190 in between.
 */
.pchs-article-hero__title {
	margin: var(--wp--preset--spacing--12) 0 0;
	color: var(--wp--preset--color--blue-500);
	font-family: var(--wp--preset--font-family--title);
	font-size: 40px;
	font-weight: 300;
	line-height: 40px; /* the frame lays H1 out on 1 exactly */
	letter-spacing: var(--wp--custom--tracking--label); /* 0.02em */
	text-transform: uppercase;
}

.pchs-article-hero__title .pchs-em {
	font-weight: 600;
}

.pchs-article-hero__byline {
	margin: var(--wp--preset--spacing--20) 0 0;
	color: var(--wp--preset--color--neutral-800);
	font-family: var(--wp--preset--font-family--body);
	font-size: var(--wp--preset--font-size--md); /* 16px */
	line-height: 1.5;

	/*
	 * 80px kept clear on the right, as every frame does. On a phone this is
	 * what makes the credit wrap onto a second line and the gold band 24px
	 * taller; from 768 up the line is far shorter than the space available
	 * and it changes nothing.
	 *
	 * Dropping it is why this band used to come out 398 at 390 wide against
	 * the frame's 422.
	 */
	padding-right: 80px;
}

/*
 * The photograph covers the last of the gold and carries on below it. 16:9,
 * the width of the page's content rather than of the page.
 */
/*
 * Above the gold, not under it. The band is positioned and this was not, so
 * the band painted over the 60-80px the picture is pulled up by and the top
 * of the photograph simply disappeared. A painting order, not a layout
 * problem, which is why the numbers all measured correctly while it looked
 * wrong.
 */
.pchs-article-hero__image {
	position: relative;
	z-index: 2;
	width: 100%;
	max-width: var(--wp--custom--breakpoint--max-page);

	/*
	 * Up over the gold by 80 at every width - frames 2221:6276, 2221:4667
	 * and 2218:3089 all pull the picture up by that much. The room below it
	 * is the hero's own padding, so that the hero measures what it occupies.
	 *
	 * This was -60 with 20 below, which adds up to the same total height and
	 * so passed a height check while sitting 20px low against the gold.
	 * Overlap and trailing space have to be checked separately.
	 */
	margin: -80px auto 0;
	padding-inline: var(--wp--preset--spacing--20);
}

.pchs-article-hero__img {
	display: block;
	width: 100%;

	/*
	 * height: auto is what makes the aspect-ratio below mean anything.
	 * WordPress prints width and height attributes on a featured image, and
	 * an HTML size attribute is a presentational hint - so without this the
	 * picture has two definite sides already, aspect-ratio is ignored, and a
	 * tall photograph comes out full height.
	 */
	height: auto;
	aspect-ratio: 16 / 9;
	border-radius: var(--wp--custom--radius--xl); /* 32px */
	object-fit: cover;
}


/* ------------------------------------------------------------
   The body
   Figma node 2216:4929.
   ------------------------------------------------------------ */

/*
 * The ginkgo drawings run the whole length of the article, faintly, behind
 * everything. Figma node 2075:7864, "blog_article_RepeatingPattern_BG" -
 * one 1738 x 1826 tile with four of them scattered across it, centred and
 * repeated downwards so an article of any length is covered without the
 * drawings lining up into rows.
 */
.pchs-article__content {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: var(--wp--preset--spacing--40); /* 40px on a phone */
	padding-block: var(--wp--preset--spacing--40);
	background-color: var(--wp--preset--color--white);
	background-image: url("../../images/blog/article-pattern.png");
	background-repeat: repeat-y;
	background-position: center top;
}

/*
 * Every block an editor adds stops at 960. The padding is on the block
 * rather than on the column so that a block marked wide can reach past it -
 * see .alignwide below.
 */
.pchs-article__content > * {
	width: 100%;
	max-width: calc(960px + (var(--wp--preset--spacing--20) * 2));
	margin: 0;
	padding-inline: var(--wp--preset--spacing--20);
}

/* Paragraphs. The first one after the headline is the one that gets pulled
   into the article's card on the blog listing, and the frame sets it larger
   and lighter than the rest - which is what a standfirst is. */
.pchs-article__content p {
	color: var(--wp--preset--color--neutral-800);
	font-family: var(--wp--preset--font-family--body);
	font-size: var(--wp--preset--font-size--md); /* 16px */
	font-weight: 400;
	line-height: 1.5;
}

.pchs-article__content > p:first-child {
	font-size: var(--wp--preset--font-size--lg); /* 20px */
	font-weight: 300;
	letter-spacing: var(--wp--custom--tracking--tight); /* -0.02em */
}

.pchs-article__content h2,
.pchs-article__content h3,
.pchs-article__content h4 {
	margin-bottom: var(--wp--preset--spacing--12);
	color: var(--wp--preset--color--blue-500);
	font-family: var(--wp--preset--font-family--title);
	text-transform: uppercase;
}

/* Figma node 2216:4935: H2 is the heavy weight at 48, with any words an
   editor marked switching to the light one - the reverse of a heading on the
   home page, where light is the base. */
.pchs-article__content h2 {
	font-size: 32px;
	font-weight: 600;
	line-height: 1.16;
	letter-spacing: var(--wp--custom--tracking--label); /* 0.02em */
}

.pchs-article__content h2 .pchs-em {
	font-weight: 300;
}

/* Figma node 2216:4941: H4 is Medium at 32, and NOT letter-spaced. */
.pchs-article__content h3,
.pchs-article__content h4 {
	font-size: 24px;
	font-weight: 500;
	line-height: 1.16;
	letter-spacing: 0;
}

/*
 * Lists. The frame draws a 6px bar rather than a disc, and sets the few
 * words that open each point in the lighter blue - which an editor does with
 * the ordinary Bold button, so <strong> is what arrives here.
 */
.pchs-article__content ul,
.pchs-article__content ol {
	display: flex;
	flex-direction: column;
	gap: var(--wp--preset--spacing--12); /* 12px */
	list-style: none;
}

.pchs-article__content li {
	position: relative;
	padding-left: calc(6px + var(--wp--preset--spacing--12));
	color: var(--wp--preset--color--neutral-800);
	font-family: var(--wp--preset--font-family--body);
	font-size: var(--wp--preset--font-size--md);
	line-height: 1.5;
}

/*
 * A 6px dot, not a bar.
 *
 * The bullet in the frame is an instance 6 wide and 22 tall (node 2216:4961)
 * and it is tempting to read that box as the mark itself. It is not: the
 * artwork inside it is `<circle cx="3" cy="11" r="3">`, a 6px disc sitting in
 * the middle of a 22px line box. Drawing the whole box gives a long capsule
 * beside every point, which is what "stretched" looked like.
 *
 * 8 from the top puts the disc's centre on the frame's cy of 11.
 */
.pchs-article__content ul li::before {
	position: absolute;
	content: "";
	left: 0;
	top: 8px;
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background-color: var(--wp--preset--color--blue-300); /* #13608b, as the SVG */
}

/* A numbered list gets the number in a disc of the same blue instead of the
   bar. Figma node 2216:4981. */
.pchs-article__content ol {
	counter-reset: pchs-step;
}

.pchs-article__content ol li {
	padding-left: calc(20px + var(--wp--preset--spacing--12));
	counter-increment: pchs-step;
}

/* Flush with the top of the line, as the frame has it (node 2216:4981 sits
   at y=0 in its row), not nudged down. */
.pchs-article__content ol li::before {
	position: absolute;
	content: counter(pchs-step);
	left: 0;
	top: 0;
	display: flex;
	width: 20px;
	height: 20px;
	align-items: center;
	justify-content: center;
	border-radius: var(--wp--custom--radius--full);
	background-color: var(--wp--preset--color--blue-300);
	color: var(--wp--preset--color--white);
	font-family: var(--wp--preset--font-family--navigation);
	font-size: var(--wp--preset--font-size--sm); /* 14px */
	font-weight: 700;
	line-height: 1;
	letter-spacing: var(--wp--custom--tracking--label);
}

.pchs-article__content li strong {
	color: var(--wp--preset--color--blue-300);
	font-weight: 600;
}

.pchs-article__content a {
	color: var(--wp--preset--color--blue-300);
	font-weight: 600;
	text-decoration: underline;
	text-underline-position: from-font;
}

.pchs-article__content a:hover,
.pchs-article__content a:focus-visible {
	color: var(--wp--preset--color--blue-500);
}

/*
 * A picture set to "Wide width" in the editor's alignment menu steps outside
 * the text column and runs to the width of the page's content. Figma node
 * 2218:3036: 1312 of the 1440, against the text's 960.
 *
 * WordPress's own alignment rather than a style of this theme's, because an
 * editor already knows where that control is and it already means exactly
 * this. The theme has supported align-wide since it was set up.
 */
.pchs-article__content .alignwide {
	max-width: var(--wp--custom--breakpoint--max-page);
}

.pchs-article__content .alignwide img {
	display: block;
	width: 100%;
	height: auto;
	border-radius: var(--wp--custom--radius--xl); /* 32px */
	box-shadow: var(--wp--preset--shadow--lg);
}


/* ------------------------------------------------------------
   Similar insights
   Figma node 2221:3160.
   ------------------------------------------------------------ */

.pchs-related {
	background-color: var(--wp--preset--color--yellow-500);
	background-image: linear-gradient(
		90.45deg,
		var(--wp--preset--color--yellow-300) 0%,
		var(--wp--preset--color--yellow-500) 100%
	);
}

.pchs-related__inner {
	width: 100%;
	max-width: var(--wp--custom--breakpoint--max-page);
	margin-inline: auto;
	padding: var(--wp--preset--spacing--40) var(--wp--preset--spacing--20);
}

.pchs-related__head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: var(--wp--preset--spacing--20);
	margin-bottom: var(--wp--preset--spacing--40);
}

.pchs-related__heading {
	margin: 0;
	color: var(--wp--preset--color--blue-500);
	font-family: var(--wp--preset--font-family--title);
	font-size: 32px;
	font-weight: 600;
	line-height: 1.16;
	letter-spacing: var(--wp--custom--tracking--label);
	text-transform: uppercase;
}


/* ------------------------------------------------------------
   768px and up
   ------------------------------------------------------------ */

@media (min-width: 768px) {

	/* 64 below the hero from here up, with or without a photograph. */
	.pchs-article-hero,
	.pchs-article-hero--no-image {
		--pchs-hero-px: var(--wp--preset--spacing--40);
		--pchs-hero-pt: var(--wp--preset--spacing--64);

		padding-bottom: var(--wp--preset--spacing--64); /* 64px */
	}

	/* From here up the drawing is contained against the right-hand edge
	   rather than filling the band - see the base rule. */
	.pchs-article-hero__band::after {
		background-position: right top;
		background-size: contain;
	}

	.pchs-article-hero__title {
		font-size: 56px;
		line-height: 56px;
	}

	.pchs-article-hero__image {
		margin-top: -80px;
		padding-inline: var(--wp--preset--spacing--40);
	}

	.pchs-article__content {
		gap: var(--wp--preset--spacing--64); /* 64px */
		padding-block: var(--wp--preset--spacing--64);
	}

	.pchs-article__content > * {
		max-width: calc(960px + (var(--wp--preset--spacing--40) * 2)); /* 1040 */
		padding-inline: var(--wp--preset--spacing--40);
	}

	.pchs-article__content h2 {
		font-size: 40px;
	}

	.pchs-article__content h3,
	.pchs-article__content h4 {
		font-size: 32px;
	}

	.pchs-related__inner {
		padding: var(--wp--preset--spacing--64) var(--wp--preset--spacing--40);
	}

	.pchs-related__heading {
		font-size: 40px;
	}
}


/* ------------------------------------------------------------
   1200px and up
   ------------------------------------------------------------ */

@media (min-width: 1200px) {

	.pchs-article-hero {
		--pchs-hero-px: var(--wp--preset--spacing--64);
		--pchs-hero-pt: var(--wp--preset--spacing--80);
	}

	.pchs-article-hero__title {
		font-size: 56px;
		line-height: 56px;
	}

	/* The words stop short of the drawing on the right. */
	.pchs-article-hero__title,
	.pchs-article-hero__byline,
	.pchs-article-hero__meta {
		max-width: 1040px;
	}

	/*
	 * Up over the gold. The band is 390 and the photograph starts at 310, so
	 * it is pulled up by the 80 between them.
	 */
	.pchs-article-hero__image {
		padding-inline: var(--wp--preset--spacing--64);
	}

	.pchs-article__content {
		padding-block: var(--wp--preset--spacing--64);
	}

	.pchs-article__content h2,
	.pchs-related__heading {
		font-size: 48px;
	}

	.pchs-article__content h3,
	.pchs-article__content h4 {
		font-size: 32px;
	}

	.pchs-article__content .alignwide {
		padding-inline: var(--wp--preset--spacing--64);
	}

	.pchs-related__inner {
		padding: var(--wp--preset--spacing--80) var(--wp--preset--spacing--64);
	}
}
