/* Catalogue (boards shop-v1 / shop-v1-mobile). Specs: DESIGN.md sections 4, 7, 8, 11. */

/* ---------- Page head: label, h1, sub ---------- */
.shop-head { padding-block: 56px; }
.shop-title-col { display: grid; gap: clamp(20px, 18.592px + 0.376vw, 24px); margin-top: 40px; }
.shop-h1 { font-size: var(--fs-display-h1); font-weight: 200; line-height: 1.05; color: var(--ink); }
.shop-sub { max-width: 700px; font-size: 13px; line-height: 1.6; color: var(--quiet); }

/* ---------- Browse: filters + results ---------- */
.browse { display: flex; flex-direction: column; padding-bottom: 64px; }
/* Below 1024 the results wrapper steps aside so the Filter panel can open between toolbar and grid. */
.results { display: contents; }
.results > * { order: 3; }

/* Toolbar: Filter (below 1024), count, rule, sort. */
.results > .toolbar { order: 1; }
.toolbar { display: flex; align-items: center; gap: 12px; padding-bottom: 4px; }
.filter-btn { min-height: 45px; padding: 10px 20px; }
.toolbar-count { font-family: var(--font-mono); font-size: 13px; font-weight: 400; letter-spacing: 0.02em; flex: none; line-height: 1.5; color: var(--ink); }
.toolbar-rule { flex: 1; min-width: 16px; height: 1px; background: var(--line); }
/* Sort: a disclosure menu of WooCommerce's orderby links, drawn like the rest of the page. */
.sort { position: relative; flex: none; }
.sort-btn {
	display: flex; align-items: center; min-height: 44px; margin-block: -12px; padding-right: 14px; list-style: none;
	background: no-repeat right center url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M.5.5l3.5 3.5L7.5.5' fill='none' stroke='%23496253' stroke-width='1.2'/%3E%3C/svg%3E");
	font-size: 12px; font-weight: 500; line-height: 1.5; letter-spacing: 0.08px; text-transform: uppercase; color: var(--sage-deep); cursor: pointer;
}
.sort-btn::-webkit-details-marker { display: none; }
.sort[open] .sort-btn { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M.5 4.5l3.5-3.5 3.5 3.5' fill='none' stroke='%23496253' stroke-width='1.2'/%3E%3C/svg%3E"); }
.sort-menu {
	position: absolute; right: 0; top: calc(100% + 12px); z-index: 10; min-width: 208px; padding: 8px 0;
	background: var(--ground); box-shadow: inset 0 0 0 1px var(--line), 0 12px 24px -16px #3B2F2340;
}
.sort-menu a {
	display: flex; align-items: center; min-height: 40px; padding: 0 16px;
	font-size: 13px; font-weight: 300; line-height: 1.45; color: var(--ink); text-decoration: none; white-space: nowrap;
}
.sort-menu a:hover { background: var(--ground-alt); }
.sort-menu a:focus-visible { outline-offset: -2px; }
.sort-menu a[aria-current] { font-weight: 500; text-decoration: underline; text-decoration-color: var(--sage); text-decoration-thickness: 1.5px; text-underline-offset: 4px; }

/* Filters: a bordered panel under the toolbar, opened by Filter (below 1024). */
.filters { order: 2; margin-top: 24px; box-shadow: inset 0 0 0 1px var(--line); }
.filters[hidden] { display: none; }
/* Until shop.js has run (html.js, not yet .shop-ready): the state it sets, drawn from the first paint - the panel closed
   below 1024, the extra factions folded unless one is active, "Show all factions" shown - so it shifts nothing (port 7). */
.js:not(.shop-ready) .filters { display: none; }
.js:not(.shop-ready) .facet-body:not(:has(.is-extra [aria-current])) .is-extra { display: none; }
.js:not(.shop-ready) .facet-more[hidden] { display: inline-block; }
.facet { padding: 16px; }
.facet + .facet { box-shadow: inset 0 1px 0 var(--line); }
.facet-head { position: relative; display: flex; align-items: center; gap: 12px; height: 24px; } /* fixed: a clear link never changes it */
.facet-h { flex: 1; display: flex; font: inherit; }
.facet-toggle {
	padding: 0; border: 0; background: none; cursor: pointer; text-align: left;
	font-family: var(--font-sans); font-size: 12px; font-weight: 500; line-height: 1.5; letter-spacing: 0.08px; text-transform: uppercase; color: var(--sage-deep);
}
/* The whole header row toggles (a 44 px band); the clear link sits above the overlay. */
.facet-toggle::after { content: ""; position: absolute; inset: -10px 0; }
.facet-clear { position: relative; z-index: 1; }
.facet-count { font-family: var(--font-mono); font-size: 13px; font-weight: 400; letter-spacing: 0.02em; line-height: 1.45; color: var(--quiet); }
.facet-glyph { width: 11px; font-size: 16px; font-weight: 300; line-height: 1.5; text-align: right; color: var(--sage-deep); }
.facet-glyph::before { content: "\2212"; }
.facet.is-collapsed .facet-glyph::before { content: "+"; }
.facet-body { margin-top: 14px; }
.facet-body[hidden] { display: none; }
.facet-list { display: grid; gap: 14px; }
.facet-list li[hidden] { display: none; }
/* Rows are drawn 19 px apart by the board; padding + negative margin give a 33 px hit area. */
.facet-row {
	display: flex; align-items: center; justify-content: space-between; gap: 12px;
	padding-block: 7px; margin-block: -7px; font-size: 13px; line-height: 1.45; text-decoration: none; color: var(--ink);
}
.facet-ct { flex: none; color: var(--quiet); }
.facet-row:hover .facet-name { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.facet-row[aria-current] .facet-name { font-weight: 500; text-decoration: underline; text-decoration-color: var(--sage); text-decoration-thickness: 1.5px; text-underline-offset: 4px; }
.facet-row[aria-current] .facet-ct::after { content: " \00d7"; color: var(--sage-deep); }
/* A term that would show nothing with the other active filters (DESIGN.md section 7: 40% + not-allowed). */
.facet-row.is-empty { opacity: 0.4; cursor: not-allowed; }
.facet-more {
	margin: 9px 0 -12px; padding: 5px 0 12px; border: 0; background: none; cursor: pointer; /* 14 above the text; the padding is hit area, starting where the last row's (7 px below it) ends - no overlap, port 7 */
	font-family: var(--font-sans); font-size: 13px; font-weight: 500; line-height: 1.4; color: var(--sage-deep);
}
.facet-more:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Product grid: cards on subgrid, one height per row (DESIGN.md section 11) ---------- */
.product-grid { margin-top: 32px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 15px; row-gap: 16px; }
.card { position: relative; display: grid; grid-row: span 4; grid-template-rows: subgrid; row-gap: 0; }
.card-img { aspect-ratio: 160 / 140; }
.card-badge {
	font-family: var(--font-mono); font-size: 11px; font-weight: 400; letter-spacing: 0.06em;
	position: absolute; top: 8px; left: 8px; padding: 3px 8px;
	background: var(--forest); color: var(--ground); line-height: 16px; text-transform: uppercase;
}
.card .sku-line { margin-top: var(--media-gap); line-height: 1.4; }
.card-name { margin-top: 8px; font-size: 15px; font-weight: 500; line-height: 1.3; }
.card-name a { text-decoration: none; }
.card-name a:hover { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; }
.card-buy { display: flex; flex-direction: column; justify-content: space-between; gap: 10px; padding-top: 16px; } /* the button at the row's foot: a sold-out line or a sale price never staggers the buttons */
.card-price { font-family: var(--font-mono); font-weight: 300; letter-spacing: -0.02em; font-size: 20px; line-height: 1.2; }
.card-price del { color: var(--quiet); font-size: 0.8em; }
.card-price ins { text-decoration: none; }
.card .btn { width: 100%; min-height: 44px; padding: 10px 8px; }

/* Load more */
.more-row { margin-top: 40px; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.shown { font-size: 13px; line-height: 1.5; color: var(--quiet); }
.load-more { width: 100%; min-height: 47px; padding: 13px 28px; }
.load-more[aria-busy="true"] { opacity: 0.4; cursor: progress; }

.shop-empty { margin-top: 32px; display: flex; flex-direction: column; align-items: flex-start; gap: 24px; color: var(--quiet); }

/* ---------- Tablet 768-1023: three across, Filter panel still on demand ---------- */
@media (min-width: 768px) {
	.product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: 24px; row-gap: 24px; }
	.card-img { aspect-ratio: 302 / 260; }
}

/* ---------- Desktop from 1024: the rail (grid columns 1-3) beside the results (4-12) ---------- */
@media (min-width: 1024px) {
	.shop-head { padding-block: 72px; }
	.shop-title-col { margin-top: 48px; }

	.browse { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--col-gap); align-items: start; padding-bottom: 72px; }
	.results { display: flex; flex-direction: column; min-width: 0; grid-column: 4 / -1; grid-row: 1; }
	.browse::before { display: block; grid-column: 4; grid-row: 1; } /* the rule: rail | grid (main.css) */
	.filters, .filters[hidden], .js:not(.shop-ready) .filters { display: flex; grid-column: 1 / 4; grid-row: 1; flex-direction: column; gap: 40px; margin-top: 0; box-shadow: none; }

	.filter-btn { display: none; }
	.sort-btn { font-size: 11px; }

	.facet, .facet + .facet { padding: 0; box-shadow: none; }
	.facet-head { align-items: flex-start; height: 32px; padding-bottom: 16px; box-shadow: inset 0 -1px 0 var(--line); }
	.facet-toggle { font-size: 11px; line-height: 1.45; cursor: default; }
	.facet-toggle:disabled { color: var(--sage-deep); }
	.facet-toggle::after { display: none; }
	.facet-count, .facet-glyph { display: none; }
	.facet-body, .facet-body[hidden] { display: block; margin-top: 16px; }
	.facet-list { gap: 16px; }
	.facet-row { padding-block: 8px; margin-block: -8px; }
	.facet-more { margin-top: 12px; padding-top: 4px; } /* 16 above the text; the hit area starts below the last row's (8 px) */

	.product-grid { margin-top: 24px; column-gap: var(--col-gap); }
	.card-badge { top: 12px; left: 12px; padding: 4px 10px; }
	.card .sku-line { line-height: 16px; }
	.card-name { font-size: 16px; line-height: 1.5; }
	.card-buy { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; }
	.card-price { line-height: 1.3; }
	.card .btn { width: auto; flex: none; padding: 10px 24px; }

	.more-row { margin-top: 24px; flex-direction: row; justify-content: space-between; gap: 20px; }
	.load-more { width: auto; min-height: 45px; padding: 12px 28px; }
}
