/*
 * Product comparison tables: both YITH WooCompare's #yith-woocompare-table (customer-picked
 * comparisons, embedded as raw HTML inside post content) and .ec-product-compare-table (the
 * ec_product_compare shortcode, fixed comparisons embedded in a product page/post) share the
 * same .ec-compare-scroll wrapper and styling.
 *
 * Plain CSS horizontal scroll + sticky first column, replacing YITH's bundled DataTables
 * scrollX/scrollY (throws with 3+ product columns, blanking rows -- see comparison.php,
 * which strips the DataTables wrapper on the "yith_woocompare_table_updated" event). The
 * shortcode table never goes near DataTables in the first place.
 */

.ec-compare-scroll {
	position: relative;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	margin-bottom: 1em;
}

.ec-compare-scroll table {
	width: auto;
	min-width: 100%;
	border-collapse: collapse;
}

.ec-compare-scroll table td,
.ec-compare-scroll table th {
	white-space: normal;
}

/* Row label column (e.g. "Price", "Display Size") stays visible while the product
   columns scroll underneath it.

   The tbody th:first-child selector is load-bearing: YITH renders its row labels
   as <th> (semantically correct row headers), NOT <td>, so the td:first-child
   rule alone matched zero cells on #yith-woocompare-table and the label column
   scrolled away with the content. The ec_product_compare shortcode table uses
   <td>, hence both are listed. Verified in-browser 2026-09-13: 31 tbody rows,
   all with th:first-child, all computing position:static before this fix. */
.ec-compare-scroll table tbody tr > td:first-child,
.ec-compare-scroll table tbody tr > th:first-child,
.ec-compare-scroll table thead tr > th:first-child {
	position: sticky;
	left: 0;
	z-index: 2;
	background: #fff;
	box-shadow: 2px 0 4px rgba(0, 0, 0, 0.06);
}

/* Zebra striping across the whole row, not just the label column, so a shopper's eye stays
   on the right row while scanning across product columns. */
.ec-compare-scroll table tbody tr:nth-child(even) > td,
.ec-compare-scroll table tbody tr:nth-child(even) > th:first-child {
	background: #f7f7f7;
}

/* Model reference rows: repeated near the top and again mid-table so shoppers always know
   which column is which console without scrolling back up (see comparison.php and
   product-comparison-shortcode.php). Same dark background on every cell including the
   sticky label column. Rows with no spec value get skipped server-side, so the "mid" anchor
   can land on either an odd or even position depending on the products compared -- the
   "tbody" here matches the zebra rule's specificity (not just source order) so this always
   wins over it either way. */
.ec-compare-scroll table tbody tr.model_anchor_top td,
.ec-compare-scroll table tbody tr.model_anchor_top th,
.ec-compare-scroll table tbody tr.model_anchor_mid td,
.ec-compare-scroll table tbody tr.model_anchor_mid th {
	background: #2d2d2d;
	color: #fff;
	font-weight: 700;
	font-size: 1.05em;
	text-align: center;
	box-shadow: none;
}

.ec-compare-scroll table tbody tr.model_anchor_top td:first-child,
.ec-compare-scroll table tbody tr.model_anchor_top th:first-child,
.ec-compare-scroll table tbody tr.model_anchor_mid td:first-child,
.ec-compare-scroll table tbody tr.model_anchor_mid th:first-child {
	text-align: left;
}

/* ec_product_compare shortcode only: product header cell (image, name, price, CTA). */
.ec-product-compare-table thead th {
	text-align: center;
	vertical-align: top;
	padding: 12px 10px;
}

.ec-product-compare-table .ec-compare-product-link {
	display: block;
	text-decoration: none;
	color: inherit;
}

.ec-product-compare-table .ec-compare-product-link img {
	max-width: 120px;
	height: auto;
	margin: 0 auto 8px;
}

.ec-product-compare-table .ec-compare-product-name {
	display: block;
	font-weight: 600;
	font-size: 0.9em;
	line-height: 1.3;
}

.ec-product-compare-table .ec-compare-product-price {
	display: block;
	margin: 6px 0;
	font-weight: 700;
}

.ec-product-compare-table .ec-compare-view-product {
	display: inline-block;
	margin-top: 4px;
	padding: 6px 14px;
	font-size: 0.8em;
}

/* Mobile: make the horizontal scroll obvious with an edge fade + hint pill, both of
   which disappear once the shopper scrolls once (.has-scrolled, toggled via JS). */
@media (max-width: 767px) {
	.ec-compare-scroll {
		border: 1px solid #e5e5e5;
		border-radius: 4px;
	}

	.ec-compare-scroll::after {
		content: "";
		position: absolute;
		top: 0;
		right: 0;
		bottom: 0;
		width: 32px;
		background: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.9));
		pointer-events: none;
		transition: opacity 0.3s ease;
	}

	.ec-compare-scroll.has-scrolled::after {
		opacity: 0;
	}

	.ec-compare-scroll::before {
		content: "\2194  Swipe to compare";
		position: sticky;
		left: 0;
		display: block;
		width: fit-content;
		margin: 0 0 6px;
		padding: 4px 10px;
		font-size: 0.75em;
		font-weight: 600;
		letter-spacing: 0.02em;
		color: #fff;
		background: #ce1d76;
		border-radius: 12px;
		transition: opacity 0.3s ease, visibility 0.3s ease;
	}

	.ec-compare-scroll.has-scrolled::before {
		opacity: 0;
		visibility: hidden;
	}
}
