/*
 * /shop/ — the all-products page.
 *
 * Owns the page frame, the filter rail and the search row. The CARDS are
 * .as-cat-card from route-category.css and the grid is .as-cat-grid, both
 * loaded before this: the mock's card is the card the category pages already
 * draw, down to the price pill and the rotated badge, so drawing it again here
 * would be a second copy of rules that have already drifted once on this site.
 */

/* ── Head: title, search, count ─────────────────────────────────────────── */

.as-ap__head {
	display: flex;
	flex-direction: column;
	gap: var(--space-4);
	padding: 44px 0 24px;
}

.as-ap__title {
	margin: 0;
	font-size: var(--text-stat);
	font-weight: 700;
	letter-spacing: -0.02em;
	line-height: var(--leading-tight);
}

.as-ap__tools {
	display: flex;
	align-items: center;
	gap: var(--space-3-5);
	flex-wrap: wrap;
}

/* The pill itself is the shared search recipe (primitives.css). */
.as-ap__search {
	display: flex;
	padding: 4px 6px 4px 18px;
	width: min(420px, 100%);
	box-sizing: border-box;
	background: var(--color-surface);
	transition: border-color var(--dur) var(--ease);
}

.as-ap__search:focus-within { border-color: var(--atomic-blue); }

.as-ap__searchicon {
	display: flex;
	flex: none;
	color: var(--atomic-blue);
}

/*
 * appearance:none kills Safari's own clear button — there is one in the markup
 * that also resets the filters, and two would disagree with each other.
 */
.as-ap__input {
	font-size: var(--text-sm);
	padding: 9px 0;
}

/* Its WebKit ⊗ is hidden with the other search fields' in primitives.css. */

.as-ap__clearq {
	border: none;
	background: var(--color-surface-alt);
	color: var(--color-text-muted);
	flex: none;
}

.as-ap__clearq:hover { color: var(--color-text); }

.as-ap__count {
	margin: 0;
	font-size: var(--text-sm);
	color: var(--color-text-muted);
}

.as-ap__clearall {
	cursor: pointer;
	border: none;
	background: none;
	padding: 0;
	font-family: inherit;
	font-size: var(--text-sm);
	font-weight: 700;
	color: var(--atomic-blue);
}

.as-ap__clearall:hover { text-decoration: underline; }

/* ── Layout ─────────────────────────────────────────────────────────────── */

.as-ap__layout {
	display: grid;
	grid-template-columns: 220px minmax(0, 1fr);
	gap: var(--space-7);
	align-items: start;
	padding-bottom: 72px;
}

.as-ap__rail {
	display: flex;
	flex-direction: column;
	gap: var(--space-6);
	position: sticky;
	top: 24px;
}

.as-ap__group {
	display: flex;
	flex-direction: column;
	gap: var(--space-2-5);
}

.as-ap__grouphead {
	margin: 0;
	color: var(--atomic-dark);
}

.as-ap__opt {
	display: flex;
	align-items: center;
	gap: var(--space-2-5);
	cursor: pointer;
}

/* The real control, kept for keyboard and screen readers, painted by __box. */
.as-ap__cb {
	position: absolute;
	width: 1px;
	height: 1px;
	opacity: 0;
	pointer-events: none;
}

.as-ap__box {
	width: 18px;
	height: 18px;
	border-radius: 5px;
	display: grid;
	place-items: center;
	flex: none;
	box-sizing: border-box;
	border: 1.5px solid var(--color-border);
	transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.as-ap__cb:checked + .as-ap__box {
	background: var(--atomic-blue);
	border-color: var(--atomic-blue);
}

.as-ap__cb:checked + .as-ap__box::after {
	content: "✓";
	color: var(--color-text-invert);
	font-size: var(--text-label);
	font-weight: 800;
	line-height: 1;
}

.as-ap__cb:focus-visible + .as-ap__box {
	outline: 2px solid var(--focus-ring);
	outline-offset: 2px;
}

.as-ap__optlabel {
	font-size: var(--text-sm);
	font-weight: 600;
	color: var(--color-text);
	flex: 1;
}

.as-ap__optn {
	font-size: var(--text-xs);
	color: var(--color-text-muted);
	font-variant-numeric: tabular-nums;
}

/* ── The help card ──────────────────────────────────────────────────────── */

.as-ap__help {
	background: var(--color-surface-tint);
	border-radius: var(--radius-lg);
	padding: 20px;
	display: flex;
	flex-direction: column;
	gap: var(--space-2-5);
}

.as-ap__helphead {
	margin: 0;
	font-weight: 800;
	font-size: var(--text-body);
	line-height: var(--leading-snug);
}

.as-ap__helpbody {
	margin: 0;
	font-size: var(--text-xs);
	color: var(--color-text-muted);
	line-height: var(--leading-body);
}

.as-ap__helpcta {
	background: var(--atomic-blue);
	color: var(--color-text-invert);
	text-align: center;
	margin-top: 2px;
}

.as-ap__helpcta:hover { background: var(--atomic-dark); color: var(--color-text-invert); }

.as-ap__helpcall {
	margin: 0;
	font-size: var(--text-label);
	font-weight: 600;
	color: var(--color-text-muted);
	text-align: center;
}

.as-ap__helpcall a { font-weight: 700; }

/* ── Results ────────────────────────────────────────────────────────────── */

.as-ap__results {
	display: flex;
	flex-direction: column;
	gap: var(--space-5);
	min-width: 0;
}

/*
 * Four across, as the mock draws it.
 *
 * The mock has a 1400px canvas with 16px padding and gets 252px a card. This
 * theme's page is --page-max 1440 inside 56px gutters, which is 120px less to
 * divide — and the page must stay 1280 because the header above it is, and
 * content wider than the header it sits under is visibly wrong.
 *
 * So the width comes out of the rail instead: 220px rather than 250, a 28px
 * column gap rather than 36, and 20px between cards. That buys back 34px per
 * card against the naive version and lands at ~215px. The rail still fits its
 * longest label ("Stickers and Decals") on one line, which is what sets its
 * floor.
 */
.as-ap__grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-5); }

