/**
 * Blog post (single.php; frames design/blog-single/ and blog-single.png).
 *
 * Meta row, share rail, summary box, FAQ block and the
 * right rail with the table of contents. Shared layout: singles.css.
 *
 * Logical properties only (RTL follows the active language). Tokens used
 * only here are local to this template.
 *
 * @package cartrack
 */

/*
 * Measured from design/subpages/blog-single.png at 1920 (TODO: verify in
 * Figma): the FAQ post's header row and hairline, a meta row and chips under
 * the title, the image covering the 508 x 284 (16:9) column, then three
 * columns: the share rail ~125px before the 788px article, an ~80px gap and
 * the ~354px right rail. Colours sampled from the frame.
 */
.sp-single--post {
	--post-heading-gap: 1.75rem;          /* Meta → chips (~28px). */
	--post-title-gap: 0.75rem;            /* Extra below the title (~40px to the meta). */
	--post-meta-gap: 2.5rem;              /* ~40px between the meta columns. */
	--post-meta-label-gap: 0.125rem;
	--post-share-col: 2.375rem;           /* 38px buttons. */
	--post-share-gap: 5.4375rem;          /* ~87px to the article. */
	--post-share-space: calc(var(--post-share-col) + var(--post-share-gap));
	--post-block-gap: var(--space-xl);    /* Summary → article → FAQ (mobile). */
	--post-rail-gap: 1.25rem;             /* Between the right rail cards (~20px). */
	--post-summary-bg: var(--sp-bg-light);    /* #f8fafc (sampled). */
	--post-summary-border: #d4e9fc;       /* Sampled. */
	--post-summary-pad: var(--space-md);
	--post-summary-badge: 1.875rem;       /* 30px. */
	--post-summary-badge-bg: #eef6fe;     /* Sampled. */
	--post-summary-badge-text: #396281;   /* Sampled. */
	--post-summary-pitch: 0.625rem;       /* ~40px row pitch with 30px badges. */
	--post-faq-space: var(--space-2xl);   /* Hairline → FAQ heading (~96px at 1920). */
	--post-faq-gap: var(--space-lg);
	--post-hr-space: var(--space-2xl);    /* Around an <hr> in the article (~80-90px at 1920). */
	--post-quote-font: var(--font-heading);   /* Montserrat quotes (blog frame). TODO: verify. */
	--post-related-heading-size: 1.75rem; /* "Other articles for you", ~28px. TODO: verify. */
	--post-related-heading-line-height: 1.25;
}

@media (min-width: 64em) { /* --bp-lg */
	.sp-single--post {
		--post-block-gap: 4.5rem;         /* ~76px summary → article. */
		--post-summary-pad: 1.75rem;      /* ~28px. */
		--post-faq-space: var(--space-3xl);
		--post-faq-gap: 2.5rem;
		--post-hr-space: 5rem;
	}
}

/* Header: title, meta row, chips | the image (.sp-single__image in singles.css). */
.sp-single--post .sp-single__heading {
	gap: var(--post-heading-gap);
}

.sp-single--post .sp-single__title {
	margin-block-end: var(--post-title-gap);
}

.sp-post__meta {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-sm) var(--post-meta-gap);
	margin: 0;
}

.sp-post__meta-item {
	display: flex;
	flex-direction: column;
	gap: var(--post-meta-label-gap);
	min-inline-size: 0;
}

.sp-post__meta-label {
	color: var(--color-text-muted);
	font-family: var(--t-small-family);
	font-size: var(--t-small-size);
	line-height: var(--t-small-line-height);
	text-transform: uppercase;
}

/* No capitals for scripts that have none (CLAUDE.md 11A). */
.sp-post__meta-label:lang(ar),
.sp-post__meta-label:lang(th),
.sp-post__meta-label:lang(zh) {
	text-transform: none;
}

.sp-post__meta-value {
	margin: 0;
	color: var(--color-text);
	font-family: var(--t-body-family);
	font-size: var(--t-body-size);
	line-height: var(--t-body-line-height);
	overflow-wrap: anywhere;
}

/* Body: share buttons, article, right rail. */
.sp-post__share:not(:has(.share-links__group:not([hidden]))) {
	display: none; /* No supported button (or no JS): no empty row. */
}

.sp-post__main {
	display: flex;
	flex-direction: column;
	gap: var(--post-block-gap);
}

.sp-post__rail {
	display: flex;
	flex-direction: column;
	gap: var(--post-rail-gap);
}

/* One TOC copy per context: inline on phones, in the rail from --bp-lg. */
.toc--rail {
	display: none;
}

@media (min-width: 64em) { /* --bp-lg */
	.toc--inline {
		display: none;
	}

	.toc--rail {
		display: block;
	}

	/* Share buttons as a row above the article; the rail beside both. */
	.sp-single--post .sp-post__layout {
		row-gap: var(--space-md);
	}

	.sp-post__share {
		grid-column: 1;
		grid-row: 1;
	}

	.sp-post__main {
		grid-column: 1;
		grid-row: 2;
	}

	.sp-post__rail {
		grid-column: 2;
		grid-row: 1 / span 2;
	}

	/* No share row: the article starts at the top. */
	.sp-post__layout:not(:has(.share-links__group:not([hidden]))) .sp-post__main {
		grid-row: 1 / span 2;
	}
}

