/*
 * Daygas archive: the shop page, the product category pages and the product card used in every loop.
 * Loaded after components.css (handle daygas-archive). Colours come from the --dg-* tokens only.
 * Sections: 1 page frame · 2 header band · 3 category cards · 4 grid and product card · 5 below the grid · 6 motion
 * Breakpoints follow the parent theme: 690px (phone / tablet) and 1000px (tablet / desktop).
 */

/* 1. Page frame ------------------------------------------------------------ */

/* The header band carries the H1: the theme's title hero and its empty products header are off. */
body.dg-archive .hero-section,
body.dg-archive .woocommerce-products-header {
	display: none;
}

/* Full-width bands: the content container of the theme becomes a plain block, the bands set their own width. */
body.dg-archive .site-main > .ct-container {
	display: block;
	width: 100%;
	max-width: none;
	padding: 0;
}

body.dg-archive .site-main > .ct-container > :is(aside, .ct-sidebar) {
	display: none;
}

/* 2. Header band ----------------------------------------------------------- */

.dg-archive-head__grid {
	display: grid;
	gap: var(--dg-space-6);
}

.dg-archive-head__main {
	min-width: 0;
}

.dg-archive-head .dg-title--xl {
	margin-bottom: var(--dg-space-4);
	font-size: clamp(1.875rem, 1.4rem + 2.2vw, 3rem);
}

.dg-archive-head__intro {
	margin-bottom: 0;
}

.dg-archive-head__intro > :first-child {
	margin-top: 0;
}

.dg-archive-head__intro > :last-child {
	margin-bottom: 0;
}

.dg-archive-head__intro p {
	margin: 0 0 var(--dg-space-3);
}

.dg-crumbs {
	margin: 0 0 var(--dg-space-4);
	font-size: var(--dg-fs-sm);
}

.dg-crumbs ol {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	margin: 0;
	padding: 0;
	list-style: none;
}

.dg-crumbs li {
	display: inline-flex;
	align-items: center;
	margin: 0;
	padding: 0;
}

.dg-crumbs li + li::before {
	content: "/";
	margin-inline: var(--dg-space-2);
	opacity: 0.5;
}

.dg-crumbs a {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	color: var(--dg-accent-text);
	text-decoration: none;
}

.dg-crumbs a:hover,
.dg-crumbs a:focus-visible {
	text-decoration: underline;
	opacity: 1;
}

.dg-crumbs [aria-current] {
	opacity: 0.95;
}

/* Data band: the ranges of the series. */
.dg-archive-stats {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: var(--dg-space-4) var(--dg-space-5);
	margin: var(--dg-space-5) 0 0;
	padding-top: var(--dg-space-4);
	border-top: 1px solid var(--dg-line);
}

.dg-archive-stats > div {
	min-width: 0;
}

