/*
 * Sidebar widgets (blog): core/search, core/categories, core/latest-posts, core/tag-cloud and a vertical
 * core/navigation, each under a heading with a light strip on its left. Core's markup is kept as it is;
 * these rules only style it. Lists get a small chevron before each item.
 * shop (Category-list-sidebar): the same search, list and chip widgets over the product taxonomies, the store's
 * price slider (a 3px bar, 9px handles) and the newest products as 120×165 tiles in two columns, 23 apart.
 * Below the tablet breakpoint the sidebar sits under the content: two widget columns, one on mobile.
 */
:where(.rt-sidebar-widgets) {
	color: var(--rt-color-contrast);
}

.rt-sidebar-widgets {
	--rt-sidebar-widgets-gap: 3.3125rem;
	--rt-sidebar-widgets-indent: 2rem;
	--rt-sidebar-widgets-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 5 8'%3E%3Cpath d='M.5.5 4 4 .5 7.5' fill='none' stroke='%23000' stroke-width='1.2'/%3E%3C/svg%3E");
	display: flex;
	flex-direction: column;
	gap: var(--rt-sidebar-widgets-gap);
	font-family: var(--rt-font-family-body);
	font-size: var(--rt-font-size-base);
	font-weight: var(--rt-font-weight-medium);
	line-height: 1.5;
}

/* Widgets after another widget sit a little further apart than the first one after the search box. */
.rt-sidebar-widgets__widget + .rt-sidebar-widgets__widget {
	padding-block-start: 1.1875rem;
}

.rt-sidebar-widgets a {
	color: inherit;
	text-decoration: none;
	text-underline-offset: 0.1875rem;
}

.rt-sidebar-widgets .rt-sidebar-widgets__title {
	display: flex;
	align-items: center;
	min-height: 3.75rem;
	margin: 0;
	padding-inline-start: 1.875rem;
	background: linear-gradient(to right, var(--rt-sidebar-widgets-strip) 0.625rem, transparent 0.625rem);
	color: var(--rt-color-contrast);
	font-family: var(--rt-font-family-body);
	font-size: var(--rt-font-size-medium);
	font-weight: var(--rt-font-weight-bold);
	line-height: var(--rt-line-height-heading);
}

/* Search: a panel with a darker edge, the placeholder reads as the widget's title. In the original theme the search block's Panel
   style draws it (wp-bridge.css), so these reference rules sit in :where(). */
:where(.rt-sidebar-widgets__search > div) {
	display: flex;
	align-items: center;
	min-height: 3.75rem;
	background: var(--rt-sidebar-widgets-panel);
	border-inline-start: 0.625rem solid var(--rt-sidebar-widgets-edge);
}

:where(.rt-sidebar-widgets__search input) {
	flex: 1;
	min-width: 0;
	margin: 0;
	padding: 0 0 0 1.1875rem;
	border: 0;
	background: transparent;
	color: var(--rt-color-contrast);
	font: inherit;
	font-size: var(--rt-font-size-medium);
	font-weight: var(--rt-font-weight-bold);
}

:where(.rt-sidebar-widgets__search input::placeholder) {
	color: var(--rt-color-contrast);
	opacity: 1;
}

:where(.rt-sidebar-widgets__search input:focus) {
	outline: none;
}

:where(.rt-sidebar-widgets__search > div:focus-within) {
	outline: 1px solid var(--rt-color-contrast);
}

:where(.rt-sidebar-widgets__search button) {
	display: flex;
	align-items: center;
	justify-content: center;
	margin: 0;
	padding: 0 1.25rem;
	border: 0;
	background: transparent;
	color: var(--rt-color-contrast);
	cursor: pointer;
}

/* The original theme's search button icon: 24px */
:where(.rt-sidebar-widgets__search svg) {
	width: 1.5rem;
	height: 1.5rem;
	fill: currentColor;
}

