/* Shop, category/tag/brand archives and product search (Concept B §4.2, §4.4). */

/* ---------- Breadcrumb: Yoast's "Use Yoast SEO breadcrumbs" setting replaces our
   woocommerce_breadcrumb() markup (.bb-crumbs) with its own (.breadcrumb-trail);
   style it to match either way. ---------- */
.breadcrumb.woo-breadcrumbs { margin: 0 0 16px; font-size: .875rem; color: var(--bb-muted); }
.breadcrumb.woo-breadcrumbs a { color: #333; text-decoration: underline; text-decoration-color: var(--bb-border-2); text-underline-offset: 3px; } /* QA A11Y-08 */
.breadcrumb.woo-breadcrumbs a:hover { text-decoration: underline; }
.breadcrumb.woo-breadcrumbs .breadcrumb_last { color: var(--bb-ink); font-weight: 600; }

/* ---------- Title row, chips ---------- */
/* Gary: clear margin between the title row (incl. the weekly banner, when
   present) and the content below it, at every width. */
.bb-archive__head { margin-bottom: 28px; }
.bb-archive__headrow { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 20px; }
.bb-archive__headtext { min-width: 0; flex: 1 1 320px; }
.bb-archive__sub { margin: 0; color: var(--bb-muted); font-size: .9375rem; }
.bb-archive__desc { color: var(--bb-muted); }
.bb-archive__desc p { display: inline; margin: 0; }
.bb-archive__avgbadge { display: flex; align-items: center; gap: 16px; flex: none; max-width: 320px; padding: 14px 18px; border-radius: var(--bb-r-tile); background: var(--bb-yellow); }
.bb-archive__avgfig { font-family: var(--bb-font-display); font-size: 1.875rem; font-weight: 800; color: var(--bb-ink); line-height: 1; }
.bb-archive__avgtext { font-size: .8125rem; font-weight: 600; color: var(--bb-ink); }
.bb-archive__chips { margin-top: 18px; }
.bb-archive__chiplist { display: flex; flex-wrap: wrap; gap: 8px; }
.bb-search__kicker { margin: 0 0 4px; color: var(--bb-muted); font-size: .875rem; }

/* ---------- Two-column layout ---------- */
.bb-archive__layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 28px; align-items: start; }
.bb-archive__sidebar { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 4px; }
.bb-archive__sidebar h2 { font-size: 1.375rem; margin-bottom: 4px; }
.bb-archive__filterbtn { display: none; margin-bottom: 16px; }
.bb-archive__products { min-width: 0; }

