/**
 * Bottom of the screen (≤1024px): Woodmart's toolbar as a floating capsule.
 *
 * Woodmart's sticky toolbar (home · menu · account), full width and 55px,
 * becomes a capsule lifted off the screen edge, in the header's glass
 * (--al-hdr-* from al-header.css, which loads first). Its stylesheet prints
 * in <body>, after this one, hence body.sticky-toolbar-on in every selector.
 *
 * One stack, iOS tab bar style: the capsule stands 16px off the sides and
 * 8px off the bottom, close to Safari's own bar under it (not closer: Safari
 * 26 samples the point 4px above the page's bottom edge to colour the strip
 * under its tab bar, and a glass capsule sitting on that point made it paint
 * a solid strip there; 16px is Material's minimum for a floating bar); what stands
 * on it (the product page's add-to-cart, the filter opener, and on one end
 * scroll-to-top over the cookie button) stands one step above it and lines
 * up with its edges. Each piece carries its own glass and shadow; there is
 * no full-width band behind the stack (2026-09-25: iOS 26 Safari draws the
 * page on below the fixed layer, around its floating tab bar, so a band that
 * stops at the layer's edge read as a cut-off shadow).
 *
 * --al-tb-off is what the capsule takes from the bottom of the screen;
 * --al-tb-top is where what stands on it starts.
 *
 * No viewport-fit=cover: without it iOS Safari (26's floating tab bar
 * included) ends the page's fixed layer above its own toolbar and the home
 * indicator, so the capsule floats clear of both and env() reads 0. With it
 * (a home-screen web app, or if the theme ever adds it), env() lifts the
 * whole stack clear of the home indicator.
 */

@media screen and (max-width: 1024px) {
	/* On the root, not body, so the page's scroll padding can use them. */
	:root:has(> body.sticky-toolbar-on) {
		--al-tb: 56px;
		--al-tb-gap: var(--al-s-4); /* off the sides */
		--al-tb-foot: var(--al-s-2); /* off the bottom */
		--al-tb-max: 480px; /* tablets: a capsule, not a bar */
		--al-tb-edge: max(var(--al-tb-gap), (100% - var(--al-tb-max)) / 2); /* the capsule's side, from the screen's */
		--al-tb-off: calc(var(--al-tb) + var(--al-tb-foot) + env(safe-area-inset-bottom, 0px));
		--al-tb-top: calc(var(--al-tb-off) + var(--al-s-2));
		--al-tb-top-atc: calc(var(--al-tb-top) + var(--wd-sticky-btn-height) + var(--al-s-2));
		--al-tb-btn: calc(2 * var(--al-fab) + var(--al-s-2)); /* the tallest thing standing on it: scroll-to-top on the cookie button */
		--al-fab-x: var(--al-tb-edge);
		--al-fab-y: var(--al-tb-top);
		/* Keyboard focus scrolls clear of the capsule (WCAG 2.4.11)... */
		scroll-padding-block-end: calc(var(--al-tb-top) + var(--al-s-3));
	}

	/* ...and of the sticky add-to-cart standing on it, which the round pair
	   then stands on. */
	:root:has(> body.sticky-toolbar-on .wd-sticky-btn-shown) {
		--al-fab-y: var(--al-tb-top-atc);
		scroll-padding-block-end: calc(var(--al-tb-top-atc) + var(--al-s-3));
	}

	/* The page ends clear of the whole stack: of the tallest thing standing
	   on it (scroll-to-top on the cookie button, 80px; the filter opener is
	   42px, and on tablets the pair stands over the footer, not in the
	   gutter). That room shows the body behind the page wrapper, the
	   footer's surface, so the footer runs on under the stack. */
	body.sticky-toolbar-on,
	body.sticky-toolbar-on.wd-sticky-btn-on,
	body.sticky-toolbar-on.wd-sticky-btn-on-mb {
		padding-block-end: calc(var(--al-tb-top) + var(--al-tb-btn) + var(--al-s-4));
		background-color: var(--al-surface);
	}

	body.sticky-toolbar-on.wd-sticky-btn-on,
	body.sticky-toolbar-on.wd-sticky-btn-on-mb {
		padding-block-end: calc(var(--al-tb-top-atc) + var(--al-tb-btn) + var(--al-s-4));
	}

	/* Opaque enough (94%) that the labels never sit on legible text, even
	   where the blur is not painted. */
	body.sticky-toolbar-on .wd-toolbar {
		inset-inline: var(--al-tb-gap);
		max-inline-size: var(--al-tb-max);
		margin-inline: auto;
		inset-block-end: calc(var(--al-tb-foot) + env(safe-area-inset-bottom, 0px));
		block-size: var(--al-tb);
		padding: var(--al-s-1) var(--al-s-2);
		overflow: hidden;
		border: 1px solid var(--al-hdr-line);
		border-radius: calc(var(--al-tb) / 2);
		background: var(--al-hdr-glass-panel);
		-webkit-backdrop-filter: var(--al-hdr-blur);
		backdrop-filter: var(--al-hdr-blur);
		box-shadow: var(--al-hdr-float); /* tight: see al-header.css */
	}

	body.sticky-toolbar-on .wd-toolbar :is(a:hover, a:focus-visible) {
		color: var(--al-ink);
	}

	/* The site's square ring, drawn outside, lost its corners to the
	   capsule's clip: inside here, and concentric with it. */
	body.sticky-toolbar-on .wd-toolbar a:focus-visible {
		outline-offset: -2px;
		border-radius: calc(var(--al-tb) / 2 - var(--al-s-1));
	}

	/* The product page's sticky add-to-cart stands on the capsule, same
	   inset. Hidden, it fades out instead of sliding behind the capsule
	   (it would show through the glass). */
	body.sticky-toolbar-on .wd-sticky-btn {
		inset-inline: var(--al-tb-gap);
		inset-block-end: var(--al-tb-top);
		border-radius: var(--al-r-lg);
		transition: transform .5s cubic-bezier(.19, 1, .22, 1), opacity var(--al-t) var(--al-ease), visibility 0s .5s;
	}

	body.sticky-toolbar-on .wd-sticky-btn:not(.wd-sticky-btn-shown) {
		visibility: hidden;
		opacity: 0;
	}

	body.sticky-toolbar-on .wd-sticky-btn.wd-sticky-btn-shown {
		transition-delay: 0s;
	}

	body.sticky-toolbar-on .wd-sticky-btn :is(.single_add_to_cart_button, .wd-sticky-add-to-cart) {
		border-radius: var(--al-r-md) !important; /* Woodmart squares it with !important on phones */
	}
}

