/**
 * Subpage section: Rich text (template-parts/sections/subpage/section-rich_text.php).
 *
 * Legal and long-form reading. No frame exists, so sizes are tokens marked
 * TODO. Narrow width keeps lines at about 65-75 characters. Tables scroll
 * inside their own box, so the page never scrolls sideways on phones.
 * Values come from assets/css/tokens.css.
 *
 * @package cartrack
 */

.rich-text {
	color: var(--color-text);
	font-family: var(--font-body);
	font-size: var(--rich-text-size);
	line-height: var(--rich-text-line-height);
	overflow-wrap: break-word;
}

.rich-text--narrow .rich-text {
	max-width: var(--rich-text-measure);
}

/* Width "edge" (2026-11-16): the section has no container, so an image-only body (Industry Solutions' collage) runs
   edge to edge; any text in it stays in the content column. */
.rich-text--edge .sp-section__inner {
	max-width: none;
	padding-inline: 0;
}

.rich-text--edge .rich-text__body img {
	display: block;
	width: 100%;
}

.rich-text--edge .rich-text__heading,
.rich-text--edge .rich-text__updated,
.rich-text--edge .rich-text__body > :not(figure):not(:has(img)) {
	padding-inline: max(var(--container-gutter), (100% - var(--sp-content-max)) / 2);
}

.rich-text__heading {
	margin: 0;
	font-family: var(--font-heading);
	font-size: var(--type-h2-size);
	font-weight: var(--font-weight-semibold);
	line-height: var(--type-h2-line-height);
	letter-spacing: var(--type-h2-tracking);
}

.rich-text__updated {
	margin: var(--space-xs) 0 0;
	color: var(--color-text-muted);
	font-size: var(--font-size-sm);
}

.rich-text__heading + .rich-text__body,
.rich-text__updated + .rich-text__body {
	margin-top: var(--rich-text-heading-gap);
}

/* ---------- Body ---------- */

.rich-text__body > :first-child {
	margin-top: 0;
}

.rich-text__body > :last-child {
	margin-bottom: 0;
}

/* Images scale to the column (an image-only body such as Industry Solutions' collage, 2026-11-13). */
.rich-text__body img {
	max-width: 100%;
	height: auto;
}

.rich-text__body p,
.rich-text__body ul,
.rich-text__body ol,
.rich-text__body blockquote,
.rich-text__body .rich-text__table {
	margin: 0 0 var(--rich-text-block-gap);
}

.rich-text__body h2,
.rich-text__body h3,
.rich-text__body h4 {
	margin: var(--rich-text-heading-space) 0 var(--space-sm);
	color: var(--color-text);
	font-family: var(--font-heading);
	font-weight: var(--font-weight-semibold);
	line-height: var(--line-height-snug);
}

.rich-text__body h2 {
	font-size: var(--type-h3-size);
}

.rich-text__body h3 {
	font-size: var(--type-h4-size);
}

.rich-text__body h4 {
	font-size: var(--font-size-base);
}

.rich-text__body ul,
.rich-text__body ol {
	padding-inline-start: var(--rich-text-list-indent);
}

.rich-text__body li + li {
	margin-top: var(--space-2xs);
}

.rich-text__body li > ul,
.rich-text__body li > ol {
	margin: var(--space-2xs) 0 0;
}

.rich-text__body ul li::marker {
	color: var(--color-primary);
}

.rich-text__body a {
	color: var(--rich-text-link);
	text-decoration: underline;
	text-underline-offset: 0.2em;
}

/* TODO: verify hover state in Figma. */
.rich-text__body a:hover {
	color: var(--color-primary-hover);
}

.rich-text__body a:focus-visible {
	outline: 2px solid var(--color-focus-dark);
	outline-offset: 2px;
}

.rich-text__body strong,
.rich-text__body b {
	font-weight: var(--font-weight-bold);
}

.rich-text__body blockquote {
	padding-inline-start: var(--space-md);
	border-inline-start: 3px solid var(--color-primary);
	color: var(--color-text-muted);
}

.rich-text__body hr {
	margin: var(--rich-text-heading-space) 0;
	border: 0;
	border-top: 1px solid var(--color-border);
}

/* ---------- Tables: scroll inside their own box ---------- */

.rich-text__table {
	max-width: 100%;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	border: 1px solid var(--color-border);
	border-radius: var(--radius-sm);
}

.rich-text__table:focus-visible {
	outline: 2px solid var(--color-focus-dark);
	outline-offset: 2px;
}

.rich-text__table table {
	width: 100%;
	min-width: var(--rich-text-table-min);
	border-collapse: collapse;
	font-size: var(--font-size-sm);
	line-height: var(--line-height-snug);
}

.rich-text__table caption {
	padding: var(--space-xs) var(--space-sm);
	color: var(--color-text-muted);
	font-size: var(--font-size-sm);
	text-align: start;
}

.rich-text__table th,
.rich-text__table td {
	padding: var(--rich-text-cell-padding-y) var(--rich-text-cell-padding-x);
	border-bottom: 1px solid var(--color-border);
	text-align: start;
	vertical-align: top;
}

.rich-text__table th {
	background-color: var(--sp-bg-light);
	font-weight: var(--font-weight-semibold);
}

.rich-text__table tr:last-child td {
	border-bottom: 0;
}

@media (min-width: 64em) { /* --bp-lg */
	.rich-text__heading {
		font-size: var(--type-h2-size-desktop);
	}

	.rich-text__body h2 {
		font-size: var(--type-h3-size-desktop);
	}

	.rich-text__body h3 {
		font-size: var(--type-h4-size-desktop);
	}
}

/* ---------- Table style "highlight" (2026-11-14) ----------
   The product pages' data tables, as on cartrack.id: a light-blue header row, taller rows with row lines and no outer
   box, on a pale-blue band (while the section background is "none"). Sampled from the saved cartrack.id crops; TODO:
   verify in Figma. Dark text on #aad4f9 is 11.2:1. */
.rich-text--table-highlight {
	--rich-text-hl-band: #eef6fe;
	--rich-text-hl-head: var(--color-secondary-light);
	--rich-text-hl-line: #dde9f6;
	--rich-text-hl-cell-y: 1.25rem;   /* ~20px */
	--rich-text-hl-cell-x: 0.9375rem; /* ~15px */
}

.sp-section--rich_text.rich-text--table-highlight.sp-section--bg-none {
	background: var(--rich-text-hl-band);
}

.rich-text--table-highlight .rich-text__table {
	border: 0;
	border-radius: 0;
}

.rich-text--table-highlight .rich-text__table th,
.rich-text--table-highlight .rich-text__table td {
	padding: var(--rich-text-hl-cell-y) var(--rich-text-hl-cell-x);
	border-bottom: 1px solid var(--rich-text-hl-line);
}

.rich-text--table-highlight .rich-text__table th,
.rich-text--table-highlight .rich-text__table thead td {
	background-color: var(--rich-text-hl-head);
	color: var(--color-text);
	font-size: var(--font-size-base);
}

.rich-text--table-highlight .rich-text__table tr:last-child td {
	border-bottom: 1px solid var(--rich-text-hl-line);
}
