/* ==========================================================================
   Shop / category listing — 0.7.1 comp.
   Product archives only. Cards remain owned by product-card.css.

   Colours, the sidebar width and the sheet breakpoint are all in tokens.css
   under "Shop / category listing". Nothing here invents a hex code.
   ========================================================================== */

body.tds-theme.tds-product-archive {
	--tds-cols-desktop: 4;
	--tds-cols-laptop: 4;
	--tds-card-title-lines: 3;
	--tds-card-gap: 20px;
	--tds-card-row-gap: 20px;
	overflow-x: visible;
}

body.tds-filter-open {
	overflow: hidden;
}

/* --- Breadcrumb + heading -------------------------------------------------- */

/* Storefront prints the breadcrumb as a direct child of .site, OUTSIDE
   .col-full, so it spans the whole window. That went unnoticed while the
   catalogue ran on the 1400px shell — the difference was ~20px. On the comp's
   1140px shell it puts "Home › Shop" 188px to the left of the heading, so the
   breadcrumb is given the same shell geometry as .col-full in base.css. */
body.tds-theme.tds-product-archive .tds-crumbs {
	box-sizing: border-box;
	width: 100%;
	max-width: var(--tds-shell);
	margin-inline: auto;
	padding-inline: var(--tds-shell-pad);
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	align-items: center;
	margin-block: 0;
	padding-block: 4px 20px;
	font-family: var(--tds-font);
	font-size: 13px;
	color: var(--tds-archive-crumb-here);
}

body.tds-theme.tds-product-archive .tds-crumbs a {
	color: var(--tds-archive-crumb);
	text-decoration: none;
}

body.tds-theme.tds-product-archive .tds-crumbs a:hover,
body.tds-theme.tds-product-archive .tds-crumbs a:focus-visible {
	color: var(--tds-archive-cta);
}

body.tds-theme.tds-product-archive .tds-crumbs__sep {
	color: var(--tds-archive-crumb);
}

body.tds-theme.tds-product-archive .woocommerce-products-header {
	margin: 0;
	padding: 0 0 22px;
}

body.tds-theme.tds-product-archive .woocommerce-products-header__title {
	display: flex;
	align-items: baseline;
	flex-wrap: wrap;
	gap: 14px;
	margin: 0;
	font-size: 30px;
	font-weight: 800;
	line-height: var(--tds-lh-tight);
	color: var(--tds-archive-ink);
}

body.tds-theme.tds-product-archive .tds-archive-count {
	font-size: 14px;
	font-weight: 400;
	color: var(--tds-archive-muted);
}

body.tds-theme.tds-product-archive .term-description {
	max-width: 70ch;
	margin: 0 0 22px;
	font-size: var(--tds-fs-md);
	line-height: var(--tds-lh-body);
	color: var(--tds-body);
}

/* --- Toolbar: Filter / chips / Sort by ------------------------------------ */

.tds-archive-toolbar {
	display: flex;
	align-items: center;
	gap: 12px;
	flex-wrap: wrap;
	margin: 0 0 28px;
	padding: 0 0 24px;
	border-bottom: 1px solid var(--tds-archive-line);
	font-family: var(--tds-font);
}

.tds-archive-toolbar__chips {
	flex: 1;
	min-width: 200px;
}

.tds-archive-toolbar__chips:empty {
	display: none;
}

/* The chip row lives inside the toolbar now, so it brings no margin of its own,
   and the rail keeps no room for a scrollbar it only shows on overflow. */
.tds-archive-toolbar .tds-chips {
	margin: 0;
}

.tds-archive-toolbar .tds-chips__rail {
	padding-bottom: 0;
}

.tds-filter-trigger {
	display: none; /* phones only — see the sheet block at the bottom */
	align-items: center;
	gap: 8px;
	min-height: var(--tds-archive-tap);
	padding: 10px 14px;
	border: 1px solid var(--tds-archive-control);
	border-radius: var(--tds-radius-sm);
	background: var(--tds-white);
	color: var(--tds-archive-ink);
	font-size: 13px;
	font-weight: 700;
	text-decoration: none;
}

.tds-filter-trigger__badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 18px;
	height: 18px;
	padding: 0 5px;
	border-radius: var(--tds-radius-pill);
	background: var(--tds-archive-cta);
	color: var(--tds-white);
	font-size: 11px;
	font-weight: 800;
}

.tds-filter-trigger__badge[hidden] {
	display: none;
}

