/**
 * TPL-6 Journal — index, post, and the category archive.
 *
 * Build spec §15.1: a 3-column card grid on the index; a 720px text column
 * on the post with 17px body at 1.75 line height.
 */

/*
 * Journal cards (and the featured card) keep their hairline on hover — the
 * design does not darken it to forest the way the shared .cmn-card:hover does.
 */
.cmn-main--journal .cmn-card:hover {
	border-color: var(--cmn-line);
}

/* ---------------------------------------------------------------------------
 * Featured card at the top of the index
 * ------------------------------------------------------------------------- */
/*
 * The featured card sits 40px under the chips, as the design draws it — the
 * page head already carries that 40px bottom pad, so the section it lives in
 * adds none on top (it was 48px, making an 88px gap).
 */
.cmn-main--journal .cmn-page-head + .cmn-section {
	padding-top: 0;
}

.cmn-featured {
	display: grid;
	grid-template-columns: 3fr 2fr;
	align-items: stretch;
	color: inherit;
	text-decoration: none;
}

.cmn-featured__media {
	display: block;
	overflow: hidden;
	/*
	 * 360px tall, as the design draws it (card ~361px). min-height let the photo
	 * render at its own 3:2 height — ~527px — and stretched the whole card with
	 * it. A fixed height crops the photo to the design's letterbox band instead.
	 */
	height: 360px;
}

.cmn-featured__image {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.cmn-featured__body {
	display: flex;
	flex-direction: column;
	gap: var(--cmn-space-1);
	justify-content: center;
	padding: var(--cmn-space-4);
}

.cmn-featured__title {
	margin: 0;
	font-family: var(--cmn-font-display);
	font-size: 40px;
	font-weight: 300;
	line-height: 1.1;
}

.cmn-featured__excerpt {
	color: var(--cmn-body-muted);
}

@media (max-width: 991px) {
	.cmn-featured {
		grid-template-columns: minmax(0, 1fr);
	}

	.cmn-featured__media {
		min-height: 0;
		/* Reset the fixed desktop height, or aspect-ratio computes width from it
		   (360 × 3/2 = 540px) and the card overflows the phone viewport. */
		height: auto;
		aspect-ratio: 3 / 2;
	}
}

/*
 * Tonal placeholder for cards with no featured image (and every planned card),
 * as the design draws them — a warm 3:2 block in place of the photo.
 */
.cmn-card__media--placeholder {
	background: rgb(217, 207, 193);
}

/* ---------------------------------------------------------------------------
 * Planned cards — present, deliberately not links
 * ------------------------------------------------------------------------- */
.cmn-card--planned {
	border-style: dashed;
	background: transparent;
}

.cmn-card--planned:hover {
	border-color: var(--cmn-line);
	transform: none;
}

.cmn-card__planned {
	margin: var(--cmn-space-1) 0 0;
	font-size: var(--cmn-small);
	font-weight: 700;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--cmn-caption);
}

/* ---------------------------------------------------------------------------
 * Post
 * ------------------------------------------------------------------------- */
.cmn-post__title {
	margin-top: var(--cmn-space-2);
	font-size: clamp(32px, 4vw, 48px);
	line-height: 1.08;
}

.cmn-post__byline {
	margin: var(--cmn-space-2) 0 0;
	font-size: var(--cmn-small);
	color: var(--cmn-caption);
}

.cmn-post__author {
	font-weight: 600;
	color: var(--cmn-charcoal);
}

.cmn-post__lead {
	max-width: 1040px;
	margin: 0 auto;
}

.cmn-post__lead-image {
	width: 100%;
	aspect-ratio: 3 / 2;
	object-fit: cover;
}

/*
 * Build spec §15.1 sets the post body at 17px / 1.75 — a step up from the
 * site body, because this is long-form reading rather than page copy.
 */
.cmn-post__body {
	font-size: 17px;
	line-height: 1.75;
}

.cmn-post__body h2 {
	font-size: 34px;
	line-height: 1.15;
}

.cmn-post__body img {
	width: 100%;
	height: auto;
}

.cmn-post__table {
	margin-top: var(--cmn-space-5);
}

/*
 * The table comes from the durations-table block, which wraps itself in its own
 * section + container. Nested inside the post's measure column that re-indents
 * and narrows the table, so it no longer lines up with the prose and FAQ. Strip
 * the nested chrome and let it fill the column.
 */
.cmn-post__table .cmn-section,
.cmn-post__table .cmn-container {
	max-width: none;
	padding: 0;
	margin: 0;
}

/*
 * The block ships its heading as a 48px/300 page heading; the design sets the
 * table heading at the body-h2 size — 34px/400 — so it reads as a section of
 * the article, not a new page title.
 */
.cmn-post__table h2 {
	font-size: 34px;
	font-weight: 400;
	line-height: 1.15;
}

/*
 * The comparison table. It comes from the ACF cmn_post_table_rows field and so
 * renders via the durations-table block in .cmn-post__table — OUTSIDE
 * .cmn-post__body. The shared .cmn-table styling lives in flexible.css, which
 * the Journal does not load, so it is styled here against the post main:
 * hairline-ruled rows, uppercase walnut column heads, a serif row label, and
 * horizontal scroll on narrow screens.
 */
.cmn-main--post .cmn-table-scroll {
	overflow-x: auto;
	margin-block: var(--cmn-space-4);
}

