/* Document table: a style for the core table block plus per-column options.
   Column classes work with or without the style; the visual style is opt-in. */

/* Column presets override the core fixed layout so 1% columns shrink to their content. */
.wp-block-table.kklidi-docs-table[class*="kklidi-table-col"] table.has-fixed-layout { table-layout: auto; }

/* Visual style */
.wp-block-table.is-style-kklidi-docs-table {
	border: 1px solid var(--kklidi-docs-border);
	border-radius: var(--kklidi-docs-radius-md);
	background: var(--kklidi-docs-background);
	overflow-x: auto;
	/* The scrolling frame also contains absolutely positioned text in a cell (the screen-reader "(new window)"
	   note of an external link), which would otherwise widen the page when the table scrolls. */
	position: relative;
}
.wp-block-table.is-style-kklidi-docs-table table {
	width: 100%;
	margin: 0;
	border: 0;
	border-collapse: collapse;
	font-size: var(--kklidi-docs-font-reference);
	line-height: 1.6;
}
.wp-block-table.is-style-kklidi-docs-table :is(th, td) {
	border: 0;
	border-bottom: 1px solid var(--kklidi-docs-border-subtle);
	padding: 10px 14px;
	text-align: left;
	vertical-align: top;
	word-break: keep-all;
	overflow-wrap: break-word;
}
.wp-block-table.is-style-kklidi-docs-table thead th,
.wp-block-table.is-style-kklidi-docs-table tfoot td {
	background: var(--kklidi-docs-surface-subtle);
	color: var(--kklidi-docs-muted);
	font-weight: 600;
	font-size: var(--kklidi-docs-font-small);
}
/* Core draws a 3px rule under thead and over tfoot; the document style uses cell borders only. */
.wp-block-table.is-style-kklidi-docs-table :is(thead, tfoot) { border: 0; }
.wp-block-table.is-style-kklidi-docs-table thead th { border-bottom-color: var(--kklidi-docs-border-strong); }
.wp-block-table.is-style-kklidi-docs-table tfoot td { border-top: 1px solid var(--kklidi-docs-border-strong); border-bottom: 0; }
.wp-block-table.is-style-kklidi-docs-table tbody tr:last-child td { border-bottom: 0; }
/* Alignment chosen per column in the editor (core has-text-align-*) wins over the document style's left alignment. */
.wp-block-table.is-style-kklidi-docs-table :is(th, td).has-text-align-left { text-align: left; }
.wp-block-table.is-style-kklidi-docs-table :is(th, td).has-text-align-center { text-align: center; }
.wp-block-table.is-style-kklidi-docs-table :is(th, td).has-text-align-right { text-align: right; }
/* Levels such as "EL-1.35" (wrapped while rendering) do not break after the hyphen. */
.wp-block-table.kklidi-docs-table .kklidi-table-nowrap { white-space: nowrap; }
/* Merged cells: a cell spanning rows is centered vertically, and one that reaches the last row drops its rule like that row's cells. */
.wp-block-table.is-style-kklidi-docs-table :is(th, td)[rowspan] { vertical-align: middle; }
.wp-block-table.is-style-kklidi-docs-table tbody tr:nth-last-child(2) td[rowspan="2"],
.wp-block-table.is-style-kklidi-docs-table tbody tr:nth-last-child(3) td[rowspan="3"],
.wp-block-table.is-style-kklidi-docs-table tbody tr:nth-last-child(4) td[rowspan="4"] { border-bottom: 0; }
.wp-block-table.is-style-kklidi-docs-table figcaption {
	margin: 10px 14px 12px;
	text-align: left;
	font-size: var(--kklidi-docs-font-figcaption, .875rem);
	color: var(--kklidi-docs-muted);
}

/* Options */
.wp-block-table.kklidi-docs-table.is-striped tbody tr:nth-child(even) td { background: var(--kklidi-docs-surface-subtle); }
.wp-block-table.kklidi-docs-table.is-compact thead th { padding: 7px 12px; }
.wp-block-table.kklidi-docs-table.is-compact :is(tbody, tfoot) td { padding: 6px 12px; font-size: var(--kklidi-docs-font-card); }
.wp-block-table.kklidi-docs-table.has-first-divider :is(th, td):first-child { border-right: 1px solid var(--kklidi-docs-border); }

