/*
 * Product blocks of aw-engine (task 10): product card, price, comparison table, disclosure.
 * Loaded only on pages with one of these blocks. Colours, sizes and spacing come from the theme
 * presets (theme.json); the fallbacks keep the blocks readable under another theme.
 */
.aw-product-card,
.aw-price-block,
.aw-comparison,
.aw-disclosure {
	--aw-b-border: var(--wp--preset--color--hairline, #e4e7eb);
	--aw-b-muted: var(--wp--preset--color--muted, #4a5260);
	--aw-b-card: var(--wp--preset--color--card, #fff);
	--aw-b-surface: var(--wp--preset--color--surface, #f2f4f7);
	--aw-b-accent: var(--wp--preset--color--accent, #1f5f8b);
	--aw-b-gap: var(--wp--preset--spacing--30, 1rem);
	--aw-b-radius: 12px;
	/* Containing block for the visually hidden texts, so they never widen the page. */
	position: relative;
}

:where(.aw-product-card, .aw-price-block, .aw-comparison) .screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Buttons: the theme's button style (wp-element-button) plus a fallback. */
.aw-button {
	display: inline-block;
	text-decoration: none;
}
.aw-button:not(.wp-element-button) {
	background: var(--aw-b-accent);
	color: #fff;
	padding: 0.75rem 1.25rem;
	border-radius: 999px;
	font-weight: 700;
}

/* Price line */
.aw-price__amount {
	font-weight: 800;
	font-size: 1.25em;
	letter-spacing: -0.01em;
}
.aw-price__vat {
	color: var(--aw-b-muted);
	font-size: var(--wp--preset--font-size--small, 0.875rem);
}

/* Sources */
.aw-src {
	font-size: 0.7em;
	margin-left: 0.15em;
	color: var(--aw-b-muted);
}
.aw-sources {
	margin-top: var(--aw-b-gap);
	color: var(--aw-b-muted);
	font-size: var(--wp--preset--font-size--small, 0.875rem);
}
.aw-sources__title {
	margin: 0 0 0.25rem;
	font-weight: 700;
}
.aw-sources ol {
	margin: 0;
	padding-left: 1.25rem;
}

/* Disclosure: a short label just above the first shop link. */
.aw-disclosure {
	margin-block: 0 0.5rem;
	color: var(--aw-b-muted);
	font-size: var(--wp--preset--font-size--small, 0.875rem);
	line-height: 1.5;
}

/* Product card */
.aw-product-card {
	display: grid;
	gap: var(--aw-b-gap);
	padding: var(--wp--preset--spacing--40, 1.5rem);
	background: var(--aw-b-card);
	border: 1px solid var(--aw-b-border);
	border-radius: var(--aw-b-radius);
	transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.aw-product-card:hover {
	box-shadow: 0 8px 24px rgba(20, 32, 43, 0.08);
}
@media (min-width: 640px) {
	.aw-product-card:has(.aw-product-card__media) {
		grid-template-columns: minmax(10rem, 2fr) 3fr;
		align-items: start;
	}
}
.aw-product-card__media {
	margin: 0;
	background: var(--aw-b-surface);
	border-radius: 8px;
	overflow: hidden;
}
.aw-product-card__image {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 4 / 3;
	object-fit: contain;
}
.aw-product-card__brand {
	margin: 0;
	color: var(--aw-b-muted);
	font-size: var(--wp--preset--font-size--small, 0.875rem);
	text-transform: uppercase;
	letter-spacing: 0.06em;
	font-weight: 700;
}
.aw-product-card__title {
	margin: 0.25rem 0 0.5rem;
	font-size: 1rem;
	line-height: 1.3;
}
.aw-specs {
	margin: 0 0 1rem;
	display: grid;
	gap: 0;
}
.aw-specs > div {
	display: flex;
	justify-content: space-between;
	gap: 1rem;
	padding: 0.4rem 0;
	border-bottom: 1px solid var(--aw-b-border);
}
.aw-specs dt {
	color: var(--aw-b-muted);
}
.aw-specs dd {
	margin: 0;
	font-weight: 600;
	text-align: right;
}
.aw-product-card__price {
	margin: 0 0 0.75rem;
}
.aw-product-card__shop {
	color: var(--aw-b-muted);
}
.aw-product-card__cta {
	margin: 0;
}
.aw-product-card__unavailable {
	margin: 0;
	font-weight: 700;
	color: var(--aw-b-muted);
}
.aw-editor-notice {
	padding: 0.75rem 1rem;
	border: 1px dashed #b26200;
	background: #fff8ee;
	color: #5c3300;
}

/* Price block */
.aw-price-block--inline .aw-price-block__link {
	font-weight: 700;
}
.aw-offers__title {
	font-weight: 700;
	margin: 0 0 0.5rem;
}
.aw-offers {
	list-style: none;
	margin: 0;
	padding: 0;
	border-top: 1px solid var(--aw-b-border);
}
.aw-offers__item {
	display: grid;
	grid-template-columns: 1fr;
	gap: 0.35rem 1rem;
	padding: 0.85rem 0;
	border-bottom: 1px solid var(--aw-b-border);
	align-items: center;
}
@media (min-width: 640px) {
	.aw-offers__item {
		grid-template-columns: minmax(8rem, 1fr) 2fr auto;
	}
	.aw-offers__details {
		grid-column: 2;
	}
	.aw-offers__cta {
		grid-column: 3;
		grid-row: 1 / span 2;
	}
}
.aw-offers__shop {
	font-weight: 700;
}
.aw-offers__details,
.aw-offers__note {
	color: var(--aw-b-muted);
	font-size: var(--wp--preset--font-size--small, 0.875rem);
}

/* Comparison table: horizontal lines only, scrolls sideways on small screens. */
.aw-comparison__criteria {
	margin: 0 0 0.75rem;
}
.aw-table-scroll {
	position: relative;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	/* Shadows at the edges show that there is more to scroll. */
	background:
		linear-gradient(to right, var(--aw-b-card), var(--aw-b-card)) left / 1.5rem 100% no-repeat local,
		linear-gradient(to left, var(--aw-b-card), var(--aw-b-card)) right / 1.5rem 100% no-repeat local,
		radial-gradient(farthest-side at 0 50%, rgba(20, 32, 43, 0.18), transparent) left / 0.75rem 100% no-repeat scroll,
		radial-gradient(farthest-side at 100% 50%, rgba(20, 32, 43, 0.18), transparent) right / 0.75rem 100% no-repeat scroll;
}
.aw-table-scroll:focus-visible {
	outline: 2px solid var(--wp--preset--color--contrast, #1a1a1a);
	outline-offset: 2px;
}
.aw-table {
	width: 100%;
	min-width: 36rem;
	border-collapse: collapse;
}
.aw-table caption {
	text-align: left;
	font-weight: 700;
	padding-bottom: 0.5rem;
}
.aw-table th,
.aw-table td {
	padding: 0.65rem 0.75rem;
	border-bottom: 1px solid var(--aw-b-border);
	text-align: left;
	vertical-align: top;
}
.aw-table thead th {
	font-size: var(--wp--preset--font-size--small, 0.875rem);
	text-transform: uppercase;
	letter-spacing: 0.05em;
	border-bottom-width: 2px;
}
.aw-table tbody th {
	color: var(--aw-b-muted);
	font-weight: 600;
	white-space: nowrap;
}
.aw-table__unknown {
	color: var(--aw-b-muted);
	font-style: italic;
}
.aw-table .aw-button {
	white-space: nowrap;
}
.aw-table__cta td {
	border-bottom: 0;
}
.aw-table-scroll__hint {
	margin: 0.35rem 0 0;
	color: var(--aw-b-muted);
	font-size: var(--wp--preset--font-size--small, 0.875rem);
}
@media (min-width: 900px) {
	.aw-table-scroll__hint {
		display: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.aw-product-card {
		transition: none;
	}
}

/* aw/material-picks: a carousel of up to nine product cards, three visible on a wide screen */
.aw-material-picks { margin-block: 1.5rem; }
.aw-material-picks__title { margin: 0 0 0.75rem; font-weight: 700; }
.aw-material-picks__viewport { position: relative; }
.aw-material-picks__grid {
	display: flex;
	gap: 1rem;
	overflow-x: auto;
	overscroll-behavior-x: contain;
	scroll-snap-type: x mandatory;
	scrollbar-width: thin;
	padding-bottom: 0.5rem;
}
.aw-material-picks__grid > .aw-product-card {
	display: flex;
	flex: 0 0 min(85%, 18rem);
	flex-direction: column;
	align-items: stretch;
	gap: 0.75rem;
	box-sizing: border-box;
	min-width: 0;
	margin: 0;
	padding: 0.875rem;
	font-size: 0.875rem;
	scroll-snap-align: start;
}
@media (min-width: 640px) {
	.aw-material-picks__grid > .aw-product-card:has(.aw-product-card__media) { align-items: stretch; }
}
.aw-material-picks__grid .aw-product-card__body {
	display: flex;
	flex: 1;
	flex-direction: column;
	min-width: 0;
	overflow-wrap: anywhere;
}
.aw-material-picks__grid .aw-product-card__title {
	display: -webkit-box;
	overflow: hidden;
	margin: 0 0 0.5rem;
	font-size: 0.9375rem;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
}
.aw-material-picks__grid .aw-product-card__media { background: #fff; }
.aw-material-picks__grid .aw-price__amount { font-size: 1.125em; }
.aw-material-picks__grid .aw-product-card__cta { margin-top: auto; }
.aw-material-picks__grid .aw-button,
.aw-material-picks__grid .aw-button.wp-element-button {
	display: block;
	box-sizing: border-box;
	width: 100%;
	padding: 0.5rem 0.75rem;
	font-size: 0.875rem;
	text-align: center;
}
.aw-material-picks__arrow {
	position: absolute;
	top: 35%;
	display: none;
	width: 2.25rem;
	height: 2.25rem;
	padding: 0;
	border: 1px solid var(--aw-b-border);
	border-radius: 50%;
	background: var(--aw-b-card);
	box-shadow: 0 2px 8px rgba(20, 32, 43, 0.15);
	color: inherit;
	font-size: 1.25rem;
	line-height: 1;
	cursor: pointer;
}
.aw-material-picks__arrow:disabled { opacity: 0; pointer-events: none; }
.aw-material-picks__prev { left: -0.75rem; }
.aw-material-picks__next { right: -0.75rem; }
@media (min-width: 40rem) {
	.aw-material-picks__grid > .aw-product-card { flex-basis: calc((100% - 2rem) / 3); }
	.aw-material-picks__arrow:not([hidden]) { display: block; }
}
