/**
 * Eco Guardian Waste Calculator — front-end styles.
 * Everything is scoped under .egwc so it can't leak into the theme.
 * Colours are CSS custom properties; override them in the theme to rebrand.
 */

.egwc {
	--egwc-secondary: #f4f4f3;
	--egwc-accent: #86a226;

	/* Muted text sitting on the PAGE background (search help, clear button).
	   Light, because the calculator sits on a dark section. */
	--egwc-muted: #f4f4f3bd;

	/* Muted text sitting on --egwc-surface / --egwc-accent-soft (SKU, qty unit,
	   card labels, empty state). Must stay dark while the surface is white —
	   this is the pair that has to move together if the surface ever changes. */
	--egwc-muted-on-surface: #5d6b64;

	--egwc-accent-soft: #eaf5ee;
	--egwc-border: #dcdfdd;
	--egwc-text: #1e2422;
	--egwc-surface: #fff;
	--egwc-radius: 10px;

	box-sizing: border-box;
	color: var(--egwc-text);
	margin: 0 auto;
	max-width: 960px;
	width: 100%;
}

.egwc *,
.egwc *::before,
.egwc *::after {
	box-sizing: inherit;
}

h3.egwc__headline {
	font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2.125rem);
	color: var(--egwc-accent);
	margin: 0 0 1rem;
}

/* --- Search ------------------------------------------------------------ */

.egwc__search {
	margin-bottom: 1.25rem;
}

.egwc__search-label {
	display: block;
	color: var(--egwc-secondary);
	margin-bottom: 0.375rem;
	font-size: 1rem;
	letter-spacing: 0.05em;
}

.egwc__search-input {
	background: var(--egwc-surface);
	border: 0;
	border-radius: var(--egwc-radius);
	color: inherit;
	font-size: 1rem;
	padding: 0.7rem 0.9rem;
	width: 100%;
}

.egwc__search-input:focus-visible {
	outline: 2px solid var(--egwc-accent);
}

.egwc__search-help {
	color: var(--egwc-muted);
	font-size: 0.8125rem;
	margin: 0.4rem 0 0;
}

/* --- Product list ------------------------------------------------------ */

.egwc__list {
	background: var(--egwc-surface);
	border: 0;
	max-height: 26rem;
	overflow: auto;
	overscroll-behavior: contain;
}

.egwc__table {
	border-collapse: collapse;
	font-size: 0.9375rem;
	margin: 0;
	width: 100%;
}

.egwc__table th,
.egwc__table td {
	border: 0 !important;
	padding: 0.6rem 0.75rem;
	text-align: left;
	vertical-align: middle;
}

.egwc__table thead th {
	background: var(--egwc-accent);
	color: var(--egwc-surface);
	font-family: var(--e-global-typography-accent-font-family), Sans-serif;
	font-weight: 400;
	font-size: 0.75rem;
	letter-spacing: 0.04em;
	position: sticky;
	text-transform: uppercase;
	top: 0;
	z-index: 1;
}

table.egwc__table tbody td,
table.egwc__table tbody>tr:nth-child(odd)>td,
table.egwc__table tbody>tr:nth-child(odd)>th,
table.egwc__table tbody td:hover,
table.egwc__table tbody>tr:nth-child(odd)>td:hover,
table.egwc__table tbody>tr:nth-child(odd)>th:hover,
table tbody tr:hover>td,
table tbody tr:hover>th {
	background-color: var(--egwc-secondary);
}

.egwc__table tbody tr:last-child td {
	border-bottom: 0;
}

td.egwc__col-select {
	width: 3rem;
	text-align: center;
}

/* Merged SKU + name cell: name on top, SKU beneath as a quiet caption. */
.egwc__col-product {
}

.egwc__name {
	display: block;
}

.egwc__sku {
	color: var(--egwc-muted-on-surface);
	display: block;
	font-size: 0.75rem;
	font-variant-numeric: tabular-nums;
	letter-spacing: 0.02em;
	margin-top: 0.1rem;
}