/* Column width presets: narrow (content width, centered), content (content width), wide. */
.wp-block-table.kklidi-docs-table.kklidi-table-col1-narrow :is(th, td):nth-child(1),
.wp-block-table.kklidi-docs-table.kklidi-table-col2-narrow :is(th, td):nth-child(2),
.wp-block-table.kklidi-docs-table.kklidi-table-col3-narrow :is(th, td):nth-child(3),
.wp-block-table.kklidi-docs-table.kklidi-table-col4-narrow :is(th, td):nth-child(4),
.wp-block-table.kklidi-docs-table.kklidi-table-col5-narrow :is(th, td):nth-child(5),
.wp-block-table.kklidi-docs-table.kklidi-table-col6-narrow :is(th, td):nth-child(6),
.wp-block-table.kklidi-docs-table.kklidi-table-col7-narrow :is(th, td):nth-child(7),
.wp-block-table.kklidi-docs-table.kklidi-table-col8-narrow :is(th, td):nth-child(8) { width: 1%; text-align: center; font-variant-numeric: tabular-nums; }
.wp-block-table.kklidi-docs-table.kklidi-table-col1-narrow td:nth-child(1),
.wp-block-table.kklidi-docs-table.kklidi-table-col2-narrow td:nth-child(2),
.wp-block-table.kklidi-docs-table.kklidi-table-col3-narrow td:nth-child(3),
.wp-block-table.kklidi-docs-table.kklidi-table-col4-narrow td:nth-child(4),
.wp-block-table.kklidi-docs-table.kklidi-table-col5-narrow td:nth-child(5),
.wp-block-table.kklidi-docs-table.kklidi-table-col6-narrow td:nth-child(6),
.wp-block-table.kklidi-docs-table.kklidi-table-col7-narrow td:nth-child(7),
.wp-block-table.kklidi-docs-table.kklidi-table-col8-narrow td:nth-child(8) { white-space: nowrap; }
/* In tables of up to four columns a narrow header also keeps one line where there is room, instead of
   breaking after every word; wider matrices keep wrapping so their headers fit beside each other. */
@media (min-width: 601px) {
	.wp-block-table.kklidi-docs-table.kklidi-table-col1-narrow:not(:has(tr > :nth-child(5))) th:nth-child(1),
	.wp-block-table.kklidi-docs-table.kklidi-table-col2-narrow:not(:has(tr > :nth-child(5))) th:nth-child(2),
	.wp-block-table.kklidi-docs-table.kklidi-table-col3-narrow:not(:has(tr > :nth-child(5))) th:nth-child(3),
	.wp-block-table.kklidi-docs-table.kklidi-table-col4-narrow:not(:has(tr > :nth-child(5))) th:nth-child(4) { white-space: nowrap; }
}
.wp-block-table.kklidi-docs-table.kklidi-table-col1-content :is(th, td):nth-child(1),
.wp-block-table.kklidi-docs-table.kklidi-table-col2-content :is(th, td):nth-child(2),
.wp-block-table.kklidi-docs-table.kklidi-table-col3-content :is(th, td):nth-child(3),
.wp-block-table.kklidi-docs-table.kklidi-table-col4-content :is(th, td):nth-child(4),
.wp-block-table.kklidi-docs-table.kklidi-table-col5-content :is(th, td):nth-child(5),
.wp-block-table.kklidi-docs-table.kklidi-table-col6-content :is(th, td):nth-child(6),
.wp-block-table.kklidi-docs-table.kklidi-table-col7-content :is(th, td):nth-child(7),
.wp-block-table.kklidi-docs-table.kklidi-table-col8-content :is(th, td):nth-child(8) { width: 1%; }
/* Content columns keep one line, header included, where there is room, so the column is as wide as
   its longer of header and body; small screens wrap them at word boundaries. */
@media (min-width: 601px) {
	.wp-block-table.kklidi-docs-table.kklidi-table-col1-content :is(th, td):nth-child(1),
	.wp-block-table.kklidi-docs-table.kklidi-table-col2-content :is(th, td):nth-child(2),
	.wp-block-table.kklidi-docs-table.kklidi-table-col3-content :is(th, td):nth-child(3),
	.wp-block-table.kklidi-docs-table.kklidi-table-col4-content :is(th, td):nth-child(4),
	.wp-block-table.kklidi-docs-table.kklidi-table-col5-content :is(th, td):nth-child(5),
	.wp-block-table.kklidi-docs-table.kklidi-table-col6-content :is(th, td):nth-child(6),
	.wp-block-table.kklidi-docs-table.kklidi-table-col7-content :is(th, td):nth-child(7),
	.wp-block-table.kklidi-docs-table.kklidi-table-col8-content :is(th, td):nth-child(8) { white-space: nowrap; }
}
.wp-block-table.kklidi-docs-table.kklidi-table-col1-wide :is(th, td):nth-child(1),
.wp-block-table.kklidi-docs-table.kklidi-table-col2-wide :is(th, td):nth-child(2),
.wp-block-table.kklidi-docs-table.kklidi-table-col3-wide :is(th, td):nth-child(3),
.wp-block-table.kklidi-docs-table.kklidi-table-col4-wide :is(th, td):nth-child(4),
.wp-block-table.kklidi-docs-table.kklidi-table-col5-wide :is(th, td):nth-child(5),
.wp-block-table.kklidi-docs-table.kklidi-table-col6-wide :is(th, td):nth-child(6),
.wp-block-table.kklidi-docs-table.kklidi-table-col7-wide :is(th, td):nth-child(7),
.wp-block-table.kklidi-docs-table.kklidi-table-col8-wide :is(th, td):nth-child(8) { width: 45%; }

