/*
 * Article content fixes (audit). Loaded after css/style.css by includes/brand/brand.php.
 *
 * Audit #4 (2026-11-30): "Table content is not device compatible".
 * css/style.css (mobile, ~line 6864) sets every table to display:block. With block tables
 * (figure.wp-block-table > table.has-fixed-layout) that squeezes the first column (words break
 * mid-word) and pushes the rest past the screen, where body{overflow-x:hidden} cuts it off.
 * Fix: keep block tables as real tables at full width; the figure (WordPress core already
 * gives it overflow-x:auto) scrolls sideways only when a table is really too wide.
 * Tables NOT inside a block figure keep the old display:block rule.
 */
@media only screen and (max-width: 768px) {
	.entry-content figure.wp-block-table {
		display: block;
		width: 100%;
		max-width: 100%;
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
		margin-left: 0;
		margin-right: 0;
	}

	.entry-content figure.wp-block-table > table {
		display: table !important;
		width: 100% !important;
		table-layout: auto !important;
		overflow: visible !important;
		font-size: 14px;
		line-height: 1.45;
	}

	.entry-content figure.wp-block-table th,
	.entry-content figure.wp-block-table td {
		min-width: 110px;
		padding: 8px 10px;
		vertical-align: top;
		word-break: normal !important;
		overflow-wrap: break-word !important;
		hyphens: none;
	}
}

/*
 * NEW (2026-12-01, audit #4 UI, v2 after user review): table look, only for block tables inside posts.
 * Before: css/style.css:6789 "td { border: 1px solid !important }" = thick black border on every cell,
 * header row looked like any other row, no row colours, serif font.
 * Now: card with soft shadow, solid blue header row (white text), only horizontal lines, zebra rows,
 * row highlight on hover, first column bold. Header row = <thead>, or a first row whose first and
 * last cells are bold (how most posts write it).
 */
.entry-content figure.wp-block-table {
	margin-top: 24px;
	margin-bottom: 28px;
}

.entry-content figure.wp-block-table > table {
	border-collapse: separate !important;
	border-spacing: 0;
	border: 1px solid #e3e8ef !important;
	border-radius: 10px;
	box-shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
	font-family: "Proxima Nova", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.55;
	color: #1f2937;
	margin: 0;
}

.entry-content figure.wp-block-table th,
.entry-content figure.wp-block-table td {
	border: 0 !important;
	border-bottom: 1px solid #edf0f4 !important;
	padding: 12px 16px;
	vertical-align: top;
	text-align: left;
	background-color: #fff;
	transition: background-color .15s ease;
}

.entry-content figure.wp-block-table tr:last-child > * {
	border-bottom: 0 !important;
}

/* First column = row label */
.entry-content figure.wp-block-table tbody td:first-child {
	font-weight: 600;
	color: #0b2b4c;
}

/* Zebra rows + hover */
.entry-content figure.wp-block-table tbody tr:nth-child(even) > td {
	background-color: #f8fafc;
}

.entry-content figure.wp-block-table tbody tr:hover > td {
	background-color: #eef5fc;
}

/* Header row. Two separate rules: a browser that doesn't know :has() skips only the second one. */
.entry-content figure.wp-block-table thead th,
.entry-content figure.wp-block-table thead td {
	background-color: #2f6aa3 !important;
	color: #fff !important;
	font-weight: 600;
	font-size: 14px;
	letter-spacing: .02em;
	border-bottom: 0 !important;
}

.entry-content figure.wp-block-table > table:not(:has(thead)) > tbody > tr:first-child:has(> td:first-child > strong, > td:first-child > b):has(> td:last-child > strong, > td:last-child > b) > td {
	background-color: #2f6aa3 !important;
	color: #fff !important;
	font-weight: 600;
	font-size: 14px;
	letter-spacing: .02em;
	border-bottom: 0 !important;
}

.entry-content figure.wp-block-table thead a,
.entry-content figure.wp-block-table > table:not(:has(thead)) > tbody > tr:first-child:has(> td:first-child > strong):has(> td:last-child > strong) a {
	color: #fff;
}

/* Rounded corners: cells must not paint over the table's rounded border */
.entry-content figure.wp-block-table tr:first-child > :first-child { border-top-left-radius: 9px; }
.entry-content figure.wp-block-table tr:first-child > :last-child { border-top-right-radius: 9px; }
.entry-content figure.wp-block-table tr:last-child > :first-child { border-bottom-left-radius: 9px; }
.entry-content figure.wp-block-table tr:last-child > :last-child { border-bottom-right-radius: 9px; }
.entry-content figure.wp-block-table thead + tbody tr:first-child > * { border-radius: 0; }

.entry-content figure.wp-block-table figcaption {
	margin-top: 8px;
	font-size: 13px;
	color: #6b7280;
	text-align: center;
}

