/**
 * Sticky add-to-cart bar — mobile single product page.
 *
 * @package Arsin_Storefront_Customizer
 */

@media (min-width: 769px) {
	#asc-product-sticky-cart {
		display: none !important;
	}
}

@media (max-width: 768px) {
	:root {
		--asc-product-sticky-cart-height: 0px;
	}

	body.single-product.asc-product-sticky-cart-visible {
		padding-bottom: calc(
			var(--asc-handheld-footer-height, 64px) + var(--asc-product-sticky-cart-height, 0px)
		);
	}

	#asc-product-sticky-cart {
		position: fixed;
		right: 0;
		left: 0;
		bottom: var(--asc-handheld-footer-height, 64px);
		/* Under .mobile-cta (25) so lift-shadow cannot tint the nav. */
		z-index: var(--arsin-z-product-sticky, var(--asc-z-product-sticky-cart, 24));
		background: #fff !important;
		background-color: #fff !important;
		background-image: none !important;
		border-top: 1px solid var(--line, var(--asc-color-border, rgba(0, 0, 0, 0.1)));
		border-bottom: 0;
		box-shadow: var(--arsin-mobile-chrome-shadow, 0 -10px 22px -12px rgba(0, 0, 0, .18));
		/* Top padding only — bottom chrome sits flush on .mobile-cta. */
		padding-block: var(--space-2, 12px) 0 !important;
		padding-inline: 0;
		box-sizing: border-box;
		max-width: 100vw;
		height: auto;
		max-height: none;
		/*
		 * Do NOT set overflow-x: hidden with overflow-y: visible — CSS forces
		 * overflow-y to auto, which adds a vertical scrollbar when sale prices
		 * stack taller than the CTA. Clip shine on the inner row instead.
		 */
		overflow: visible;
		overflow-anchor: none;
	}

	/* Quote-contact shares chrome padding with purchasable (flush on .mobile-cta). */
	#asc-product-sticky-cart[data-layout="quote-contact"] {
		padding-block: var(--space-2, 12px) 0 !important;
		padding-inline: 0 !important;
		box-shadow: var(--arsin-mobile-chrome-shadow, 0 -10px 22px -12px rgba(0, 0, 0, .18));
	}

	#asc-product-sticky-cart[hidden] {
		display: none !important;
	}

	#asc-product-sticky-cart:not([hidden]) {
		display: block;
	}

	.asc-product-sticky-cart__inner[hidden] {
		display: none !important;
	}

	.asc-product-sticky-cart__inner--purchasable:not([hidden]) {
		display: flex;
		align-items: center;
		justify-content: space-between;
		gap: 0.65rem;
		min-height: 38px;
		overflow-x: clip;
		overflow-y: visible;
	}

	.asc-product-sticky-cart__inner--quote-contact:not([hidden]) {
		display: block;
		padding-inline: max(11px, calc((100% - var(--container, 1200px)) / 2));
	}

	.asc-product-sticky-cart__price {
		flex: 1 1 auto;
		min-width: 0;
		font-size: large;
		font-weight: 600;
		line-height: 1.35;
		color: var(--asc-color-primary);
	}

	.asc-product-sticky-cart__price .price,
	.asc-product-sticky-cart__price .woocommerce-Price-amount {
		margin: 0;
		font-size: inherit;
		color: inherit;
	}

	.asc-product-sticky-cart__price del,
	.asc-product-sticky-cart__price del .woocommerce-Price-amount {
		opacity: 1;
		color: var(--asc-color-text-muted);
		font-size: 0.85em;
	}

	.asc-product-sticky-cart__price ins,
	.asc-product-sticky-cart__price ins .woocommerce-Price-amount {
		color: var(--asc-color-primary);
		text-decoration: none;
	}

	/* Non-sale only — hide when sticky price has sale/discount markup. */
	.asc-product-sticky-cart__price .asc-price-stale-days {
		display: block;
		margin-top: 0.15rem;
		font-size: 0.58rem;
		font-weight: 400;
		color: #94a3b8;
		line-height: 1.25;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}

	.asc-product-sticky-cart__price:has(ins) .asc-price-stale-days,
	.asc-product-sticky-cart__price:has(del) .asc-price-stale-days,
	.asc-product-sticky-cart__price:has(.product-card__price-stack) .asc-price-stale-days {
		display: none !important;
	}

	.asc-product-sticky-cart__actions {
		display: flex;
		align-items: center;
		gap: 0.5rem;
		flex: 0 0 auto;
		flex-shrink: 0;
		width: fit-content;
	}

	.asc-product-sticky-cart__actions:has(.asc-product-sticky-cart__qty-input:not([type="hidden"])) {
		flex: 1 1 auto;
		flex-shrink: 1;
		width: auto;
		min-width: 0;
	}

	.asc-product-sticky-cart__qty:not(:has(.asc-product-sticky-cart__qty-input:not([type="hidden"]))) {
		display: none !important;
	}

	.asc-product-sticky-cart__qty:has(.asc-product-sticky-cart__qty-input:not([type="hidden"])) {
		flex-shrink: 0;
	}

	.asc-product-sticky-cart__qty .quantity {
		margin: 0;
	}

	.asc-product-sticky-cart__qty .qty {
		width: 2.75rem;
		min-height: 37px;
		height: 37px;
		padding: 0.25rem;
		text-align: center;
		font-family: var(--asc-font-family);
	}

	.asc-product-sticky-cart__cta {
		flex: 0 0 auto;
		flex-shrink: 0;
		width: max-content;
		min-width: 11.25rem;
		white-space: nowrap;
		font-family: var(--asc-font-family) !important;
		font-size: 0.75rem !important;
		padding: 0 0.65rem !important;
		margin: 0 !important;
		height: 37px;
		min-height: 37px !important;
		line-height: 1.2 !important;
		overflow: hidden;
		contain: paint;
	}

	.asc-product-sticky-cart__cta:disabled {
		opacity: 0.65;
		cursor: not-allowed;
	}

	/*
	 * Quote-contact sticky — CTA-first single row (~36–38px).
	 * Long OOS notice lives in the buy-box; sticky hides it to avoid clip/overlap.
	 */
	.asc-product-sticky-cart__inner--quote-contact .asc-quote-contact-stock-wrapper {
		margin: 0 !important;
		padding: 0 !important;
		background: transparent !important;
		border: none !important;
		border-radius: 0 !important;
		min-width: 0;
		max-width: 100%;
	}

	.asc-product-sticky-cart__inner--quote-contact .asc-quote-contact-stock {
		display: flex;
		flex-flow: row nowrap;
		align-items: stretch;
		gap: var(--space-2, 8px);
		margin: 0 !important;
		padding: 0 !important;
		min-width: 0;
		width: 100%;
		line-height: 1.3;
	}

	.asc-product-sticky-cart__inner--quote-contact .asc-quote-contact-text {
		display: inline-flex !important;
		flex: 0 0 auto;
		align-items: center;
		justify-content: center;
		max-width: 5.5rem;
		padding: 0 5px;
		border-radius: var(--radius, 8px);
		background: color-mix(in srgb, var(--brand, #b91c1c) 10%, #fff);
		color: var(--brand, #b91c1c);
		font-size: 10px;
		font-weight: 800;
		line-height: 1.2;
		white-space: nowrap;
	}

	.asc-product-sticky-cart__inner--quote-contact .asc-quote-contact-actions {
		display: flex;
		flex: 1 1 auto;
		flex-flow: row nowrap;
		align-items: stretch;
		gap: var(--space-2, 8px);
		width: auto;
		min-width: 0;
		max-width: 100%;
		margin: 0;
	}

	.asc-product-sticky-cart__inner--quote-contact .asc-quote-contact-tel,
	.asc-product-sticky-cart__inner--quote-contact .asc-quote-contact-related-btn {
		box-sizing: border-box;
		display: inline-flex !important;
		flex: 1 1 0;
		align-items: center;
		justify-content: center;
		gap: 4px;
		min-width: 0;
		width: auto !important;
		max-width: none;
		height: 37px;
		min-height: 37px !important;
		margin: 0 !important;
		padding: 0 6px !important;
		border-radius: var(--radius, 8px) !important;
		font-family: inherit !important;
		font-size: 11px !important;
		font-weight: 700 !important;
		line-height: 1.2 !important;
		text-align: center;
		text-decoration: none !important;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
		box-shadow: none !important;
		cursor: pointer;
	}

	.asc-product-sticky-cart__inner--quote-contact .asc-quote-contact-visible-desktop-only {
		display: none !important;
	}

	.asc-product-sticky-cart__inner--quote-contact .asc-quote-contact-visible-mobile-only {
		display: inline-flex !important;
		align-items: center;
		justify-content: center;
	}

	.asc-product-sticky-cart__inner--quote-contact .asc-quote-contact-related-btn {
		cursor: pointer;
	}

	/* Scroll targets — keep visible above sticky bar + footer */
	.single-product form.cart,
	.single-product .single_variation_wrap {
		scroll-margin-bottom: calc(
			var(--asc-handheld-footer-height, 64px) + var(--asc-product-sticky-cart-height, 56px) + 16px
		);
	}

	.single-product .asc-quote-contact-stock-wrapper {
		scroll-margin-bottom: calc(
			var(--asc-handheld-footer-height, 64px) + var(--asc-product-sticky-cart-height, 56px) + 16px
		);
	}

	.single-product .related.products.asc-related-products-carousel {
		scroll-margin-bottom: calc(
			var(--asc-handheld-footer-height, 64px) + var(--asc-product-sticky-cart-height, 56px) + 16px
		);
	}

	/* Categories panel sits above sticky cart when visible */
	.asc-handheld-categories {
		bottom: calc(
			var(--asc-handheld-footer-height, 64px) + var(--asc-product-sticky-cart-height, 0px)
		);
	}
}
