/* Dishco blog tables — card look + scroll that beats body overflow-x:hidden */

/*
 * Root cause of Satiety-tip clip: Additional CSS sets `html, body { overflow-x: hidden }`
 * and flex children default to min-width:auto, so wide tables expand the flex item
 * and get clipped by the body instead of scrolling inside a shell.
 *
 * Content column is often ~848px while the viewport is wider — container queries on
 * the scroll shell key mid-width layout off table width, not the window.
 */
.wp-site-blocks,
main,
.d-post,
.wp-block-group.d-post,
.d-post .wp-block-group,
.d-post__content,
.d-post__hero,
.d-table-scroll,
.d-post figure.wp-block-table {
	min-width: 0 !important;
	max-width: 100%;
}

.d-post__content {
	overflow-x: visible;
}

.d-table-scroll,
.d-post figure.wp-block-table:not(:has(.d-table-scroll)) {
	display: block;
	width: 100%;
	max-width: 100%;
	margin: 1.75em 0;
	overflow-x: auto !important;
	overflow-y: visible;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior-x: contain;
	border-radius: 14px;
	container-type: inline-size;
	container-name: dishco-table;
}

.d-post figure.wp-block-table:has(.d-table-scroll) {
	display: block;
	width: 100%;
	max-width: 100%;
	margin: 1.75em 0;
	overflow: visible;
	container-type: inline-size;
	container-name: dishco-table;
}

.d-table-scroll > table,
.d-post figure.wp-block-table > table,
.d-post table {
	border-collapse: separate;
	border-spacing: 0;
	margin: 0;
	font-size: 0.95rem;
	line-height: 1.45;
	color: #1a1a1a;
	background: #fff;
	border: 1px solid #ebe7e2;
	border-radius: 14px;
	overflow: visible !important;
	box-shadow: none;
	table-layout: fixed !important;
	width: 100% !important;
	min-width: 0 !important;
	max-width: 100% !important;
}

.d-post > table,
.d-post__content > table {
	margin: 1.75em 0;
}

.d-post table thead th,
.d-post figure.wp-block-table table thead th {
	background: #f6f3ef;
	color: #2a2420;
	font-weight: 650;
	font-size: 0.82rem;
	letter-spacing: 0.02em;
	text-align: left;
	padding: 0.75rem 0.85rem;
	border: 0;
	border-bottom: 1px solid #ebe7e2;
	vertical-align: bottom;
	white-space: normal;
	min-width: 0;
	overflow-wrap: anywhere;
}

.d-post table thead th:first-child,
.d-post figure.wp-block-table table thead th:first-child {
	border-top-left-radius: 13px;
}
.d-post table thead th:last-child,
.d-post figure.wp-block-table table thead th:last-child {
	border-top-right-radius: 13px;
}

.d-post table tbody td,
.d-post figure.wp-block-table table tbody td {
	padding: 0.75rem 0.85rem;
	border: 0;
	border-bottom: 1px solid #f0ece7;
	vertical-align: top;
	background: #fff;
	white-space: normal;
	word-break: normal;
	overflow-wrap: anywhere;
	min-width: 0;
}

.d-post table tbody tr:last-child td {
	border-bottom: 0;
}
.d-post table tbody tr:last-child td:first-child {
	border-bottom-left-radius: 13px;
}
.d-post table tbody tr:last-child td:last-child {
	border-bottom-right-radius: 13px;
}

.d-post table tbody tr:nth-child(even) td {
	background: #fbfaf8;
}
.d-post table tbody tr:hover td {
	background: #f7f4f0;
}

.d-post table tbody td:first-child {
	font-weight: 600;
	color: #2a2420;
}

/*
 * Exactly 4 columns: stack last col (Watch-outs) under the first three when the
 * table shell is ≤900px (~848 content width). Uses container query, not viewport.
 */
