/* =====================================================================
 * Product archive infinite scroll — loader + state styles.
 *
 * Enqueued only on WooCommerce archives (shop, product_cat, product_tag,
 * product_taxonomy) by /add-ons/utils/product-archive-infinite.php.
 *
 * Scope prefix `body.has-infinite-product-archive` is added by the JS
 * module on boot; this lets the CSS hide the legacy pagination only when
 * JS is actually running (graceful fallback to native pagination when JS
 * is off or fails).
 * =================================================================== */

.product-archive-sentinel {
	/* Invisible observer anchor — sits at the bottom of the product grid.
	   Keep it in flow (height: 1px) so it reliably enters the viewport as
	   the user scrolls, even on short pages. */
	height: 1px;
	margin: 0;
	padding: 0;
	pointer-events: none;
}

/* Hide the native pagination when JS is driving the page.
   Without this class (JS off / failed), the pagination stays visible. */
body.has-infinite-product-archive .woocommerce-pagination {
	display: none !important;
}

/* ---------------------------------------------------------------------
 * Loading indicator — three pulse-dots centered under the grid
 * ------------------------------------------------------------------- */
.product-archive-loader {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.75rem;
	padding: 2.5rem 1rem 3rem;
	color: #4b5563;
	font-size: 0.9rem;
	font-weight: 600;
	letter-spacing: 0.02em;
}

.product-archive-loader[hidden] {
	display: none !important;
}

.product-archive-loader__dots {
	display: inline-flex;
	gap: 0.5rem;
	align-items: center;
}

