/*
 * Shop page — shop, category and tag archives.
 * The layout is built from blocks on the Shop page in wp-admin. This
 * file only adds what block settings can't: the wider page, the look of
 * the collection links, sort dropdown and filter drawer. WooCommerce
 * only uses its drawer on phones, so the rules at the end extend it to
 * every screen size. Card styling lives in product-card.css.
 */

.post-type-archive-product,
.tax-product_cat,
.tax-product_tag {
	--wpr-shop-gutter: clamp(24px, 4.2vw, 48px);
}

:root {
	--wpr-shop-ink: var(--global-palette3);
	--wpr-shop-muted: var(--wpr-muted);
	--wpr-shop-line: rgba(13, 13, 13, 0.1);
	--wpr-shop-gold: var(--global-palette2);
	--wpr-shop-gold-text: var(--wpr-gold-text);
}

.post-type-archive-product .content-container.site-container,
.tax-product_cat .content-container.site-container,
.tax-product_tag .content-container.site-container {
	max-width: 1720px;
	padding-left: var(--wpr-shop-gutter);
	padding-right: var(--wpr-shop-gutter);
}

/* Title area — Kadence's default height pushes the grid below the fold. */
.post-type-archive-product .entry-hero .entry-header,
.tax-product_cat .entry-hero .entry-header,
.tax-product_tag .entry-hero .entry-header {
	min-height: 0;
	padding-top: 80px; /* The same 80/64/48 gap under the header as other pages. */
	padding-bottom: clamp(12px, 2vw, 20px);
}

@media (max-width: 1024px) {
	.post-type-archive-product .entry-hero .entry-header,
	.tax-product_cat .entry-hero .entry-header,
	.tax-product_tag .entry-hero .entry-header {
		padding-top: 64px;
	}
}

@media (max-width: 767px) {
	.post-type-archive-product .entry-hero .entry-header,
	.tax-product_cat .entry-hero .entry-header,
	.tax-product_tag .entry-hero .entry-header {
		padding-top: 48px;
	}
}

.post-type-archive-product .entry-hero .hero-section-overlay,
.tax-product_cat .entry-hero .hero-section-overlay,
.tax-product_tag .entry-hero .hero-section-overlay {
	min-height: 0;
}

.post-type-archive-product .content-area,
.tax-product_cat .content-area,
.tax-product_tag .content-area {
	margin-top: 8px;
}

.wc-block-product-template:not(.is-product-collection-layout-carousel) {
	width: 100%;
	margin-left: 0;
	margin-right: 0;
	padding-left: 0;
}

/* Collection links — the "wpr-collection-nav" Group block on the Shop page */
.wpr-collection-nav {
	gap: 8px 32px;
	margin-bottom: 32px;
}

.wpr-collection-nav p,
.single-content .wpr-collection-nav p {
	margin: 0;
	font-family: 'Montserrat', sans-serif;
	font-size: 14px;
	font-weight: 500;
}

.wpr-collection-nav a {
	display: inline-block;
	padding: 8px 0;
	border-bottom: 1.5px solid transparent;
	color: var(--wpr-shop-muted);
	text-decoration: none;
	transition: color 200ms ease, border-color 200ms ease;
}

.wpr-collection-nav a:hover,
.post-type-archive-product .wpr-collection-nav a[href='/shop/'],
.term-gift-sets .wpr-collection-nav a[href*='gift-sets'],
.term-signature-scents .wpr-collection-nav a[href*='signature-scents'],
.page .wpr-collection-nav a[href='/on-sale/'] {
	border-bottom-color: var(--wpr-shop-gold);
	color: var(--wpr-shop-ink);
}

/* Toolbar — the "wpr-shop-toolbar" Group block on the Shop page */
.wpr-shop-toolbar {
	align-items: center;
	gap: 20px;
	margin-bottom: 32px;
	padding: 6px 0;
	border-top: 1px solid var(--wpr-shop-line);
	border-bottom: 1px solid var(--wpr-shop-line);
}

.wpr-shop-toolbar .wp-block-woocommerce-product-results-count {
	margin-right: auto;
}

.wpr-shop-toolbar .woocommerce-result-count,
.wpr-shop-toolbar .woocommerce-ordering {
	margin: 0;
}

