/**
 * TMT Responsive Table
 *
 * Two ideas carry the whole file:
 *
 * 1. Every editable value arrives as a CSS custom property. Elementor writes the
 *    global ones onto `.tmt-table`; the renderer writes per-column, per-row and
 *    per-cell ones inline onto the element they belong to. A cell then resolves
 *    its own value through a fallback chain, so an override wins by being more
 *    specific in the *data*, not by being more specific in the selector. That is
 *    why no visual rule below needs `!important` -- the only one in the file is on
 *    the screen-reader-only utility, where it is the point.
 *
 * 2. The breakpoints only change layout, never content. The markup is identical
 *    at every size, which is what lets the stacked mobile view keep real table
 *    semantics.
 *
 * Breakpoints follow Elementor's defaults: tablet <= 1024px, mobile <= 767px.
 */

.tmt-table {
	--tmt-tbl-table-bg: #ffffff;

	--tmt-tbl-head-bg: #eef1f4;
	--tmt-tbl-head-color: #16324f;
	--tmt-tbl-head-align: left;
	--tmt-tbl-head-valign: top;
	--tmt-tbl-head-pad: 16px 18px;

	--tmt-tbl-body-bg: #ffffff;
	--tmt-tbl-body-color: #2b3a45;
	--tmt-tbl-body-align: left;
	--tmt-tbl-body-valign: top;
	--tmt-tbl-body-pad: 16px 18px;

	--tmt-tbl-cell-border-style: solid;
	--tmt-tbl-cell-border-width: 1px;
	--tmt-tbl-cell-border-color: #d9dee3;

	--tmt-tbl-link: #0d6fb8;
	--tmt-tbl-link-hover: #0a5589;
	--tmt-tbl-link-decoration: underline;
	--tmt-tbl-link-hover-decoration: underline;

	--tmt-tbl-min-width: 720px;
	--tmt-tbl-stack-gap: 16px;
	--tmt-tbl-label-color: #6a7c88;

	box-sizing: border-box;
	width: 100%;
	max-width: 100%;
}

.tmt-table *,
.tmt-table *::before,
.tmt-table *::after {
	box-sizing: border-box;
}

/* ---------------------------------------------------------------- shell */

/*
 * The element that rounds, clips and scrolls.
 *
 * `overflow-x: auto` is the base state, not something scroll mode turns on:
 * a table that somehow ends up wider than its container then scrolls instead
 * of being cut off, and the page itself never gains a horizontal scrollbar.
 * When nothing overflows the scrollbar simply never appears.
 */
.tmt-table__scroller {
	position: relative;
	max-width: 100%;
	background: var(--tmt-tbl-table-bg);
	overflow-x: auto;
	overflow-y: hidden;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior-x: contain;
	/*
	 * Scroll affordance with no JavaScript. Two gradients sit at the left and
	 * right edges of the scroll port; two more, attached to the scrolling
	 * content, mask them at the extremes. The shadow therefore appears only on
	 * the side that still has content hidden, and disappears entirely when the
	 * table fits.
	 */
	background-image:
		linear-gradient(to right, var(--tmt-tbl-table-bg), rgba(255, 255, 255, 0)),
		linear-gradient(to left, var(--tmt-tbl-table-bg), rgba(255, 255, 255, 0)),
		linear-gradient(to right, rgba(9, 30, 42, 0.16), rgba(9, 30, 42, 0)),
		linear-gradient(to left, rgba(9, 30, 42, 0.16), rgba(9, 30, 42, 0));
	background-position: 0 0, 100% 0, 0 0, 100% 0;
	background-repeat: no-repeat;
	background-size: 26px 100%, 26px 100%, 13px 100%, 13px 100%;
	background-attachment: local, local, scroll, scroll;
}

.tmt-table__scroller:focus-visible {
	outline: 2px solid var(--tmt-tbl-link);
	outline-offset: 2px;
}