/* ---------- Filter fields (shared: desktop sidebar + mobile dialog) ---------- */
.bb-archive__checkrow { display: flex; align-items: center; gap: 10px; min-height: 32px; font-size: .875rem; cursor: pointer; }
.bb-archive__checkrow input { width: 18px; height: 18px; flex: none; }
.bb-archive__checklabel { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bb-archive__checkcount { flex: none; width: 36px; text-align: right; color: var(--bb-muted); font-size: .8125rem; }
.bb-archive__showmore { margin-top: 4px; padding: 0; border: 0; background: transparent; color: var(--bb-ink); font: 600 .875rem var(--bb-font-body); cursor: pointer; }
.bb-archive__showmore:hover { text-decoration: underline; }
.bb-archive__filterbtns { display: flex; gap: 10px; margin-top: 6px; }
.bb-archive__filterbtns .bb-btn--block { flex: 1; }
fieldset.bb-field { border: 0; padding: 0; margin: 0 0 18px; }
fieldset.bb-field legend.bb-label { padding: 0; margin-bottom: 10px; }

/* ---------- Mobile filter dialog ---------- */
.bb-archive__filterdialog { width: min(420px, calc(100vw - 32px)); }

/* ---------- Toolbar: pills + sort ---------- */
.bb-archive__toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.bb-archive__pills { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; flex: 1 1 auto; min-width: 0; }
.bb-archive__pill { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 14px; border: 1px solid var(--bb-border); border-radius: var(--bb-r-pill); background: var(--bb-surface); color: var(--bb-ink); font-size: .875rem; font-weight: 600; text-decoration: none; }
.bb-archive__pill:hover { border-color: var(--bb-ink); }
.bb-archive__pill .bb-icon { width: 14px; height: 14px; }
.bb-archive__clearall { padding: 0 4px; border: 0; background: transparent; color: var(--bb-ink); font-weight: 700; font-size: .875rem; text-decoration: none; }
.bb-archive__clearall:hover { text-decoration: underline; }
/* C9: with no pills rendered (no filter active), "justify-content: space-between" on a
   single remaining flex item left Sort by stuck on the left instead of the right. */
.bb-archive__sort { display: flex; align-items: center; gap: 10px; flex: none; margin-left: auto; }
.bb-archive__sort label { font-size: .875rem; font-weight: 600; white-space: nowrap; }
.bb-archive__sort select { min-width: 200px; min-height: 40px; font: 600 .875rem var(--bb-font-body); }

/* ---------- Load more ---------- */
.bb-archive__loadmore { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 32px; text-align: center; }
.bb-archive__count { margin: 0; color: var(--bb-muted); font-size: .875rem; font-weight: 600; }
.bb-archive__progress { width: min(280px, 100%); height: 6px; border-radius: var(--bb-r-pill); background: var(--bb-border-2); overflow: hidden; }
.bb-archive__morebtn { min-width: 220px; min-height: var(--bb-touch, 44px); margin-top: 4px; }
.bb-archive__done { margin: 0; color: var(--bb-muted); font-size: .875rem; }
.bb-archive__loader { display: inline-flex; align-items: center; gap: 10px; padding: 10px 18px; border-radius: var(--bb-r-pill); background: var(--bb-surface); border: 1px solid var(--bb-border); font-size: .875rem; font-weight: 600; }
.bb-archive__loader[hidden], .bb-archive__done[hidden], .bb-archive__morebtn[hidden] { display: none; }
.bb-archive__spinner { width: 18px; height: 18px; border: 2.5px solid var(--bb-border-2); border-top-color: var(--bb-ink); border-radius: 50%; animation: bb-spin .7s linear infinite; }
@keyframes bb-spin { to { transform: rotate(360deg); } }
/* Newly appended cards fade up gently. */
.bb-appear { animation: bb-appear .35s var(--bb-ease) both; }
@keyframes bb-appear { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
	.bb-appear { animation: none; }
	.bb-archive__spinner { animation-duration: 1.6s; }
}
.bb-archive__progressbar { height: 100%; background: var(--bb-ink); transition: width .25s var(--bb-ease); }

/* ---------- Weekly deals banner ----------
   Gary's follow-up moved this up beside the H1 (template-parts/archive/head.php's
   own .bb-archive__weeklybanner, real bbt_weekly() data). The bb-weekly-deals
   plugin's own copy (hooked on woocommerce_before_shop_loop via an anonymous
   closure - can't be remove_action()'d from this area's files) still renders
   in the product column; hidden here so the two don't duplicate. */
.bb-archive__products .bbwd.bbwd-compact { display: none; }

.bb-archive__weeklybanner {
	/* Gary: one compact line - label, items, was → now, save - to save height. */
	display: flex; flex-wrap: nowrap; align-items: center; gap: 14px;
	flex: 0 1 auto; align-self: flex-start;
	padding: 10px 12px 10px 18px; border-radius: var(--bb-r-pill);
	background: var(--bb-ink); color: #fff; font-size: .875rem; white-space: nowrap;
}
.bb-archive__weeklybanner > span + span:not(.bb-archive__weeklybanner-save)::before { content: ""; display: inline-block; width: 1px; height: 14px; margin-right: 14px; background: rgba(255, 255, 255, .25); vertical-align: -2px; }
.bb-archive__weeklybanner-kicker { font-family: var(--bb-font-display); font-weight: 800; font-size: .9375rem; color: var(--bb-yellow); }
.bb-archive__weeklybanner-items { color: #ddd; }
.bb-archive__weeklybanner-prices s { color: #bbb; }
.bb-archive__weeklybanner-prices b { color: #fff; }
.bb-archive__weeklybanner-save { padding: 3px 10px; border-radius: var(--bb-r-small); background: var(--bb-yellow); color: var(--bb-ink); font-weight: 800; }
@media (max-width: 1024px) {
	.bb-archive__weeklybanner { align-self: center; }
}
/* Phones: allow a second line, still compact. */
@media (max-width: 600px) {
	.bb-archive__weeklybanner { flex-wrap: wrap; gap: 6px 12px; border-radius: var(--bb-r-tile); white-space: normal; }
	.bb-archive__weeklybanner > span + span:not(.bb-archive__weeklybanner-save)::before { display: none; }
	.bb-archive__weeklybanner-kicker { flex-basis: 100%; }
}

/* ---------- Trust banner ---------- */
.bb-archive__trust { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 20px; margin-top: var(--bb-section); }
.bb-archive__trusttext strong { color: var(--bb-yellow); font-size: 1.375rem; }
.bb-archive__trusttext p { margin: 6px 0 0; color: #ddd; }

/* ---------- Search: filter bar, cross-sell, empty state ---------- */
.bb-search__head { margin-bottom: 16px; }
/* S1: 40px, not the global h1 clamp's 44px at this width. */
.bb-search__head .bb-pagehead__title { font-size: 2.5rem; }
.bb-search__sort { display: flex; flex-direction: column; gap: 4px; flex: none; }
.bb-search__sort label { font-size: .875rem; font-weight: 600; }
.bb-search__sort select { min-width: 220px; min-height: 44px; }
.bb-search__filterbar { display: flex; flex-wrap: wrap; align-items: end; gap: 16px; margin-bottom: 20px; }
.bb-search__field { display: flex; flex-direction: column; gap: 6px; min-width: 160px; }
.bb-search__field label { font-size: .875rem; font-weight: 600; }
.bb-search__field select { min-height: 44px; }
.bb-search__pricepair { display: flex; gap: 8px; }
.bb-search__pricepair input { width: 90px; min-height: 44px; }
.bb-search__crosshead { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin: var(--bb-section) 0 16px; }
.bb-search__crosshead h2 { margin: 0; font-size: 1.5rem; }
.bb-search__empty { text-align: center; margin-top: 24px; }
.bb-search__empty h2 { font-size: 1.75rem; margin-bottom: 8px; }
.bb-search__empty p { max-width: 520px; margin-inline: auto; }

/* ---------- S6/W4: "Can't find it? get alerts" panel ---------- */
.bb-search__alert { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: center; margin-top: 32px; }
.bb-search__alert-text h2 { margin: 0; font-size: 1.5rem; }
.bb-search__alert-form { background: #fff; border-radius: var(--bb-r-panel); padding: 18px 20px; }
@media (max-width: 767px) {
	.bb-search__alert { grid-template-columns: 1fr; text-align: left; }
}

/* ================= Responsive ================= */
@media (max-width: 1024px) {
	.bb-archive__layout { grid-template-columns: 240px minmax(0, 1fr); gap: 20px; }
}
@media (max-width: 767px) {
	.bb-archive__avgbadge { width: 100%; }
	/* C14: .bb-archive__headtext's flex-basis of 320px (written for the desktop
	   ROW layout, where it set a width) became a 320px-tall floor on the
	   mobile COLUMN layout once flex-direction switched - a ~280px empty gap
	   between the item count and the sub-category chips below it. */
	.bb-archive__headrow { flex-direction: column; align-items: stretch; }
	.bb-archive__headtext { flex-basis: auto; }
	.bb-archive__layout { grid-template-columns: 1fr; }
	.bb-archive__sidebar { display: none; }
	.bb-archive__filterbtn { display: inline-flex; width: 100%; justify-content: center; }
	.bb-archive__toolbar { flex-direction: column; align-items: stretch; }
	.bb-archive__sort { justify-content: space-between; }
	.bb-archive__sort select { flex: 1; min-width: 0; }
	.bb-archive__pill, .bb-archive__clearall { min-height: 40px; }
	.bb-archive__trust { flex-direction: column; align-items: flex-start; }
	.bb-search__filterbar { flex-direction: column; align-items: stretch; }
	.bb-search__field, .bb-search__field select { width: 100%; min-width: 0; }
	.bb-search__pricepair input { width: 0; flex: 1; }
	.bb-search__head .bb-archive__headrow { flex-direction: column; align-items: stretch; }
	.bb-search__sort select { width: 100%; }
}
@media (max-width: 359px) {
	.bb-archive__avgfig { font-size: 1.5rem; }
}

/* Weekly deals: minimal newsletter link under the savings bar (Gary). */
.bb-archive__weeklyside { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; align-self: flex-start; }
.bb-archive__weeklyside .bb-archive__weeklybanner { align-self: auto; }
.bb-archive__weeklysub { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; color: var(--bb-muted); font-size: .8125rem; text-decoration: none; }
.bb-archive__weeklysub svg { color: var(--bb-ink); }
.bb-archive__weeklysub strong { color: var(--bb-ink); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.bb-archive__weeklysub:hover strong { text-decoration-thickness: 2px; }
@media (max-width: 1024px) { .bb-archive__weeklyside { align-items: flex-start; align-self: stretch; } }
@media (max-width: 600px) { .bb-archive__weeklyside { align-items: stretch; } .bb-archive__weeklysub { flex-wrap: wrap; } }

/* ================= Toolbar v2: results count, view toggle, custom sort ================= */

/* Toolbar: an optional pills+clear row, then ONE row with the results count and the
   view+sort controls side by side, vertically centred (Gary: same line, not stacked). */
.bb-archive__toolbar { align-items: stretch; flex-direction: column; }
.bb-archive__toolbar-row,
.bb-search__toolbar-row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	width: 100%;
}
.bb-archive__resultscount { margin: 0; color: var(--bb-muted); font-size: .875rem; font-weight: 600; }
.bb-archive__toolbar-controls { display: flex; align-items: center; gap: 12px; flex: none; margin-left: auto; }

/* ---------- Grid / list view toggle ---------- */
.bb-archive__viewtoggle { display: inline-flex; align-items: center; gap: 2px; flex: none; padding: 3px; border: 1px solid var(--bb-border); border-radius: var(--bb-r-control); background: var(--bb-surface); }
.bb-archive__viewbtn { display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: calc(var(--bb-r-control) - 3px); background: transparent; color: var(--bb-muted); cursor: pointer; transition: background-color .15s var(--bb-ease), color .15s var(--bb-ease); }
.bb-archive__viewbtn:hover { color: var(--bb-ink); }
.bb-archive__viewbtn[aria-pressed="true"] { background: var(--bb-ink); color: var(--bb-yellow); }

/* ---------- Custom sort control (button + listbox), native <select> is the no-JS fallback ---------- */
.bb-archive__sort { position: relative; }
.bb-archive__sort--enhanced { display: block; }
.bb-archive__sort--enhanced > label,
.bb-archive__sort--enhanced > select { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.bb-archive__sortbtn { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; min-width: 200px; padding: 0 14px; border: 1.5px solid var(--bb-border); border-radius: var(--bb-r-control); background: var(--bb-surface); color: var(--bb-ink); font: 600 .875rem var(--bb-font-body); cursor: pointer; transition: border-color .15s var(--bb-ease); }
.bb-archive__sortbtn:hover { border-color: var(--bb-ink); }
.bb-archive__sort--enhanced .bb-archive__sortbtn[aria-expanded="true"] { border-color: var(--bb-ink); box-shadow: 0 0 0 3px rgba(255, 207, 2, .55); }
.bb-archive__sortprefix { color: var(--bb-muted); font-weight: 600; }
.bb-archive__sortcurrent { flex: 1; text-align: left; color: var(--bb-ink); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bb-archive__sortchev { flex: none; width: 10px; height: 10px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translateY(-2px); color: var(--bb-muted); transition: transform .2s var(--bb-ease); }
.bb-archive__sortbtn[aria-expanded="true"] .bb-archive__sortchev { transform: rotate(225deg) translateY(-2px); }
.bb-archive__sortlist { position: absolute; z-index: 20; top: calc(100% + 6px); right: 0; min-width: 100%; max-height: min(60vh, 360px); margin: 0; padding: 6px; overflow-y: auto; list-style: none; border: 1px solid var(--bb-border); border-radius: var(--bb-r-tile); background: var(--bb-surface); box-shadow: var(--bb-shadow), 0 16px 40px -16px rgba(17, 17, 17, .25); }
.bb-archive__sortoption { padding: 10px 12px; border-radius: var(--bb-r-small); font-size: .875rem; font-weight: 600; color: var(--bb-ink); white-space: nowrap; cursor: pointer; }
.bb-archive__sortoption:hover { background: var(--bb-ground); }
.bb-archive__sortoption:focus, .bb-archive__sortoption:focus-visible { outline: none; background: var(--bb-selected); }
.bb-archive__sortoption[aria-selected="true"] { background: var(--bb-pale-yellow); font-weight: 800; }

/* ---------- Dual-handle price slider (replaces visible min/max boxes) ---------- */
.bb-archive__pricefilter .bb-label { margin-bottom: 10px; }
.bb-archive__pricerange { display: block; }
.bb-archive__pricelabel { margin: 0 0 14px; font-weight: 800; color: var(--bb-ink); font-size: 1rem; }
.bb-archive__slider { position: relative; height: 24px; margin: 0 2px; }
.bb-archive__slidertrack { position: absolute; left: 0; right: 0; top: 50%; height: 4px; margin-top: -2px; border-radius: var(--bb-r-pill); background: var(--bb-border-2); cursor: pointer; }
.bb-archive__sliderrange { position: absolute; top: 0; bottom: 0; border-radius: var(--bb-r-pill); background: var(--bb-yellow); }
.bb-archive__sliderthumb { position: absolute; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; background: var(--bb-ink); border: 3px solid var(--bb-surface); box-shadow: 0 1px 4px rgba(17, 17, 17, .35); cursor: grab; touch-action: none; }
.bb-archive__sliderthumb:hover { transform: scale(1.08); }
.bb-archive__sliderthumb:active { cursor: grabbing; }
.bb-archive__sliderthumb:focus-visible { outline: 3px solid var(--bb-ink); outline-offset: 3px; }

/* ---------- Grid / list view ---------- */
/* More specific than main.css's ".bb-grid, ul.products" base rule, so it wins at every width. */
.bb-archive__products.is-list-view .products,
.bb-archive__products.is-list-view.bb-grid { display: flex; flex-direction: column; gap: 12px; grid-template-columns: none; }

.bb-card--row { flex-direction: row; align-items: stretch; height: auto; }
.bb-card--row .bb-card__media { flex: 0 0 150px; width: 150px; height: 140px; align-self: center; }
.bb-card--row .bb-card__body {
	flex: 1; display: grid;
	grid-template-columns: minmax(0, 1fr) 160px;
	grid-template-rows: auto auto auto;
	column-gap: 18px; row-gap: 2px;
	align-items: center;
	padding: 14px 16px;
}
.bb-card--row .bb-card__brand { grid-column: 1; grid-row: 1; }
.bb-card--row .bb-card__name { grid-column: 1; grid-row: 2; -webkit-line-clamp: 1; min-height: 0; }
.bb-card--row .bb-card__meta { grid-column: 1; grid-row: 3; justify-content: flex-start; }
.bb-card--row .bb-card__price { grid-column: 2; grid-row: 1 / 3; flex-direction: column; align-items: flex-end; justify-self: end; align-self: center; }
.bb-card--row .bb-card__action { grid-column: 2; grid-row: 3; justify-self: end; align-self: end; width: 100%; margin-top: 0; padding-top: 0; }

@media (max-width: 480px) {
	.bb-card--row .bb-card__media { flex-basis: 96px; width: 96px; height: 96px; }
	.bb-card--row .bb-card__body { grid-template-columns: 1fr; padding: 8px 10px; }
	.bb-card--row .bb-card__brand { grid-column: 1; grid-row: 1; }
	.bb-card--row .bb-card__name { grid-column: 1; grid-row: 2; }
	.bb-card--row .bb-card__price { grid-column: 1; grid-row: 3; flex-direction: row; align-items: baseline; justify-self: start; }
	.bb-card--row .bb-card__meta { grid-column: 1; grid-row: 4; }
	.bb-card--row .bb-card__action { grid-column: 1; grid-row: 5; justify-self: stretch; }
}

/* ---------- Search page: reuses the same toolbar controls/classes ---------- */
.bb-search__toolbar-controls { display: flex; align-items: center; gap: 12px; flex: none; }
.bb-search__sort { min-width: 0; }
.bb-search__sort select { min-width: 200px; }
.bb-search__field--price { min-width: 240px; flex: 1 1 240px; }

@media (max-width: 767px) {
	.bb-archive__toolbar-controls { width: 100%; justify-content: space-between; margin-left: 0; }
	.bb-archive__sortbtn { min-width: 0; flex: 1; }
	.bb-search__head .bb-archive__headrow { align-items: stretch; }
	.bb-search__toolbar-controls { width: 100%; justify-content: space-between; }
	/* Phones: grid stays 2-up (main.css); list stays the explicit 1-up rows above. */
}
@media (max-width: 400px) {
	.bb-archive__sortlist { left: 0; right: 0; min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
	.bb-archive__sliderthumb, .bb-archive__sortchev, .bb-archive__viewbtn { transition: none; }
}
