/*
 * GCS Table (Elementor widget) and the "GCS table" style of the Gutenberg table block.
 * Colours come from custom properties that the widget's style controls set per table.
 */
.gcs-table-wrap {
	max-width: 100%;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

.gcs-table,
.wp-block-table.is-style-gcs-table table {
	--gcs-table-border: #d8d8d8;
	--gcs-table-border-width: 1px;
	--gcs-table-head-bg: transparent;
	--gcs-table-head-color: inherit;
	--gcs-table-head-weight: 700;
	--gcs-table-odd: transparent;
	--gcs-table-even: transparent;
	--gcs-table-hover: transparent;
	--gcs-table-valign: middle;
	--gcs-table-padding: 15px;
	width: 100%;
	max-width: none;
	margin: 0;
	border: 0;
	border-collapse: collapse;
	border-spacing: 0;
	background: none;
}

/* A table WP Table Builder laid out again on narrow screens: the copy for each width (see render()). */
.gcs-table-box > .gcs-table-wrap:not(.is-d) {
	display: none;
}

.gcs-table-box--container {
	container: gcs-table / inline-size;
}

@media (max-width: 700px) {
	.gcs-table-box--window > .gcs-table-wrap.is-t {
		display: block;
	}

	.gcs-table-box--window > .gcs-table-wrap:not(.is-t) {
		display: none;
	}
}

@media (max-width: 375px) {
	.gcs-table-box--window > .gcs-table-wrap.is-m {
		display: block;
	}

	.gcs-table-box--window > .gcs-table-wrap:not(.is-m) {
		display: none;
	}
}

@container gcs-table (max-width: 700px) {
	.gcs-table-box--container > .gcs-table-wrap.is-t {
		display: block;
	}

	.gcs-table-box--container > .gcs-table-wrap:not(.is-t) {
		display: none;
	}
}

@container gcs-table (max-width: 375px) {
	.gcs-table-box--container > .gcs-table-wrap.is-m {
		display: block;
	}

	.gcs-table-box--container > .gcs-table-wrap:not(.is-m) {
		display: none;
	}
}

/* Gutenberg: the look of the most used table on the site. */
.wp-block-table.is-style-gcs-table table {
	--gcs-table-head-bg: #007ac1;
	--gcs-table-head-color: #fff;
	--gcs-table-odd: #f2f6f9;
	--gcs-table-even: #e1e6ea;
	font-size: 14px;
}

.wp-block-table.is-style-gcs-table {
	overflow-x: auto;
}

.gcs-table > * > tr > *,
.wp-block-table.is-style-gcs-table table > * > tr > * {
	padding: var(--gcs-table-padding);
	border: 0;
	background: none;
	color: inherit;
	font-weight: inherit;
	text-align: start;
	vertical-align: var(--gcs-table-valign);
}

.gcs-table:not(.gcs-table--alt) > tbody > tr:nth-child(odd) > *,
.wp-block-table.is-style-gcs-table table > tbody > tr:nth-child(odd) > * {
	background-color: var(--gcs-table-odd);
}

.gcs-table:not(.gcs-table--alt) > tbody > tr:nth-child(even) > *,
.wp-block-table.is-style-gcs-table table > tbody > tr:nth-child(even) > * {
	background-color: var(--gcs-table-even);
}

.gcs-table > thead > tr > *,
.wp-block-table.is-style-gcs-table table > thead > tr > * {
	background-color: var(--gcs-table-head-bg);
	color: var(--gcs-table-head-color);
	font-weight: var(--gcs-table-head-weight);
	vertical-align: var(--gcs-table-head-valign, var(--gcs-table-valign));
}

.gcs-table--hover-yes .gcs-table:not(.gcs-table--alt) > tbody > tr:hover > * {
	background-color: var(--gcs-table-hover);
}

/* A rearranged copy: each cell keeps the colours of its row in the table. */
.gcs-table--alt > tbody > tr > .is-odd {
	background-color: var(--gcs-table-odd);
}

.gcs-table--alt > tbody > tr > .is-even {
	background-color: var(--gcs-table-even);
}

.gcs-table--alt > tbody > tr > .is-head {
	background-color: var(--gcs-table-head-bg);
	color: var(--gcs-table-head-color);
	font-weight: var(--gcs-table-head-weight);
	vertical-align: var(--gcs-table-head-valign, var(--gcs-table-valign));
}

/* Borders: around every cell (the widget's default and the Gutenberg style), between rows, none. */
.gcs-table--borders-all .gcs-table > * > tr > *,
.wp-block-table.is-style-gcs-table table > * > tr > * {
	border: var(--gcs-table-border-width) solid var(--gcs-table-border);
}

.gcs-table--borders-rows .gcs-table > tbody > tr + tr > *,
.gcs-table--borders-rows .gcs-table > thead + tbody > tr:first-child > *,
.gcs-table--borders-rows .gcs-table > thead > tr + tr > * {
	border-top: var(--gcs-table-border-width) solid var(--gcs-table-border);
}

/* Cell text: paragraphs sit tight, as in the tables this widget replaced. */
.gcs-table__text > :first-child {
	margin-top: 0;
}

.gcs-table__text > :last-child {
	margin-bottom: 0;
}

.gcs-table__text p,
.wp-block-table.is-style-gcs-table table p {
	margin: 0;
}

.gcs-table__text li {
	line-height: 1.2;
}

/* Line around the table "As the theme": Astra's line on top and left of a table (table, td, th
   { border: 1px solid var(--ast-border-color) } table { border-width: 1px 0 0 1px }). */
.gcs-table--outer-theme .gcs-table {
	border-color: var(--ast-border-color, #dddddd);
	border-style: solid;
	border-width: 1px 0 0 1px;
}

/* Long words "Break to fit the cell" (WP Table Builder's): a word wider than its cell is broken. */
.gcs-table--words-break .gcs-table > * > tr > * {
	overflow-wrap: break-word;
	word-break: break-word;
}

/* Lists "Compact" (WP Table Builder's): no indent, the bullet or number in the first 1.1em. The
   list's padding is counted in the table's font size, as WP Table Builder counted it in the cell's
   base size whatever the size of the list text. */
@property --gcs-table-list-em {
	syntax: "<length>";
	inherits: true;
	initial-value: 16px;
}

.gcs-table--lists-compact .gcs-table {
	--gcs-table-list-em: 1em;
}

.gcs-table--lists-compact .gcs-table__text :is(ul, ol) {
	margin: 0;
	padding: var(--gcs-table-list-em) calc(0.2 * var(--gcs-table-list-em)) calc(0.4 * var(--gcs-table-list-em));
	list-style: none;
}

.gcs-table--lists-compact .gcs-table__text li {
	position: relative;
	margin: 0;
	padding-inline-start: 1.1em;
}

.gcs-table--lists-compact .gcs-table__text ul > li::before {
	position: absolute;
	inset-inline-start: 0;
	content: "\25cf";
}

.gcs-table--lists-compact .gcs-table__text ol {
	counter-reset: gcs-table-item;
}

.gcs-table--lists-compact .gcs-table__text ol > li {
	counter-increment: gcs-table-item;
}

.gcs-table--lists-compact .gcs-table__text ol > li::before {
	position: absolute;
	inset-inline-start: 0;
	content: counter(gcs-table-item) ".";
}

.gcs-table img {
	max-width: none;
	margin: 0;
	padding: 0;
	border: 0;
}

/* Phones: a table wider than the screen scrolls in its box; the first column can stay in view. */
@media (max-width: 767px) {
	.gcs-table--sticky-yes .gcs-table:not(.gcs-table--alt) > * > tr > :first-child {
		position: sticky;
		left: 0;
		z-index: 1;
	}
}

/*
 * Search, sorting and pages (DataTables, assets/table-datatable.js): TablePress 3.4.1's default
 * DataTables CSS for the same look. The table scrolls sideways in its own cell, so the search
 * box and the pages stay in place and the page does not get wider than the screen.
 */
.gcs-table {
	--gcs-table-head-active-bg: #049cdb;
	--gcs-table-head-active-color: var(--gcs-table-head-color);
}

.gcs-table-wrap:has(> .dt-container) {
	overflow: visible;
}

.gcs-table-wrap .dt-container {
	clear: both;
	margin-bottom: 1rem;
	position: relative;
}

.gcs-table-wrap .dt-container .dt-layout-row {
	display: flex;
	flex-direction: row;
	flex-wrap: wrap;
	justify-content: space-between;
}

.gcs-table-wrap .dt-container .dt-layout-row.dt-layout-table .dt-layout-cell {
	display: block;
	width: 100%;
	overflow-x: auto;
}

.gcs-table-wrap .dt-container .dt-layout-cell {
	display: flex;
	flex-direction: row;
	flex-wrap: wrap;
	gap: 1em;
	padding: 5px 0;
}

.gcs-table-wrap .dt-container .dt-layout-cell.dt-layout-full {
	align-items: center;
	justify-content: space-between;
	width: 100%;
}

.gcs-table-wrap .dt-container .dt-layout-cell.dt-layout-full > :only-child {
	margin: auto;
}

.gcs-table-wrap .dt-container .dt-layout-cell.dt-layout-start {
	align-items: center;
	justify-content: flex-start;
	margin-right: auto;
}

.gcs-table-wrap .dt-container .dt-layout-cell.dt-layout-end {
	align-items: center;
	justify-content: flex-end;
	margin-left: auto;
}

.gcs-table-wrap .dt-container .dt-layout-cell:empty {
	display: none;
}

.gcs-table-wrap .dt-container .dt-input,
.gcs-table-wrap .dt-container label {
	display: inline;
	width: auto;
}

.gcs-table-wrap .dt-container .dt-input {
	font-size: inherit;
	padding: 5px;
}

.gcs-table-wrap .dt-container .dt-length,
.gcs-table-wrap .dt-container .dt-search {
	align-items: center;
	display: flex;
	flex-wrap: wrap;
	gap: 5px;
	justify-content: center;
}

.gcs-table-wrap .dt-container .dt-paging .dt-paging-button {
	background: #0000;
	border: 1px solid #0000;
	border-radius: 2px;
	box-sizing: border-box;
	color: inherit !important;
	cursor: pointer;
	display: inline-block;
	font-size: 1em;
	height: 32px;
	margin-left: 2px;
	min-width: 32px;
	padding: 0 5px;
	text-align: center;
	text-decoration: none !important;
	vertical-align: middle;
}

.gcs-table-wrap .dt-container .dt-paging .dt-paging-button.current,
.gcs-table-wrap .dt-container .dt-paging .dt-paging-button:hover {
	border: 1px solid #111;
}

.gcs-table-wrap .dt-container .dt-paging .dt-paging-button.disabled,
.gcs-table-wrap .dt-container .dt-paging .dt-paging-button.disabled:active,
.gcs-table-wrap .dt-container .dt-paging .dt-paging-button.disabled:hover {
	border: 1px solid #0000;
	color: #0000004d !important;
	cursor: default;
	outline: none;
}

.gcs-table-wrap .dt-container .dt-paging > .dt-paging-button:first-child {
	margin-left: 0;
}

.gcs-table-wrap .dt-container .dt-paging .ellipsis {
	padding: 0 1em;
}

@media screen and (max-width: 767px) {
	.gcs-table-wrap .dt-container .dt-layout-row {
		flex-direction: column;
	}

	.gcs-table-wrap .dt-container .dt-layout-cell {
		flex-direction: column;
		padding: 0.5em 0;
	}
}

.gcs-table > thead > tr > * .dt-column-header {
	align-items: center;
	display: flex;
	gap: 4px;
	justify-content: space-between;
}

.gcs-table > thead > tr > * .dt-column-header .dt-column-title {
	flex-grow: 1;
}

.gcs-table > thead > tr > * .dt-column-header .dt-column-title:empty {
	display: none;
}

.gcs-table thead .dt-orderable-asc,
.gcs-table thead .dt-orderable-desc {
	cursor: pointer;
	outline-offset: -2px;
}

.gcs-table thead th:active {
	outline: none;
}

.gcs-table thead .dt-orderable-asc:hover,
.gcs-table thead .dt-orderable-desc:hover,
.gcs-table thead .dt-ordering-asc,
.gcs-table thead .dt-ordering-desc {
	background-color: var(--gcs-table-head-active-bg);
	color: var(--gcs-table-head-active-color);
}

.gcs-table thead .dt-orderable-asc .dt-column-order,
.gcs-table thead .dt-orderable-desc .dt-column-order,
.gcs-table thead .dt-ordering-asc .dt-column-order,
.gcs-table thead .dt-ordering-desc .dt-column-order {
	color: var(--gcs-table-head-active-color);
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif !important;
	font-size: 14px;
	height: 24px;
	line-height: 12px;
	position: relative;
	width: 12px;
}

.gcs-table thead .dt-orderable-asc .dt-column-order::before,
.gcs-table thead .dt-ordering-asc .dt-column-order::before {
	bottom: 50%;
	content: "\25b2";
	content: "\25b2" / "";
	display: block;
	position: absolute;
}

.gcs-table thead .dt-orderable-desc .dt-column-order::after,
.gcs-table thead .dt-ordering-desc .dt-column-order::after {
	content: "\25bc";
	content: "\25bc" / "";
	display: block;
	position: absolute;
	top: 50%;
}

.gcs-table thead .dt-orderable-asc .dt-column-order::after,
.gcs-table thead .dt-orderable-asc .dt-column-order::before,
.gcs-table thead .dt-orderable-desc .dt-column-order::after,
.gcs-table thead .dt-orderable-desc .dt-column-order::before,
.gcs-table thead .dt-ordering-asc .dt-column-order::after,
.gcs-table thead .dt-ordering-asc .dt-column-order::before,
.gcs-table thead .dt-ordering-desc .dt-column-order::after,
.gcs-table thead .dt-ordering-desc .dt-column-order::before {
	opacity: 0.2;
}

.gcs-table thead .dt-ordering-asc .dt-column-order::before,
.gcs-table thead .dt-ordering-desc .dt-column-order::after {
	opacity: 0.8;
}

/*
 * Spacing as a paragraph (widget setting "Spacing"). A table cut out of a text editor was a
 * paragraph of that text: the paragraph margin above and below it, shared with the margins of the
 * text next to it, and no widget spacing. Widgets do not share margins, so the paragraph gap goes
 * into empty boxes at the edge of the text joined to the table, where it is shared with that
 * text's own margin again, or inside the table widget on a side with no text joined; the widget
 * spacing between the table and the text it is joined to is taken out, whatever sets it (kit,
 * column "Widgets space", custom CSS), hence !important.
 * --gcs-table-paragraph-gap is the theme's paragraph margin (Tables::register_style() sets
 * Astra's), counted in the font size of the text next to the table.
 */
:root {
	--gcs-table-paragraph-gap: 1.12em;
}

/* The widget spacing is a margin, in sections and (the site's custom CSS) in flexbox containers. */
:is(.elementor-widget-wrap, .e-con, .e-con-inner) > .elementor-widget:has(+ .gcs-table--paragraph-above, + .gcs-table--paragraph-both),
:is(.elementor-widget-wrap, .e-con, .e-con-inner) > .elementor-widget.gcs-table--paragraph-below,
:is(.elementor-widget-wrap, .e-con, .e-con-inner) > .elementor-widget.gcs-table--paragraph-both {
	margin-block-end: 0 !important;
}

/* A boxed flexbox container spaces its items with a gap (--row-gap): taken back with a negative
   margin. A full-width one has a gap only when "Gaps" is set, which none holding a table has. */
.e-con-inner > .elementor-widget.gcs-table--paragraph-above,
.e-con-inner > .elementor-widget.gcs-table--paragraph-both,
.e-con-inner > .gcs-table--paragraph-below + .elementor-widget,
.e-con-inner > .gcs-table--paragraph-both + .elementor-widget {
	margin-block-start: calc(-1 * var(--row-gap, 0px)) !important;
}

/* Above the table: at the end of the text above, or inside the table widget. */
:is(.elementor-widget-wrap, .e-con, .e-con-inner) > .elementor-widget:has(+ .gcs-table--paragraph-above, + .gcs-table--paragraph-both)::after,
.elementor-widget.gcs-table--paragraph-alone::before,
.elementor-widget.gcs-table--paragraph-below::before {
	content: "";
	display: block;
	margin-block-start: var(--gcs-table-paragraph-gap);
}

/* Below the table: at the start of the text below (a table joined above has it already), or inside the table widget. */
:is(.elementor-widget-wrap, .e-con, .e-con-inner) > .gcs-table--paragraph-below + .elementor-widget:not(.gcs-table--paragraph-above, .gcs-table--paragraph-both)::before,
:is(.elementor-widget-wrap, .e-con, .e-con-inner) > .gcs-table--paragraph-both + .elementor-widget:not(.gcs-table--paragraph-above, .gcs-table--paragraph-both)::before,
.elementor-widget.gcs-table--paragraph-alone::after,
.elementor-widget.gcs-table--paragraph-above::after {
	content: "";
	display: block;
	margin-block-end: var(--gcs-table-paragraph-gap);
}

/* The space under the search, sorting and pages goes into the paragraph gap, as it did in the text. */
.gcs-table--paragraph-below .gcs-table-wrap .dt-container,
.gcs-table--paragraph-both .gcs-table-wrap .dt-container {
	margin-bottom: 0;
}