.dg-archive-stats dt {
	margin: 0 0 2px;
	color: var(--dg-muted);
	font-size: var(--dg-fs-xs);
	font-weight: 500;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

.dg-archive-stats dd {
	margin: 0;
	color: var(--dg-ink);
	font-size: var(--dg-fs-lg);
	font-weight: 600;
	line-height: 1.25;
	font-variant-numeric: tabular-nums;
}

/* Call to action card: a light card on the warm band. */
.dg-archive-head .dg-archive-head__tool {
	min-width: 0;
	padding: var(--dg-space-4);
	border-color: transparent;
	background: var(--dg-white);
	color: var(--dg-text);
}

.dg-archive-head .dg-archive-head__tool :is(h1, h2, h3, h4, .dg-title) {
	color: var(--dg-ink);
}

.dg-archive-head .dg-archive-head__tool a:not(.dg-btn) {
	color: var(--dg-ink);
}

.dg-archive-cta p {
	margin: 0 0 var(--dg-space-4);
	line-height: 1.5;
}

@media (min-width: 690px) {
	.dg-archive-stats {
		grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
	}

	.dg-archive-head .dg-archive-head__tool {
		padding: var(--dg-space-5);
	}
}

@media (min-width: 1000px) {
	.dg-archive-head__grid--tool {
		grid-template-columns: minmax(0, 1.2fr) minmax(340px, 0.8fr);
		gap: var(--dg-space-7);
		align-items: center;
	}
}

/* 3. Shop page: category cards --------------------------------------------- */

.dg-archive-cats__group + .dg-archive-cats__group {
	margin-top: var(--dg-space-7);
}

.dg-archive-cats__title {
	margin: 0 0 var(--dg-space-4);
	color: var(--dg-ink);
	font-size: var(--dg-fs-h3);
	font-weight: 700;
	line-height: 1.2;
}

.dg-archive-cats__grid {
	display: grid;
	gap: var(--dg-space-3);
	grid-template-columns: minmax(0, 1fr);
}

.dg-archive-cat {
	display: grid;
	grid-template-columns: 56px minmax(0, 1fr) auto;
	align-items: center;
	gap: var(--dg-space-3);
	padding: var(--dg-space-3) var(--dg-space-4);
	color: var(--dg-text);
	text-decoration: none;
}

.dg-archive-cat__media {
	display: grid;
	place-items: center;
	width: 56px;
	height: 56px;
	overflow: hidden;
	border-radius: var(--dg-radius);
	background: var(--dg-bg-soft);
	color: var(--dg-accent-hover);
}

.dg-archive-cat__icon {
	width: 30px;
	height: 30px;
}

/* Absolute: the 16:9 box takes its height from aspect-ratio, which a 100% height does not resolve against. */
.dg-archive-cat--photo .dg-archive-cat__media {
	position: relative;
}

.dg-archive-cat__img {
	position: absolute;
	inset: 0;
	display: block;
	box-sizing: border-box;
	width: 100%;
	max-width: none;
	height: 100%;
	padding: 6px;
	object-fit: contain;
	mix-blend-mode: multiply;
}

/* A product photo needs more room than the icon: a wider thumbnail on a phone. */
.dg-archive-cat--photo {
	grid-template-columns: 88px minmax(0, 1fr) auto;
}

.dg-archive-cat--photo .dg-archive-cat__media {
	width: 88px;
	height: 66px;
}

.dg-archive-cat__body {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: var(--dg-space-1);
	min-width: 0;
}

.dg-archive-cat .dg-card__title {
	margin: 0;
	color: var(--dg-ink);
	font-size: var(--dg-fs-md);
}

.dg-archive-cat__text {
	color: var(--dg-muted);
	font-size: var(--dg-fs-sm);
	line-height: 1.45;
}

.dg-archive-cat__more {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	color: var(--dg-ink);
	font-size: var(--dg-fs-sm);
	font-weight: 600;
}

.dg-archive-cat__more .dg-icon {
	transform: rotate(-90deg);
}

/* Phones keep the card as a row: the arrow only, the label stays for screen readers. */
.dg-archive-cat__more-label {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

@media (min-width: 690px) {
	.dg-archive-cats__grid {
		grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
		gap: var(--dg-space-4);
	}

	/* Four heaters: 2 x 2 until four fit, never 3 + 1. Three part groups: one row. */
	.dg-archive-cats__grid.dg-archive-cats__grid--heaters {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.dg-archive-cats__grid.dg-archive-cats__grid--parts {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}

	.dg-archive-cat {
		grid-template-columns: minmax(0, 1fr);
		align-content: start;
		align-items: start;
		gap: var(--dg-space-4);
		padding: var(--dg-space-5);
	}

	.dg-archive-cat__media,
	.dg-archive-cat--photo .dg-archive-cat__media {
		width: 100%;
		height: auto;
		aspect-ratio: 16 / 9;
	}

	.dg-archive-cat--photo {
		grid-template-columns: minmax(0, 1fr);
	}

	.dg-archive-cat__img {
		padding: 5% 8%;
	}

	.dg-archive-cat__icon {
		width: 44px;
		height: 44px;
	}

	.dg-archive-cat .dg-card__title {
		font-size: var(--dg-fs-h3);
	}

	.dg-archive-cat__more {
		align-self: end;
	}

	.dg-archive-cat__more-label {
		position: static;
		width: auto;
		height: auto;
		margin: 0;
		overflow: visible;
		clip: auto;
		white-space: normal;
	}
}

@media (min-width: 1200px) {
	.dg-archive-cats__grid.dg-archive-cats__grid--heaters {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}
}

/* 4. Grid and product card ------------------------------------------------- */

.dg-archive-grid__title {
	margin: 0 0 var(--dg-space-4);
	color: var(--dg-ink);
	font-size: var(--dg-fs-h3);
	font-weight: 700;
	line-height: 1.2;
}

/* Result count and sorting: desktop and tablet only. */
.dg-archive-grid .woo-listing-top {
	display: none;
}

@media (min-width: 690px) {
	.dg-archive-grid .woo-listing-top {
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		justify-content: space-between;
		gap: var(--dg-space-3);
		margin-bottom: var(--dg-space-5);
	}

	.dg-archive-grid .woo-listing-top :is(.woocommerce-result-count, .woocommerce-ordering) {
		margin: 0;
	}
}

ul.products.dg-products {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: var(--dg-space-3);
	margin: 0;
	padding: 0;
	list-style: none;
}

@media (min-width: 690px) {
	ul.products.dg-products:not(.dg-products--c2) {
		grid-template-columns: repeat(3, minmax(0, 1fr));
		gap: var(--dg-space-4);
	}
}

/* Same specificity as the :not(.dg-products--c2) rule above, or that rule keeps 3 columns on desktop. */
@media (min-width: 1000px) {
	ul.products.dg-products.dg-products--c4 {
		grid-template-columns: repeat(4, minmax(0, 1fr));
		gap: var(--dg-space-5);
	}
}

/* The card. Equal height: the grid stretches the items, the price and the button sit at the bottom. */
.dg-products > li.product {
	position: relative;
	display: flex;
	flex-direction: column;
	box-sizing: border-box;
	min-width: 0;
	margin: 0;
	padding: 0;
	overflow: hidden;
	border: 1px solid var(--dg-line);
	border-radius: var(--dg-radius-lg);
	background: var(--dg-white);
	color: var(--dg-text);
	list-style: none;
	transition: border-color 160ms var(--dg-ease), box-shadow 160ms var(--dg-ease), transform 160ms var(--dg-ease);
}

.dg-products > li.product:hover {
	border-color: var(--dg-accent);
	box-shadow: var(--dg-shadow);
	transform: translateY(-2px);
}

.dg-products > li.product:has(.dg-pcard__link:focus-visible) {
	border-color: var(--dg-accent);
	box-shadow: var(--dg-focus);
}

.dg-pcard__media {
	position: relative;
	display: block;
	aspect-ratio: 1 / 1;
	background: var(--dg-bg-soft);
}

.dg-pcard__media-link {
	display: grid;
	place-items: center;
	box-sizing: border-box;
	width: 100%;
	height: 100%;
	padding: 9%;
}

.dg-pcard__media .dg-pcard__img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: contain;
	mix-blend-mode: multiply;
}

.dg-pcard__badge {
	position: absolute;
	top: var(--dg-space-2);
	inset-inline-start: var(--dg-space-2);
	z-index: 1;
	max-width: calc(100% - 2 * var(--dg-space-2));
	border-radius: 12px;
	background: var(--dg-white);
	white-space: normal;
	line-height: 1.3;
}

.dg-pcard__body {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	gap: var(--dg-space-2);
	padding: var(--dg-space-3) var(--dg-space-3) 0;
}

.dg-pcard__title {
	margin: 0;
	color: var(--dg-ink);
	font-size: var(--dg-fs-md);
	font-weight: 600;
	line-height: 1.3;
	text-wrap: balance;
	overflow-wrap: anywhere;
}

.dg-pcard__link {
	color: inherit;
	text-decoration: none;
}

/* One link for the whole card: the name stretches over it, the button sits above. */
.dg-pcard__link::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
}

.dg-pcard__link:focus-visible {
	outline: none;
}

.dg-pcard__chips {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	min-width: 0;
	margin: 0;
	padding: 0;
	list-style: none;
}

/* A chip may wrap inside a narrow card ("For series: Radium U" on a 360px phone); the figures hold their units with a no-break space. */
.dg-pcard__chips li {
	min-width: 0;
	max-width: 100%;
	margin: 0;
	padding: 2px 9px;
	border-radius: 16px;
	background: var(--dg-bg-soft);
	color: var(--dg-ink);
	font-size: 0.875rem;
	font-weight: 500;
	line-height: 1.5;
	white-space: normal;
	overflow-wrap: anywhere;
	font-variant-numeric: tabular-nums;
}

.dg-pcard__price {
	margin: auto 0 0;
	padding-top: var(--dg-space-2);
	color: var(--dg-ink);
	font-size: var(--dg-fs-md);
	font-weight: 600;
	line-height: 1.3;
}

.dg-pcard__price ins {
	text-decoration: none;
}

.dg-pcard__price del {
	color: var(--dg-muted);
	font-weight: 400;
}

.dg-pcard__price--quote {
	color: var(--dg-muted);
	font-weight: 500;
}

.dg-pcard__actions {
	position: relative;
	z-index: 2;
	padding: var(--dg-space-3);
}

.dg-pcard__actions .dg-btn {
	width: 100%;
	min-height: var(--dg-tap);
	padding-inline: var(--dg-space-3);
	font-size: var(--dg-fs-sm);
}

/* WooCommerce AJAX add to cart: loading, added and the "view cart" link that follows. */
.dg-pcard__actions .dg-btn.loading {
	opacity: 0.6;
	pointer-events: none;
}

.dg-pcard__actions .added_to_cart {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	margin-top: var(--dg-space-2);
	color: var(--dg-ink);
	font-size: var(--dg-fs-sm);
	font-weight: 600;
	text-decoration: underline;
	text-decoration-color: var(--dg-accent);
	text-decoration-thickness: 2px;
	text-underline-offset: 4px;
}

@media (min-width: 690px) {
	.dg-pcard__body {
		padding: var(--dg-space-4) var(--dg-space-4) 0;
	}

	.dg-pcard__actions {
		padding: var(--dg-space-3) var(--dg-space-4) var(--dg-space-4);
	}
}

/* 5. Below the grid -------------------------------------------------------- */

.dg-archive-pick__box {
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: var(--dg-space-4);
	padding: var(--dg-space-4) var(--dg-space-5);
}

.dg-archive-pick__text {
	flex: 1 1 260px;
	margin: 0;
	color: var(--dg-ink);
	font-size: var(--dg-fs-lg);
	font-weight: 600;
	line-height: 1.35;
}

.dg-archive-pick__box .dg-btn {
	flex: 0 0 auto;
}

@media (max-width: 689px) {
	.dg-archive-pick__box .dg-btn {
		width: 100%;
	}
}

.dg-archive-table__lead {
	max-width: 62ch;
	margin: 0 0 var(--dg-space-5);
}

/* The rest of the term description: how it works, what else is needed, questions. */
.dg-archive-prose__body {
	max-width: 780px;
}

.dg-archive-prose__body > * + * {
	margin-top: var(--dg-space-4);
}

.dg-archive-prose__body h2 {
	margin: var(--dg-space-7) 0 var(--dg-space-3);
	color: var(--dg-ink);
	font-size: var(--dg-fs-h2);
	font-weight: 700;
	line-height: 1.15;
	letter-spacing: -0.01em;
	text-wrap: balance;
}

.dg-archive-prose__body > h2:first-child {
	margin-top: 0;
}

.dg-archive-prose__body h3 {
	margin: var(--dg-space-5) 0 var(--dg-space-2);
	color: var(--dg-ink);
	font-size: var(--dg-fs-h3);
	font-weight: 700;
	line-height: 1.2;
}

.dg-archive-prose__body :is(p, li) {
	font-size: var(--dg-fs-md);
	line-height: 1.65;
}

.dg-archive-prose__body ul:not(.dg-checks),
.dg-archive-prose__body ol {
	margin-block: var(--dg-space-3);
	padding-inline-start: 1.25em;
}

.dg-archive-prose__body li + li {
	margin-top: var(--dg-space-2);
}

.dg-archive-prose__body a {
	color: var(--dg-ink);
	font-weight: 600;
	text-decoration: underline;
	text-decoration-color: var(--dg-accent);
	text-decoration-thickness: 2px;
	text-underline-offset: 4px;
}

.dg-archive-prose__body a:hover {
	color: var(--dg-accent-hover);
}

.dg-archive-prose__body .dg-faq {
	margin-top: var(--dg-space-4);
}

.dg-archive-prose__body .dg-faq details > :not(summary) {
	font-size: var(--dg-fs-md);
	line-height: 1.65;
}

/* Closing call to action. */
.dg-archive-close__inner {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: var(--dg-space-4) var(--dg-space-6);
}

.dg-archive-close__text {
	flex: 1 1 320px;
	max-width: 52ch;
	margin: 0;
	color: var(--dg-ink);
	font-size: var(--dg-fs-lg);
	font-weight: 600;
	line-height: 1.4;
}

.dg-archive-close__inner .dg-btn {
	flex: 0 0 auto;
}

@media (max-width: 689px) {
	.dg-archive-close__inner .dg-btn {
		width: 100%;
	}
}

/* Documents: one row per file, the language marked on every row. */
.dg-archive-docs__lead {
	max-width: 62ch;
	margin: 0 0 var(--dg-space-5);
}

.dg-archive-docs__list {
	display: grid;
	gap: var(--dg-space-3);
	margin: 0;
	padding: 0;
	list-style: none;
}

.dg-archive-docs__list > li {
	min-width: 0;
	margin: 0;
}

.dg-archive-doc {
	display: flex;
	align-items: center;
	gap: var(--dg-space-3);
	min-height: var(--dg-tap);
	padding: var(--dg-space-3) var(--dg-space-4);
	border: 1px solid var(--dg-line);
	border-radius: var(--dg-radius);
	background: var(--dg-white);
	color: var(--dg-ink);
	text-decoration: none;
	transition: border-color 160ms var(--dg-ease), box-shadow 160ms var(--dg-ease);
}

.dg-archive-doc:hover {
	border-color: var(--dg-accent);
	box-shadow: var(--dg-shadow);
}

.dg-archive-doc:focus-visible {
	outline: none;
	box-shadow: var(--dg-focus);
}

.dg-archive-doc__icon {
	flex: none;
	width: 24px;
	height: 24px;
	color: var(--dg-ink);
}

.dg-archive-doc__text {
	display: flex;
	flex: 1 1 auto;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--dg-space-1) var(--dg-space-3);
	min-width: 0;
}

.dg-archive-doc__label {
	font-size: var(--dg-fs-md);
	font-weight: 600;
	line-height: 1.3;
	overflow-wrap: anywhere;
}

.dg-archive-doc__meta {
	display: inline-flex;
	align-items: center;
	gap: var(--dg-space-2);
	color: var(--dg-muted);
	font-size: var(--dg-fs-sm);
}

@media (min-width: 690px) {
	.dg-archive-docs__list {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

/* 6. Motion ---------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
	.dg-products > li.product,
	.dg-archive-cat,
	.dg-archive-doc,
	:is(.dg-archive-head, .dg-archive-pick, .dg-archive-close, .dg-archive-cta, .dg-pcard__actions) .dg-btn {
		transition: none;
	}

	.dg-products > li.product:hover,
	.dg-archive-cat:hover,
	:is(.dg-archive-head, .dg-archive-pick, .dg-archive-close, .dg-archive-cta, .dg-pcard__actions) .dg-btn:hover {
		transform: none;
	}
}