.tds-sort {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 13px;
	color: var(--tds-archive-muted);
}

body.tds-theme.tds-product-archive .tds-sort .woocommerce-ordering {
	float: none;
	margin: 0;
}

body.tds-theme.tds-product-archive .tds-sort select {
	max-width: 230px;
	margin: 0;
	padding: 9px 10px;
	border: 1px solid var(--tds-archive-control);
	border-radius: var(--tds-radius-sm);
	background: var(--tds-white);
	color: var(--tds-archive-ink);
	font-family: inherit;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
}

/* --- Two-column shell ----------------------------------------------------- */

.tds-archive-layout {
	display: grid;
	grid-template-columns: var(--tds-archive-sidebar) minmax(0, 1fr);
	gap: var(--tds-archive-gap);
	align-items: start;
	clear: both;
}

.tds-archive-products {
	min-width: 0;
}

.tds-filters {
	font-family: var(--tds-font);
}

.tds-filters__head,
.tds-filter-overlay {
	display: none; /* sheet only */
}

/* --- Applied filters ------------------------------------------------------ */

.tds-applied {
	margin-bottom: 6px;
	padding: 0 0 18px;
	border-bottom: 1px solid var(--tds-archive-line);
}

.tds-applied__head {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 8px;
	padding-bottom: 10px;
}

.tds-applied__label {
	font-size: 12px;
	font-weight: 800;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--tds-archive-faint);
}

.tds-applied__clear {
	font-size: 12px;
	font-weight: 700;
	color: var(--tds-archive-cta);
	text-decoration: none;
}

.tds-applied__clear:hover,
.tds-applied__clear:focus-visible {
	color: var(--tds-archive-ink);
}

.tds-applied__chips {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
}

.tds-applied__chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 6px 12px;
	border: 1px solid var(--tds-archive-chip-line);
	border-radius: var(--tds-radius-pill);
	background: var(--tds-archive-chip-bg);
	color: var(--tds-archive-ink);
	font-size: 12px;
	font-weight: 700;
	text-decoration: none;
}

.tds-applied__chip:hover,
.tds-applied__chip:focus-visible {
	background: #e2e9f8;
	color: var(--tds-archive-ink);
}

.tds-applied__chip span[aria-hidden] {
	color: var(--tds-archive-faint);
}

/* --- Filter groups -------------------------------------------------------- */

.tds-filter-group {
	border-bottom: 1px solid var(--tds-archive-line);
}

.tds-filter-group__head {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 8px;
	padding: 16px 0;
	font-size: 14px;
	font-weight: 700;
	color: var(--tds-archive-ink);
	cursor: pointer;
	list-style: none;
}

/* Safari still draws the disclosure triangle without this. */
.tds-filter-group__head::-webkit-details-marker {
	display: none;
}

.tds-filter-group__arrow {
	flex-shrink: 0;
	color: var(--tds-archive-faint);
	font-size: 12px;
	transition: transform 0.2s ease;
}

.tds-filter-group[open] .tds-filter-group__arrow {
	transform: rotate(180deg);
}

.tds-filter-options {
	display: grid;
	gap: 2px;
	max-height: 300px;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 0 4px 16px 0;
}

.tds-filter-options--short {
	max-height: none;
	overflow: visible;
}

.tds-filter-option {
	display: grid;
	grid-template-columns: 18px minmax(0, 1fr) auto;
	gap: 10px;
	align-items: center;
	min-height: 32px;
	margin: 0;
	padding: 3px 0;
	font-size: 13.5px;
	line-height: 1.35;
	color: var(--tds-archive-option);
	cursor: pointer;
}

.tds-filter-option input {
	width: 18px;
	height: 18px;
	margin: 0;
	border: 1.5px solid var(--tds-archive-control);
	background: var(--tds-white);
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
}

.tds-filter-option input[type="checkbox"] {
	border-radius: 4px;
}

.tds-filter-option input[type="radio"] {
	border-radius: 50%;
}

.tds-filter-option input:checked {
	border-color: var(--tds-archive-cta);
	background: var(--tds-archive-cta);
}

.tds-filter-option input[type="checkbox"]:checked::after {
	content: "✓";
	display: block;
	margin-top: -2px;
	color: var(--tds-white);
	font-size: 11px;
	font-weight: 800;
	line-height: 15px;
	text-align: center;
}

