/* Floating mobile bottom bar (T-04). Layer on WoodMart's .wd-toolbar. Breakpoint <=1024px (D-10). */
@media (max-width: 1024px) {
	body.sticky-toolbar-on {
		--ct-bar-h: 64px;
		--ct-bar-gap: 12px;
		--ct-safe-b: env(safe-area-inset-bottom, 0px);
		--ct-bar-total: calc(var(--ct-bar-h) + var(--ct-bar-gap) * 2 + var(--ct-safe-b));
		/* content is never hidden behind the bar */
		padding-bottom: var(--ct-bar-total);
		/* landscape notch: keep content out of the side cut-outs (0 in portrait) */
		padding-inline: env(safe-area-inset-left, 0px) env(safe-area-inset-right, 0px);
	}
	body.sticky-toolbar-on.wd-sticky-btn-on,
	body.sticky-toolbar-on.wd-sticky-btn-on-mb {
		padding-bottom: calc(var(--ct-bar-total) + var(--wd-sticky-btn-height, 0px));
	}

	body.sticky-toolbar-on .wd-toolbar {
		inset-inline-start: max(var(--ct-bar-gap), env(safe-area-inset-left, 0px));
		inset-inline-end: max(var(--ct-bar-gap), env(safe-area-inset-right, 0px));
		bottom: calc(var(--ct-bar-gap) + var(--ct-safe-b));
		height: var(--ct-bar-h);
		padding: 6px;
		border-radius: 16px;
		background-color: #fff;
		box-shadow: 0 6px 24px rgba(0, 0, 0, .16), 0 1px 4px rgba(0, 0, 0, .1);
		overflow: hidden;
		z-index: 350;
		transition: transform .22s ease;
		will-change: transform;
	}
	body.sticky-toolbar-on .wd-toolbar.ct-bar-hidden {
		transform: translateY(calc(100% + 24px + var(--ct-safe-b)));
	}

	/* items: >=44px targets, icon + label */
	body.sticky-toolbar-on .wd-toolbar > div { flex: 1 1 0; min-width: 0; }
	body.sticky-toolbar-on .wd-toolbar.wd-toolbar-label-show > div a {
		position: relative;
		display: flex;
		align-items: center;
		justify-content: center;
		height: 100%;
		min-height: 48px;
		padding-bottom: 18px;
		border-radius: 12px;
		color: #333;
		-webkit-tap-highlight-color: transparent;
	}
	body.sticky-toolbar-on .wd-toolbar .wd-toolbar-label {
		inset-inline: 0;
		bottom: 6px;
		display: block;
		font-size: 12px;
		line-height: 1.2;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
		font-weight: 600;
		color: inherit;
	}
	body.sticky-toolbar-on .wd-toolbar .wd-custom-icon img { height: 22px; width: 22px; }

	/* very narrow phones (320px): keep the longest label ("كل المنتجات") unclipped */
	@media (max-width: 340px) {
		body.sticky-toolbar-on .wd-toolbar { padding: 3px; }
		body.sticky-toolbar-on .wd-toolbar .wd-toolbar-label { font-size: 11px; }
	}

	/* current page / open menu */
	body.sticky-toolbar-on .wd-toolbar .ct-current a,
	body.sticky-toolbar-on .wd-toolbar a[aria-current="page"],
	body.sticky-toolbar-on .wd-toolbar a[aria-expanded="true"],
	body.woocommerce-cart.sticky-toolbar-on .wd-toolbar .wd-header-cart a {
		color: #dd3333;
	}
	body.sticky-toolbar-on .wd-toolbar .ct-current a::before,
	body.sticky-toolbar-on .wd-toolbar a[aria-current="page"]::before,
	body.sticky-toolbar-on .wd-toolbar a[aria-expanded="true"]::before,
	body.woocommerce-cart.sticky-toolbar-on .wd-toolbar .wd-header-cart a::before {
		content: "";
		position: absolute;
		top: 0;
		inset-inline: 28%;
		height: 3px;
		border-radius: 0 0 3px 3px;
		background: #dd3333;
	}

	/* visible keyboard focus */
	body.sticky-toolbar-on .wd-toolbar a:focus-visible {
		outline: 2px solid #dd3333;
		outline-offset: -2px;
	}

	/* D-1: Chaty is desktop-only. Its own per-channel Mobile flags are UA-based, so a narrow desktop-UA window
	   (iPadOS reports a desktop UA) would still overlap the bar; hide it by width as a fallback. */
	body.sticky-toolbar-on .chaty { display: none !important; }

	/* re-offset floating elements that used to sit above the 55px bar */
	body.sticky-toolbar-on .wd-sticky-btn {
		bottom: calc(var(--ct-bar-total));
		transition: bottom .22s ease;
	}
	body.sticky-toolbar-on:has(.wd-toolbar.ct-bar-hidden) .wd-sticky-btn { bottom: 0; }
	body.sticky-toolbar-on .scrollToTop {
		bottom: calc(var(--ct-bar-total) + 8px);
		transition: bottom .22s ease, opacity .25s ease, visibility .25s ease;
	}
	body.sticky-toolbar-on .wd-sticky-btn-shown.scrollToTop {
		bottom: calc(var(--ct-bar-total) + 8px + var(--wd-sticky-btn-height, 0px));
	}
	body.sticky-toolbar-on:has(.wd-toolbar.ct-bar-hidden) .scrollToTop { bottom: calc(var(--ct-bar-gap) + var(--ct-safe-b)); }
	body.sticky-toolbar-on:has(.wd-toolbar.ct-bar-hidden) .wd-sticky-btn-shown.scrollToTop {
		bottom: calc(var(--ct-bar-gap) + var(--ct-safe-b) + var(--wd-sticky-btn-height, 0px));
	}
}

@media (prefers-reduced-motion: reduce) {
	body.sticky-toolbar-on .wd-toolbar,
	body.sticky-toolbar-on .wd-sticky-btn,
	body.sticky-toolbar-on .scrollToTop {
		transition: none !important;
	}
}