/* Lists: categories, latest posts, menu. Vertical spacing is padding: the the original theme bridge resets group children's margins. */
.rt-sidebar-widgets__categories,
.rt-sidebar-widgets__recent,
.rt-sidebar-widgets__menu ul {
	margin: 0;
	padding: 0;
	list-style: none;
}

.rt-sidebar-widgets .rt-sidebar-widgets__categories,
.rt-sidebar-widgets nav.rt-sidebar-widgets__menu {
	padding-block-start: var(--rt-spacing-40);
	padding-inline-start: var(--rt-sidebar-widgets-indent);
}

/* core/navigation also prints the class on its inner list, hence nav. */
.rt-sidebar-widgets nav.rt-sidebar-widgets__menu {
	font-family: var(--rt-font-family-body);
	font-size: var(--rt-font-size-base);
	font-weight: var(--rt-font-weight-medium);
	line-height: 1.5;
}

.rt-sidebar-widgets__categories li,
.rt-sidebar-widgets__recent li,
.rt-sidebar-widgets__menu li {
	position: relative;
	margin: 0;
	padding-inline-start: 1.3125rem;
}

.rt-sidebar-widgets__categories li + li,
.rt-sidebar-widgets__menu li + li {
	margin-block-start: 0.875rem;
}

.rt-sidebar-widgets__categories li::before,
.rt-sidebar-widgets__recent li::before,
.rt-sidebar-widgets__menu li::before {
	content: "";
	position: absolute;
	inset-inline-start: 0;
	top: 0.5rem;
	width: 0.3125rem;
	height: 0.5rem;
	background: currentColor;
	-webkit-mask: var(--rt-sidebar-widgets-chevron) center / contain no-repeat;
	mask: var(--rt-sidebar-widgets-chevron) center / contain no-repeat;
}

.rt-sidebar-widgets__categories a:hover,
.rt-sidebar-widgets__categories a:focus-visible,
.rt-sidebar-widgets__categories a[aria-current],
.rt-sidebar-widgets__menu a:hover,
.rt-sidebar-widgets__menu a:focus-visible,
.rt-sidebar-widgets__menu a[aria-current] {
	text-decoration: underline;
}

/* Menu: submenus stay open as an indented list. */
.rt-sidebar-widgets__menu li ul {
	margin-block-start: 0.8125rem;
	padding-inline-start: 0.125rem;
}

.rt-sidebar-widgets__menu li li + li {
	margin-block-start: 0.625rem;
}

/* Latest posts: title, then core's author and date lines in small type; a cream row on hover. */
.rt-sidebar-widgets .rt-sidebar-widgets__recent {
	padding-block-start: 0.5625rem;
	padding-inline-start: 0.625rem;
}

.rt-sidebar-widgets__recent li {
	display: flex;
	flex-wrap: wrap;
	column-gap: var(--rt-spacing-20);
	padding: 0.9375rem 0.3125rem 0.9375rem 2.6875rem;
	transition: background-color 0.2s ease;
}

.rt-sidebar-widgets__recent li + li {
	margin-block-start: 0.3125rem;
}

.rt-sidebar-widgets__recent li::before {
	inset-inline-start: 1.375rem;
	top: 1.4375rem;
}

.rt-sidebar-widgets__recent li:hover,
.rt-sidebar-widgets__recent li:focus-within {
	background: var(--rt-sidebar-widgets-hover);
}

.rt-sidebar-widgets__recent li > a {
	flex-basis: 100%;
}

/* Author and date: core/latest-posts' own size (0.8125em: 13px) and line height 1.5 */
.rt-sidebar-widgets__recent li > :not(a) {
	margin: 0.25rem 0 0;
	color: var(--rt-color-body);
	font-size: 0.8125em;
	line-height: 1.5;
}

/* Tags: one font size (block setting), chips on a light panel; dark on hover. */
.rt-sidebar-widgets .rt-sidebar-widgets__tags {
	display: flex;
	flex-wrap: wrap;
	gap: 0.625rem;
	margin: 0;
	padding: 1.875rem 0 0;
	padding-inline-start: var(--rt-sidebar-widgets-indent);
}