/*
 * `separate` rather than `collapse`: collapsed borders ignore the container's
 * border-radius, and the outer-border control would fight the cell borders.
 * With separate + zero spacing the grid looks the same, and the trailing edges
 * are dropped below so no line is ever doubled.
 */
.tmt-table__table {
	width: 100%;
	margin: 0;
	border: 0;
	border-collapse: separate;
	border-spacing: 0;
	table-layout: fixed;
	background: none;
	color: var(--tmt-tbl-body-color);
}

.tmt-table--auto .tmt-table__table {
	table-layout: auto;
}

.tmt-table__caption {
	padding: 0 0 10px;
	color: var(--tmt-tbl-body-color);
	text-align: left;
	caption-side: top;
}

.tmt-table__sr-only {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	border: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
}

/* ----------------------------------------------------------------- cells */

.tmt-table__cell {
	border-style: var(--tmt-tbl-cell-border-style);
	border-color: var(--tmt-tbl-cell-border-color);
	/* Right and bottom only; trailing edges removed below, which leaves exactly
	   one border between any two cells. */
	border-width: 0 var(--tmt-tbl-cell-border-width) var(--tmt-tbl-cell-border-width) 0;
	/* A long unbroken string -- a URL, a reference number -- wraps instead of
	   forcing its column wider than its share. */
	overflow-wrap: anywhere;
	word-break: break-word;
}

.tmt-table__row > .tmt-table__cell:last-child {
	border-right-width: 0;
}

.tmt-table__body > .tmt-table__row:last-child > .tmt-table__cell {
	border-bottom-width: 0;
}

.tmt-table__cell--head {
	padding: var(--tmt-tbl-head-pad);
	background: var(--tmt-tbl-head-bg);
	color: var(--tmt-tbl-head-color);
	/* An alignment set on the column wins over the header default. */
	text-align: var(--tmt-tbl-col-align, var(--tmt-tbl-head-align, left));
	vertical-align: var(--tmt-tbl-head-valign, top);
}

/*
 * The override chain, in one place:
 *
 *     cell -> row -> column -> zebra -> body
 *
 * Each level is only defined when an editor actually set it, so an unset level
 * falls straight through to the next one.
 */
.tmt-table__cell--body {
	padding: var(--tmt-tbl-body-pad);
	background: var(--tmt-tbl-cell-bg, var(--tmt-tbl-row-bg, var(--tmt-tbl-col-bg, var(--tmt-tbl-zebra-bg, var(--tmt-tbl-body-bg, transparent)))));
	color: var(--tmt-tbl-cell-color, var(--tmt-tbl-col-color, var(--tmt-tbl-body-color, inherit)));
	text-align: var(--tmt-tbl-cell-align, var(--tmt-tbl-col-align, var(--tmt-tbl-body-align, left)));
	vertical-align: var(--tmt-tbl-body-valign, top);
}

.tmt-table--zebra .tmt-table__body > .tmt-table__row:nth-child(odd) {
	--tmt-tbl-zebra-bg: var(--tmt-tbl-odd-bg);
}

.tmt-table--zebra .tmt-table__body > .tmt-table__row:nth-child(even) {
	--tmt-tbl-zebra-bg: var(--tmt-tbl-even-bg);
}

/* --------------------------------------------------------- cell content */

.tmt-table__cell-inner > *:first-child {
	margin-top: 0;
}

.tmt-table__cell-inner > *:last-child {
	margin-bottom: 0;
}

.tmt-table__cell-inner p {
	margin: 0 0 0.75em;
}

.tmt-table__cell-inner ul,
.tmt-table__cell-inner ol {
	margin: 0 0 0.75em;
	padding-left: 1.25em;
}

.tmt-table__cell-inner li {
	margin: 0 0 0.35em;
}

.tmt-table__cell-inner li:last-child {
	margin-bottom: 0;
}

.tmt-table__cell-inner h1,
.tmt-table__cell-inner h2,
.tmt-table__cell-inner h3,
.tmt-table__cell-inner h4,
.tmt-table__cell-inner h5,
.tmt-table__cell-inner h6 {
	margin: 0 0 0.5em;
	color: inherit;
	font-size: 1.05em;
	line-height: 1.35;
}

