/* Ksquare Table Styler — styles for core/table blocks marked with .kst */

.wp-block-table.kst {
	--kst-radius: 10px;
	--kst-border: #e2e8f0;
	--kst-stripe: #f8fafc;
	--kst-hover: #eef4ff;
	--kst-pad-y: .75em;
	--kst-pad-x: 1em;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	max-width: 100%;
}
.wp-block-table.kst.kst-pad-compact { --kst-pad-y: .45em; --kst-pad-x: .7em; }
.wp-block-table.kst.kst-pad-relaxed { --kst-pad-y: 1.05em; --kst-pad-x: 1.3em; }
/* Front end: the table sits in .kst-scroll, which scrolls and carries the shadow.
   Editor (no wrapper): let the shadow spill out of the figure instead of clipping it. */
.wp-block-table.kst.kst-shadow,
.wp-block-table.kst.kst-wrapped { overflow: visible; }
.wp-block-table.kst .kst-scroll {
	overflow-x: auto;
	overflow-y: hidden;
	-webkit-overflow-scrolling: touch;
	max-width: 100%;
	border-radius: var(--kst-radius);
}
.wp-block-table.kst.kst-wrapped.kst-shadow .kst-scroll {
	box-shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 6px 18px rgba(15, 23, 42, .07);
}

