/**
 * CBS userguide tables — default styling for plugin documentation tables.
 *
 * Hooks (any one applies styles):
 * - .cbs-userguide-table on the Table block figure (auto on doc templates)
 * - Block style “User guide” (.is-style-cbs-userguide)
 * - Tables in CBS Documentation Guide / Hub intro (legacy auto-scope)
 *
 * @see .cursor/rules/carbon-based-studio-userguide-tables.mdc
 */

:is(
	.cbs-userguide-table,
	.wp-block-table.is-style-cbs-userguide,
	.editor-styles-wrapper .wp-block-table.is-style-cbs-userguide,
	.cbs-doc-page-wrap .cbs-doc-main .wp-block-table,
	.cbs-doc-hub-wrap .cbs-doc-hub-intro .wp-block-table
) {
	border: 1px solid var(--cbs-border, #d5dbe3);
	border-radius: 8px;
	overflow: hidden;
	margin: 0 0 1.5rem;
}

.cbs-doc-page-wrap .cbs-doc-main table:not(:where(.wp-block-table *)),
.cbs-doc-hub-wrap .cbs-doc-hub-intro table:not(:where(.wp-block-table *)),
table.cbs-userguide-table {
	width: 100%;
	border: 1px solid var(--cbs-border, #d5dbe3);
	border-radius: 8px;
	border-collapse: separate;
	border-spacing: 0;
	overflow: hidden;
	margin: 0 0 1.5rem;
	background: #fff;
}

:is(
	.cbs-userguide-table,
	.wp-block-table.is-style-cbs-userguide,
	.editor-styles-wrapper .wp-block-table.is-style-cbs-userguide,
	.cbs-doc-page-wrap .cbs-doc-main .wp-block-table,
	.cbs-doc-hub-wrap .cbs-doc-hub-intro .wp-block-table
) table {
	width: 100%;
	border: 0;
	border-radius: 0;
	border-collapse: separate;
	border-spacing: 0;
	margin: 0;
	background: #fff;
}

:is(
	.cbs-userguide-table,
	.wp-block-table.is-style-cbs-userguide,
	.editor-styles-wrapper .wp-block-table.is-style-cbs-userguide,
	.cbs-doc-page-wrap .cbs-doc-main .wp-block-table,
	.cbs-doc-hub-wrap .cbs-doc-hub-intro .wp-block-table
) thead,
:is(
	.cbs-userguide-table,
	.wp-block-table.is-style-cbs-userguide,
	.editor-styles-wrapper .wp-block-table.is-style-cbs-userguide,
	.cbs-doc-page-wrap .cbs-doc-main .wp-block-table,
	.cbs-doc-hub-wrap .cbs-doc-hub-intro .wp-block-table
) tfoot {
	border: 0;
}

:is(
	.cbs-userguide-table,
	.wp-block-table.is-style-cbs-userguide,
	.editor-styles-wrapper .wp-block-table.is-style-cbs-userguide,
	.cbs-doc-page-wrap .cbs-doc-main .wp-block-table,
	.cbs-doc-hub-wrap .cbs-doc-hub-intro .wp-block-table,
	.cbs-doc-page-wrap .cbs-doc-main table:not(:where(.wp-block-table *)),
	.cbs-doc-hub-wrap .cbs-doc-hub-intro table:not(:where(.wp-block-table *)),
	table.cbs-userguide-table
) :is(th, td) {
	padding: 12px 16px;
	border: 0;
	border-bottom: 1px solid var(--cbs-border, #d5dbe3);
	text-align: left;
	vertical-align: middle;
	font-size: var(--cbs-font-size-body, 16px);
	line-height: var(--cbs-line-height-body, 1.65);
}

:is(
	.cbs-userguide-table,
	.wp-block-table.is-style-cbs-userguide,
	.editor-styles-wrapper .wp-block-table.is-style-cbs-userguide,
	.cbs-doc-page-wrap .cbs-doc-main .wp-block-table,
	.cbs-doc-hub-wrap .cbs-doc-hub-intro .wp-block-table,
	.cbs-doc-page-wrap .cbs-doc-main table:not(:where(.wp-block-table *)),
	.cbs-doc-hub-wrap .cbs-doc-hub-intro table:not(:where(.wp-block-table *)),
	table.cbs-userguide-table
) :is(th, td):not(:last-child) {
	border-right: 1px solid var(--cbs-border, #d5dbe3);
}

:is(
	.cbs-userguide-table,
	.wp-block-table.is-style-cbs-userguide,
	.editor-styles-wrapper .wp-block-table.is-style-cbs-userguide,
	.cbs-doc-page-wrap .cbs-doc-main .wp-block-table,
	.cbs-doc-hub-wrap .cbs-doc-hub-intro .wp-block-table,
	.cbs-doc-page-wrap .cbs-doc-main table:not(:where(.wp-block-table *)),
	.cbs-doc-hub-wrap .cbs-doc-hub-intro table:not(:where(.wp-block-table *)),
	table.cbs-userguide-table
) :is(thead th, tbody th, tbody td:first-child) {
	background: #f6f7f7;
	color: var(--cbs-text, #3a3a3a);
	font-weight: var(--cbs-font-weight-nav, 500);
}

/* Label column floor — use col min-width, not th/td min-width (table layout quirk). */
:is(
	.cbs-userguide-table,
	.wp-block-table.is-style-cbs-userguide,
	.editor-styles-wrapper .wp-block-table.is-style-cbs-userguide,
	.cbs-doc-page-wrap .cbs-doc-main .wp-block-table,
	.cbs-doc-hub-wrap .cbs-doc-hub-intro .wp-block-table,
	.cbs-doc-page-wrap .cbs-doc-main table:not(:where(.wp-block-table *)),
	.cbs-doc-hub-wrap .cbs-doc-hub-intro table:not(:where(.wp-block-table *)),
	table.cbs-userguide-table
) col.cbs-userguide-table__labels {
	min-width: 148px;
	width: auto;
}

:is(
	.cbs-userguide-table,
	.wp-block-table.is-style-cbs-userguide,
	.editor-styles-wrapper .wp-block-table.is-style-cbs-userguide,
	.cbs-doc-page-wrap .cbs-doc-main .wp-block-table,
	.cbs-doc-hub-wrap .cbs-doc-hub-intro .wp-block-table,
	.cbs-doc-page-wrap .cbs-doc-main table:not(:where(.wp-block-table *)),
	.cbs-doc-hub-wrap .cbs-doc-hub-intro table:not(:where(.wp-block-table *)),
	table.cbs-userguide-table
) tbody td:not(:first-child) {
	background: #fff;
	color: var(--cbs-text, #3a3a3a);
	font-weight: var(--cbs-font-weight-body, 400);
}

/* UA strong/b use font-weight: bolder — inherit cell weight instead. */
:is(
	.cbs-userguide-table,
	.wp-block-table.is-style-cbs-userguide,
	.editor-styles-wrapper .wp-block-table.is-style-cbs-userguide,
	.cbs-doc-page-wrap .cbs-doc-main .wp-block-table,
	.cbs-doc-hub-wrap .cbs-doc-hub-intro .wp-block-table,
	.cbs-doc-page-wrap .cbs-doc-main table:not(:where(.wp-block-table *)),
	.cbs-doc-hub-wrap .cbs-doc-hub-intro table:not(:where(.wp-block-table *)),
	table.cbs-userguide-table
) :is(strong, b) {
	font-weight: inherit;
}

:is(
	.cbs-userguide-table,
	.wp-block-table.is-style-cbs-userguide,
	.editor-styles-wrapper .wp-block-table.is-style-cbs-userguide,
	.cbs-doc-page-wrap .cbs-doc-main .wp-block-table,
	.cbs-doc-hub-wrap .cbs-doc-hub-intro .wp-block-table,
	.cbs-doc-page-wrap .cbs-doc-main table:not(:where(.wp-block-table *)),
	.cbs-doc-hub-wrap .cbs-doc-hub-intro table:not(:where(.wp-block-table *)),
	table.cbs-userguide-table
) tbody tr:last-child :is(th, td) {
	border-bottom: none;
}

:is(
	.cbs-userguide-table,
	.wp-block-table.is-style-cbs-userguide,
	.editor-styles-wrapper .wp-block-table.is-style-cbs-userguide,
	.cbs-doc-page-wrap .cbs-doc-main .wp-block-table,
	.cbs-doc-hub-wrap .cbs-doc-hub-intro .wp-block-table
) {
	overflow-x: auto;
}

@media (max-width: 781px) {
	:is(
		.cbs-userguide-table,
		.wp-block-table.is-style-cbs-userguide,
		.cbs-doc-page-wrap .cbs-doc-main .wp-block-table,
		.cbs-doc-hub-wrap .cbs-doc-hub-intro .wp-block-table,
		.cbs-doc-page-wrap .cbs-doc-main table:not(:where(.wp-block-table *)),
		.cbs-doc-hub-wrap .cbs-doc-hub-intro table:not(:where(.wp-block-table *)),
		table.cbs-userguide-table
	) {
		display: block;
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
	}
}