.tmt-table__cell-inner img {
	max-width: 100%;
	height: auto;
}

.tmt-table__cell-inner a {
	color: var(--tmt-tbl-link);
	text-decoration: var(--tmt-tbl-link-decoration);
	text-underline-offset: 0.15em;
}

.tmt-table__cell-inner a:hover,
.tmt-table__cell-inner a:focus-visible {
	color: var(--tmt-tbl-link-hover);
	text-decoration: var(--tmt-tbl-link-hover-decoration);
}

.tmt-table__cell-inner a:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/* The stacked-layout label and the scroll hint exist at every size; the
   breakpoint blocks below are the only things that reveal them. */
.tmt-table__cell--body::before {
	display: none;
	margin-bottom: 6px;
	color: var(--tmt-tbl-label-color);
	/* Defaults so the label reads as a label even before the widget's typography
	   control has been touched; Elementor's own rule outranks all of these. */
	font-size: 0.8em;
	font-weight: 700;
	line-height: 1.3;
	letter-spacing: 0.4px;
	text-transform: uppercase;
	content: attr(data-tmt-label);
}

.tmt-table__hint {
	display: none;
	margin: 0 0 8px;
	color: var(--tmt-tbl-label-color);
	font-size: 0.85em;
}

/* ==========================================================================
 * Layout modes
 *
 * Desktop is the base layout above, so it needs no query at all. Each range
 * below switches one mode on.
 *
 * Scroll mode is additive: the overflow container and its shadows are already
 * in the base rules, so all it adds is a minimum table width, the hint line and
 * the sticky first column.
 *
 * The stacked block is written out in both ranges rather than shared. It cannot
 * be hoisted into a single `(max-width: 1024.98px)` rule, because "stack on
 * tablet, scroll on mobile" is a legal combination and a shared rule would keep
 * stacking below 768px. Two explicit copies are longer but provably correct.
 * ========================================================================== */

@media (min-width: 768px) and (max-width: 1024.98px) {
	/* --- tablet: scroll --------------------------------------------- */
	.tmt-table--t-scroll .tmt-table__table {
		min-width: var(--tmt-tbl-min-width);
	}

	.tmt-table--t-scroll .tmt-table__hint {
		display: block;
	}

	.tmt-table--t-scroll.tmt-table--sticky-first .tmt-table__row > .tmt-table__cell:first-child {
		position: sticky;
		left: 0;
		z-index: 2;
	}

	/* The sticky column floats over the scrolling content, so it needs a drawn
	   edge: its own border scrolls away with the cell it belongs to. */
	.tmt-table--t-scroll.tmt-table--sticky-first .tmt-table__row > .tmt-table__cell:first-child::after {
		position: absolute;
		top: 0;
		right: 0;
		bottom: 0;
		width: var(--tmt-tbl-cell-border-width);
		background: var(--tmt-tbl-cell-border-color);
		content: "";
	}

	/* --- tablet: stacked cards --------------------------------------- */
	.tmt-table--t-stack .tmt-table__scroller {
		overflow: visible;
		background-image: none;
	}

	.tmt-table--t-stack .tmt-table__table,
	.tmt-table--t-stack .tmt-table__body,
	.tmt-table--t-stack .tmt-table__row,
	.tmt-table--t-stack .tmt-table__cell {
		display: block;
		width: auto;
		min-width: 0;
	}

	.tmt-table--t-stack .tmt-table__head,
	.tmt-table--t-stack colgroup {
		position: absolute;
		width: 1px;
		height: 1px;
		margin: -1px;
		padding: 0;
		border: 0;
		overflow: hidden;
		clip: rect(0 0 0 0);
		clip-path: inset(50%);
		white-space: nowrap;
	}

	.tmt-table--t-stack .tmt-table__row--body {
		margin-bottom: var(--tmt-tbl-stack-gap);
		border: var(--tmt-tbl-cell-border-width) var(--tmt-tbl-cell-border-style) var(--tmt-tbl-cell-border-color);
		overflow: hidden;
	}

	.tmt-table--t-stack .tmt-table__body > .tmt-table__row--body:last-child {
		margin-bottom: 0;
	}

	.tmt-table--t-stack .tmt-table__cell--body {
		border-width: 0 0 var(--tmt-tbl-cell-border-width) 0;
		text-align: var(--tmt-tbl-cell-align, var(--tmt-tbl-body-align, left));
	}

	.tmt-table--t-stack .tmt-table__row--body > .tmt-table__cell--body:last-child {
		border-bottom-width: 0;
	}

	.tmt-table--t-stack .tmt-table__cell--body::before {
		display: block;
	}

	.tmt-table--t-stack .tmt-table__cell--empty {
		display: none;
	}
}

