/**
 * Products archive — mobile-first layout polish
 */

/* ── Page shell ── */
.cx-archive-shell {
	background: var(--cx-bg, #f8fafc);
	min-height: 60vh;
}

.cx-archive-wrap {
	max-width: 1280px;
	margin: 0 auto;
	padding: 16px 12px 28px;
	font-family: var(--cx-font, 'Plus Jakarta Sans', system-ui, sans-serif);
	overflow-x: hidden;
}

@media (min-width: 640px) {
	.cx-archive-wrap { padding: 24px 20px 36px; }
}

@media (min-width: 1024px) {
	.cx-archive-wrap { padding: 28px 24px 40px; }
}

/* ── Page heading ── */
.cx-archive-header {
	margin-bottom: 16px;
}

.cx-archive-title {
	font-size: clamp(1.35rem, 4.5vw, 1.875rem);
	font-weight: 800;
	line-height: 1.15;
	letter-spacing: -0.03em;
	color: var(--cx-text, #0f172a);
	margin: 0 0 6px;
}

.cx-archive-desc {
	font-size: clamp(13px, 3.2vw, 15px);
	line-height: 1.5;
	color: var(--cx-g500, #64748b);
	margin: 0;
	max-width: 52ch;
}

/* Nested app from shortcode — avoid double padding */
.cx-archive-wrap > .cx-app {
	max-width: none;
	margin: 0;
	padding: 0;
}

/* Bottom clearance: bottom nav + compare bar */
body.post-type-archive-comparix_product .cx-archive-shell,
body.cx-archive-products .cx-archive-shell {
	padding-bottom: env(safe-area-inset-bottom, 0);
}

body.cx-nav-bottom-bar.cx-archive-products .cx-archive-shell {
	padding-bottom: calc(var(--cx-nav-bottom-h, 56px) + env(safe-area-inset-bottom, 0));
}

body.cx-bar-active.cx-archive-products .cx-archive-shell {
	padding-bottom: calc(52px + env(safe-area-inset-bottom, 0));
}

body.cx-bar-active.cx-nav-bottom-bar.cx-archive-products .cx-archive-shell {
	padding-bottom: calc(var(--cx-nav-bottom-h, 56px) + 52px + env(safe-area-inset-bottom, 0));
}

/* ── Toolbar v2 ── */
.cx-archive-wrap .cx-toolbar-v2 {
	display: flex;
	flex-direction: column;
	gap: 10px;
	margin-bottom: 12px;
	padding: 12px;
	background: var(--cx-card, #fff);
	border: 1px solid var(--cx-border, #e2e8f0);
	border-radius: var(--cx-radius-lg, 16px);
	box-shadow: var(--cx-shadow-sm, 0 1px 3px rgba(15, 23, 42, 0.06));
}

.cx-archive-wrap .cx-toolbar-row {
	display: flex;
	align-items: stretch;
	gap: 8px;
	min-width: 0;
}

.cx-archive-wrap .cx-toolbar-row--primary {
	flex-wrap: nowrap;
}

.cx-archive-wrap .cx-toolbar-row--secondary {
	flex-wrap: wrap;
}

.cx-archive-wrap .cx-search-box {
	flex: 1;
	min-width: 0;
	position: relative;
	display: flex;
	align-items: center;
}

.cx-archive-wrap .cx-search-box svg {
	position: absolute;
	left: 12px;
	top: 50%;
	transform: translateY(-50%);
	color: var(--cx-g400, #94a3b8);
	pointer-events: none;
	flex-shrink: 0;
}

.cx-archive-wrap .cx-search-box input {
	width: 100%;
	min-height: 44px;
	padding: 0 12px 0 38px;
	border: 1px solid var(--cx-g200, #e2e8f0);
	border-radius: var(--cx-radius-md, 12px);
	font-size: 14px;
	font-family: inherit;
	background: var(--cx-g50, #f8fafc);
	color: var(--cx-text, #0f172a);
}

.cx-archive-wrap .cx-search-box input::placeholder {
	color: var(--cx-g400, #94a3b8);
	opacity: 1;
}

.cx-archive-wrap .cx-search-box input:focus {
	outline: none;
	border-color: var(--cx-primary, #6366f1);
	box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
	background: var(--cx-card, #fff);
}

.cx-archive-wrap .cx-sort,
.cx-archive-wrap .cx-status-sel {
	min-height: 44px;
	padding: 0 32px 0 12px;
	border: 1px solid var(--cx-g200, #e2e8f0);
	border-radius: var(--cx-radius-md, 12px);
	font-size: 13px;
	font-weight: 600;
	font-family: inherit;
	background: var(--cx-card, #fff);
	color: var(--cx-text, #0f172a);
	cursor: pointer;
	appearance: none;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 10px center;
	flex: 1;
	min-width: 0;
}

.cx-archive-wrap .cx-sort:focus,
.cx-archive-wrap .cx-status-sel:focus {
	outline: none;
	border-color: var(--cx-primary, #6366f1);
}

.cx-archive-wrap .cx-layout-toggle {
	display: flex;
	border: 1px solid var(--cx-g200, #e2e8f0);
	border-radius: var(--cx-radius-md, 12px);
	overflow: hidden;
	flex-shrink: 0;
}

.cx-archive-wrap .cx-layout-btn {
	min-width: 44px;
	min-height: 44px;
	padding: 0 12px;
	border: none;
	background: var(--cx-card, #fff);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--cx-g400, #94a3b8);
}

.cx-archive-wrap .cx-layout-btn.active {
	background: var(--cx-primary, #6366f1);
	color: #fff;
}

.cx-archive-wrap .cx-mobile-filter-btn {
	display: none;
	align-items: center;
	justify-content: center;
	gap: 6px;
	min-height: 44px;
	padding: 0 14px;
	border: 1px solid var(--cx-g200, #e2e8f0);
	border-radius: var(--cx-radius-md, 12px);
	background: var(--cx-card, #fff);
	font-size: 13px;
	font-weight: 700;
	font-family: inherit;
	color: var(--cx-text, #0f172a);
	cursor: pointer;
	flex-shrink: 0;
	white-space: nowrap;
}

.cx-archive-wrap .cx-toolbar-meta {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	margin-bottom: 12px;
	min-height: 20px;
}

.cx-archive-wrap .cx-result-count {
	font-size: 13px;
	font-weight: 600;
	color: var(--cx-g500, #64748b);
	margin: 0;
}

/* ── Sidebar filters ── */
.cx-archive-wrap .cx-sidebar {
	width: 260px;
	padding: 16px;
	background: var(--cx-card, #fff);
	border: 1px solid var(--cx-border, #e2e8f0);
	border-radius: var(--cx-radius-lg, 16px);
	box-shadow: var(--cx-shadow-sm);
}

.cx-archive-wrap .cx-sidebar-head {
	margin-bottom: 14px;
	padding-bottom: 12px;
	border-bottom: 1px solid var(--cx-g100, #f1f5f9);
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
}

.cx-archive-wrap .cx-sidebar-actions {
	display: flex;
	align-items: center;
	gap: 6px;
	flex-shrink: 0;
}

.cx-archive-wrap .cx-sidebar-head h3 {
	font-size: 15px;
	font-weight: 800;
	color: var(--cx-text, #0f172a);
	margin: 0;
}

.cx-archive-wrap .cx-clear-all {
	font-size: 12px;
	font-weight: 700;
	color: var(--cx-primary, #6366f1);
	padding: 6px 10px;
	border-radius: var(--cx-radius-sm, 8px);
}

.cx-archive-wrap .cx-clear-all:not([style*="inline"]) {
	display: none;
}

.cx-archive-wrap .cx-clear-all.is-visible {
	display: inline-flex !important;
}

.cx-archive-wrap .cx-filter-group {
	margin-bottom: 16px;
	padding-bottom: 14px;
	border-bottom: 1px solid var(--cx-g100, #f1f5f9);
}

.cx-archive-wrap .cx-filter-group:last-child {
	border-bottom: none;
	margin-bottom: 0;
	padding-bottom: 0;
}

.cx-archive-wrap .cx-filter-group > label:first-child {
	font-size: 11px;
	font-weight: 800;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--cx-g500, #64748b);
	margin-bottom: 8px;
}

.cx-archive-wrap .cx-filter-group select {
	min-height: 40px;
}

/* ── Product grid & cards ── */
.cx-archive-wrap .cx-grid {
	gap: 10px;
	grid-template-columns: repeat(var(--cx-cols, 3), minmax(0, 1fr));
}

.cx-archive-wrap .cx-card {
	border-radius: var(--cx-radius-md, 12px);
	border: 1px solid var(--cx-border, #e2e8f0);
	overflow: hidden;
	-webkit-tap-highlight-color: transparent;
}

.cx-archive-wrap .cx-card-img {
	aspect-ratio: 4 / 5;
	background: linear-gradient(180deg, var(--cx-g50, #f8fafc) 0%, var(--cx-g100, #f1f5f9) 100%);
}

.cx-archive-wrap .cx-card-img img {
	object-fit: contain;
	padding: 8px;
}

.cx-archive-wrap .cx-card-body {
	padding: 10px 11px 11px;
}

.cx-archive-wrap .cx-card-title {
	font-size: clamp(12px, 3.4vw, 14px);
	font-weight: 700;
	line-height: 1.35;
	margin-bottom: 4px;
}

.cx-archive-wrap .cx-card-title a {
	color: var(--cx-text, #0f172a);
	text-decoration: none;
}

.cx-archive-wrap .cx-card-brand {
	font-size: 10px;
	margin-bottom: 3px;
}

.cx-archive-wrap .cx-price {
	font-size: clamp(13px, 3.6vw, 15px);
}

.cx-archive-wrap .cx-card-foot {
	padding-top: 6px;
	margin-top: 4px;
}

.cx-archive-wrap .cx-card-specs span {
	font-size: 10px;
	padding: 2px 6px;
}

@media (hover: hover) and (pointer: fine) {
	.cx-archive-wrap .cx-card:hover {
		transform: translateY(-2px);
		box-shadow: var(--cx-shadow-md);
		border-color: rgba(99, 102, 241, 0.2);
	}
	.cx-archive-wrap .cx-card-title a:hover {
		color: var(--cx-primary, #6366f1);
	}
}

.cx-archive-wrap .cx-card:active {
	transform: scale(0.99);
}

/* List layout on archive */
.cx-archive-wrap .cx-grid[data-layout="list"] .cx-card-img {
	width: 112px;
	aspect-ratio: 1;
}

.cx-archive-wrap .cx-grid[data-layout="list"] .cx-card-body {
	padding: 12px;
}

/* ── Pagination ── */
.cx-archive-wrap .cx-pagination {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	align-items: center;
	gap: 6px;
	margin-top: 24px;
	padding-top: 8px;
}

.cx-archive-wrap .cx-pagination button,
.cx-archive-wrap .cx-pg {
	min-height: 40px;
	min-width: 40px;
	padding: 0 12px;
	border: 1px solid var(--cx-g200, #e2e8f0);
	border-radius: var(--cx-radius-md, 12px);
	background: var(--cx-card, #fff);
	font-size: 13px;
	font-weight: 700;
	font-family: inherit;
	color: var(--cx-text, #0f172a);
	cursor: pointer;
}

.cx-archive-wrap .cx-pagination button.active,
.cx-archive-wrap .cx-pg.active {
	background: var(--cx-primary, #6366f1);
	color: #fff;
	border-color: var(--cx-primary, #6366f1);
}

.cx-archive-wrap .cx-loadmore-btn {
	min-height: 48px;
	border-radius: var(--cx-radius-full, 9999px);
	font-size: 14px;
}

/* ── Mobile ── */
@media (max-width: 768px) {
	.cx-archive-wrap .cx-layout {
		flex-direction: column;
		gap: 0;
	}

	.cx-archive-wrap .cx-sidebar {
		display: none;
		position: fixed;
		left: 0;
		top: 0;
		bottom: 0;
		width: min(88vw, 320px);
		max-height: 100vh;
		z-index: 999;
		border-radius: 0;
		border-left: none;
		border-top: none;
		border-bottom: none;
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
	}

	.cx-archive-wrap .cx-sidebar.open {
		display: block;
	}

	.cx-archive-wrap .cx-sidebar-close {
		display: flex;
		align-items: center;
		justify-content: center;
		width: 36px;
		height: 36px;
		border-radius: var(--cx-radius-sm, 8px);
	}

	.cx-archive-wrap .cx-mobile-filter-btn {
		display: inline-flex;
	}

	.cx-archive-wrap .cx-layout-toggle {
		display: none;
	}

	.cx-archive-wrap .cx-toolbar-row--secondary {
		display: grid;
		grid-template-columns: 1fr 1fr;
	}

	.cx-archive-wrap .cx-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
		gap: 8px;
	}

	.cx-archive-wrap .cx-grid[data-layout="list"] {
		grid-template-columns: 1fr !important;
	}

	.cx-archive-wrap .cx-card-body {
		padding: 8px 9px 9px;
	}

	.cx-archive-wrap .cx-card-img img {
		padding: 4px;
	}
}

@media (max-width: 430px) {
	.cx-archive-wrap .cx-toolbar-v2 {
		padding: 10px;
		gap: 8px;
	}

	.cx-archive-wrap .cx-toolbar-row--secondary {
		grid-template-columns: 1fr;
	}
}

@media (max-width: 319px) {
	.cx-archive-wrap .cx-grid {
		grid-template-columns: 1fr !important;
	}
}

@media (min-width: 769px) {
	.cx-archive-wrap .cx-toolbar-row--secondary .cx-sort {
		flex: 1;
		max-width: 220px;
	}

	.cx-archive-wrap .cx-toolbar-row--secondary .cx-status-sel {
		flex: 1;
		max-width: 200px;
	}
}

@media (min-width: 1024px) {
	.cx-archive-wrap .cx-grid {
		gap: 14px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.cx-archive-wrap .cx-card:active {
		transform: none;
	}
}
