/**
 * Editorial tables: legal pages + single posts (notes).
 * Overrides WP block-library and theme components (.sb-single-note__content).
 * Sin :where() en el tramo crítico: si no, pierde contra components.css por especificidad.
 */

.legal-page,
.sb-single-note {
	--editorial-table-grid: rgba(158, 161, 181, 0.48);
	--editorial-table-ink: var(--sb-color-ink, #2e2c38);
	--editorial-table-ink-soft: var(--sb-color-ink-soft, #434150);
	--editorial-table-muted: var(--sb-color-muted-strong, #7c7d93);
	--editorial-table-surface-veil: var(--sb-color-surface-strong, #e0e3ec);
	--editorial-table-font-heading: var(--sb-font-heading, "Satoshi", system-ui, sans-serif);
}

@supports (color: color-mix(in srgb, white 50%, black)) {
	.legal-page,
	.sb-single-note {
		--editorial-table-grid: color-mix(in srgb, var(--sb-color-accent, #9ea1b5) 58%, transparent);
	}
}

.legal-page__content .wp-block-table,
.sb-single-note__content .wp-block-table {
	max-width: 100%;
	margin-top: clamp(1.75rem, 4vw, 2.75rem);
	margin-bottom: 0.25rem;
	padding: 0;
	overflow-x: auto;
	border: 0;
	border-radius: 0;
	background: color-mix(in srgb, var(--sb-color-surface, #e9ebf2) 42%, transparent);
	box-shadow: none;
	-webkit-overflow-scrolling: touch;
}

@supports not (color: color-mix(in srgb, white 50%, black)) {
	.legal-page__content .wp-block-table,
	.sb-single-note__content .wp-block-table {
		background: rgba(233, 235, 242, 0.45);
	}
}

.legal-page__content .wp-block-table table,
.legal-page__content table,
.sb-single-note__content .wp-block-table table,
.sb-single-note__content table {
	width: 100%;
	min-width: 42rem;
	border-collapse: collapse;
	border-spacing: 0;
	font-size: var(--sb-type-step--1, clamp(0.92rem, 0.88rem + 0.08vw, 1rem));
	line-height: 1.58;
	border: 0;
	border-radius: 0;
	overflow: hidden;
}

.legal-page__content table,
.sb-single-note__content table {
	display: block;
	max-width: 100%;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

.legal-page__content .wp-block-table table,
.sb-single-note__content .wp-block-table table {
	display: table;
	overflow: visible;
}

/* WordPress block-library: thead/tfoot y celdas sin color → currentColor oscuro. */
.legal-page .legal-page__content .wp-block-table thead,
.sb-single-note .sb-single-note__content .wp-block-table thead {
	border-bottom: 1px solid var(--editorial-table-grid);
}

.legal-page .legal-page__content .wp-block-table tfoot,
.sb-single-note .sb-single-note__content .wp-block-table tfoot {
	border-top: 1px solid var(--editorial-table-grid);
}

.legal-page .legal-page__content .wp-block-table table th,
.legal-page .legal-page__content .wp-block-table table td,
.sb-single-note .sb-single-note__content .wp-block-table table th,
.sb-single-note .sb-single-note__content .wp-block-table table td {
	border: 1px solid var(--editorial-table-grid);
}

.legal-page .legal-page__content > table th,
.legal-page .legal-page__content > table td,
.sb-single-note .sb-single-note__content > table th,
.sb-single-note .sb-single-note__content > table td {
	border: 1px solid var(--editorial-table-grid);
}

.legal-page__content thead,
.sb-single-note__content thead {
	background: var(--editorial-table-ink);
}

@supports (color: color-mix(in srgb, white 50%, black)) {
	.legal-page__content thead,
	.sb-single-note__content thead {
		background: linear-gradient(
			180deg,
			var(--editorial-table-ink) 0%,
			color-mix(in srgb, var(--editorial-table-ink) 88%, #1a1822) 100%
		);
	}
}

.legal-page__content tfoot,
.sb-single-note__content tfoot {
	background: var(--editorial-table-surface-veil);
}

/* 0,2,1 — por encima de .sb-single-note__content th (0,1,1) */
.legal-page__content thead th,
.sb-single-note__content thead th {
	padding: 1.05rem 1.15rem;
	border: 1px solid var(--editorial-table-grid);
	color: rgba(246, 247, 251, 0.92);
	font-family: var(--editorial-table-font-heading);
	font-size: 0.8rem;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-align: left;
	text-transform: uppercase;
	vertical-align: bottom;
	white-space: nowrap;
}

.legal-page__content tfoot th,
.legal-page__content tfoot td,
.sb-single-note__content tfoot th,
.sb-single-note__content tfoot td {
	padding: 0.85rem 1.1rem;
	border: 1px solid var(--editorial-table-grid);
	color: var(--editorial-table-ink);
	font-weight: 600;
}

.legal-page__content tbody td,
.sb-single-note__content tbody td {
	padding: 1rem 1.15rem;
	border: 1px solid var(--editorial-table-grid);
	color: var(--editorial-table-ink-soft);
	vertical-align: top;
}

.legal-page__content tbody tr,
.sb-single-note__content tbody tr {
	background: color-mix(in srgb, var(--sb-color-surface, #e9ebf2) 58%, transparent);
	transition: background-color var(--sb-transition-base, 220ms ease);
}

.legal-page__content tbody tr:nth-child(even),
.sb-single-note__content tbody tr:nth-child(even) {
	background: color-mix(in srgb, var(--sb-color-bg, #f1f2f7) 72%, transparent);
}

@supports not (color: color-mix(in srgb, white 50%, black)) {
	.legal-page__content tbody tr,
	.sb-single-note__content tbody tr {
		background: rgba(233, 235, 242, 0.62);
	}

	.legal-page__content tbody tr:nth-child(even),
	.sb-single-note__content tbody tr:nth-child(even) {
		background: rgba(241, 242, 247, 0.82);
	}
}

@media (hover: hover) {
	.legal-page__content tbody tr:hover,
	.sb-single-note__content tbody tr:hover {
		background: rgba(158, 161, 181, 0.14);
	}
}

.legal-page__content .wp-block-table figcaption,
.sb-single-note__content .wp-block-table figcaption {
	margin-top: 0.85rem;
	color: var(--editorial-table-muted);
	font-size: 0.88rem;
	line-height: 1.55;
}

@media (max-width: 700px) {
	.legal-page__content .wp-block-table table,
	.legal-page__content table,
	.sb-single-note__content .wp-block-table table,
	.sb-single-note__content table {
		min-width: 36rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.legal-page__content tbody tr,
	.sb-single-note__content tbody tr {
		transition: none;
	}
}
