/* t02: code blocks + tables. Scoped to post content (.entry-content / .wp-block-post-content).
   Matches motrice tokens: mono, base #FAF8F4, contrast #17130D, primary #C24A0A, tertiary #EFE9DF. */

.entry-content .motrice-pre,
.wp-block-post-content .motrice-pre {
	position: relative;
	max-width: 100%;
	min-width: 0;
}

.entry-content pre,
.wp-block-post-content pre {
	box-sizing: border-box;
	max-width: 100%;
	min-width: 0;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	font-family: var(--wp--preset--font-family--mono);
	font-size: 0.9em;
	line-height: 1.55;
	tab-size: 2;
	color: var(--wp--preset--color--contrast);
	background: var(--wp--preset--color--tertiary);
	border: 1px solid color-mix(in srgb, var(--wp--preset--color--contrast) 12%, transparent);
	border-radius: 14px;
	padding: 2.55em 1.15em 0.9em 1.15em;
}

.entry-content pre code,
.wp-block-post-content pre code {
	font-family: inherit;
	font-size: inherit;
	background: none;
	padding: 0;
	border-radius: 0;
	color: inherit;
}

.entry-content :not(pre) > code,
.wp-block-post-content :not(pre) > code {
	font-family: var(--wp--preset--font-family--mono);
	font-size: 0.9em;
	background: color-mix(in srgb, var(--wp--preset--color--contrast) 8%, var(--wp--preset--color--base));
	padding: 0.15em 0.4em;
	border-radius: 4px;
	word-break: break-word;
}

.entry-content .motrice-copy,
.wp-block-post-content .motrice-copy {
	position: absolute;
	top: 0.45em;
	right: 0.45em;
	z-index: 1;
	font-family: var(--wp--preset--font-family--mono);
	font-size: var(--wp--preset--font-size--x-small);
	line-height: 1;
	padding: 0.35em 0.7em;
	border-radius: 999px;
	border: 1px solid color-mix(in srgb, var(--wp--preset--color--contrast) 18%, transparent);
	background: var(--wp--preset--color--base);
	color: var(--wp--preset--color--contrast);
	cursor: pointer;
	user-select: none;
}

.entry-content .motrice-copy:hover,
.wp-block-post-content .motrice-copy:hover {
	border-color: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--primary);
}

.entry-content .motrice-copy:focus-visible,
.wp-block-post-content .motrice-copy:focus-visible {
	outline: 2px solid var(--wp--preset--color--primary);
	outline-offset: 2px;
}

.entry-content table,
.wp-block-post-content table {
	border-collapse: collapse;
	min-width: 100%;
	font-size: 0.95rem;
	border: 1px solid color-mix(in srgb, var(--wp--preset--color--contrast) 12%, transparent);
}

.entry-content th,
.entry-content td,
.wp-block-post-content th,
.wp-block-post-content td {
	padding: 0.65rem 0.9rem;
	text-align: left;
	vertical-align: top;
	border: 1px solid color-mix(in srgb, var(--wp--preset--color--contrast) 12%, transparent);
}

.entry-content thead th,
.entry-content thead td,
.wp-block-post-content thead th,
.wp-block-post-content thead td,
.entry-content table:not(:has(thead)) > tr:first-child > th,
.entry-content table:not(:has(thead)) > tr:first-child > td,
.entry-content table:not(:has(thead)) > tbody > tr:first-child > th,
.entry-content table:not(:has(thead)) > tbody > tr:first-child > td,
.wp-block-post-content table:not(:has(thead)) > tr:first-child > th,
.wp-block-post-content table:not(:has(thead)) > tr:first-child > td,
.wp-block-post-content table:not(:has(thead)) > tbody > tr:first-child > th,
.wp-block-post-content table:not(:has(thead)) > tbody > tr:first-child > td {
	font-weight: 700;
	white-space: nowrap;
	background: color-mix(in srgb, var(--wp--preset--color--contrast) 6%, var(--wp--preset--color--base));
	border-bottom: 2px solid var(--wp--preset--color--primary);
}

.entry-content tbody tr:nth-child(odd),
.wp-block-post-content tbody tr:nth-child(odd) {
	background: color-mix(in srgb, var(--wp--preset--color--contrast) 4%, transparent);
}

/* JS wrapper (preferred) + CSS fallback if JS has not wrapped yet */
.entry-content .table-scroll,
.wp-block-post-content .table-scroll,
.entry-content > table,
.wp-block-post-content > table {
	display: block;
	max-width: 100%;
	min-width: 0;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

.entry-content .table-scroll table,
.wp-block-post-content .table-scroll table {
	display: table;
	width: 100%;
}