.rt-sidebar-widgets__tags a {
	display: inline-block;
	padding: 0.8125rem 1.5625rem;
	background: var(--rt-sidebar-widgets-strip);
	color: var(--rt-color-contrast);
	font-size: var(--rt-font-size-base);
	line-height: 1.5rem;
	transition: background-color 0.2s ease, color 0.2s ease;
}

.rt-sidebar-widgets__tags a:hover,
.rt-sidebar-widgets__tags a:focus-visible {
	background: var(--rt-color-contrast);
	color: var(--rt-color-base);
}

/* Shop: price filter. The store's slider without the text inputs; the bar and handles in the text colour. */
.rt-sidebar-widgets .rt-sidebar-widgets__price {
	--wc-product-filter-price-slider: var(--rt-color-contrast);
	--wc-product-filter-price-slider-handle: var(--rt-color-contrast);
	--wc-product-filter-price-slider-handle-border: var(--rt-color-contrast);
	padding-block-start: var(--rt-spacing-40);
	padding-inline-start: var(--rt-sidebar-widgets-indent);
	color: var(--rt-color-contrast);
	font-size: var(--rt-font-size-x-small);
}

/*
 * The store's slider (product-filter-price-slider-style.css, which the original theme loads): the bar between the handles in
 * the slider colour, the rest of the track at 30%, round handles, the bounds under the ends. The reference has no
 * The store stylesheet, so the same rules sit here.
 */
.rt-sidebar-widgets__price .wc-block-product-filter-price-slider__content {
	display: grid;
	grid-template-areas: "price-slider price-slider price-slider" "left-input middle-input right-input";
	grid-template-columns: auto 1fr auto;
	column-gap: 12px;
}

.rt-sidebar-widgets__price .wc-block-product-filter-price-slider__left {
	grid-area: left-input;
}

.rt-sidebar-widgets__price .wc-block-product-filter-price-slider__right {
	grid-area: right-input;
}

.rt-sidebar-widgets__price .wc-block-product-filter-price-slider__range {
	--rt-price-range-colour: var(--wc-product-filter-price-slider, currentColor);
	position: relative;
	grid-area: price-slider;
	height: 4px;
	margin: 15px 0;
	border-radius: 4px;
}

.rt-sidebar-widgets__price .wc-block-product-filter-price-slider__range::before {
	position: absolute;
	inset: 0;
	content: "";
	background: var(--rt-price-range-colour);
	opacity: 0.3;
}

.rt-sidebar-widgets__price .wc-block-product-filter-price-slider__range .range-bar {
	position: relative;
	height: 4px;
	background: linear-gradient(to right, transparent var(--low), var(--rt-price-range-colour) 0, var(--rt-price-range-colour) var(--high), transparent 0) no-repeat 0 100% / 100% 100%;
}

.rt-sidebar-widgets__price .wc-block-product-filter-price-slider__range input[type="range"] {
	position: absolute;
	inset-block-start: 0;
	inset-inline-start: 0;
	display: block;
	width: 100%;
	height: 0;
	margin: 0;
	padding: 0;
	border: 0;
	outline: none;
	background: transparent;
	pointer-events: none;
	appearance: none;
}

.rt-sidebar-widgets__price .wc-block-product-filter-price-slider__range input[type="range"]::-webkit-slider-runnable-track {
	height: 1px;
	appearance: none;
	cursor: default;
}

.rt-sidebar-widgets__price .wc-block-product-filter-price-slider__range input[type="range"]::-webkit-slider-thumb {
	box-sizing: content-box;
	width: 12px;
	height: 12px;
	margin: -5px 0 0;
	border: 2px solid var(--wc-product-filter-price-slider-handle-border, currentColor);
	border-radius: 100%;
	background: var(--wc-product-filter-price-slider-handle, currentColor);
	cursor: pointer;
	pointer-events: auto;
	appearance: none;
	transition: transform 0.2s ease-in-out;
}