/* The editor's rich text keeps pre-wrap; repeat the no-wrap rule for the editable spans of narrow body cells, narrow headers of small tables and content cells. */
.wp-block-table.kklidi-docs-table.kklidi-table-col1-narrow td:nth-child(1) .block-editor-rich-text__editable,
.wp-block-table.kklidi-docs-table.kklidi-table-col2-narrow td:nth-child(2) .block-editor-rich-text__editable,
.wp-block-table.kklidi-docs-table.kklidi-table-col3-narrow td:nth-child(3) .block-editor-rich-text__editable,
.wp-block-table.kklidi-docs-table.kklidi-table-col4-narrow td:nth-child(4) .block-editor-rich-text__editable,
.wp-block-table.kklidi-docs-table.kklidi-table-col5-narrow td:nth-child(5) .block-editor-rich-text__editable,
.wp-block-table.kklidi-docs-table.kklidi-table-col6-narrow td:nth-child(6) .block-editor-rich-text__editable,
.wp-block-table.kklidi-docs-table.kklidi-table-col7-narrow td:nth-child(7) .block-editor-rich-text__editable,
.wp-block-table.kklidi-docs-table.kklidi-table-col8-narrow td:nth-child(8) .block-editor-rich-text__editable { white-space: nowrap !important; }
@media (min-width: 601px) {
	.wp-block-table.kklidi-docs-table.kklidi-table-col1-narrow:not(:has(tr > :nth-child(5))) th:nth-child(1) .block-editor-rich-text__editable,
	.wp-block-table.kklidi-docs-table.kklidi-table-col2-narrow:not(:has(tr > :nth-child(5))) th:nth-child(2) .block-editor-rich-text__editable,
	.wp-block-table.kklidi-docs-table.kklidi-table-col3-narrow:not(:has(tr > :nth-child(5))) th:nth-child(3) .block-editor-rich-text__editable,
	.wp-block-table.kklidi-docs-table.kklidi-table-col4-narrow:not(:has(tr > :nth-child(5))) th:nth-child(4) .block-editor-rich-text__editable,
	.wp-block-table.kklidi-docs-table.kklidi-table-col1-content :is(th, td):nth-child(1) .block-editor-rich-text__editable,
	.wp-block-table.kklidi-docs-table.kklidi-table-col2-content :is(th, td):nth-child(2) .block-editor-rich-text__editable,
	.wp-block-table.kklidi-docs-table.kklidi-table-col3-content :is(th, td):nth-child(3) .block-editor-rich-text__editable,
	.wp-block-table.kklidi-docs-table.kklidi-table-col4-content :is(th, td):nth-child(4) .block-editor-rich-text__editable,
	.wp-block-table.kklidi-docs-table.kklidi-table-col5-content :is(th, td):nth-child(5) .block-editor-rich-text__editable,
	.wp-block-table.kklidi-docs-table.kklidi-table-col6-content :is(th, td):nth-child(6) .block-editor-rich-text__editable,
	.wp-block-table.kklidi-docs-table.kklidi-table-col7-content :is(th, td):nth-child(7) .block-editor-rich-text__editable,
	.wp-block-table.kklidi-docs-table.kklidi-table-col8-content :is(th, td):nth-child(8) .block-editor-rich-text__editable { white-space: nowrap !important; }
}

/* Emphasis column: slightly heavier text in body cells. */
.wp-block-table.kklidi-docs-table.has-emphasis-1 tbody td:nth-child(1),
.wp-block-table.kklidi-docs-table.has-emphasis-2 tbody td:nth-child(2),
.wp-block-table.kklidi-docs-table.has-emphasis-3 tbody td:nth-child(3),
.wp-block-table.kklidi-docs-table.has-emphasis-4 tbody td:nth-child(4),
.wp-block-table.kklidi-docs-table.has-emphasis-5 tbody td:nth-child(5),
.wp-block-table.kklidi-docs-table.has-emphasis-6 tbody td:nth-child(6),
.wp-block-table.kklidi-docs-table.has-emphasis-7 tbody td:nth-child(7),
.wp-block-table.kklidi-docs-table.has-emphasis-8 tbody td:nth-child(8) { font-weight: 600; }
/* A narrow first column reads as a row number: muted, never emphasized. */
.wp-block-table.is-style-kklidi-docs-table.kklidi-table-col1-narrow tbody td:nth-child(1) { color: var(--kklidi-docs-muted); font-weight: 400; }

