/**
 * Shop enhancements for Leopard Controls.
 *
 *   1. Collapsible product-category sidebar
 *   2. Content-area breadcrumb trail
 *   3. "Recently Viewed" row at the bottom of the page
 *
 * Deliberately additive: everything is scoped to the classes added by
 * shop-sidebar.js / the child theme's PHP, so no existing Bridge styling is
 * overridden and nothing changes if these features are removed.
 *
 * @package Bridge Child
 */

/* Fallback only -- Bridge already ships .screen-reader-text, but this file may
   load in contexts where it does not. */
.lc-cat-toggle .screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect( 0, 0, 0, 0 );
	white-space: nowrap;
	border: 0;
}

/* ------------------------------------------------------------------
 * 1. Collapsible category sidebar
 * ----------------------------------------------------------------*/

/*
 * Undo the legacy "only ever show the brand you are already in" rule. The
 * site's saved custom CSS (theme options, not a file) contains:
 *
 *   .woocommerce aside .widget ul.product-categories li.cat-parent { display: none; }
 *   .woocommerce aside .widget ul.product-categories li.cat-parent.current-cat,
 *   .woocommerce aside .widget ul.product-categories li.cat-parent.current-cat-parent { display: block; }
 *
 * ...which is precisely the behaviour the collapsible sidebar replaces: every
 * brand should be listed, each one expandable. That rule scores (0,4,3), so the
 * selector below deliberately carries one extra class to outrank it.
 *
 * Scoping to .lc-collapsible means this only takes effect once the JS has run.
 * If the script fails to load, the sidebar falls back to today's live behaviour
 * rather than dumping every brand out fully expanded.
 */
.woocommerce aside .widget.lc-collapsible ul.product-categories li.cat-parent {
	display: block;
}

/* Top-level rows get a divider, matching the sidebar design. */
.widget_product_categories > ul.product-categories > li.cat-item {
	position: relative;
	padding: 8px 0;
	border-bottom: 1px solid rgba( 0, 0, 0, 0.12 );
}

.widget_product_categories > ul.product-categories > li.cat-item:last-child {
	border-bottom: 0;
}

/* Leave room for the toggle button on the right. */
.widget_product_categories.lc-collapsible li.lc-has-toggle > a {
	display: inline-block;
	padding-right: 28px;
}

/* The current category reads as the active one. */
.widget_product_categories li.current-cat > a {
	font-weight: 700;
}

/* Collapsed by default once JS has taken over; .lc-open reveals. */
.widget_product_categories.lc-collapsible li.lc-has-toggle > ul.children {
	display: none;
}

.widget_product_categories.lc-collapsible li.lc-has-toggle.lc-open > ul.children {
	display: block;
}

.widget_product_categories ul.children {
	margin: 6px 0 2px;
	padding-left: 14px;
}

.widget_product_categories ul.children li.cat-item {
	padding: 3px 0;
	font-size: 0.9em;
	text-transform: uppercase;
	letter-spacing: 0.02em;
}

/* Toggle control: a real <button> so it is keyboard reachable. The arrow is
   drawn here rather than in markup so screen readers get words, not glyphs. */
.lc-cat-toggle {
	position: absolute;
	top: 6px;
	right: 0;
	width: 26px;
	height: 26px;
	padding: 0;
	background: none;
	border: 0;
	cursor: pointer;
	color: inherit;
	line-height: 1;
}

.lc-cat-toggle::after {
	content: "";
	display: block;
	width: 7px;
	height: 7px;
	margin: 0 auto;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: translateY( -2px ) rotate( 45deg ); /* points down = collapsed */
	transition: transform 0.18s ease;
}

.lc-has-toggle.lc-open > .lc-cat-toggle::after {
	transform: translateY( 2px ) rotate( -135deg ); /* points up = expanded */
}

.lc-cat-toggle:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/* ------------------------------------------------------------------
 * 2. Content-area breadcrumb trail
 * ----------------------------------------------------------------*/

.lc-shop-trail {
	margin: 0 0 22px;
	font-size: 14px;
	line-height: 1.5;
}

/*
 * The theme's global link colour is the brand yellow (#ffe100), which fails
 * contrast badly on the white content background -- the crumbs were close to
 * unreadable. Force the dark body colour instead and lean on the underline for
 * hover affordance.
 */
.lc-shop-trail a,
.lc-shop-trail a:link,
.lc-shop-trail a:visited {
	color: #231f20;
	text-decoration: none;
}

.lc-shop-trail a:hover,
.lc-shop-trail a:focus {
	color: #000;
	text-decoration: underline;
}

.lc-shop-trail__sep {
	margin: 0 8px;
	opacity: 0.5;
}

.lc-shop-trail__current {
	font-weight: 700;
}

/* ------------------------------------------------------------------
 * 3. Recently Viewed row
 * ----------------------------------------------------------------*/

.lc-recently-viewed {
	clear: both;
	margin: 48px 0 0;
	padding-top: 24px;
	border-top: 1px solid rgba( 0, 0, 0, 0.12 );
}

.lc-recently-viewed__title {
	margin: 0 0 18px;
	font-size: 18px;
}

/* Let WooCommerce's own .products grid do the layout so these cards match the
   rest of the shop; we only need it to breathe a little less than the main loop. */
.lc-recently-viewed ul.products {
	margin: 0;
}

.lc-recently-viewed ul.products li.product {
	margin-bottom: 1em;
}