/* Desktop: the product page's sticky add-to-cart bar spans the window foot.
   Keyboard focus scrolls clear of it, and the round pair, which sat over the
   bar's packshot, stands on it. */
@media (min-width: 1025px) {
	:root:has(.wd-sticky-btn-shown) {
		--al-fab-y: calc(var(--wd-sticky-btn-height) + var(--al-s-3));
		scroll-padding-block-end: calc(var(--wd-sticky-btn-height) + var(--al-s-3));
	}
}

/* The round pair, at every width: scroll-to-top stands on the
   cookie-settings button, 8px above it, on its end (the plugin's .right or
   .left, physical sides, so these are too); before consent the cookie
   button is hidden and scroll-to-top takes its place. --al-fab-x/-y is the
   cookie button's corner: the window's on desktop, the capsule's end or the
   add-to-cart's on the stack above. */
:root {
	--al-fab: 36px;
	--al-fab-x: var(--al-s-4);
	--al-fab-y: var(--al-s-4);
}

/* Scroll-to-top only fades: Woodmart's slide-in runs the LTR way, so in RTL
   it slid in from the page, its own width off the edge it settles on. The
   class three times: over Woodmart's toolbar and sticky-bar offsets, up to
   (0,3,0). */
body .scrollToTop.scrollToTop.scrollToTop {
	right: var(--al-fab-x);
	left: auto;
	inset-block-end: var(--al-fab-y);
	inline-size: var(--al-fab);
	block-size: var(--al-fab);
	font-size: 13px; /* Woodmart's 14px on 40px, scaled */
	transform: none;
	transition: opacity var(--al-t) var(--al-ease);
}

body:has(pressidium-floating-button.left) .scrollToTop.scrollToTop.scrollToTop {
	right: auto;
	left: var(--al-fab-x);
}