.wpr-shop-toolbar .woocommerce-result-count,
.wpr-shop-toolbar .wp-block-woocommerce-product-results-count {
	font-family: 'Montserrat', sans-serif;
	font-size: 13px;
	color: var(--wpr-shop-muted);
}

/* Sort dropdown — built by assets/js/shop-sort.js over the real select */
.wpr-sort-enhanced {
	position: relative;
}

.wpr-sort-enhanced select.orderby {
	display: none;
}

.wpr-sort-toggle {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	min-height: 44px;
	padding: 0 4px;
	border: 0;
	border-radius: 0;
	background: transparent;
	box-shadow: none;
	color: var(--wpr-shop-ink);
	font-family: 'Montserrat', sans-serif;
	font-size: 14px;
	font-weight: 500;
	cursor: pointer;
}

.wpr-sort-toggle:hover,
.wpr-sort-toggle:focus {
	background: transparent;
	box-shadow: none;
	color: var(--wpr-shop-ink);
}

.wpr-sort-toggle:focus-visible,
.wp-block-woocommerce-product-filters .wc-block-product-filters__open-overlay:focus-visible,
.wp-block-woocommerce-product-filters .wc-block-product-filters__close-overlay:focus-visible {
	outline: 2px solid var(--wpr-shop-ink);
	outline-offset: 2px;
}

.wpr-sort-toggle svg {
	transition: transform 200ms ease;
}

.wpr-sort-toggle[aria-expanded='true'] svg {
	transform: rotate(180deg);
}

.wpr-sort-list {
	position: absolute;
	top: calc(100% + 8px);
	right: 0;
	z-index: 9001; /* Above the floating WhatsApp button (9000), which otherwise covers the last options. */
	box-sizing: border-box;
	width: 260px;
	max-width: calc(100vw - 32px);
	margin: 0;
	padding: 6px;
	border: 1px solid var(--wpr-shop-line);
	border-radius: 14px;
	background: var(--global-palette9);
	box-shadow: 0 16px 40px rgba(13, 13, 13, 0.12);
	list-style: none;
	outline: none;
	animation: wpr-sort-in 160ms ease-out;
}