.product-archive-loader__dots span {
	display: inline-block;
	width: 12px;
	height: 12px;
	border-radius: 50%;
	background: linear-gradient(135deg, #F26322 0%, #d14d16 100%);
	box-shadow: 0 2px 8px rgba(242, 99, 34, 0.35);
	animation: product-archive-bounce 1.2s infinite ease-in-out both;
}

.product-archive-loader__dots span:nth-child(1) { animation-delay: -0.32s; }
.product-archive-loader__dots span:nth-child(2) { animation-delay: -0.16s; }
.product-archive-loader__dots span:nth-child(3) { animation-delay: 0s; }

@keyframes product-archive-bounce {
	0%, 80%, 100% {
		transform: scale(0.6);
		opacity: 0.6;
	}
	40% {
		transform: scale(1);
		opacity: 1;
	}
}

.product-archive-loader__text {
	color: #6b7280;
	font-size: 0.85rem;
	letter-spacing: 0.04em;
}

@media (prefers-reduced-motion: reduce) {
	.product-archive-loader__dots span {
		animation: none;
		opacity: 0.85;
	}
}

/* ---------------------------------------------------------------------
 * End-of-inventory state
 *
 * The "You've reached the end" status row. Visibility is owned by the
 * outer #productArchiveEnd[hidden] attribute — toggled by
 * js/product-archive-infinite.js when infinite scroll exhausts or the
 * initial query is empty.
 *
 * The Special Orders banner (.so-banner) is rendered as a sibling AFTER
 * this element by content-archive-woo.php and stays visible at all times,
 * independent of this end-state toggle.
 * ------------------------------------------------------------------- */
.product-archive-end {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	padding: 2rem 1rem 1rem;
	color: #9ca3af;
	font-size: 0.85rem;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.product-archive-end[hidden] {
	display: none !important;
}

.product-archive-end .bi {
	font-size: 1rem;
	color: #F26322;
	opacity: 0.8;
}

/* ---------------------------------------------------------------------
 * .so-banner — Special Orders archive-bottom recovery banner
 *
 * Always visible at the bottom of every product archive (full width
 * within the parent .container). Sits below #productArchiveEnd so it
 * appears whether or not the "You've reached the end" message has been
 * triggered — the banner doesn't depend on the JS end-state toggle.
 *
 * Cream surface, hairline brand-orange border, two-column desktop layout
 * (icon + copy + CTA), stacks vertically on mobile. Calm/trustworthy
 * tone, no animations. Visually a sibling of the Financing Banner so
 * the archive surfaces read as one design system.
 * ------------------------------------------------------------------- */
.so-banner {
	display: grid;
	grid-template-columns: auto 1fr auto;
	align-items: center;
	gap: 1.1rem;
	width: 100%;
	margin: 0 0 3rem;
	padding: 1.4rem 1.5rem;
	background: #fff8ef;
	border: 1px solid rgba(207, 91, 31, .25);
	border-radius: 12px;
	transition: border-color .2s ease, transform .2s ease, box-shadow .2s ease;
}
/* When the "You've reached the end" message is hidden (i.e. the user
   hasn't yet scrolled to the end), the banner sits right under the
   products grid — give it a little air above. */
.product-archive-end[hidden] + .so-banner {
	margin-top: 2.5rem;
}
.so-banner:hover {
	border-color: var(--ui-primary, #cf5b1f);
	transform: translateY(-1px);
	box-shadow: 0 4px 14px rgba(31, 20, 8, .08);
}

.so-banner__icon {
	width: 48px;
	height: 48px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	background: rgba(207, 91, 31, .1);
	color: var(--ui-primary, #cf5b1f);
	font-size: 1.4rem;
	flex: 0 0 auto;
}

.so-banner__copy {
	min-width: 0;
}

.so-banner__eyebrow {
	display: block;
	font-size: .68rem;
	font-weight: 700;
	letter-spacing: .14em;
	text-transform: uppercase;
	color: var(--ui-primary, #cf5b1f);
	line-height: 1.2;
	margin-bottom: .25rem;
}

.so-banner__headline {
	margin: 0 0 .35rem;
	font-size: 1.1rem;
	font-weight: 700;
	line-height: 1.25;
	letter-spacing: -.01em;
	color: #1f1408;
}

.so-banner__body {
	margin: 0;
	font-size: .88rem;
	line-height: 1.45;
	color: rgba(31, 20, 8, .65);
}

.so-banner__cta {
	display: inline-flex;
	align-items: center;
	gap: .45rem;
	padding: .7rem 1.2rem;
	background: var(--ui-primary, #cf5b1f);
	color: #fff;
	font-size: .92rem;
	font-weight: 700;
	letter-spacing: .005em;
	text-decoration: none;
	border-radius: 999px;
	white-space: nowrap;
	flex: 0 0 auto;
	transition: background-color .2s ease, gap .2s ease, transform .2s ease;
}
.so-banner__cta:hover,
.so-banner__cta:focus-visible {
	background: #a8481a;
	color: #fff;
	text-decoration: none;
	gap: .65rem;
}
.so-banner__cta:focus-visible {
	outline: 2px solid var(--ui-primary, #cf5b1f);
	outline-offset: 3px;
}
.so-banner__cta .bi {
	font-size: 1rem;
	transition: transform .2s ease;
}
.so-banner__cta:hover .bi,
.so-banner__cta:focus-visible .bi {
	transform: translateX(2px);
}

/* Mobile — stack vertically; CTA goes full-width below the copy block. */
@media (max-width: 575.98px) {
	.so-banner {
		grid-template-columns: 1fr;
		gap: .9rem;
		padding: 1.2rem;
		text-align: center;
	}
	.so-banner__icon {
		margin: 0 auto;
		width: 44px;
		height: 44px;
		font-size: 1.25rem;
	}
	.so-banner__headline {
		font-size: 1.02rem;
	}
	.so-banner__body {
		font-size: .85rem;
	}
	.so-banner__cta {
		justify-content: center;
		width: 100%;
	}
}

/* ---------------------------------------------------------------------
 * Newly-appended cards animate in so the infinite scroll feels alive
 * rather than cards just popping into existence. We can't attach this
 * via the PHP markup (cached), so use a tiny CSS animation that runs
 * on every .product that's freshly in the DOM — flash is imperceptible
 * for initial-page cards since they're already in view on load.
 * ------------------------------------------------------------------- */
body.has-infinite-product-archive .products > .product {
	animation: product-archive-enter 0.45s ease-out both;
}

@keyframes product-archive-enter {
	from {
		opacity: 0;
		transform: translateY(12px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

@media (prefers-reduced-motion: reduce) {
	body.has-infinite-product-archive .products > .product {
		animation: none;
	}
}
