/*
 * A plan article's blog images and tables (AIPC_Article_Display, 3.117.0).
 */

/*
 * Blog images: the column's full width on every theme. A theme that does not load WordPress's block styles leaves the
 * browser's own figure margin (40px each side), so the image came out narrower than the text around it.
 */
figure.aipc-blog-image {
	display: block;
	width: 100%;
	max-width: 100%;
	margin: 1.5em 0;
	padding: 0;
}

figure.aipc-blog-image img {
	display: block;
	width: 100%;
	max-width: 100%;
	height: auto;
	margin: 0;
}

/*
 * Tables of a plan article: never wider than the column on a phone.
 *
 * The frame is a CSS container, so the choice below is made on the width of the article's own column
 * (not the window) before the first paint — no script, no layout shift. Inherits the theme's fonts,
 * colours and cell padding; only what keeps the table inside the column is set here.
 */

.aipc-table-wrap {
	display: block;
	max-width: 100%;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	container-type: inline-size;
}

.aipc-table-wrap > table {
	max-width: 100%;
}

/* A word breaks inside a cell only when it cannot fit at all (never hyphenated for looks). */
.aipc-table-wrap th,
.aipc-table-wrap td {
	overflow-wrap: anywhere;
}

/* A narrow column: each row of a simple table becomes a card, each value under its column name. */
@container (max-width: 599px) {
	.aipc-table-wrap > .aipc-rtable--stack,
	.aipc-table-wrap > .aipc-rtable--stack > tbody,
	.aipc-table-wrap > .aipc-rtable--stack > tfoot,
	.aipc-table-wrap > .aipc-rtable--stack > tbody > tr,
	.aipc-table-wrap > .aipc-rtable--stack > tfoot > tr,
	.aipc-table-wrap > .aipc-rtable--stack > tr,
	.aipc-table-wrap > .aipc-rtable--stack td,
	.aipc-table-wrap > .aipc-rtable--stack th {
		display: block;
		width: auto;
		max-width: none;
	}

	.aipc-table-wrap > .aipc-rtable--stack {
		width: 100%;
		border: 0;
	}

	/* The header row: hidden for the eye, still read by screen readers. */
	.aipc-table-wrap > .aipc-rtable--stack > thead,
	.aipc-table-wrap > .aipc-rtable--stack .aipc-rtable__head {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip: rect(0 0 0 0);
		clip-path: inset(50%);
		white-space: nowrap;
	}

	.aipc-table-wrap > .aipc-rtable--stack > tbody > tr,
	.aipc-table-wrap > .aipc-rtable--stack > tfoot > tr,
	.aipc-table-wrap > .aipc-rtable--stack > tr {
		margin: 0 0 16px;
		border: 1px solid rgba(128, 128, 128, 0.35);
		border-radius: 6px;
		overflow: hidden;
	}

	.aipc-table-wrap > .aipc-rtable--stack td,
	.aipc-table-wrap > .aipc-rtable--stack th {
		border: 0;
		border-bottom: 1px solid rgba(128, 128, 128, 0.2);
		text-align: left;
	}

	.aipc-table-wrap > .aipc-rtable--stack tr > :last-child {
		border-bottom: 0;
	}

	.aipc-table-wrap > .aipc-rtable--stack [data-label]:not([data-label=""])::before {
		content: attr(data-label);
		display: block;
		margin-bottom: 4px;
		font-weight: 700;
	}
}