@keyframes wpr-sort-in {
	from {
		opacity: 0;
		transform: translateY(-6px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.wpr-sort-option {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	min-height: 44px;
	margin: 0;
	padding: 0 12px;
	border-radius: 9px;
	color: var(--wpr-shop-ink);
	font-family: 'Montserrat', sans-serif;
	font-size: 14px;
	cursor: pointer;
}

.wpr-sort-option.is-active {
	background: var(--global-palette7);
}

.wpr-sort-option[aria-selected='true'] {
	font-weight: 600;
}

.wpr-sort-option[aria-selected='true']::after {
	content: '\2713';
	color: var(--wpr-shop-gold-text);
}

/* Filter drawer — WooCommerce's own, extended to every screen size. */
.wp-block-woocommerce-product-filters {
	display: inline-flex;
	font-family: 'Montserrat', sans-serif;
}

.wp-block-woocommerce-product-filters .wc-block-product-filters__open-overlay {
	display: flex;
	gap: 4px;
	min-height: 44px;
	font-size: 14px;
	font-weight: 600;
	color: var(--wpr-shop-ink);
	cursor: pointer;
}

.wp-block-woocommerce-product-filters .wc-block-product-filters__overlay {
	position: fixed;
	inset: 0;
	top: var(--top-padding, 0);
	flex-grow: 0;
	background: transparent;
	pointer-events: none;
	visibility: hidden; /* Keeps the closed drawer's controls out of the Tab order. */
	transition: background-color 280ms ease, visibility 0s linear 280ms;
}

.wp-block-woocommerce-product-filters.is-overlay-opened .wc-block-product-filters__overlay {
	position: fixed;
	z-index: 9999;
	background: rgba(13, 13, 13, 0.45);
	pointer-events: auto;
	visibility: visible;
	transition: background-color 280ms ease;
}

.wp-block-woocommerce-product-filters .wc-block-product-filters__overlay-wrapper {
	width: 100%;
	height: 100%;
}

.wp-block-woocommerce-product-filters .wc-block-product-filters__overlay-dialog {
	position: absolute;
	inset: 0 0 0 auto;
	width: min(420px, 100vw);
	background: var(--global-palette9);
	color: var(--wpr-shop-ink);
	transform: translateX(100%);
	transition: transform 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

.wp-block-woocommerce-product-filters.is-overlay-opened .wc-block-product-filters__overlay-dialog {
	position: absolute;
	transform: translateX(0);
}

/* Kadence's button transition would delay this button's visibility, and focus. */
.wp-block-woocommerce-product-filters .wc-block-product-filters__close-overlay {
	min-width: 44px;
	min-height: 44px;
	transition: none;
}

.wp-block-woocommerce-product-filters .wc-block-product-filters__overlay-header,
.wp-block-woocommerce-product-filters.is-overlay-opened .wc-block-product-filters__overlay-header {
	display: flex;
	padding: 16px 24px;
	border-bottom: 1px solid var(--wpr-shop-line);
}

.wp-block-woocommerce-product-filters .wc-block-product-filters__overlay-content,
.wp-block-woocommerce-product-filters.is-overlay-opened .wc-block-product-filters__overlay-content {
	gap: 24px;
	overflow-y: auto;
	padding: 24px;
}

.wp-block-woocommerce-product-filters .wc-block-product-filters__overlay-footer,
.wp-block-woocommerce-product-filters.is-overlay-opened .wc-block-product-filters__overlay-footer {
	display: block;
	padding: 16px 24px;
	box-shadow: none;
	border-top: 1px solid var(--wpr-shop-line);
}

.wp-block-woocommerce-product-filters .wc-block-product-filters__overlay-content h2 {
	margin: 0 0 16px;
	font-family: 'Montserrat', sans-serif;
	font-size: 13px;
	font-weight: 600;
}

.wp-block-woocommerce-product-filters .wc-block-product-filters__apply {
	min-height: 48px;
	border: 0;
	border-radius: var(--wpr-btn-radius);
	background: var(--global-palette-btn-bg);
	color: var(--global-palette-btn);
}

.wp-block-woocommerce-product-filters .wc-block-product-filters__apply:hover {
	background: var(--global-palette-btn-bg-hover);
	color: var(--global-palette-btn-hover);
}

.wp-block-woocommerce-product-filters {
	--wc-product-filter-price-slider: var(--global-palette3); /* Gold would fall below 3:1 on white. */
}

.wc-block-product-filter-price-slider__left input,
.wc-block-product-filter-price-slider__right input {
	box-sizing: border-box;
	width: 104px !important;
	max-width: none !important;
}

.wc-block-product-filter-price-slider__right {
	display: flex;
	justify-content: flex-end;
}

/* Checkboxes need a visible edge against the white drawer (WCAG 1.4.11). */
.wc-block-product-filter-checkbox-list {
	--wc-product-filter-checkbox-list-option-element: var(--global-palette9);
	--wc-product-filter-checkbox-list-option-element-border: var(--wpr-shop-muted);
}

.wc-block-product-filter-checkbox-list__input-wrapper::before {
	display: none;
}

@media (prefers-reduced-motion: reduce) {
	.wp-block-woocommerce-product-filters .wc-block-product-filters__overlay,
	.wp-block-woocommerce-product-filters .wc-block-product-filters__overlay-dialog,
	.wp-block-woocommerce-product-filters.is-overlay-opened .wc-block-product-filters__overlay,
	.wpr-sort-list {
		animation: none;
		transition: none;
	}
}

@media (max-width: 600px) {
	/* :root outranks the Group block's own centring, which would push the first link off-screen. */
	:root .wpr-collection-nav {
		margin-bottom: 24px;
		flex-wrap: nowrap;
		justify-content: flex-start;
		gap: 24px;
		overflow-x: auto;
		scrollbar-width: none;
	}

	.wpr-collection-nav p {
		flex-shrink: 0;
	}

	.wpr-shop-toolbar .wp-block-woocommerce-product-results-count {
		display: none;
	}
}

/* Small phones: keep "Filter products" and "Default sorting" on one line each. */
@media (max-width: 400px) {
	.wpr-shop-toolbar {
		gap: 12px;
	}

	.wpr-shop-toolbar .wc-block-product-filters__open-overlay,
	.wpr-sort-toggle {
		font-size: 13px;
		white-space: nowrap;
	}
}