@container dishco-table (max-width: 900px) {
	table:has(thead th:nth-child(4):last-child) {
		display: block;
		table-layout: auto !important;
		width: 100% !important;
		min-width: 0 !important;
		max-width: 100% !important;
		border: 1px solid #ebe7e2;
		border-radius: 14px;
		overflow: hidden;
	}

	table:has(thead th:nth-child(4):last-child) thead,
	table:has(thead th:nth-child(4):last-child) tbody {
		display: block;
		width: 100%;
	}

	table:has(thead th:nth-child(4):last-child) thead tr {
		display: grid;
		grid-template-columns: minmax(0, 1.05fr) minmax(0, 1.35fr) minmax(0, 1.35fr);
		width: 100%;
		background: #f6f3ef;
	}

	table:has(thead th:nth-child(4):last-child) thead th {
		border-bottom: 1px solid #ebe7e2;
	}

	table:has(thead th:nth-child(4):last-child) thead th:last-child {
		display: none;
	}

	table:has(thead th:nth-child(4):last-child) tbody tr {
		display: grid;
		grid-template-columns: minmax(0, 1.05fr) minmax(0, 1.35fr) minmax(0, 1.35fr);
		width: 100%;
		border-bottom: 1px solid #f0ece7;
	}

	table:has(thead th:nth-child(4):last-child) tbody tr:last-child {
		border-bottom: 0;
	}

	table:has(thead th:nth-child(4):last-child) tbody td {
		min-width: 0 !important;
		border-bottom: 0;
		overflow-wrap: anywhere;
	}

	table:has(thead th:nth-child(4):last-child) tbody td:last-child {
		grid-column: 1 / -1;
		margin: 0 0.75rem 0.75rem;
		padding: 0.55rem 0.75rem;
		background: #f6f3ef !important;
		border-radius: 10px;
		font-size: 0.9em;
		line-height: 1.4;
	}

	table:has(thead th:nth-child(4):last-child) tbody td:last-child::before {
		content: "Watch-outs";
		display: block;
		font-weight: 650;
		font-size: 0.72rem;
		letter-spacing: 0.02em;
		color: #6b635c;
		margin-bottom: 0.15rem;
	}

}

/* Narrow phones: 5+ col utility tables keep swipe-scroll */
@media (max-width: 781px) {
	.d-table-scroll:not(:has(> table thead th:nth-child(4):last-child))::before {
		content: "Swipe → for full table";
		display: block;
		font-size: 0.75rem;
		font-weight: 500;
		color: #8a6a5c;
		margin: 0 0 0.4rem;
	}

	.d-post figure.wp-block-table:not(:has(.d-table-scroll)):not(:has(table thead th:nth-child(4):last-child))::before {
		content: "Swipe → for full table";
		display: block;
		font-size: 0.75rem;
		font-weight: 500;
		color: #8a6a5c;
		margin: 0 0 0.4rem;
	}

	.d-table-scroll:not(:has(> table thead th:nth-child(4):last-child)) > table,
	.d-post figure.wp-block-table:not(:has(table thead th:nth-child(4):last-child)) > table,
	.d-post table:not(:has(thead th:nth-child(4):last-child)) {
		width: max-content !important;
		min-width: 36rem !important;
		max-width: none !important;
		table-layout: auto !important;
		font-size: 0.88rem;
		border-radius: 12px;
	}

	.d-post table:not(:has(thead th:nth-child(4):last-child)) thead th,
	.d-post table:not(:has(thead th:nth-child(4):last-child)) tbody td {
		padding: 0.7rem 0.8rem;
		min-width: 7rem;
	}

	.d-post table:not(:has(thead th:nth-child(4):last-child)) tbody td:last-child {
		min-width: 12rem;
	}

	table:has(thead th:nth-child(4):last-child) {
		font-size: 0.88rem;
	}
}

.d-post figure.wp-block-table figcaption {
	margin-top: 0.55rem;
	font-size: 0.85rem;
	color: #6b635c;
	text-align: left;
}