@media only screen and (max-width: 768px) {
	.entry-content figure.wp-block-table > table {
		font-size: 14px;
	}

	.entry-content figure.wp-block-table th,
	.entry-content figure.wp-block-table td {
		padding: 10px 12px;
		min-width: 140px;
	}

	/* Wide table: first column stays in place while swiping sideways */
	.entry-content figure.wp-block-table.le-table-scroll tr > :first-child {
		position: sticky;
		left: 0;
		z-index: 1;
		min-width: 120px;
		box-shadow: 6px 0 8px -6px rgba(16, 24, 40, .25);
	}

	/* Hint above a table that is wider than the screen (class added by a small script in brand.php) */
	.entry-content figure.wp-block-table.le-table-scroll::before {
		content: "Swipe to see more \2192";
		position: sticky;
		left: 0;
		display: inline-block;
		margin-bottom: 8px;
		padding: 3px 10px;
		border-radius: 999px;
		background: #eef5fc;
		font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
		font-size: 12px;
		font-weight: 600;
		color: #2f6aa3;
	}
}

/*
 * NEW (2026-12-01, user request): Table of contents (Yoast "Table of contents" block) look.
 * Before: plain bullet list under a big "Table of contents" heading, very long on phones.
 * Now: light card with a blue left edge, small clickable title (open/close, closed by default on phones),
 * numbered main sections, sub-sections indented. Open/close handled by a small script in brand.php.
 */
.entry-content .yoast-table-of-contents {
	margin: 28px 0 32px;
	padding: 18px 22px;
	background: #f5f8fc;
	border: 1px solid #e3e8ef;
	border-left: 4px solid #2f6aa3;
	border-radius: 10px;
	font-family: "Proxima Nova", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

.entry-content .yoast-table-of-contents > h2 {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin: 0;
	font-size: 18px;
	line-height: 1.3;
	font-weight: 700;
	color: #0b2b4c;
	cursor: pointer;
	user-select: none;
}

.entry-content .yoast-table-of-contents > h2::after {
	content: "";
	flex: 0 0 auto;
	width: 9px;
	height: 9px;
	margin-right: 4px;
	border-right: 2px solid #2f6aa3;
	border-bottom: 2px solid #2f6aa3;
	transform: rotate(45deg) translateY(-3px);
	transition: transform .2s ease;
}

.entry-content .yoast-table-of-contents.le-toc-closed > h2::after {
	transform: rotate(-45deg);
}

.entry-content .yoast-table-of-contents.le-toc-closed > ul {
	display: none;
}

.entry-content .yoast-table-of-contents ul {
	list-style: none;
	margin: 0;
	padding: 0;
}

.entry-content .yoast-table-of-contents > ul {
	margin-top: 12px;
	counter-reset: le-toc;
}

.entry-content .yoast-table-of-contents > ul > li {
	counter-increment: le-toc;
	margin: 0;
	padding: 7px 0;
	border-top: 1px solid #e3e8ef;
}

.entry-content .yoast-table-of-contents > ul > li:first-child {
	border-top: 0;
}

.entry-content .yoast-table-of-contents > ul > li > a {
	display: flex;
	gap: 10px;
	font-size: 15px;
	font-weight: 600;
	line-height: 1.45;
	color: #1f2937;
	text-decoration: none;
}

.entry-content .yoast-table-of-contents > ul > li > a::before {
	content: counter(le-toc);
	flex: 0 0 22px;
	height: 22px;
	border-radius: 50%;
	background: #2f6aa3;
	color: #fff;
	font-size: 12px;
	line-height: 22px;
	text-align: center;
}

.entry-content .yoast-table-of-contents li li {
	margin: 0;
	padding: 3px 0 3px 32px;
}

.entry-content .yoast-table-of-contents li li a {
	display: block;
	position: relative;
	padding-left: 12px;
	font-size: 14px;
	line-height: 1.45;
	color: #4b5563;
	text-decoration: none;
}

.entry-content .yoast-table-of-contents li li a::before {
	content: "";
	position: absolute;
	left: 0;
	top: .6em;
	width: 5px;
	height: 5px;
	border-radius: 50%;
	background: #9fb6cf;
}

.entry-content .yoast-table-of-contents > ul > li > ul {
	margin-top: 4px;
}

.entry-content .yoast-table-of-contents a:hover,
.entry-content .yoast-table-of-contents a:focus {
	color: #2f6aa3;
	text-decoration: underline;
}

@media only screen and (max-width: 768px) {
	.entry-content .yoast-table-of-contents {
		padding: 14px 16px;
	}
	.entry-content .yoast-table-of-contents > h2 {
		font-size: 17px;
	}
	.entry-content .yoast-table-of-contents > ul > li > a {
		font-size: 14px;
	}
}

/*
 * NEW (2026-12-01, audit #10): rating in the post header (template-parts/post-header.php).
 * Before: only stars; average + count hidden by css/style.css:424/:580, not clickable.
 * Now: stars + "4.3 (based on 1,234 reviews)", whole thing clickable (opens the rating popup).
 */
.post-header .ratingarea .le-rating-open {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	cursor: pointer;
	text-decoration: none;
}

.post-header .ratingarea .le-rating-text {
	font-family: "Proxima Nova", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
	font-size: 13px;
	font-weight: 500;
	color: #4b5563;
	white-space: nowrap;
	text-transform: none;
}

@media only screen and (max-width: 400px) {
	.post-header .ratingarea .le-rating-text {
		font-size: 12px;
		white-space: normal;
	}
}

.post-header .ratingarea .le-rating-text strong {
	font-weight: 700;
	color: #1f2937;
}

.post-header .ratingarea .le-rating-open:hover .le-rating-text,
.post-header .ratingarea .le-rating-open:focus .le-rating-text {
	color: #2f6aa3;
	text-decoration: underline;
}