/* Table shell */
.wp-block-table.kst table {
	width: 100%;
	margin: 0;
	border-collapse: separate;
	border-spacing: 0;
	border: 1px solid var(--kst-border);
	border-radius: var(--kst-radius);
	background: var(--kst-body-bg, var(--theme-palette-color-8, #fff));
	color: var(--kst-body-color, inherit);
	font-size: var(--kst-font-size, inherit);
	line-height: 1.5;
}
.wp-block-table.kst.kst-shadow:not(.kst-wrapped) table {
	box-shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 6px 18px rgba(15, 23, 42, .07);
}

/* Reset core + theme cell styles */
.wp-block-table.kst table thead,
.wp-block-table.kst table tfoot,
.wp-block-table.kst table tbody,
.wp-block-table.kst table tr { border: 0; background: none; }

.wp-block-table.kst table th,
.wp-block-table.kst table td {
	border: 0;
	padding: var(--kst-pad-y) var(--kst-pad-x);
	text-align: var(--kst-body-align, start);
	vertical-align: middle;
	background-clip: padding-box;
	transition: background-color .15s ease;
}

/* Keep core per-column alignment ("Align column" in the toolbar) */
.wp-block-table.kst table .has-text-align-left { text-align: left; }
.wp-block-table.kst table .has-text-align-center { text-align: center; }
.wp-block-table.kst table .has-text-align-right { text-align: right; }

/* Header */
/* Background sits on the row so a gradient flows across all header cells. */
.wp-block-table.kst table thead tr { background: var(--kst-head-bg, transparent); }
.wp-block-table.kst:not(.kst-wrapped) table { overflow: hidden; } /* editor: clip row corners to the radius */
.wp-block-table.kst table thead th,
.wp-block-table.kst table thead td {
	background: transparent;
	color: var(--kst-head-color, inherit);
	font-weight: 600;
	text-align: var(--kst-head-align, var(--kst-body-align, start));
}
.wp-block-table.kst table thead a { color: inherit; }
.wp-block-table.kst.kst-upper table thead th,
.wp-block-table.kst.kst-upper table thead td {
	text-transform: uppercase;
	letter-spacing: .04em;
	font-size: .85em;
}

/* Footer */
.wp-block-table.kst table tfoot td,
.wp-block-table.kst table tfoot th { font-weight: 600; }

/* Rounded corners on edge cells */
.wp-block-table.kst table > :first-child > tr:first-child > :first-child { border-top-left-radius: calc(var(--kst-radius) - 1px); }
.wp-block-table.kst table > :first-child > tr:first-child > :last-child { border-top-right-radius: calc(var(--kst-radius) - 1px); }
.wp-block-table.kst table > :last-child > tr:last-child > :first-child { border-bottom-left-radius: calc(var(--kst-radius) - 1px); }
.wp-block-table.kst table > :last-child > tr:last-child > :last-child { border-bottom-right-radius: calc(var(--kst-radius) - 1px); }

/* Border modes */
.wp-block-table.kst.kst-b-rows table tbody tr > *,
.wp-block-table.kst.kst-b-all table tbody tr > *,
.wp-block-table.kst.kst-b-lines table tbody tr > * { border-top: 1px solid var(--kst-border); }
.wp-block-table.kst.kst-b-rows table thead + tbody tr:first-child > *,
.wp-block-table.kst.kst-b-all table thead + tbody tr:first-child > * { border-top: 0; }
.wp-block-table.kst.kst-b-rows table > tbody:first-child tr:first-child > *,
.wp-block-table.kst.kst-b-all table > tbody:first-child tr:first-child > *,
.wp-block-table.kst.kst-b-lines table > tbody:first-child tr:first-child > * { border-top: 0; }
.wp-block-table.kst.kst-b-rows table tfoot tr > *,
.wp-block-table.kst.kst-b-all table tfoot tr > *,
.wp-block-table.kst.kst-b-lines table tfoot tr > * { border-top: 2px solid var(--kst-border); }

.wp-block-table.kst.kst-b-all table tr > *:not(:last-child) { border-right: 1px solid var(--kst-border); }
.wp-block-table.kst.kst-b-all table thead tr > *:not(:last-child) { border-right-color: rgba(255, 255, 255, .18); }

.wp-block-table.kst.kst-b-lines table,
.wp-block-table.kst.kst-b-none table { border: 0; }
.wp-block-table.kst.kst-b-lines table thead tr > * { border-bottom: 2px solid var(--kst-border); }

/* Bold first column */
.wp-block-table.kst.kst-first-bold table tbody tr > :first-child { font-weight: 600; }

/* Links */
.wp-block-table.kst.kst-links table tbody a,
.wp-block-table.kst.kst-links table tfoot a { color: var(--kst-link); }

/* Sticky first column (horizontal scroll) */
.wp-block-table.kst.kst-sticky-first table tr > :first-child {
	position: sticky;
	left: 0;
	z-index: 1;
}
.wp-block-table.kst.kst-sticky-first table tbody tr > :first-child,
.wp-block-table.kst.kst-sticky-first table tfoot tr > :first-child {
	background-color: var(--kst-body-bg, var(--theme-palette-color-8, #fff));
	box-shadow: inset -1px 0 0 var(--kst-border);
}

/* Stripes + hover */
.wp-block-table.kst.kst-striped table tbody tr:nth-child(odd) > * { background-color: var(--kst-stripe-odd, var(--kst-body-bg, var(--theme-palette-color-8, #fff))); }
.wp-block-table.kst.kst-striped table tbody tr:nth-child(even) > * { background-color: var(--kst-stripe); }
.wp-block-table.kst.kst-hover table tbody tr:hover > * { background-color: var(--kst-hover); }

/* Caption */
.wp-block-table.kst figcaption {
	margin-top: .65em;
	font-size: .875em;
	text-align: center;
	opacity: .75;
}

/* Mobile: stack rows as cards */
@media (max-width: 640px) {
	.wp-block-table.kst.kst-stack { overflow: visible; padding: 0; }
	.wp-block-table.kst.kst-stack .kst-scroll { overflow: visible; box-shadow: none !important; border-radius: 0; }
	.wp-block-table.kst.kst-stack table,
	.wp-block-table.kst.kst-stack table tbody,
	.wp-block-table.kst.kst-stack table tfoot,
	.wp-block-table.kst.kst-stack table tr,
	.wp-block-table.kst.kst-stack table td,
	.wp-block-table.kst.kst-stack table th {
		display: block;
		width: 100% !important;
		min-width: 0 !important;
		box-sizing: border-box;
	}
	.wp-block-table.kst.kst-stack table {
		border: 0;
		background: none;
		box-shadow: none;
	}
	.wp-block-table.kst.kst-stack table thead {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip: rect(0 0 0 0);
		white-space: nowrap;
	}
	.wp-block-table.kst.kst-stack table tbody tr,
	.wp-block-table.kst.kst-stack table tfoot tr {
		margin-bottom: 12px;
		border: 1px solid var(--kst-border);
		border-radius: var(--kst-radius);
		overflow: hidden;
		background: var(--kst-body-bg, var(--theme-palette-color-8, #fff));
	}
	.wp-block-table.kst.kst-stack.kst-shadow table tbody tr { box-shadow: 0 2px 10px rgba(15, 23, 42, .06); }
	.wp-block-table.kst.kst-stack table tr > * {
		position: static;
		display: flex;
		justify-content: space-between;
		align-items: baseline;
		gap: 1em;
		text-align: right !important;
		border: 0 !important;
		border-radius: 0 !important;
		border-top: 1px solid var(--kst-border) !important;
		box-shadow: none !important;
	}
	.wp-block-table.kst.kst-stack table tr > :first-child {
		border-top: 0 !important;
		background: var(--kst-head-bg, transparent) !important;
		color: var(--kst-head-color, inherit) !important;
		font-weight: 600;
	}
	.wp-block-table.kst.kst-stack table tr > :first-child a { color: inherit; }
	.wp-block-table.kst.kst-stack table tr > * > * { min-width: 0; }
	.wp-block-table.kst.kst-stack table tr > [data-label]::before {
		content: attr(data-label);
		flex: 0 0 38%;
		text-align: left;
		font-weight: 600;
		opacity: .8;
	}
	.wp-block-table.kst.kst-stack table tr > [data-label=""]::before { display: none; }
}