.egwc__col-qty {
	white-space: nowrap;
}

.egwc__checkbox {
	accent-color: var(--egwc-accent);
	height: 1.1rem;
	margin: 0;
	width: 1.1rem;
}

input[type=number].egwc__qty {
	border: 1px solid var(--egwc-border);
	border-radius: 6px;
	font-size: 0.9375rem;
	padding: 0.35rem 0.5rem;
	width: 4.5rem;
}

.egwc__empty {
	color: var(--egwc-muted-on-surface);
	margin: 0;
	padding: 1.25rem 0.75rem;
	text-align: center;
}

/* --- Results ----------------------------------------------------------- */

.egwc__results {
	margin-top: 1.5rem;
}

.egwc__cards {
	display: grid;
	gap: 0.875rem;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr));
}

.egwc__card {
/*
	background: var(--egwc-accent-soft);
	border: 1px solid var(--egwc-border);
	border-radius: var(--egwc-radius);
*/
	padding: 1rem 1.125rem;
}

.egwc__card-label {
    color: var(--egwc-surface);
    font-family: var(--e-global-typography-accent-font-family), Sans-serif;
    font-weight: 400;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
	text-transform: uppercase;
	margin: 0 0 0.35rem;
	text-align: center;
}

.egwc__card-value {
	font-size: clamp(1.5rem, 1.3rem + 0.9vw, 2rem);
	font-variant-numeric: tabular-nums;
	color: var(--egwc-accent);
    font-family: var(--e-global-typography-primary-font-family), Sans-serif;
    letter-spacing: var(--e-global-typography-primary-letter-spacing);
	text-align: center;
	line-height: 1.1;
	margin: 0;
}

.egwc__equivalents {
	color: var(--egwc-surface);
	font-size: 1rem;
	margin: 1rem 0 0;
	text-align: center;
}

.egwc__clear {
	background: none;
	display: block;
	border: 1px solid var(--egwc-border);
	border-radius: 999px;
	color: var(--egwc-muted);
	cursor: pointer;
	font-size: 0.8125rem;
	margin: 1rem auto 0;
	padding: 0.4rem 0.9rem;
}

.egwc__clear:hover,
.egwc__clear:focus-visible {
	border-color: var(--egwc-accent);
	color: var(--egwc-accent);
	background-color: transparent;
}

.egwc__error {
	background: #fff4f4;
	border-left: 4px solid #c33;
	padding: 0.75rem 1rem;
}

/* --- Narrow screens: stack each product row as a card ------------------- */

@media (max-width: 600px) {
	.egwc__list {
		max-height: 30rem;
	}

	.egwc__table thead {
		display: none;
	}

	.egwc__table tr {
		display: grid;
		grid-template-areas:
			"select product"
			"select qty";
		grid-template-columns: 2rem 1fr;
		gap: 0.25rem 0.5rem;
		padding: 0.75rem;
	}

	.egwc__table td {
		border: 0;
		padding: 0;
		width: auto;
	}

	.egwc__table tr {
		border-bottom: 1px solid var(--egwc-border);
	}

	.egwc__col-select {
		align-self: start;
		grid-area: select;
		padding-top: 0.2rem;
	}

	.egwc__col-product {
		grid-area: product;
	}

	.egwc__name {
		font-weight: 600;
	}

	.egwc__col-qty {
		grid-area: qty;
		margin-top: 0.25rem;
	}
}

/* --- Dark sections ------------------------------------------------------
 * Opt-in only — add class="egwc egwc--dark" (or set these vars in the theme)
 * where the calculator sits on a dark background. Deliberately NOT tied to
 * prefers-color-scheme, so it never fights a light-only theme.
 * --------------------------------------------------------------------- */

.egwc--dark {
	--egwc-accent: #6fce97;
	--egwc-accent-soft: #1c2a22;
	--egwc-border: #35403a;
	--egwc-text: #e8ece9;
	--egwc-muted: #a3b0a8;
	--egwc-muted-on-surface: #a3b0a8;
	--egwc-surface: #151a18;
}