.cmn-main--post .cmn-table {
	width: 100%;
	border-collapse: collapse;
	/* Body cells are 20px in the design, a step up from site body copy. */
	font-size: 20px;
	min-width: 560px;
}

.cmn-main--post .cmn-table th,
.cmn-main--post .cmn-table td {
	padding: 14px 16px 14px 0;
	border-bottom: 1px solid var(--cmn-line);
	text-align: left;
	vertical-align: top;
}

.cmn-main--post .cmn-table thead th {
	/* The column heads sit tight to their rule: no top pad, 12px below. */
	padding: 0 16px 12px 0;
	font-family: var(--cmn-font-text);
	font-size: var(--cmn-eyebrow);
	font-weight: 700;
	letter-spacing: 0.18em;
	text-transform: uppercase;
	color: var(--cmn-walnut);
}

.cmn-main--post .cmn-table tbody th {
	font-family: var(--cmn-font-display);
	font-size: 20px;
	font-weight: 400;
}

/*
 * Below 768px the table stacks into label/value rows instead of scrolling
 * sideways — the design's behaviour (and what the durations-table block does on
 * flexible pages, whose CSS the post does not load). The column name comes from
 * each cell's data-label, so it survives the stack with the <thead> hidden.
 */
@media (max-width: 767px) {
	.cmn-main--post .cmn-table {
		min-width: 0;
		display: block;
	}

	.cmn-main--post .cmn-table thead {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip-path: inset(50%);
		white-space: nowrap;
	}

	.cmn-main--post .cmn-table tbody,
	.cmn-main--post .cmn-table tr,
	.cmn-main--post .cmn-table th,
	.cmn-main--post .cmn-table td {
		display: block;
	}

	.cmn-main--post .cmn-table tr {
		padding: 18px 0 16px;
		border-bottom: 1px solid var(--cmn-line);
	}

	.cmn-main--post .cmn-table th,
	.cmn-main--post .cmn-table td {
		padding: 3px 0;
		border: 0;
	}

	.cmn-main--post .cmn-table td[data-label] {
		display: grid;
		grid-template-columns: auto 1fr;
		column-gap: var(--cmn-space-2);
		text-align: right;
	}

	.cmn-main--post .cmn-table td[data-label]::before {
		content: attr(data-label);
		font-size: 13px;
		font-weight: 700;
		letter-spacing: 0.12em;
		text-transform: uppercase;
		color: var(--cmn-walnut);
		text-align: left;
	}
}

/* ---------------------------------------------------------------------------
 * Short-answer box
 *
 * Build spec §17's writing rule: open with a one-sentence direct answer. It
 * is an <aside> with its own heading, so it reads as a pull-out rather than
 * as the first paragraph of the body.
 * ------------------------------------------------------------------------- */
.cmn-shortanswer {
	margin-bottom: var(--cmn-space-4);
	padding: 22px 24px;
	background: var(--cmn-white);
	/* A 3px forest rule across the TOP, as the design draws it — not a moss
	   rule down the left. */
	border-top: 3px solid var(--cmn-forest);
}

.cmn-shortanswer__text {
	margin: 0;
	font-size: var(--cmn-body-lg);
	line-height: 1.6;
}

/* ---------------------------------------------------------------------------
 * Post FAQ
 *
 * The faq-accordion block is full-bleed by default (it is a page-width section
 * elsewhere). On the post it must sit in the same narrow text column as the
 * body and align with it — the design draws it as a 720px centred column with a
 * 34px heading, not the 48px page heading the block ships with.
 * ------------------------------------------------------------------------- */
.cmn-main--post .cmn-faq {
	/* 32px above, 80px below — the prose/table sits right on top of it, so the
	   section's default 80px top would open too large a gap (the design draws
	   32/80, on the page's cream, not on a white band). */
	padding-block: 32px 80px;
}

.cmn-main--post .cmn-faq .cmn-container {
	max-width: calc(var(--cmn-measure) + (var(--cmn-gutter) * 2));
}

.cmn-main--post #cmn-faq-title {
	font-size: 34px;
	font-weight: 400;
	line-height: 1.15;
}

/* Search form, shared with search.php */
.cmn-search__form {
	margin-top: var(--cmn-space-3);
}

.cmn-search__form input[type="search"] {
	padding: 14px;
	border: 1px solid var(--cmn-field-border);
	border-radius: var(--cmn-radius);
	font-size: 16px;
}

.cmn-search__form input[type="submit"] {
	min-height: var(--cmn-btn-min-h);
	padding: 12px 20px;
	border: 1px solid var(--cmn-moss);
	border-radius: var(--cmn-radius);
	background: var(--cmn-forest);
	color: var(--cmn-white);
	font-size: var(--cmn-button);
	font-weight: 700;
	letter-spacing: var(--cmn-btn-ls);
	text-transform: uppercase;
	cursor: pointer;
}

/*
 * The Journal index "Latest" heading is 40px in the design — a step below a
 * primary 48px section heading (the gallery index keeps 48px, hence the id
 * scope rather than .cmn-index__heading).
 */
#cmn-latest-title {
	font-size: 40px;
	line-height: 1.1;
	/*
	 * 28px down to the grid, as the design draws it. The .cmn-index__heading
	 * margin that would do this lives in what-we-make.css, which the Journal
	 * does not load — so the heading sat flush on the cards.
	 */
	margin-bottom: 28px;
}

/* Empty-state line when a topic filter matches no cards (journal-filter.js). */
.cmn-journal-empty {
	margin: 0;
	color: var(--cmn-body-muted);
}