.tds-filter-option input[type="radio"]:checked::after {
	content: "";
	display: block;
	width: 6px;
	height: 6px;
	margin: 4px auto;
	border-radius: 50%;
	background: var(--tds-white);
}

.tds-filter-option input:focus-visible {
	outline: 2px solid var(--tds-archive-cta);
	outline-offset: 2px;
}

.tds-filter-option span {
	min-width: 0;
	overflow-wrap: anywhere;
}

.tds-filter-option small {
	color: var(--tds-archive-faint);
	font-size: 12px;
}

/* --- Apply / clear -------------------------------------------------------
   The comp has no Apply button on the desktop sidebar: a tick applies at once.
   With the script running we submit on change and hide this row; with the
   script blocked it stays, and it is the only way to apply a filter.
   ------------------------------------------------------------------------ */

.tds-filter-actions {
	display: flex;
	gap: 12px;
	align-items: center;
	padding-top: 16px;
}

.tds-filter-actions__clear {
	flex: 1;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	height: 48px;
	border: 1px solid var(--tds-archive-control);
	border-radius: var(--tds-radius-sm);
	background: var(--tds-white);
	color: var(--tds-archive-ink);
	font-size: 14px;
	font-weight: 700;
	text-decoration: none;
}

.tds-filter-actions__apply {
	flex: 2;
	height: 48px;
	padding: 0 12px;
	border: 0;
	border-radius: var(--tds-radius-sm);
	background: var(--tds-archive-cta);
	color: var(--tds-white);
	font-family: inherit;
	font-size: 14px;
	font-weight: 700;
	cursor: pointer;
}

.tds-filter-actions__apply:hover,
.tds-filter-actions__apply:focus-visible {
	background: var(--tds-archive-cta-ink);
}

.tds-filters-ready .tds-filter-actions {
	display: none;
}

/* --- Product grid --------------------------------------------------------- */

body.tds-theme.tds-product-archive ul.products li.product .tds-card-media {
	background: #f8faff;
}

body.tds-theme.tds-product-archive ul.products li.product .woocommerce-loop-product__title {
	font-size: 0.9rem;
}

body.tds-theme.tds-product-archive .woocommerce-info {
	margin-top: var(--tds-space-4);
}

/* --- Pagination ----------------------------------------------------------- */

/* Storefront floats the pager to the right of the grid, which left it 394px
   wide — centring inside it centred nothing. Cleared first, then centred. */
body.tds-theme.tds-product-archive nav.woocommerce-pagination {
	float: none;
	clear: both;
	width: 100%;
	margin: 0;
	padding-top: 48px;
	font-family: var(--tds-font);
	text-align: center;
}

body.tds-theme.tds-product-archive nav.woocommerce-pagination ul {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	align-items: center;
	gap: 6px;
	border: 0;
	margin: 0;
}

body.tds-theme.tds-product-archive nav.woocommerce-pagination ul li {
	border: 0;
	margin: 0;
	overflow: visible;
}

body.tds-theme.tds-product-archive nav.woocommerce-pagination ul li a,
body.tds-theme.tds-product-archive nav.woocommerce-pagination ul li span {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: var(--tds-archive-pager);
	height: var(--tds-archive-pager);
	padding: 0 6px;
	border: 1px solid var(--tds-archive-line);
	border-radius: var(--tds-radius-sm);
	background: var(--tds-white);
	color: var(--tds-archive-option);
	font-size: 13.5px;
	font-weight: 700;
}

body.tds-theme.tds-product-archive nav.woocommerce-pagination ul li a:hover,
body.tds-theme.tds-product-archive nav.woocommerce-pagination ul li a:focus-visible {
	background: var(--tds-archive-hover);
	color: var(--tds-archive-ink);
}

body.tds-theme.tds-product-archive nav.woocommerce-pagination ul li span.current {
	border-color: var(--tds-archive-ink);
	background: var(--tds-archive-ink);
	color: var(--tds-white);
}

body.tds-theme.tds-product-archive nav.woocommerce-pagination ul li span.dots {
	min-width: 30px;
	border-color: transparent;
	background: transparent;
	color: var(--tds-archive-crumb);
	font-weight: 400;
}

body.tds-theme.tds-product-archive nav.woocommerce-pagination ul li a.prev,
body.tds-theme.tds-product-archive nav.woocommerce-pagination ul li a.next {
	width: var(--tds-archive-pager);
	color: var(--tds-archive-crumb-here);
	font-size: 15px;
}

/* --- Tablet --------------------------------------------------------------- */

