/**
 * Shop / product archive — hero, category filter tabs, grid states, Load More.
 *
 * Loaded only on the shop + product taxonomy archives (inc/shop-page.php).
 * The product grid itself comes from main.css (.hpf-shop.hpf-archive
 * ul.products) and the cards from the global card (.hpf-pcard--global) — this
 * file only adds the surrounding chrome, so the card design stays untouched.
 *
 * @package HPF_Trickle_Up
 */

/* =========================================================
 * 1. HERO
 * =======================================================*/
.hpf-shop-hero {
	position: relative;
	overflow: hidden;
	border-radius: var(--hrp-radius-lg, 26px);
	margin: 8px 0 30px;
	padding: 60px 40px;
	text-align: center;
	color: #fff;
	isolation: isolate;
	background: linear-gradient(135deg, var(--hrp-teal, #60BABF), var(--hrp-teal-deep, #3f989d));
}

/* Optional background image sits under a scrim so text stays readable. */
.hpf-shop-hero__bg {
	position: absolute;
	inset: 0;
	z-index: -2;
	background-size: cover;
	background-position: center;
	transform: scale(1.04);
}
.hpf-shop-hero.has-image::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: -1;
	background: linear-gradient(135deg, rgba(13, 95, 89, .82), rgba(63, 152, 157, .74));
}
/* Soft brand orb (matches the Subscribe card's treatment). */
.hpf-shop-hero::before {
	content: "";
	position: absolute;
	top: -140px;
	right: -90px;
	width: 340px;
	height: 340px;
	border-radius: 50%;
	background: rgba(255, 255, 255, .09);
	pointer-events: none;
	z-index: -1;
}

.hpf-shop-hero__inner { position: relative; z-index: 1; max-width: 720px; margin: 0 auto; }

.hpf-shop-hero__crumbs { margin-bottom: 14px; font-size: 13px; }
.hpf-shop-hero__crumbs .woocommerce-breadcrumb { color: rgba(255, 255, 255, .8); margin: 0; padding: 0; font-size: 13px; }
.hpf-shop-hero__crumbs a { color: #fff !important; text-decoration: none; opacity: .9; }
.hpf-shop-hero__crumbs a:hover { opacity: 1; text-decoration: underline; }

.hpf-shop-hero__eyebrow {
	display: inline-block;
	background: rgba(255, 255, 255, .2);
	color: #fff;
	font-family: var(--hrp-head, inherit);
	font-size: 12.5px;
	font-weight: 800;
	letter-spacing: .14em;
	text-transform: uppercase;
	padding: 7px 16px;
	border-radius: 999px;
	margin-bottom: 16px;
}
.hpf-shop-hero__title {
	font-family: var(--hrp-head, inherit);
	font-size: clamp(1.9rem, 4vw, 2.9rem);
	font-weight: 800;
	line-height: 1.12;
	letter-spacing: -.01em;
	color: #fff;
	margin: 0 0 12px;
}
.hpf-shop-hero__desc { font-size: 1.02rem; line-height: 1.6; color: rgba(255, 255, 255, .9); }
.hpf-shop-hero__desc p { margin: 0 0 8px; }
.hpf-shop-hero__desc p:last-child { margin-bottom: 0; }

.hpf-shop-hero__chips {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 10px;
	list-style: none;
	margin: 22px 0 0;
	padding: 0;
}
.hpf-shop-hero__chips li {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	background: rgba(255, 255, 255, .16);
	border: 1px solid rgba(255, 255, 255, .24);
	border-radius: 999px;
	padding: 8px 15px;
	font-size: 13px;
	font-weight: 700;
	color: #fff;
}
.hpf-shop-hero__chips svg { width: 14px; height: 14px; flex: 0 0 auto; }

/* =========================================================
 * 2. LAYOUT — left sidebar + product grid
 * =======================================================*/
.hpf-shop-layout {
	display: grid;
	grid-template-columns: 264px minmax(0, 1fr);
	gap: 32px;
	/* Must stay `stretch` (not `start`): a sticky element can only travel inside
	   its containing block, so the sidebar column has to span the full row height
	   or .hpf-shop-sidebar__panel has no room to stick and scrolls away. */
	align-items: stretch;
}
.hpf-shop-main { min-width: 0; } /* lets the grid shrink instead of overflowing */

/* =========================================================
 * 3. CATEGORY SIDEBAR (hierarchical)
 * =======================================================*/
.hpf-shop-sidebar__panel {
	background: #fff;
	border: 1px solid var(--hpf-border, #e6eeed);
	border-radius: 18px;
	padding: 20px 16px;
	box-shadow: 0 8px 24px rgba(29, 35, 39, .05);
	position: sticky;
	top: 96px;
}
.hpf-shop-sidebar__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.hpf-shop-sidebar__title {
	font-family: var(--hrp-head, inherit);
	font-size: 15px;
	font-weight: 800;
	letter-spacing: .08em;
	text-transform: uppercase;
	color: var(--hrp-teal-deep, #3f989d);
	margin: 0;
}
/* Close button + backdrop only exist for the mobile drawer. */
.hpf-shop-sidebar__close { display: none; }
.hpf-shop-sidebar__backdrop { display: none; }

.hpf-shop-cats,
.hpf-shop-cats__sub { list-style: none; margin: 0; padding: 0; }
.hpf-shop-cats--root { margin-bottom: 2px; }

.hpf-shop-cats__row { display: flex; align-items: center; gap: 2px; }

.hpf-shop-cats__link {
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 9px 10px;
	border-radius: 10px;
	font-size: 14.5px;
	font-weight: 600;
	color: var(--hpf-ink, #1d2327);
	text-decoration: none;
	transition: background .2s ease, color .2s ease;
}
.hpf-shop-cats__link:hover { background: var(--hrp-teal-soft, #e7f4f5); color: var(--hrp-teal-deep, #3f989d); }
.hpf-shop-cats__link.is-active {
	background: linear-gradient(135deg, var(--hrp-teal, #60BABF), var(--hrp-teal-deep, #3f989d));
	color: #fff;
	font-weight: 800;
	box-shadow: 0 6px 16px rgba(63, 152, 157, .3);
}
.hpf-shop-cats__link:focus-visible { outline: 2px solid var(--hrp-teal-deep, #3f989d); outline-offset: 1px; }
.hpf-shop-cats__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hpf-shop-cats__count {
	flex: 0 0 auto;
	display: inline-grid;
	place-items: center;
	min-width: 22px;
	height: 20px;
	padding: 0 6px;
	border-radius: 999px;
	background: var(--hrp-teal-soft, #e7f4f5);
	color: var(--hrp-teal-deep, #3f989d);
	font-size: 11.5px;
	font-weight: 800;
	transition: background .2s ease, color .2s ease;
}
.hpf-shop-cats__link.is-active .hpf-shop-cats__count { background: rgba(255, 255, 255, .26); color: #fff; }

/* Expand / collapse chevron */
.hpf-shop-cats__toggle {
	flex: 0 0 auto;
	display: grid;
	place-items: center;
	width: 28px;
	height: 28px;
	padding: 0;
	border: 0;
	border-radius: 8px;
	background: transparent;
	color: var(--hpf-muted, #5b6566);
	cursor: pointer;
	transition: background .2s ease, color .2s ease;
}
.hpf-shop-cats__toggle:hover { background: var(--hrp-teal-soft, #e7f4f5); color: var(--hrp-teal-deep, #3f989d); }
.hpf-shop-cats__toggle svg { width: 15px; height: 15px; transition: transform .28s var(--hpf-ease, ease); }
.hpf-shop-cats__item.is-open > .hpf-shop-cats__row > .hpf-shop-cats__toggle svg { transform: rotate(180deg); }
.hpf-shop-cats__toggle:focus-visible { outline: 2px solid var(--hrp-teal-deep, #3f989d); outline-offset: 1px; }

/* Nested levels: indent + guide rail. Collapsed by default. */
.hpf-shop-cats__sub {
	margin: 2px 0 2px 12px;
	padding-left: 10px;
	border-left: 2px solid var(--hpf-border, #e6eeed);
	display: none;
}
.hpf-shop-cats__item.is-open > .hpf-shop-cats__sub { display: block; }
.hpf-shop-cats__sub .hpf-shop-cats__link { font-size: 13.8px; font-weight: 600; padding: 8px 10px; }
.hpf-shop-cats__sub .hpf-shop-cats__sub .hpf-shop-cats__link { font-size: 13.2px; }

/* =========================================================
 * 4. MOBILE FILTER TRIGGER (hidden on desktop)
 * =======================================================*/
.hpf-shop-filter-trigger {
	display: none;
	align-items: center;
	gap: 9px;
	background: #fff;
	border: 1px solid var(--hpf-border, #e6eeed);
	border-radius: 999px;
	padding: 11px 18px;
	font-family: var(--hrp-head, inherit);
	font-size: 14px;
	font-weight: 800;
	color: var(--hpf-ink, #1d2327);
	cursor: pointer;
	box-shadow: 0 6px 16px rgba(29, 35, 39, .07);
}
.hpf-shop-filter-trigger svg { width: 17px; height: 17px; color: var(--hrp-teal-deep, #3f989d); }
.hpf-shop-filter-trigger__current {
	max-width: 130px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	background: var(--hrp-teal-soft, #e7f4f5);
	color: var(--hrp-teal-deep, #3f989d);
	border-radius: 999px;
	padding: 3px 10px;
	font-size: 12px;
	font-weight: 700;
}

/* =========================================================
 * 3. RESULTS + LOADING STATE
 * =======================================================*/
.hpf-shop__results { position: relative; min-height: 200px; }
.hpf-shop__results ul.products { transition: opacity .25s ease, filter .25s ease; }
.hpf-shop__results.is-loading ul.products { opacity: .35; filter: saturate(.6); pointer-events: none; }

/* Bouncing dots shown while replacing the grid. */
.hpf-shop__loader {
	position: absolute;
	top: 90px;
	left: 50%;
	transform: translateX(-50%);
	display: flex;
	gap: 8px;
	opacity: 0;
	visibility: hidden;
	transition: opacity .25s ease, visibility .25s ease;
	z-index: 5;
}
.hpf-shop__loader[aria-hidden="false"] { opacity: 1; visibility: visible; }
.hpf-shop__loader span {
	width: 12px;
	height: 12px;
	border-radius: 50%;
	background: var(--hrp-teal, #60BABF);
	animation: hpfShopBounce 1.05s ease-in-out infinite;
}
.hpf-shop__loader span:nth-child(2) { animation-delay: .14s; background: var(--hrp-pink, #D46681); }
.hpf-shop__loader span:nth-child(3) { animation-delay: .28s; background: var(--hrp-gold, #E4B451); }
@keyframes hpfShopBounce {
	0%, 80%, 100% { transform: translateY(0); opacity: .55; }
	40% { transform: translateY(-11px); opacity: 1; }
}

/* Same reason as .hpf-shop__more[hidden]: main.css sets `display:grid` on
   `.hpf-shop.hpf-archive ul.products`, which would beat the UA's [hidden] and
   leave an empty grid taking up space when a filter returns no results. */
.hpf-shop.hpf-archive .hpf-shop__results ul.products[hidden],
.hpf-shop__results ul.products[hidden] { display: none; }

.hpf-shop__empty {
	text-align: center;
	padding: 56px 20px;
	font-size: 16px;
	color: var(--hpf-muted, #5b6566);
}

/* =========================================================
 * 4. LOAD MORE
 * =======================================================*/
.hpf-shop__more { display: flex; justify-content: center; margin: 34px 0 6px; }
/* Must re-assert [hidden] because the `display:flex` above is an author rule and
   would otherwise beat the UA's `[hidden]{display:none}`, leaving the button on
   screen once every product is loaded. */
.hpf-shop__more[hidden] { display: none; }
.hpf-shop__more-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	min-width: 210px;
	background: linear-gradient(135deg, var(--hrp-teal, #60BABF), var(--hrp-teal-deep, #3f989d));
	color: #fff;
	border: 0;
	border-radius: 999px;
	padding: 15px 34px;
	font-family: var(--hrp-head, inherit);
	font-size: 15px;
	font-weight: 800;
	cursor: pointer;
	box-shadow: 0 10px 26px rgba(63, 152, 157, .32);
	transition: transform .25s var(--hpf-ease, ease), box-shadow .25s ease, opacity .2s ease;
}
.hpf-shop__more-btn:hover:not(:disabled) { transform: translateY(-3px); box-shadow: 0 16px 34px rgba(63, 152, 157, .45); }
.hpf-shop__more-btn:disabled { opacity: .7; cursor: default; }
.hpf-shop__more-btn.is-loading::after {
	content: "";
	width: 15px;
	height: 15px;
	border-radius: 50%;
	border: 2px solid rgba(255, 255, 255, .4);
	border-top-color: #fff;
	animation: hpfShopSpin .7s linear infinite;
}
@keyframes hpfShopSpin { to { transform: rotate(360deg); } }

.hpf-shop__pagination[hidden] { display: none; }

/* =========================================================
 * 5. RESPONSIVE
 * =======================================================*/
@media (max-width: 1100px) {
	.hpf-shop-layout { grid-template-columns: 232px minmax(0, 1fr); gap: 24px; }
}

/* ---- Tablet / mobile: sidebar becomes a slide-in drawer ---- */
@media (max-width: 900px) {
	.hpf-shop-hero { padding: 46px 26px; margin-bottom: 24px; }
	.hpf-shop-layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
	.hpf-shop-filter-trigger { display: inline-flex; }

	.hpf-shop-sidebar__backdrop {
		display: block;
		position: fixed;
		inset: 0;
		z-index: 998;
		background: rgba(19, 32, 33, .45);
		/* MUST stay non-interactive while closed — this is a full-screen fixed
		   layer, so without pointer-events:none it swallows every tap on the
		   page (opacity:0 alone does not disable hit-testing). */
		opacity: 0;
		visibility: hidden;
		pointer-events: none;
		transition: opacity .3s ease, visibility .3s ease;
	}
	.hpf-shop-sidebar.is-open .hpf-shop-sidebar__backdrop {
		opacity: 1;
		visibility: visible;
		pointer-events: auto;
	}

	.hpf-shop-sidebar__panel {
		position: fixed;
		top: 0;
		left: 0;
		bottom: 0;
		z-index: 999;
		width: min(86vw, 330px);
		border-radius: 0;
		border: 0;
		padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
		box-shadow: 0 0 60px rgba(0, 0, 0, .3);
		display: flex;
		flex-direction: column;
		transform: translateX(-100%);
		/* visibility keeps the closed drawer out of the tab order */
		visibility: hidden;
		transition: transform .34s var(--hpf-ease, cubic-bezier(.22, 1, .36, 1)), visibility .34s;
		overscroll-behavior: contain;
	}
	.hpf-shop-sidebar.is-open .hpf-shop-sidebar__panel { transform: translateX(0); visibility: visible; }

	.hpf-shop-sidebar__head {
		padding-bottom: 14px;
		margin-bottom: 8px;
		border-bottom: 1px solid var(--hpf-border, #e6eeed);
	}
	.hpf-shop-sidebar__title { font-size: 16px; }
	.hpf-shop-sidebar__close {
		display: grid;
		place-items: center;
		width: 38px;
		height: 38px;
		padding: 0;
		border: 0;
		border-radius: 50%;
		background: var(--hrp-teal-soft, #e7f4f5);
		color: var(--hrp-teal-deep, #3f989d);
		cursor: pointer;
	}
	.hpf-shop-sidebar__close svg { width: 17px; height: 17px; }
	/* Only the list scrolls, so the header stays pinned. */
	.hpf-shop-sidebar__body { flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch; }

	/* Comfortable tap targets on touch. */
	.hpf-shop-cats__link { padding: 12px 12px; font-size: 15px; }
	.hpf-shop-cats__sub .hpf-shop-cats__link { padding: 11px 12px; font-size: 14.2px; }
	.hpf-shop-cats__toggle { width: 40px; height: 40px; }
	.hpf-shop-cats__toggle svg { width: 17px; height: 17px; }
}

@media (max-width: 600px) {
	/* Edge-to-edge on mobile. Scoped to .hpf-shop-page (added via body_class in
	   inc/shop-page.php) so the shared site-wide .hpf-container keeps its gutter
	   on every other page. Sections below re-add their own breathing room. */
	.hpf-shop-page .hpf-container { padding-left: 0; padding-right: 0; }
	.hpf-shop-page .hpf-shop-hero { border-radius: 0; }

	/* Hero stays full-bleed; the grid + Why section take a slim gutter back. */
	.hpf-shop-page .hpf-shop-layout,
	.hpf-shop-page .hpf-why { padding: 0 10px; }

	.hpf-shop-hero { padding: 38px 20px; border-radius: 20px; }
	.hpf-shop-hero__chips { gap: 8px; }
	.hpf-shop-hero__chips li { padding: 7px 12px; font-size: 12px; }
	.hpf-shop-hero__crumbs { display: none; }
	.hpf-shop__more-btn { width: 100%; }
	.hpf-shop__loader { top: 60px; }
}

/* Scroll-lock the page while the drawer is open. */
body.hpf-filters-open { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
	.hpf-shop-cats__link,
	.hpf-shop-cats__toggle svg,
	.hpf-shop-sidebar__panel,
	.hpf-shop-sidebar__backdrop,
	.hpf-shop__more-btn,
	.hpf-shop__results ul.products { transition: none; }
	.hpf-shop__more-btn:hover:not(:disabled) { transform: none; }
	.hpf-shop__loader span { animation: none; }
	.hpf-shop__more-btn.is-loading::after { animation-duration: 1.6s; }
}