.rt-sidebar-widgets__price .wc-block-product-filter-price-slider__range input[type="range"]::-moz-range-thumb {
	box-sizing: content-box;
	width: 12px;
	height: 12px;
	border: 2px solid var(--wc-product-filter-price-slider-handle-border, currentColor);
	border-radius: 100%;
	background: var(--wc-product-filter-price-slider-handle, currentColor);
	cursor: pointer;
	pointer-events: auto;
}

.rt-sidebar-widgets__price .wc-block-product-filter-price-slider__range input[type="range"]::-moz-range-track {
	background: none;
}

.rt-sidebar-widgets__price .wc-block-product-filter-price-slider__range input[type="range"]:focus-visible::-webkit-slider-thumb {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/* Shop: newest products, image tile, title and price centred under it. */
.rt-sidebar-widgets .rt-sidebar-widgets__products {
	padding-block-start: 1.875rem;
	padding-inline-start: var(--rt-sidebar-widgets-indent);
}

/* Two columns 20px apart both ways (the store's product template, Columns 2); one column on phones */
.rt-sidebar-widgets__products .wc-block-product-template {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 1.25rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

/* The store sizes flex-layout items with a width (two columns); the grid sizes them here. */
.rt-sidebar-widgets .rt-sidebar-widgets__products .wc-block-product-template > li.wc-block-product {
	width: auto;
	max-width: none;
	margin: 0;
	padding: 0;
	text-align: center;
}

.rt-sidebar-widgets .rt-sidebar-widgets__product-image {
	margin: 0 0 1.3125rem;
	background: var(--rt-sidebar-widgets-panel);
}

.rt-sidebar-widgets__product-image img {
	display: block;
	width: 100%;
	height: auto;
}

.rt-sidebar-widgets .rt-sidebar-widgets__product-title {
	margin: 0;
	color: var(--rt-color-contrast);
	font-family: var(--rt-font-family-body);
	font-size: var(--rt-font-size-x-small);
	font-weight: var(--rt-font-weight-medium);
	line-height: 1.15;
}

.rt-sidebar-widgets__product-title a:hover,
.rt-sidebar-widgets__product-title a:focus-visible {
	text-decoration: underline;
}

.rt-sidebar-widgets .rt-sidebar-widgets__product-price {
	margin: 0.3125rem 0 0;
	color: var(--rt-color-contrast);
	font-size: var(--rt-font-size-x-small);
	font-weight: var(--rt-font-weight-regular);
	line-height: 1.15;
}

/* The sale price without an underline; the struck-through price keeps the price's dark colour (the original theme's product
   price block in the widget) */
.rt-sidebar-widgets__product-price ins {
	text-decoration: none;
}

@media (max-width: 64rem) {
	.rt-sidebar-widgets {
		display: grid;
		grid-template-columns: repeat(2, minmax(0, 1fr));
		/* The original theme's sidebar grid: 72px between the widgets both ways (Block spacing) on tablets and phones */
		gap: 4.5rem;
	}

	/* The search field sits above that grid with the sidebar's own 53px gap */
	.rt-sidebar-widgets__search {
		grid-column: 1 / -1;
		margin-block-end: calc(var(--rt-sidebar-widgets-gap) - 4.5rem);
	}

	.rt-sidebar-widgets__widget + .rt-sidebar-widgets__widget {
		padding-block-start: 0;
	}
}

@media (max-width: 37.5rem) {
	.rt-sidebar-widgets {
		grid-template-columns: minmax(0, 1fr);
	}

	.rt-sidebar-widgets__products .wc-block-product-template {
		grid-template-columns: minmax(0, 1fr);
	}
}

@media (prefers-reduced-motion: reduce) {
	.rt-sidebar-widgets__recent li,
	.rt-sidebar-widgets__tags a {
		transition: none;
	}
}