@media (max-width: 1099px) {
	body.tds-theme.tds-product-archive {
		--tds-cols-tablet: 3;
		--tds-archive-sidebar: 220px;
		--tds-archive-gap: 28px;
	}
}

/* --- Phones: the sidebar becomes a bottom sheet ---------------------------
   Breakpoint mirrored in assets/js/product-filters.js.
   ------------------------------------------------------------------------ */

@media (max-width: 820px) {
	.tds-archive-layout {
		display: block;
	}

	.tds-filter-trigger {
		display: inline-flex;
	}

	.tds-archive-toolbar__chips {
		order: 3;
		flex-basis: 100%;
	}

	.tds-sort {
		margin-left: auto;
	}

	.tds-sort > span {
		display: none;
	}

	body.tds-theme.tds-product-archive .tds-sort select {
		min-height: var(--tds-archive-tap);
	}

	body.tds-theme.tds-product-archive .woocommerce-products-header__title {
		font-size: 24px;
	}

	/* No script: the filters stay in the page, above the grid, and the Apply
	   row below them is what submits. */
	.tds-filters {
		margin-bottom: var(--tds-space-5);
	}

	.tds-filters-ready .tds-filters {
		position: fixed;
		z-index: 10002;
		left: 0;
		right: 0;
		bottom: 0;
		display: flex;
		flex-direction: column;
		max-height: 80vh;
		margin: 0;
		border-radius: 16px 16px 0 0;
		background: var(--tds-white);
		transform: translateY(100%);
		visibility: hidden;
		transition: transform 0.25s ease-out, visibility 0.25s ease-out;
	}

	.tds-filters-ready .tds-filters.is-open {
		transform: translateY(0);
		visibility: visible;
	}

	.tds-filters-ready .tds-filter-form {
		display: flex;
		flex-direction: column;
		min-height: 0;
		max-height: 80vh;
	}

	.tds-filters-ready .tds-filters__head {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 18px 20px 12px;
		border-bottom: 1px solid var(--tds-archive-line);
	}

	.tds-filters-ready .tds-filters__head h2 {
		margin: 0;
		font-size: 16px;
		font-weight: 800;
		color: var(--tds-archive-ink);
	}

	.tds-filters-ready .tds-filters__close {
		width: var(--tds-archive-tap);
		height: var(--tds-archive-tap);
		padding: 0;
		border: 0;
		background: none;
		color: var(--tds-archive-faint);
		font-size: 16px;
		cursor: pointer;
	}

	.tds-filters-ready .tds-filters__body {
		flex: 1;
		min-height: 0;
		overflow-y: auto;
		overscroll-behavior: contain;
		padding: 4px 20px 8px;
	}

	/* Inside the sheet the whole list scrolls, not each group. */
	.tds-filters-ready .tds-filter-options {
		max-height: none;
		overflow: visible;
	}

	.tds-filters-ready .tds-filter-option {
		min-height: var(--tds-archive-tap);
		font-size: 14px;
	}

	.tds-filters-ready .tds-filter-group__head {
		min-height: var(--tds-archive-tap);
	}

	.tds-filters-ready .tds-filter-actions {
		display: flex;
		padding: 14px 20px 22px;
		border-top: 1px solid var(--tds-archive-line);
	}

	.tds-filters-ready .tds-filter-overlay {
		position: fixed;
		z-index: 10001;
		inset: 0;
		display: block;
		background: rgba(22, 38, 92, 0.45);
		opacity: 0;
		visibility: hidden;
		transition: opacity 0.25s ease, visibility 0.25s ease;
	}

	.tds-filters-ready .tds-filter-overlay.is-open {
		opacity: 1;
		visibility: visible;
	}
}

@media (max-width: 767px) {
	body.tds-theme.tds-product-archive {
		--tds-cols-mobile: 2;
		--tds-card-gap: var(--tds-space-3);
		--tds-card-row-gap: var(--tds-space-4);
	}

	body.tds-theme.tds-product-archive ul.products li.product .woocommerce-loop-product__title {
		font-size: 0.78rem;
	}

	body.tds-theme.tds-product-archive ul.products li.product .tds-card-badge {
		padding: 3px 6px;
		font-size: 0.6rem;
	}
}

@media (max-width: 420px) {
	body.tds-theme.tds-product-archive .col-full,
	body.tds-theme.tds-product-archive .tds-crumbs {
		padding-inline: 14px;
	}
}