body:has(pressidium-floating-button[status="visible"]) .scrollToTop.scrollToTop.scrollToTop {
	inset-block-end: calc(var(--al-fab-y) + var(--al-fab) + var(--al-s-2));
}

/* The cookie-settings button: its z-index 9999 put it over open drawers.
   Its 48px button lives in a shadow root with nothing to size it by from
   outside (no part, no variable), so the host is scaled from its outer
   bottom corner; taps follow the transform, so the tap area is what is
   drawn. Before consent it is hidden but its box still took taps, a dead
   spot over the page corner. */
html body pressidium-floating-button {
	z-index: 345;
	inset-block-end: var(--al-fab-y);
	transform: scale(.75); /* 48px to --al-fab */
}
html body pressidium-floating-button.right {
	right: var(--al-fab-x);
	transform-origin: 100% 100%;
}
html body pressidium-floating-button.left {
	left: var(--al-fab-x);
	transform-origin: 0 100%;
}
pressidium-floating-button[status="hidden"] {
	pointer-events: none;
}

/* Woodmart's phone sticky bar (quantity + button, up to 768px) is the
   capsule's accessory: as wide, and a capsule too, like a mini player over
   an iOS tab bar. From 769px it is the desktop bar (packshot, title, price,
   quantity, button) and keeps the full width it needs. */
@media screen and (max-width: 768.98px) {
	/* A size under the page's own 48px button; the quantity follows it. */
	:root:has(> body.sticky-toolbar-on) {
		--wd-sticky-btn-height: 44px;
	}

	body.sticky-toolbar-on .wd-sticky-btn {
		--btn-accented-height: var(--wd-sticky-btn-height);
		max-inline-size: var(--al-tb-max);
		margin-inline: auto;
		border-radius: calc(var(--wd-sticky-btn-height) / 2);
		box-shadow: var(--al-hdr-float); /* the stack's one shadow, not Woodmart's 9px halo */
	}

	body.sticky-toolbar-on .wd-sticky-btn :is(.single_add_to_cart_button, .wd-sticky-add-to-cart) {
		border-radius: calc(var(--wd-sticky-btn-height) / 2) !important;
	}

	/* The button fills the bar and the bar clips (Woodmart's overflow), so
	   the site's ring, drawn outside, never showed: inside here, following
	   the capsule; the quantity's end button rounds with the bar's end so
	   its ring does too. The quantity field, which had none, gets the same. */
	body.sticky-toolbar-on .wd-sticky-btn :is(button, a, input):focus-visible {
		outline: 2px solid var(--al-ink);
		outline-offset: -2px;
	}

	body.sticky-toolbar-on .wd-sticky-btn .quantity .minus {
		border-start-start-radius: calc(var(--wd-sticky-btn-height) / 2);
		border-end-start-radius: calc(var(--wd-sticky-btn-height) / 2);
	}
}

/* Tablets: the desktop bar spans the window, 16px in, so while it shows,
   the round pair stands on its end, not the capsule's. */
@media screen and (min-width: 769px) and (max-width: 1024px) {
	:root:has(> body.sticky-toolbar-on .wd-sticky-btn-shown) {
		--al-tb-edge: var(--al-tb-gap);
	}
}

/* A field has the on-screen keyboard (html.al-kb, al-header.js): the whole
   stack steps aside, so it does not cover the next row of fields. Written
   out, not with :is(), so browsers before it (iOS 13) keep the rule. */
@media screen and (max-width: 1024px) {
	html.al-kb body.sticky-toolbar-on .wd-toolbar,
	html.al-kb body.sticky-toolbar-on .wd-sticky-btn,
	html.al-kb body.sticky-toolbar-on .wd-sidebar-opener,
	html.al-kb body.sticky-toolbar-on .scrollToTop,
	html.al-kb body pressidium-floating-button {
		visibility: hidden;
		opacity: 0;
		pointer-events: none;
	}
}

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

/* Paper has no bottom stack: fixed, it would print over every page foot. */
@media print {
	.wd-toolbar,
	.wd-sticky-btn,
	.scrollToTop,
	pressidium-floating-button {
		display: none !important;
	}
}
