/* ==========================================================================
   Shop archive — filter sidebar + product grid
   Mobile-first. Sidebar becomes an off-canvas drawer below 1024px.
   ========================================================================== */

.shop-archive {
	/* Product archive is capped at ~1340px regardless of the site-wide
	   full-width container it sits inside. */
	max-width: 1340px;
	margin-inline: auto;
	padding-block: 16px 48px;
}

.shop-archive__layout {
	display: block;
}

@media (min-width: 1024px) {
	.shop-archive__layout {
		display: grid;
		grid-template-columns: 260px 1fr;
		gap: 40px;
		align-items: start;
	}
}

/* ---------- Mobile "Filter + Sort" bar ---------- */
.shop-archive__mobile-bar {
	padding-inline: 16px;
	margin-bottom: 16px;
}

@media (min-width: 1024px) {
	.shop-archive__mobile-bar {
		display: none;
	}
}

.shop-filter-trigger {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	width: 100%;
	justify-content: center;
	padding: 12px 16px;
	background: var(--wp--preset--color--paper);
	border: 1px solid var(--manarchy--fg);
	font-size: var(--wp--preset--font-size--sm);
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.02em;
}

.shop-filter-scrim {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.4);
	z-index: 90;
}

.shop-filter-scrim[hidden] {
	display: none;
}

/* ---------- Sidebar ---------- */
.shop-filters {
	padding-inline: 16px;
}

@media (min-width: 1024px) {
	.shop-filters {
		padding-inline: 0;
		position: sticky;
		top: 96px;
		max-height: calc(100vh - 120px);
		overflow-y: auto;
		/* Hide the scrollbar itself — the panel still scrolls with wheel/touch/keyboard. */
		scrollbar-width: none; /* Firefox */
		-ms-overflow-style: none; /* older Edge/IE */
	}

	.shop-filters::-webkit-scrollbar {
		display: none; /* Chrome, Safari, newer Edge */
	}
}

/* Off-canvas drawer on mobile/tablet */
@media (max-width: 1023.98px) {
	.shop-filters {
		position: fixed;
		top: 0;
		right: 0;
		bottom: 0;
		width: min(340px, 88vw);
		background: var(--wp--preset--color--paper);
		z-index: 100;
		overflow-y: auto;
		transform: translateX(100%);
		transition: transform 0.28s ease;
		padding-bottom: 24px;
		scrollbar-width: none;
		-ms-overflow-style: none;
	}

	.shop-filters::-webkit-scrollbar {
		display: none;
	}

	.shop-filters.is-open {
		transform: translateX(0);
	}
}

.shop-filters__drawer-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 16px;
	border-bottom: 1px solid var(--wp--preset--color--line);
	font-weight: 600;
	text-transform: uppercase;
	font-size: var(--wp--preset--font-size--sm);
	letter-spacing: 0.02em;
}

.shop-filters__close {
	background: none;
	border: 0;
	padding: 4px;
	color: var(--manarchy--fg);
}

@media (min-width: 1024px) {
	.shop-filters__drawer-head {
		display: none;
	}
}

.shop-filters__divider {
	height: 1px;
	background: var(--wp--preset--color--line);
	margin: 4px 16px;
}

@media (min-width: 1024px) {
	.shop-filters__divider {
		margin-inline: 0;
	}
}

.shop-filters__heading-row {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	padding: 16px 16px 4px;
}

.shop-filters__heading {
	font-family: var(--wp--preset--font-family--body);
	font-weight: 700;
	font-size: var(--wp--preset--font-size--lg);
	text-transform: none;
	margin: 0;
}

.shop-filters__reset {
	background: none;
	border: 0;
	padding: 0;
	font-size: var(--wp--preset--font-size--xs);
	font-weight: 600;
	text-decoration: underline;
	color: var(--wp--preset--color--smoke);
	white-space: nowrap;
	cursor: pointer;
}

.shop-filters__reset:hover {
	color: var(--manarchy--fg);
}

@media (min-width: 1024px) {
	.shop-filters__heading-row {
		padding-inline: 0;
	}
}

/* ---------- Accordions ---------- */
.shop-accordion__item {
	border-bottom: 1px solid var(--wp--preset--color--line);
}

.shop-accordion__trigger {
	width: 100%;
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 16px;
	background: none;
	border: 0;
	font-size: var(--wp--preset--font-size--md);
	font-weight: 400;
	color: var(--manarchy--fg);
	text-align: left;
}

@media (min-width: 1024px) {
	.shop-accordion__trigger {
		padding-inline: 0;
	}
}

.shop-accordion__icon {
	position: relative;
	width: 14px;
	height: 14px;
	flex-shrink: 0;
}

