/*
 * Forever Muslim cart layer (PDP add-to-cart row, toasts, header cart drawer, cart page).
 * Every rule is scoped to html.fm-sf so nothing changes while the UI is off.
 * Tokens come from fm-base.css; the fallbacks keep this file usable on its own.
 */

/* ---------------------------------------------------------------- PDP add row */

/* One row: quantity stepper on the left, primary button takes the rest. Flex, no floats or magic widths. */
/* !important: Woo's .woocommerce div.product form.cart .variations_button rule would otherwise force display:block. */
html.fm-sf .single-product form.cart:not(.variations_form),
html.fm-sf .single-product .woocommerce-variation-add-to-cart {
	display: flex !important;
	flex-wrap: wrap;
	align-items: stretch;
	gap: 10px;
	box-sizing: border-box;
	width: 100%;
	margin: 0 0 14px;
}

/* The variation wrapper shrink-wraps by default, which stopped the button from filling the row on desktop. */
html.fm-sf .single-product form.variations_form .single_variation_wrap {
	width: 100%;
}

html.fm-sf .single-product form.cart:not(.variations_form) > .quantity,
html.fm-sf .single-product .woocommerce-variation-add-to-cart > .quantity {
	display: inline-flex;
	align-items: stretch;
	flex: 0 0 auto;
	float: none;
	width: auto;
	height: 52px;
	margin: 0;
	overflow: hidden;
	border: 1px solid var(--fm-line-strong, #cfcfcf);
	border-radius: var(--fm-radius-sm, 8px);
	background: var(--fm-card, #fff);
}

/* Astra renders the +/- as links; make them real 44px targets. */
html.fm-sf .single-product .quantity a.minus,
html.fm-sf .single-product .quantity a.plus {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	min-width: 44px;
	height: 52px;
	margin: 0;
	padding: 0;
	color: var(--fm-ink, #111);
	font: 400 22px/1 var(--fm-font, 'Jost', system-ui, sans-serif);
	text-decoration: none;
	border: 0;
}

html.fm-sf .single-product .quantity a.minus:focus-visible,
html.fm-sf .single-product .quantity a.plus:focus-visible,
html.fm-sf .single-product .quantity input.qty:focus-visible {
	outline: none;
	box-shadow: inset 0 0 0 2px var(--fm-ink, #111);
}

/* 16px minimum: iOS zooms the page on focus for smaller inputs. */
html.fm-sf .single-product .quantity input.qty {
	width: 52px;
	min-width: 52px;
	height: 52px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: transparent;
	box-shadow: none;
	color: var(--fm-ink, #111);
	font: 500 16px/1 var(--fm-font, 'Jost', system-ui, sans-serif);
	text-align: center;
	-moz-appearance: textfield;
	appearance: textfield;
}

html.fm-sf .single-product .quantity input.qty::-webkit-outer-spin-button,
html.fm-sf .single-product .quantity input.qty::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

html.fm-sf .single-product form.cart .single_add_to_cart_button,
html.fm-sf .single-product .woocommerce-variation-add-to-cart .single_add_to_cart_button {
	flex: 1 1 180px;
	float: none !important;
	width: auto !important;
	min-height: 52px;
	height: 52px;
	margin: 0 !important;
	padding: 0 20px;
	border: 0;
	border-radius: var(--fm-radius-sm, 8px);
	background: var(--fm-primary, #111);
	color: #fff;
	font: 600 15px/1 var(--fm-font, 'Jost', system-ui, sans-serif);
	letter-spacing: 0.02em;
	text-transform: none;
	cursor: pointer;
}

html.fm-sf .single-product .single_add_to_cart_button:hover {
	background: var(--fm-primary-hover, #000);
	color: #fff;
}

/* Variable product, no choice made yet: looks inactive, still tappable so the hint can explain. */
/* Written with the same ancestor chain as the base button rule (form.cart) so it wins on specificity. */
html.fm-sf .single-product form.cart .single_add_to_cart_button.disabled,
html.fm-sf .single-product form.cart .single_add_to_cart_button.wc-variation-selection-needed,
html.fm-sf .single-product form.cart .single_add_to_cart_button.wc-variation-is-unavailable,
html.fm-sf .single-product form.cart .single_add_to_cart_button[aria-disabled="true"] {
	background: #e9e9e7;
	color: var(--fm-muted, #6b6b6b);
	cursor: not-allowed;
}

html.fm-sf .single-product .single_add_to_cart_button.is-loading {
	opacity: 0.75;
	cursor: progress;
}

html.fm-sf .single-product .single_add_to_cart_button:focus-visible {
	outline: 2px solid var(--fm-ink, #111);
	outline-offset: 3px;
}

/* Woo's "View cart" link after an add: keep it, make it a clear secondary action. */
html.fm-sf .single-product .added_to_cart {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	font: 500 14px/1 var(--fm-font, 'Jost', system-ui, sans-serif);
	color: var(--fm-ink, #111);
	text-decoration: underline;
	text-underline-offset: 4px;
	width: 100%;
	flex: 0 0 100%;
}

/* Inline hint under the add row for variable products. */
html.fm-sf .single-product .fm-atc-hint {
	flex: 0 0 100%;
	order: 9;
	display: none;
	margin: 2px 0 0;
	font: 500 14px/1.4 var(--fm-font, 'Jost', system-ui, sans-serif);
	color: var(--fm-body, #2b2b2b);
}

html.fm-sf .single-product .fm-atc-hint.is-shown {
	display: block;
}

/* ------------------------------------------------------------------- toast */

html.fm-sf .fm-toast {
	position: fixed;
	left: 50%;
	bottom: calc(16px + env(safe-area-inset-bottom, 0px));
	z-index: 100000;
	box-sizing: border-box;
	width: max-content;
	max-width: min(92vw, 420px);
	padding: 12px 16px;
	border-radius: var(--fm-radius, 10px);
	background: var(--fm-ink, #111);
	color: #fff;
	font: 500 14px/1.4 var(--fm-font, 'Jost', system-ui, sans-serif);
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
	opacity: 0;
	pointer-events: none;
	transform: translate(-50%, 12px);
	transition: opacity 0.2s ease, transform 0.2s ease;
}

html.fm-sf .fm-toast.is-shown {
	opacity: 1;
	transform: translate(-50%, 0);
}

html.fm-sf .fm-toast.is-error {
	background: var(--fm-error, #b3261e);
}

/* ------------------------------------------------- header cart icon hit area */

/* Only the cart icon is touched here; the rest of the header belongs to the shell styles. */
html.fm-sf .ast-header-woo-cart a.cart-container {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 44px;
	min-height: 44px;
}

/* -------------------------------------------------------------- cart drawer */

html.fm-sf #astra-mobile-cart-drawer.astra-cart-drawer {
	font-family: var(--fm-font, 'Jost', system-ui, sans-serif);
	color: var(--fm-body, #2b2b2b);
	background: #fff;
}

html.fm-sf #astra-mobile-cart-drawer .astra-cart-drawer-header {
	display: flex;
	align-items: center;
	gap: 8px;
	min-height: 60px;
	padding: 8px 12px 8px 20px;
	border-bottom: 1px solid var(--fm-line, #e6e6e6);
}

html.fm-sf #astra-mobile-cart-drawer .astra-cart-drawer-title {
	flex: 1 1 auto;
	font: 600 18px/1.2 var(--fm-font, 'Jost', system-ui, sans-serif);
	color: var(--fm-ink, #111);
}

html.fm-sf #astra-mobile-cart-drawer .astra-cart-drawer-close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	margin: 0 -8px 0 0;
	padding: 0;
	border: 0;
	background: transparent;
	color: var(--fm-ink, #111);
	cursor: pointer;
}

html.fm-sf #astra-mobile-cart-drawer .astra-cart-drawer-close:focus-visible {
	outline: 2px solid var(--fm-ink, #111);
	outline-offset: 2px;
}

html.fm-sf #astra-mobile-cart-drawer .astra-cart-drawer-content {
	display: flex;
	flex-direction: column;
	min-height: 0;
}

html.fm-sf #astra-mobile-cart-drawer .widget_shopping_cart,
html.fm-sf #astra-mobile-cart-drawer .widget_shopping_cart_content {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	min-height: 0;
}

html.fm-sf #astra-mobile-cart-drawer ul.woocommerce-mini-cart {
	flex: 1 1 auto;
	min-height: 0;
	margin: 0;
	padding: 0 20px;
	overflow-y: auto;
	list-style: none;
	-webkit-overflow-scrolling: touch;
}

/* Row: thumb | name, variant, price | remove ; stepper underneath. */
html.fm-sf #astra-mobile-cart-drawer li.fm-mi {
	display: grid;
	grid-template-columns: 72px minmax(0, 1fr) auto;
	grid-template-areas:
		'thumb body remove'
		'thumb qty  qty';
	column-gap: 14px;
	row-gap: 10px;
	align-items: start;
	margin: 0;
	padding: 16px 0;
	border-bottom: 1px solid var(--fm-line, #e6e6e6);
}

html.fm-sf #astra-mobile-cart-drawer .fm-mi-thumb {
	grid-area: thumb;
	display: block;
	width: 72px;
	height: 72px;
	overflow: hidden;
	border-radius: var(--fm-radius-sm, 8px);
	background: var(--fm-canvas, #f6f6f4);
}

html.fm-sf #astra-mobile-cart-drawer .fm-mi-thumb img {
	display: block;
	width: 72px;
	height: 72px;
	object-fit: cover;
	margin: 0;
}

html.fm-sf #astra-mobile-cart-drawer .fm-mi-body {
	grid-area: body;
	min-width: 0;
}

html.fm-sf #astra-mobile-cart-drawer .fm-mi-name {
	display: block;
	font: 500 15px/1.35 var(--fm-font, 'Jost', system-ui, sans-serif);
	color: var(--fm-ink, #111);
	text-decoration: none;
	overflow-wrap: anywhere;
}

html.fm-sf #astra-mobile-cart-drawer dl.fm-mi-var {
	margin: 4px 0 0;
	font-size: 13px;
	line-height: 1.4;
	color: var(--fm-muted, #6b6b6b);
}

html.fm-sf #astra-mobile-cart-drawer dl.fm-mi-var dt,
html.fm-sf #astra-mobile-cart-drawer dl.fm-mi-var dd {
	display: inline;
	margin: 0;
}

html.fm-sf #astra-mobile-cart-drawer dl.fm-mi-var dt::after {
	content: ' ';
}

html.fm-sf #astra-mobile-cart-drawer p.fm-mi-meta {
	margin: 3px 0 0;
	font: 400 13px/1.4 var(--fm-font, 'Jost', system-ui, sans-serif);
	color: var(--fm-muted, #6b6b6b);
}

html.fm-sf #astra-mobile-cart-drawer .fm-mi-price {
	margin-top: 4px;
	font: 500 14px/1.3 var(--fm-font, 'Jost', system-ui, sans-serif);
	color: var(--fm-body, #2b2b2b);
}

/* 44px hit area for remove, pulled up so the glyph still sits level with the name. */
html.fm-sf #astra-mobile-cart-drawer a.fm-mi-remove {
	grid-area: remove;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	margin: -10px -10px 0 0;
	padding: 0;
	color: var(--fm-muted, #6b6b6b);
	border-radius: 50%;
	text-decoration: none;
}

html.fm-sf #astra-mobile-cart-drawer a.fm-mi-remove:hover {
	color: var(--fm-ink, #111);
	background: var(--fm-canvas, #f6f6f4);
}

html.fm-sf #astra-mobile-cart-drawer a.fm-mi-remove:focus,
html.fm-sf #astra-mobile-cart-drawer a.fm-mi-remove:focus-visible {
	color: var(--fm-ink, #111);
	box-shadow: none;
	outline: 2px solid var(--fm-ink, #111);
	outline-offset: 2px;
}

html.fm-sf #astra-mobile-cart-drawer a.fm-mi-remove svg {
	width: 20px;
	height: 20px;
}

/* Quantity stepper: 44px buttons so every tap lands. */
html.fm-sf #astra-mobile-cart-drawer .fm-mq {
	grid-area: qty;
	display: inline-flex;
	align-items: stretch;
	justify-self: start;
	height: 44px;
	overflow: hidden;
	border: 1px solid var(--fm-line-strong, #cfcfcf);
	border-radius: var(--fm-radius-sm, 8px);
	background: #fff;
	transition: opacity 0.15s ease;
}

html.fm-sf #astra-mobile-cart-drawer .fm-mq.is-busy {
	opacity: 0.55;
}

html.fm-sf #astra-mobile-cart-drawer .fm-mq-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	min-width: 44px;
	height: 44px;
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
	color: var(--fm-ink, #111);
	font: 400 20px/1 var(--fm-font, 'Jost', system-ui, sans-serif);
	cursor: pointer;
}

html.fm-sf #astra-mobile-cart-drawer .fm-mq-btn:focus-visible {
	outline: 2px solid var(--fm-ink, #111);
	outline-offset: -2px;
}

html.fm-sf #astra-mobile-cart-drawer .fm-mq-val {
	display: inline-flex;
	align-items: center;
	min-width: 36px;
	justify-content: center;
	font: 500 15px/1 var(--fm-font, 'Jost', system-ui, sans-serif);
	color: var(--fm-ink, #111);
}

/* Footer: subtotal and microcopy stay above the two buttons. */
html.fm-sf #astra-mobile-cart-drawer .woocommerce-mini-cart__total {
	flex: 0 0 auto;
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
	margin: 0;
	padding: 14px 20px 2px;
	border-top: 1px solid var(--fm-line, #e6e6e6);
	border-bottom: 0;
	font: 600 15px/1.3 var(--fm-font, 'Jost', system-ui, sans-serif);
	color: var(--fm-ink, #111);
}

html.fm-sf #astra-mobile-cart-drawer .fm-cart-note {
	flex: 0 0 auto;
	margin: 0;
	padding: 2px 20px 14px;
	font: 400 12.5px/1.4 var(--fm-font, 'Jost', system-ui, sans-serif);
	color: var(--fm-muted, #6b6b6b);
}

html.fm-sf #astra-mobile-cart-drawer p.woocommerce-mini-cart__buttons {
	flex: 0 0 auto;
	display: grid !important;
	grid-template-columns: 1fr 1fr;
	gap: 10px;
	margin: 0;
	padding: 12px 20px calc(16px + env(safe-area-inset-bottom, 0px));
	border-top: 1px solid var(--fm-line, #e6e6e6);
	background: #fff;
}

/* Astra's clearfix pseudo-elements would take grid cells and push the buttons out of line. */
html.fm-sf #astra-mobile-cart-drawer p.woocommerce-mini-cart__buttons::before,
html.fm-sf #astra-mobile-cart-drawer p.woocommerce-mini-cart__buttons::after {
	content: none !important;
	display: none !important;
}

html.fm-sf #astra-mobile-cart-drawer p.woocommerce-mini-cart__buttons a.button {
	display: flex;
	align-items: center;
	justify-content: center;
	float: none !important;
	width: auto !important;
	min-height: 48px;
	margin: 0 !important;
	padding: 0 12px;
	border: 1.5px solid var(--fm-ink, #111);
	border-radius: var(--fm-radius-sm, 8px);
	background: #fff;
	color: var(--fm-ink, #111);
	font: 600 14px/1.2 var(--fm-font, 'Jost', system-ui, sans-serif);
	text-align: center;
	text-decoration: none;
}

html.fm-sf #astra-mobile-cart-drawer p.woocommerce-mini-cart__buttons a.button.checkout,
html.fm-sf #astra-mobile-cart-drawer p.woocommerce-mini-cart__buttons a.button.wc-forward.checkout {
	border-color: var(--fm-ink, #111);
	background: var(--fm-ink, #111);
	color: #fff;
}

html.fm-sf #astra-mobile-cart-drawer p.woocommerce-mini-cart__buttons a.button:focus-visible {
	outline: 2px solid var(--fm-ink, #111);
	outline-offset: 2px;
}

/* Empty state. */
html.fm-sf #astra-mobile-cart-drawer .woocommerce-mini-cart__empty-message {
	margin: 36px 20px 16px;
	text-align: center;
	font: 500 16px/1.4 var(--fm-font, 'Jost', system-ui, sans-serif);
	color: var(--fm-ink, #111);
}

html.fm-sf #astra-mobile-cart-drawer .fm-cart-empty-cta {
	padding: 0 20px 24px;
}

html.fm-sf .fm-btn--primary {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	width: 100%;
	min-height: 48px;
	padding: 0 24px;
	border: 0;
	border-radius: var(--fm-radius-sm, 8px);
	background: var(--fm-ink, #111);
	color: #fff;
	font: 600 15px/1 var(--fm-font, 'Jost', system-ui, sans-serif);
	cursor: pointer;
}

html.fm-sf .fm-btn--primary:hover {
	background: var(--fm-primary-hover, #000);
}

html.fm-sf .fm-btn--primary:focus-visible {
	outline: 2px solid var(--fm-ink, #111);
	outline-offset: 3px;
}

/* Skeleton: shown instead of any cart content until Woo's fragments arrive. */
html.fm-sf #astra-mobile-cart-drawer .fm-cart-skel {
	display: none;
	padding: 16px 20px;
}

html.fm-sf #astra-mobile-cart-drawer.fm-cart-pending .fm-cart-skel {
	display: block;
}

html.fm-sf #astra-mobile-cart-drawer.fm-cart-pending .widget_shopping_cart_content {
	display: none;
}

html.fm-sf .fm-skel-row {
	display: block;
	height: 72px;
	margin-bottom: 14px;
	border-radius: var(--fm-radius-sm, 8px);
	background: linear-gradient(90deg, #f0f0ee 25%, #e4e4e1 37%, #f0f0ee 63%);
	background-size: 400% 100%;
	animation: fm-skel 1.2s ease infinite;
}

@keyframes fm-skel {
	0% { background-position: 100% 50%; }
	100% { background-position: 0 50%; }
}

@media (prefers-reduced-motion: reduce) {
	html.fm-sf .fm-skel-row,
	html.fm-sf .fm-toast {
		animation: none;
		transition: none;
	}
}

/* Desktop: the same drawer, shown as a right-hand flyout. */
@media (min-width: 768px) {
	html.fm-sf #astra-mobile-cart-drawer.astra-cart-drawer {
		width: min(440px, 100vw);
	}
}

/* ---------------------------------------------------------------- cart page */

/* Heading row above the cart block: "Your cart (N)" and a Continue shopping link. */
html.fm-sf body.woocommerce-cart .fm-cart-head {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	gap: 16px;
	margin: 24px 15px 16px;
	padding: 0 0 12px;
	border-bottom: 1px solid var(--fm-line, #e6e6e6);
}

/* Desktop: the Blocks sidebar layout puts the totals column 21px inside the wrapper's right edge; align to it. */
@media (min-width: 1024px) {
	html.fm-sf body.woocommerce-cart .fm-cart-head {
		margin: 24px 21px 16px 0;
	}
}

html.fm-sf body.woocommerce-cart .fm-cart-head__title {
	margin: 0;
	font: 500 26px/1.15 var(--fm-font, 'Jost', system-ui, sans-serif);
	color: var(--fm-ink, #111);
	letter-spacing: -0.01em;
}

html.fm-sf body.woocommerce-cart .fm-cart-head__count {
	font-weight: 400;
	color: var(--fm-muted, #6b6b6b);
}

html.fm-sf body.woocommerce-cart .fm-cart-head__continue {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	font: 500 14px/1.2 var(--fm-font, 'Jost', system-ui, sans-serif);
	color: var(--fm-ink, #111);
	text-decoration: underline;
	text-underline-offset: 4px;
	white-space: nowrap;
}

/* The cart block (WooCommerce Blocks): keep its behaviour, lift its tap targets and type. */
/* Keep the line-items table inside the gutter: fixed columns stop the price and sale badge spilling past the right edge on narrow phones. */
html.fm-sf body.woocommerce-cart .wc-block-cart-items {
	table-layout: fixed;
	width: 100%;
}

html.fm-sf body.woocommerce-cart .wc-block-cart-item__total,
html.fm-sf body.woocommerce-cart .wc-block-cart-item__total-price-and-sale-badge-wrapper {
	white-space: normal;
	min-width: 0;
}

html.fm-sf body.woocommerce-cart .wp-block-woocommerce-cart .wc-block-components-quantity-selector {
	min-height: 44px;
	border-radius: var(--fm-radius-sm, 8px);
	border-color: var(--fm-line-strong, #cfcfcf);
}

html.fm-sf body.woocommerce-cart .wc-block-components-quantity-selector__button {
	width: 44px;
	min-width: 44px;
	height: 44px;
	color: var(--fm-ink, #111);
	font-size: 20px;
}

html.fm-sf body.woocommerce-cart .wc-block-components-quantity-selector__input {
	width: 44px;
	height: 44px;
	font: 500 16px/1 var(--fm-font, 'Jost', system-ui, sans-serif);
	color: var(--fm-ink, #111);
}

html.fm-sf body.woocommerce-cart .wc-block-cart-item__remove-link {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 44px;
	min-height: 44px;
	color: var(--fm-muted, #6b6b6b);
}

html.fm-sf body.woocommerce-cart .wc-block-cart .wc-block-components-button,
html.fm-sf body.woocommerce-cart .wc-block-cart .wc-block-cart__submit-button {
	min-height: 52px;
	border-radius: var(--fm-radius-sm, 8px);
	font: 600 15px/1.2 var(--fm-font, 'Jost', system-ui, sans-serif);
}

html.fm-sf body.woocommerce-cart .wc-block-cart .wc-block-cart__submit-button {
	background: var(--fm-ink, #111);
	color: #fff;
}

html.fm-sf body.woocommerce-cart .wc-block-cart .wc-block-cart__submit-button:hover {
	background: var(--fm-primary-hover, #000);
}

/* The page's decorative dot separator sits above the new heading row; it adds nothing on the cart. */
html.fm-sf body.woocommerce-cart .wp-block-separator.is-style-dots {
	display: none;
}

html.fm-sf body.woocommerce-cart .wc-block-components-panel__button {
	min-height: 44px;
	display: flex;
	align-items: center;
	font: 500 15px/1.2 var(--fm-font, 'Jost', system-ui, sans-serif);
	color: var(--fm-ink, #111);
}

html.fm-sf body.woocommerce-cart .wc-block-components-totals-coupon__button,
html.fm-sf body.woocommerce-cart .wc-block-components-totals-coupon-link {
	min-height: 44px;
	font: 500 15px/1.2 var(--fm-font, 'Jost', system-ui, sans-serif);
	color: var(--fm-ink, #111);
}

html.fm-sf body.woocommerce-cart .wc-block-components-text-input input,
html.fm-sf body.woocommerce-cart .wc-block-components-totals-coupon__form input {
	font-size: 16px;
}

html.fm-sf body.woocommerce-cart .wc-block-cart__empty-cart__title,
html.fm-sf body.woocommerce-cart .wc-block-cart__empty-text {
	font-family: var(--fm-font, 'Jost', system-ui, sans-serif);
}

/* Woo injects a "View cart" link after an AJAX add; the theme pins it to the viewport bottom. With the drawer open it is redundant. */
html.fm-sf.ast-mobile-cart-active a.added_to_cart {
	display: none !important;
}