/*
 * From --bp-xl the share rail sits in the margin before the article, as in
 * the frame. The header text and the article start at the same place: the
 * content row's start, or far enough in for the rail when the margin is
 * too narrow (below about 1520px).
 */
@media (min-width: 80em) { /* --bp-xl */
	.sp-single--post .sp-single__header-inner {
		max-inline-size: none;
		margin-inline: 0;
		padding-inline:
			max(var(--container-gutter), (100% - var(--single-max)) / 2, var(--post-share-space) + var(--container-gutter))
			max(var(--container-gutter), (100% - var(--single-max)) / 2);
	}

	.sp-single--post .sp-post__layout {
		grid-template-columns: var(--post-share-col) var(--post-share-gap) minmax(0, 1fr) var(--single-column-gap) var(--single-rail-width);
		column-gap: 0;
		max-inline-size: none;
		margin-inline: 0;
		padding-inline:
			max(var(--container-gutter), (100% - var(--single-max)) / 2 - var(--post-share-space))
			max(var(--container-gutter), (100% - var(--single-max)) / 2);
	}

	.sp-single--post .sp-post__layout.sp-single__layout--no-rail {
		grid-template-columns: var(--post-share-col) var(--post-share-gap) minmax(0, calc(var(--single-max) - var(--single-rail-width) - var(--single-column-gap)));
	}

	.sp-post__share {
		position: sticky;
		top: calc(var(--header-height) + var(--wp-admin--admin-bar--height, 0px) + var(--space-md));
		align-self: start;
	}

	.sp-post__share,
	.sp-post__share .share-links__group,
	.sp-post__share .share-links__list {
		flex-direction: column;
		align-items: flex-start;
	}

	.sp-post__main,
	.sp-post__layout:not(:has(.share-links__group:not([hidden]))) .sp-post__main {
		grid-column: 3;
		grid-row: 1;
	}

	.sp-post__rail {
		grid-column: 5;
		grid-row: 1;
	}
}

/* Summary box: light card, icon heading, numbered list in badges. */
.sp-summary {
	padding: var(--post-summary-pad);
	border: 1px solid var(--post-summary-border);
	background: var(--post-summary-bg);
}

.sp-summary__heading {
	display: flex;
	align-items: center;
	gap: var(--space-sm);
	margin: 0 0 var(--space-md);
	color: var(--color-text);
	font-family: var(--t-subtitle-medium-family);
	font-size: var(--t-subtitle-medium-size);
	font-weight: var(--t-subtitle-medium-weight);
	line-height: var(--t-subtitle-medium-line-height);
	letter-spacing: var(--t-subtitle-medium-tracking);
	overflow-wrap: anywhere;
}

.sp-summary__heading .icon {
	flex: none;
	inline-size: 1.25rem;
	block-size: 1.25rem;
}

.sp-summary__list {
	display: grid;
	gap: var(--post-summary-pitch);
	margin: 0;
	padding: 0;
	list-style: none;
	counter-reset: sp-summary;
}

.sp-summary__item {
	display: flex;
	align-items: flex-start;
	gap: var(--space-md);
	color: var(--color-text);
	font-family: var(--t-body-family);
	font-size: var(--t-body-size);
	line-height: var(--t-body-line-height);
	counter-increment: sp-summary;
	overflow-wrap: anywhere;
}

/* The number is part of the list semantics (<ol>), so the badge is decorative. */
.sp-summary__item::before {
	content: counter(sp-summary);
	display: inline-flex;
	flex: none;
	align-items: center;
	justify-content: center;
	inline-size: var(--post-summary-badge);
	block-size: var(--post-summary-badge);
	margin-block-start: -0.1875rem; /* Centres the 30px badge on the first 24px line. */
	background-color: var(--post-summary-badge-bg);
	color: var(--post-summary-badge-text);
	font-size: var(--t-small-size);
	line-height: 1;
}

/*
 * Article: Montserrat quotes (0,2,0 outranks the shared .prose rule on the
 * same element, whatever the load order) and more space around a rule.
 */
.sp-single--post .sp-post__content {
	--prose-quote-font: var(--post-quote-font);
}

.sp-post__content hr {
	margin-block: var(--post-hr-space);
}

/* FAQ block: hairline, .t-h2 heading, accordion, orange button. */
.sp-post__faq {
	padding-block-start: var(--post-faq-space);
	border-block-start: 1px solid var(--single-rule);
}

.sp-post__faq-heading {
	margin: 0 0 var(--post-faq-gap);
	color: var(--color-text);
	font-family: var(--t-h2-family);
	font-size: var(--t-h2-size);
	font-weight: var(--t-h2-weight);
	line-height: var(--t-h2-line-height);
	letter-spacing: var(--t-h2-tracking);
	overflow-wrap: anywhere;
	scroll-margin-block-start: calc(var(--header-height) + var(--space-md));
}

.sp-post__accordion {
	--accordion-faq-padding-x: 0;
}

.sp-post__accordion .accordion__title {
	min-inline-size: 0;
	overflow-wrap: anywhere;
}

.sp-post__faq-actions {
	margin: var(--post-faq-gap) 0 0;
}

/* "Other articles for you": a smaller heading than the shared section heading (~28px). */
.sp-single--post .related__heading {
	font-size: var(--post-related-heading-size);
	line-height: var(--post-related-heading-line-height);
}