/* Phones: tables stay tables (the former stacked card view is gone; a saved stacking setting is ignored).
   docs-table-view.js marks a table of three or more columns that cannot show its rows without squeezing them
   (is-swipe); it then scrolls sideways inside the frame with its first column fixed. Up to four columns, every
   later column is as wide as the room beside the first one, so one swipe brings in one whole column; matrices
   of five or more columns keep the smallest desktop layout and scroll freely. Until the script has measured
   (or without it), tables of four or more columns keep that smallest layout. Content-based columns throughout,
   so a fixed-layout table does not split the width evenly and break values mid-word. */
@media (max-width: 600px) {
	.wp-block-table.is-style-kklidi-docs-table { --kklidi-docs-table-lead: 8em; }
	/* Two columns: a steady label column leaves the value column room for one-line values ("EL-2.0 + 1.0 = EL-1.0"). */
	.wp-block-table.is-style-kklidi-docs-table:not(:has(tr > :nth-child(3))):not(.kklidi-table-col1-narrow):not(.kklidi-table-col1-wide) :is(th, td):first-child { width: var(--kklidi-docs-table-lead); }
	html:not(.kklidi-docs-tables-measured) .wp-block-table.is-style-kklidi-docs-table:has(tr > :nth-child(4)) table { min-width: 600px; table-layout: auto; }
	/* While the script measures: every cell on one line at its natural width. */
	.wp-block-table.is-style-kklidi-docs-table.is-measuring :is(th, td) { white-space: nowrap !important; width: auto !important; min-width: 0 !important; max-width: none !important; position: static !important; }
	.wp-block-table.is-style-kklidi-docs-table.is-swipe { scroll-snap-type: x proximity; }
	.wp-block-table.is-style-kklidi-docs-table:is(.is-swipe, .is-fitted) table { table-layout: auto; }
	.wp-block-table.is-style-kklidi-docs-table.is-fitted table { width: 100%; }
	.wp-block-table.is-style-kklidi-docs-table.is-swipe:not(.has-many-columns) table { width: max-content; min-width: 100%; }
	.wp-block-table.is-style-kklidi-docs-table.is-swipe :is(th, td):first-child { position: sticky; left: 0; z-index: 1; background: var(--kklidi-docs-background); box-shadow: inset -1px 0 0 var(--kklidi-docs-border-subtle); }
	.wp-block-table.is-style-kklidi-docs-table.is-swipe :is(thead th, tfoot td):first-child { background: var(--kklidi-docs-surface-subtle); }
	.wp-block-table.is-style-kklidi-docs-table:is(.is-swipe, .is-fitted):not(.kklidi-table-col1-narrow) :is(th, td):first-child { box-sizing: border-box; width: var(--kklidi-docs-table-lead-width, var(--kklidi-docs-table-lead)); min-width: var(--kklidi-docs-table-lead-width, var(--kklidi-docs-table-lead)); max-width: var(--kklidi-docs-table-lead-width, var(--kklidi-docs-table-lead)); white-space: normal; }
	/* Widths measured by the script: fitted tables share the frame; in scrolling ones no later column is wider than the room beside the fixed one. */
	.wp-block-table.is-style-kklidi-docs-table:is(.is-swipe:not(.has-many-columns), .is-fitted) :is(th, td):not(:first-child) { box-sizing: border-box; }
	.wp-block-table.is-style-kklidi-docs-table.is-swipe:not(.has-many-columns) :is(th, td):not(:first-child) { scroll-snap-align: start; }
	.wp-block-table.is-style-kklidi-docs-table:is(.is-swipe:not(.has-many-columns), .is-fitted) :is(th, td):nth-child(2) { width: var(--kklidi-docs-table-col2); min-width: var(--kklidi-docs-table-col2); }
	.wp-block-table.is-style-kklidi-docs-table:is(.is-swipe:not(.has-many-columns), .is-fitted) :is(th, td):nth-child(3) { width: var(--kklidi-docs-table-col3); min-width: var(--kklidi-docs-table-col3); }
	.wp-block-table.is-style-kklidi-docs-table:is(.is-swipe:not(.has-many-columns), .is-fitted) :is(th, td):nth-child(4) { width: var(--kklidi-docs-table-col4); min-width: var(--kklidi-docs-table-col4); }
	.wp-block-table.is-style-kklidi-docs-table.is-swipe.has-many-columns { scroll-snap-type: none; }
	.wp-block-table.is-style-kklidi-docs-table.is-swipe.has-many-columns table { min-width: 600px; }
	/* Columns remain to the right: the frame's edge fades over the strip where the next column peeks in. */
	.wp-block-table.is-style-kklidi-docs-table.is-swipe.has-more { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 2.25em), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 2.25em), transparent); }
}