@media (max-width: 767.98px) {
	/* --- mobile: scroll ---------------------------------------------- */
	.tmt-table--m-scroll .tmt-table__table {
		min-width: var(--tmt-tbl-min-width);
	}

	.tmt-table--m-scroll .tmt-table__hint {
		display: block;
	}

	.tmt-table--m-scroll.tmt-table--sticky-first .tmt-table__row > .tmt-table__cell:first-child {
		position: sticky;
		left: 0;
		z-index: 2;
	}

	.tmt-table--m-scroll.tmt-table--sticky-first .tmt-table__row > .tmt-table__cell:first-child::after {
		position: absolute;
		top: 0;
		right: 0;
		bottom: 0;
		width: var(--tmt-tbl-cell-border-width);
		background: var(--tmt-tbl-cell-border-color);
		content: "";
	}

	/* --- mobile: stacked cards --------------------------------------- */
	/*
	 * `display:block` on table elements strips their table semantics in every
	 * browser, which is exactly why the markup carries explicit role
	 * attributes: the roles survive the display change, so screen readers still
	 * announce rows, cells and column headers. The header row stays in the
	 * document, visually hidden, so the heading/cell relationship is preserved;
	 * sighted users get the same information from the ::before label.
	 */
	.tmt-table--m-stack .tmt-table__scroller {
		overflow: visible;
		background-image: none;
	}

	.tmt-table--m-stack .tmt-table__table,
	.tmt-table--m-stack .tmt-table__body,
	.tmt-table--m-stack .tmt-table__row,
	.tmt-table--m-stack .tmt-table__cell {
		display: block;
		width: auto;
		min-width: 0;
	}

	.tmt-table--m-stack .tmt-table__head,
	.tmt-table--m-stack colgroup {
		position: absolute;
		width: 1px;
		height: 1px;
		margin: -1px;
		padding: 0;
		border: 0;
		overflow: hidden;
		clip: rect(0 0 0 0);
		clip-path: inset(50%);
		white-space: nowrap;
	}

	.tmt-table--m-stack .tmt-table__row--body {
		margin-bottom: var(--tmt-tbl-stack-gap);
		border: var(--tmt-tbl-cell-border-width) var(--tmt-tbl-cell-border-style) var(--tmt-tbl-cell-border-color);
		overflow: hidden;
	}

	.tmt-table--m-stack .tmt-table__body > .tmt-table__row--body:last-child {
		margin-bottom: 0;
	}

	.tmt-table--m-stack .tmt-table__cell--body {
		border-width: 0 0 var(--tmt-tbl-cell-border-width) 0;
		/* Column alignment is meaningless once the cells are stacked. */
		text-align: var(--tmt-tbl-cell-align, var(--tmt-tbl-body-align, left));
	}

	.tmt-table--m-stack .tmt-table__row--body > .tmt-table__cell--body:last-child {
		border-bottom-width: 0;
	}

	.tmt-table--m-stack .tmt-table__cell--body::before {
		display: block;
	}

	/* An empty cell would leave a stray label above a blank block. The class is
	   set by the renderer, so no :has() support is required. */
	.tmt-table--m-stack .tmt-table__cell--empty {
		display: none;
	}
}