.as-ap__empty {
	background: var(--color-surface-alt);
	border-radius: var(--radius-xl);
	padding: 40px;
	text-align: center;
	display: flex;
	flex-direction: column;
	gap: var(--space-2);
	align-items: center;
}

.as-ap__emptyhead { margin: 0; font-weight: 700; font-size: var(--text-body-lg); }

.as-ap__emptybody { margin: 0; font-size: var(--text-sm); color: var(--color-text-muted); }

.as-ap__emptycta {
	background: var(--atomic-blue);
	color: var(--color-text-invert);
	margin-top: 6px;
}

.as-ap__emptycta:hover { background: var(--atomic-dark); color: var(--color-text-invert); }

/*
 * [hidden] vs display.
 *
 * The browser's own `[hidden] { display: none }` is a plain type-less rule, so
 * ANY class here that sets display beats it and the element stays on screen
 * with the attribute set — which is exactly what happened to the empty state:
 * hidden="true" in the DOM, display:flex on the screen, "Nothing matches"
 * sitting above sixty-five matching products.
 *
 * So every element this page hides declares it, rather than trusting the
 * default to win.
 */
.as-cat-card[hidden],
.as-ap__empty[hidden],
.as-ap__clearq[hidden],
.as-ap__clearall[hidden] { display: none; }

/* ── Narrower ───────────────────────────────────────────────────────────── */

/*
 * Below ~1150 four columns stop being cards and start being thumbnails, so the
 * grid steps down before the layout does.
 *
 * That two-step used to be 940 then 860 — an 80px window where the grid was
 * already two across but the rail was still a rail. Both are 900 on the
 * ladder now, so the two happen together and the separate grid rule below
 * became a dead duplicate of the one inside the layout block. The window is
 * gone; nothing measured differently with it gone.
 */
@media (max-width: 1200px) {
	.as-ap__layout { grid-template-columns: 200px minmax(0, 1fr); gap: var(--space-6); }
	.as-ap__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/*
 * One column, and the rail stops being a rail.
 *
 * Two changes, and the second matters more than it looks. Sticky goes, because
 * a sidebar that follows you down a single column covers what you are reading.
 *
 * And the help card moves BELOW the products. Stacked in source order the rail
 * puts six filters and a quote CTA — some 380px — between the customer and the
 * first product, so the page opens on an advert for talking to someone instead
 * of on the catalogue it exists to show. The filters earn their place at the
 * top; "Not sure what you need?" only makes sense once you have looked.
 *
 * display:contents dissolves the rail box so its two children become items of
 * the layout and can be ordered independently. The desktop rail is untouched.
 */
@media (max-width: 900px) {
	.as-ap__layout {
		display: flex;
		flex-direction: column;
		gap: var(--space-6);
	}
	.as-ap__rail { display: contents; }
	.as-ap__group { order: 1; gap: var(--space-3); }
	.as-ap__results { order: 2; }
	.as-ap__help { order: 3; }

	/* Two across still reads at tablet width; 560 takes it to one. */
	.as-ap__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.as-ap__title { font-size: var(--text-h2); }
	.as-ap__head { padding: 28px 0 18px; }
}

@media (max-width: 560px) {
	.as-ap__search { width: 100%; }
	.as-ap__title { font-size: var(--text-h2); }
	/* Two across, as on the category pages — see route-category.css. */
	.as-ap__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4-5); }
}