.shop-accordion__icon::before,
.shop-accordion__icon::after {
	content: "";
	position: absolute;
	background: var(--manarchy--fg);
	transition: transform 0.15s ease;
}

.shop-accordion__icon::before {
	top: 6px;
	left: 0;
	width: 14px;
	height: 2px;
}

.shop-accordion__icon::after {
	top: 0;
	left: 6px;
	width: 2px;
	height: 14px;
}

.shop-accordion__trigger[aria-expanded="true"] .shop-accordion__icon::after {
	transform: scaleY(0);
}

.shop-accordion__panel {
	padding: 0 16px 18px;
}

@media (min-width: 1024px) {
	.shop-accordion__panel {
		padding-inline: 0;
	}
}

.shop-checklist {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.shop-checklist label {
	display: flex;
	align-items: center;
	gap: 10px;
	font-size: var(--wp--preset--font-size--sm);
	cursor: pointer;
}

.shop-checklist input {
	width: 16px;
	height: 16px;
	accent-color: var(--wp--preset--color--ink);
}

.shop-filters__empty {
	font-size: var(--wp--preset--font-size--sm);
	color: var(--wp--preset--color--smoke);
	margin: 0;
}

.shop-filters__apply {
	display: none;
}

@media (max-width: 1023.98px) {
	.shop-filters__apply {
		display: block;
		width: calc(100% - 32px);
		margin: 16px;
		padding: 14px;
		background: var(--wp--preset--color--ink);
		/* --manarchy--on-dark (not --paper): --ink is fixed black in both
		   modes, but --paper flips to near-black (#1f1f21) in dark mode,
		   which dropped this to a ~1.15:1 contrast ratio — unreadable. */
		color: var(--manarchy--on-dark);
		border: 0;
		text-transform: uppercase;
		font-weight: 600;
		letter-spacing: 0.02em;
		font-size: var(--wp--preset--font-size--sm);
	}

	/* Dark mode flips this one button to a white fill/dark text instead of
	   following the light-mode black-fill/white-text treatment above.
	   --manarchy--on-dark (not --paper): --paper flips to near-black
	   (#1f1f21) in dark mode, so it wouldn't read as "white" here. */
	:root[data-theme="dark"] .shop-filters__apply {
		background: var(--manarchy--on-dark);
		color: var(--wp--preset--color--ink);
	}
}

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

[data-shop-products-results].is-loading {
	opacity: 0.5;
	pointer-events: none;
	transition: opacity 0.15s ease;
}

.shop-archive__content {
	padding-inline: 16px;
}

/* Mobile: bleed out of the site-wide .manarchy-container gutter so the
   product grid runs edge to edge. The mobile filter bar and off-canvas
   drawer keep their own padding-inline, so they're unaffected. */
@media (max-width: 1023.98px) {
	.shop-archive {
		margin-inline: -16px;
	}

	.shop-archive__content {
		padding-inline: 0;
	}
}

@media (min-width: 1024px) {
	.shop-archive__content {
		padding-inline: 0;
	}
}

ul.products {
	display: grid !important;
	grid-template-columns: repeat(2, 1fr) !important;
	gap: 8px 12px;
	list-style: none;
	margin: 0;
	padding: 0;
}

/*
 * WooCommerce core adds ::before/::after clearfix pseudo-elements to
 * ul.products (content: " "; display: table;) for its old float-based
 * grid. Since this theme uses CSS Grid instead, those generated boxes
 * become actual grid items — silently occupying the first and last cell
 * of the grid with nothing in them. Kill them.
 */
ul.products::before,
ul.products::after {
	content: none !important;
	display: none !important;
}

@media (min-width: 640px) {
	ul.products {
		gap: 12px 16px;
	}
}

@media (min-width: 1024px) {
	ul.products {
		grid-template-columns: repeat(3, 1fr) !important;
		gap: 24px;
	}

	/*
	 * WooCommerce's [products]/[sale_products]/etc. shortcodes render a
	 * columns-N class on the <ul> based on the shortcode's columns=""
	 * attribute (e.g. [products columns="4"] → class="products columns-4").
	 * The rule above is just the default when no columns-N class is present;
	 * these override it so the shortcode attribute is actually respected.
	 */
	ul.products.columns-1 { grid-template-columns: repeat(1, 1fr) !important; }
	ul.products.columns-2 { grid-template-columns: repeat(2, 1fr) !important; }
	ul.products.columns-3 { grid-template-columns: repeat(3, 1fr) !important; }
	ul.products.columns-4 { grid-template-columns: repeat(4, 1fr) !important; }
	ul.products.columns-5 { grid-template-columns: repeat(5, 1fr) !important; }
	ul.products.columns-6 { grid-template-columns: repeat(6, 1fr) !important; }
}

ul.products li.product,
.shop-card {
	position: relative;
	margin: 0 !important;
	width: auto !important;
	float: none !important;
}

.shop-card__media {
	position: relative;
	display: block;
	background: var(--wp--preset--color--bone);
	aspect-ratio: 3 / 4;
	overflow: hidden;
}

/* Wishlist heart toggle — sits on top of the card image, same button markup
   used on the PDP (see .wishlist-toggle in layout.css). */
.shop-card .wishlist-toggle {
	position: absolute;
	top: 8px;
	right: 8px;
	z-index: 1;
}

ul.products li.product.shop-card .shop-card__media img,
.shop-card__media img {
	display: block;
	width: 100% !important;
	height: 100% !important;
	max-width: 100% !important;
	object-fit: cover !important;
}

.shop-card__urgency {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 8px 6px;
	background: rgba(255, 255, 255, 0.92);
	font-size: var(--wp--preset--font-size--xs);
	font-weight: 600;
	color: var(--wp--preset--color--ink);
	text-align: center;
}

.shop-card__body {
	padding-top: 10px;
}

.shop-card__eyebrow {
	/* var(--manarchy--eyebrow), not a hardcoded hex: the fixed #1857b8 blue
	   drops to ~2.4:1 against the dark card background (fails WCAG AA's
	   4.5:1). The token lightens automatically in dark mode. */
	color: var(--manarchy--eyebrow, #1857b8);
	font-size: var(--wp--preset--font-size--xs);
	font-weight: 600;
	margin: 0 0 2px;
}

.shop-card__title {
	font-family: var(--wp--preset--font-family--body);
	text-transform: none;
	font-weight: 400;
	font-size: 12px;
	color: var(--manarchy--fg);
	margin: 0 0 4px;
	line-height: 1.35;
}

.shop-card__title a {
	color: var(--manarchy--fg);
}

.shop-card__price {
	font-size: 13px;
	font-weight: 500;
	margin-bottom: 4px;
}

.shop-card__price ins {
	text-decoration: none;
}

.shop-card__price del {
	color: var(--wp--preset--color--smoke);
	margin-right: 6px;
}

.shop-card__promo,
.shop-card__fabric {
	font-size: var(--wp--preset--font-size--xs);
	color: var(--wp--preset--color--smoke);
	margin: 0 0 2px;
	line-height: 1.4;
}

.shop-card__deal {
	font-size: var(--wp--preset--font-size--xs);
	font-weight: 700;
	/* var(--manarchy--deal): fixed #c22a1e drops to ~2.9:1 against the dark
	   card background (fails WCAG AA). Token lightens in dark mode; also
	   shared with .manarchy-badge--deal so both stay in sync. */
	color: var(--manarchy--deal);
	margin: 4px 0 0;
}

/* Pagination — compact window of page numbers (see woocommerce_pagination_args
   filter in functions.php) with distinct prev/next arrow buttons and a
   filled current-page indicator. */
.woocommerce-pagination {
	margin-top: 32px;
}

.woocommerce-pagination ul.page-numbers {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	list-style: none;
	padding: 0;
	margin: 0;
}

.woocommerce-pagination .page-numbers li {
	display: flex;
}

.woocommerce-pagination a.page-numbers,
.woocommerce-pagination span.page-numbers {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 36px;
	height: 36px;
	padding-inline: 4px;
	border-radius: 999px;
	font-size: var(--wp--preset--font-size--sm);
	color: var(--manarchy--fg);
}

.woocommerce-pagination a.page-numbers:hover {
	background: var(--wp--preset--color--bone);
}

/* Current page — filled pill. Text uses the fixed --on-dark token rather
   than --paper: --ink (the pill's background) stays black in both modes,
   but --paper flips to near-black in dark mode, which took this pairing
   down to a ~1.15:1 contrast ratio (page number effectively invisible). */
.woocommerce-pagination span.page-numbers.current {
	background: var(--wp--preset--color--ink);
	color: var(--manarchy--on-dark);
	font-weight: 600;
}

/* The "…" gap marker — plain text, no button chrome. */
.woocommerce-pagination .page-numbers.dots {
	color: var(--wp--preset--color--smoke);
	background: none;
}

/* Prev/Next arrows — outlined circular buttons so they read as controls,
   not page numbers. */
.woocommerce-pagination a.next.page-numbers,
.woocommerce-pagination a.prev.page-numbers {
	border: 1px solid var(--wp--preset--color--line);
	font-size: var(--wp--preset--font-size--md);
}

.woocommerce-pagination a.next.page-numbers:hover,
.woocommerce-pagination a.prev.page-numbers:hover {
	border-color: var(--manarchy--fg);
	background: var(--wp--preset--color--paper);
}
