/**
 * WooCommerce catalogue and quote basket.
 *
 * Scoped overrides only — WooCommerce's own stylesheets still load, so this
 * file corrects what clashes with the brand rather than restating Woo.
 */

/* --- Product grids --------------------------------------------------- *
 * Explicit column counts rather than auto-fill. Auto-fill fitted five
 * across at desktop, which left the last row half empty and set a different
 * rhythm from the category tiles above it. Four matches the prototype and
 * divides the twelve-per-page cleanly into three full rows.
 */
.woocommerce ul.products {
	display: grid;
	gap: var(--damf-space-3);
	/* Two across even on phones: one-up made the catalogue several screens
	   of a single card at a time. */
	grid-template-columns: repeat(2, minmax(0, 1fr));
	margin: 0;
	padding: 0;
	list-style: none;
}

@media (min-width: 600px) {
	.woocommerce ul.products {
		gap: var(--damf-space-6);
	}
}

@media (min-width: 900px) {
	.woocommerce ul.products {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

@media (min-width: 1200px) {
	.woocommerce ul.products {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}
}

.woocommerce ul.products::before,
.woocommerce ul.products::after {
	content: none;
}

/* Cards are equal-height columns so the call to action sits on a common
   baseline. Product names run from "DEUMIX" to "DEUCOAT COLD APPLIED BITUMEN
   EMULSION", and without this the links step up and down across the row.
   Both selectors are needed: the catalogue renders a link, and a Woo button
   returns if catalogue mode is ever switched off. */
/* The [class*="columns-"] selector matches woocommerce-smallscreen.css,
   whose width: 48% and float otherwise out-rank this rule below 768px and
   squeeze every card into half of its grid cell. */
.woocommerce ul.products li.product,
.woocommerce ul.products[class*="columns-"] li.product {
	display: flex;
	flex-direction: column;
	inline-size: auto;
	margin: 0;
	padding: 0;
	float: none;
	text-align: start;
}

.woocommerce ul.products li.product .button,
.woocommerce ul.products li.product .damf-card__more {
	margin-block-start: auto;
	align-self: start;
}

.woocommerce ul.products li.product .damf-card__media {
	margin: 0;
}

.woocommerce ul.products li.product .damf-eyebrow,
.woocommerce ul.products li.product .damf-card__title,
.woocommerce ul.products li.product .button {
	margin-inline: var(--damf-space-5);
}

.woocommerce ul.products li.product .damf-card__more {
	margin-inline: var(--damf-space-5);
	margin-block-end: var(--damf-space-5);
}

/* Half-width cards on phones need tighter insets to leave room for names. */
@media (max-width: 599px) {
	.woocommerce ul.products li.product .damf-eyebrow,
	.woocommerce ul.products li.product .damf-card__title,
	.woocommerce ul.products li.product .damf-card__more {
		margin-inline: var(--damf-space-3);
	}

	.woocommerce ul.products li.product .damf-card__more {
		margin-block-end: var(--damf-space-3);
	}

	.woocommerce ul.products li.product .damf-card__media {
		padding: var(--damf-space-2);
	}
}

.woocommerce ul.products li.product .damf-eyebrow {
	margin-block-start: var(--damf-space-5);
}

.woocommerce ul.products li.product .button {
	margin-block-end: var(--damf-space-5);
}

/* Woo's default buttons, restyled rather than duplicated. */
.woocommerce a.button,
.woocommerce button.button,
.woocommerce input.button,
.woocommerce #respond input#submit,
.woocommerce a.button.alt,
.woocommerce button.button.alt {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: var(--damf-space-4) var(--damf-space-6);
	background: var(--damf-navy);
	color: var(--damf-white);
	border: 1.5px solid transparent;
	border-radius: var(--damf-radius);
	font-family: var(--damf-font-body);
	font-size: var(--damf-text-base);
	font-weight: 700;
	line-height: 1;
	text-decoration: none;
}

.woocommerce a.button:hover,
.woocommerce button.button:hover,
.woocommerce input.button:hover,
.woocommerce a.button.alt:hover,
.woocommerce button.button.alt:hover {
	background: var(--damf-navy-deep);
	color: var(--damf-white);
}

/* --- Single product -------------------------------------------------- */
.woocommerce div.product .product_title {
	font-family: var(--damf-font-heading);
	font-size: var(--damf-text-3xl);
	color: var(--damf-navy);
}

.woocommerce div.product .woocommerce-product-details__short-description {
	font-size: var(--damf-text-md);
	color: var(--damf-text-muted);
}

/* Quote mode hides prices server-side; this catches any stray markup that
   Woo or a plugin prints directly. */
body.damf-quote-mode .price,
body.damf-quote-mode .woocommerce-Price-amount {
	display: none;
}

/* --- Cart / quote basket --------------------------------------------- */
.woocommerce table.shop_table {
	border: var(--damf-border);
	border-radius: var(--damf-radius);
	border-collapse: collapse;
}

.woocommerce table.shop_table thead th {
	background: var(--damf-navy);
	color: var(--damf-white);
	font-family: var(--damf-font-body);
	font-weight: 700;
}

.woocommerce table.shop_table td {
	border-block-start: 1px solid var(--damf-rule);
}

/* --- Quote form ------------------------------------------------------ */
.damf-quote-form {
	margin-block-start: var(--damf-space-10);
	padding: var(--damf-space-8);
	background: var(--damf-tint);
	border: var(--damf-border);
	border-radius: var(--damf-radius);
}

.damf-quote-form__grid {
	display: grid;
	gap: var(--damf-space-4);
	grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
	margin-block-end: var(--damf-space-5);
}

.damf-quote-form__grid p {
	margin: 0;
}

.damf-quote-form__wide {
	grid-column: 1 / -1;
}

.damf-quote-form label {
	display: block;
	margin-block-end: var(--damf-space-2);
	font-size: var(--damf-text-sm);
	font-weight: 700;
	color: var(--damf-navy);
}

.damf-quote-form label span {
	color: var(--damf-red);
}

.damf-quote-errors {
	margin-block-end: var(--damf-space-5);
	padding: var(--damf-space-4) var(--damf-space-5);
	background: color-mix(in srgb, var(--damf-red) 8%, white);
	border-inline-start: 3px solid var(--damf-red);
	border-radius: var(--damf-radius);
	color: var(--damf-navy-deep);
}

.damf-quote-errors ul {
	margin: 0;
}

.damf-quote-confirmation {
	border-inline-start: 3px solid var(--damf-navy);
}

/* Honeypot — off-screen rather than display:none, which some bots detect. */
.damf-hp {
	position: absolute !important;
	inline-size: 1px;
	block-size: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

/* --- Notices --------------------------------------------------------- */
.woocommerce-message,
.woocommerce-info,
.woocommerce-error {
	border-block-start-color: var(--damf-navy);
	background: var(--damf-tint);
	border-radius: var(--damf-radius);
}

.woocommerce-error {
	border-block-start-color: var(--damf-red);
}

/* --- Single product: DAMF layout ------------------------------------- */
.damf-product__subtitle {
	margin-block: -0.25rem 1.25rem;
	font-size: var(--damf-text-sm);
	color: var(--damf-text-faint);
}

.woocommerce div.product .damf-eyebrow {
	text-decoration: none;
}

.damf-product__heading {
	margin-block: var(--damf-space-6) var(--damf-space-3);
	font-family: var(--damf-font-heading);
	font-size: var(--damf-text-md);
	color: var(--damf-navy);
}

.damf-product__documents {
	display: flex;
	flex-wrap: wrap;
	gap: var(--damf-space-3);
	margin-block-start: var(--damf-space-6);
}

/*
 * WooCommerce floats the gallery and summary side by side, and normally it
 * is the tabs panel that clears them. This theme removes the tabs, so
 * whatever comes after the summary must clear instead — the technical and
 * usage sections when a product has them, or WooCommerce's related and
 * upsell blocks when it does not. Clearing only the theme's own sections
 * let "Related products" ride up beside the image on sparse products.
 */
.woocommerce div.product > .summary ~ * {
	clear: both;
}

.damf-product__section {
	margin-block-start: var(--damf-space-12);
}

.damf-product__section > h2 {
	font-size: var(--damf-text-xl);
}

/* Surface prep / application / coverage / packing / storage.
 *
 * These were side-by-side columns, but their lengths are wildly uneven —
 * "Surface Preparation" runs to about 100 characters and "Mode of
 * Application" to 640 — so every row stretched to the tallest cell and left
 * the short ones sitting above a void. Reading as rows, label beside prose,
 * removes the raggedness entirely and matches how the datasheets themselves
 * are laid out.
 */
.damf-product__usage {
	display: block;
}

.damf-product__usage > div {
	display: grid;
	gap: var(--damf-space-2);
	grid-template-columns: minmax(0, 1fr);
	padding-block: var(--damf-space-6);
	border-block-end: var(--damf-border);
}

.damf-product__usage > div:last-child {
	border-block-end: 0;
}

@media (min-width: 800px) {
	.damf-product__usage > div {
		gap: var(--damf-space-10);
		grid-template-columns: 15rem minmax(0, 1fr);
		align-items: start;
	}
}

.damf-product__usage h2 {
	margin: 0;
	font-size: var(--damf-text-lg);
}

.damf-product__usage-body > :last-child {
	margin-block-end: 0;
}

/* --- Single product columns ------------------------------------------ *
 * The prototype gives the detail column more room than the photograph —
 * it carries the description, the advantages list and four buttons.
 */
@media (min-width: 900px) {
	.woocommerce div.product div.images {
		inline-size: 44%;
	}

	.woocommerce div.product div.summary {
		inline-size: 52%;
	}
}

.woocommerce div.product div.images img {
	border-radius: var(--damf-radius-lg);
}

/* --- Technical data table -------------------------------------------- */
.damf-table-scroll {
	overflow-x: auto;
}

.damf-tech-table {
	inline-size: 100%;
	min-inline-size: 34rem;
	border-collapse: collapse;
}

.damf-tech-table thead tr {
	background: var(--damf-navy);
	color: var(--damf-white);
}

.damf-tech-table th,
.damf-tech-table td {
	padding: var(--damf-space-3) var(--damf-space-4);
	text-align: start;
}

/* Row headers are the property names — bold navy, not the white-on-navy
   treatment used for the column headers. */
.damf-tech-table tbody th {
	font-weight: 700;
	color: var(--damf-navy-deep);
}

.damf-tech-table tbody tr {
	border-block-end: 1px solid var(--damf-navy);
}

.damf-tech-table tbody tr:last-child {
	border-block-end: 0;
}

.damf-tech-table__method {
	color: var(--damf-text-faint);
	white-space: nowrap;
}

/* --- Direct enquiry: one button, a popover with the two channels -------- */
.damf-enquiry {
	margin-block: var(--damf-space-6);
}

.damf-enquiry__trigger {
	inline-size: 100%;
}

/* Popover panels sit in the top layer, centred by the browser. Without
   popover support the panel shows inline under the button, which still
   works — so these styles must read both ways. */
/* No position here: the browser's position: fixed keeps the open panel
   centred on the screen however far the page is scrolled. */
.damf-enquiry__panel {
	display: grid;
	gap: var(--damf-space-3);
	inline-size: min(26rem, calc(100vw - 2 * var(--damf-gutter)));
	padding: var(--damf-space-10) var(--damf-space-8) var(--damf-space-8);
	background: var(--damf-white);
	border: var(--damf-border);
	border-radius: var(--damf-radius-lg);
	box-shadow: var(--damf-shadow-md);
	color: var(--damf-text);
}

.damf-enquiry__panel:not(:popover-open) {
	display: none;
}

.damf-enquiry__panel::backdrop {
	background: rgba(36, 40, 74, 0.45);
}

.damf-enquiry__title {
	margin: 0 0 var(--damf-space-2);
	font-family: var(--damf-font-heading);
	font-size: var(--damf-text-lg);
	font-weight: 700;
	color: var(--damf-navy);
}

/* Hidden in the inline fallback, where it would do nothing. The selector
   is invalid to browsers without popover support, so it stays hidden there. */
.damf-enquiry__close {
	display: none;
}

.damf-enquiry__panel:popover-open .damf-enquiry__close {
	display: block;
	position: absolute;
	inset-block-start: var(--damf-space-2);
	inset-inline-end: var(--damf-space-2);
	inline-size: 2.5rem;
	block-size: 2.5rem;
	padding: 0;
	background: none;
	border: 0;
	font-size: 1.75rem;
	line-height: 1;
	color: var(--damf-text-faint);
	cursor: pointer;
}

.damf-enquiry__close:hover,
.damf-enquiry__close:focus-visible {
	color: var(--damf-navy);
}

.damf-enquiry__icon {
	flex-shrink: 0;
}

/* WhatsApp's own green, deliberately off-palette: it is a platform mark,
   and recolouring it to navy loses the instant recognition that makes the
   button worth having. */
.damf-button--whatsapp {
	background: #25d366;
	color: var(--damf-navy-deep);
}

.damf-button--whatsapp:hover,
.damf-button--whatsapp:focus-visible {
	background: #1eb457;
	color: var(--damf-navy-deep);
}


/* --- Pagination ------------------------------------------------------ *
 * WooCommerce wraps its pager in <ul class="page-numbers">, so a bare
 * .page-numbers rule styles the list itself as though it were a button.
 * Everything here is scoped to the links and spans inside it.
 */
.woocommerce nav.woocommerce-pagination {
	margin-block-start: var(--damf-space-10);
	text-align: center;
}

.woocommerce nav.woocommerce-pagination ul.page-numbers {
	display: inline-flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: var(--damf-space-2);
	margin: 0;
	padding: 0;
	border: 0;
	list-style: none;
}

.woocommerce nav.woocommerce-pagination ul.page-numbers li {
	margin: 0;
	border: 0;
	overflow: visible;
}

.woocommerce nav.woocommerce-pagination li a.page-numbers,
.woocommerce nav.woocommerce-pagination li span.page-numbers {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-inline-size: 2.5rem;
	block-size: 2.5rem;
	padding-inline: var(--damf-space-3);
	border: 1px solid var(--damf-rule);
	border-radius: var(--damf-radius);
	background: var(--damf-white);
	color: var(--damf-navy);
	font-weight: 700;
	line-height: 1;
	text-decoration: none;
	transition: background var(--damf-transition), color var(--damf-transition),
		border-color var(--damf-transition);
}

.woocommerce nav.woocommerce-pagination li a.page-numbers:hover,
.woocommerce nav.woocommerce-pagination li a.page-numbers:focus-visible {
	border-color: var(--damf-navy);
	background: var(--damf-navy);
	color: var(--damf-white);
}

.woocommerce nav.woocommerce-pagination li span.page-numbers.current {
	background: var(--damf-navy);
	border-color: var(--damf-navy);
	color: var(--damf-white);
}

.woocommerce nav.woocommerce-pagination li .page-numbers.dots {
	border-color: transparent;
	background: none;
}
