/**
 * My Custom Woo Features - floating bar.
 *
 * Colours, font and corners come from the Design tab (--mcwf-* variables);
 * the Floating Bar tab can set its own colours (--mcwf-fbar-*).
 *
 * The bar shows below 768px ("mobile"), below 1025px ("tablet") or always
 * ("all"). Where it shows, --mcwf-fbar-space holds its height, and the
 * page, the sticky add to cart bar, the floating cart button and toasts
 * make room for it.
 */

/* -------------------------------------------------------------------------
 * Space for the bar
 * ---------------------------------------------------------------------- */

body.mcwf-fbar-on {
	--mcwf-fbar-h: 62px;
}

body.mcwf-fbar-on.mcwf-fbar-no-labels {
	--mcwf-fbar-h: 54px;
}

body.mcwf-fbar-on--all {
	--mcwf-fbar-space: calc(var(--mcwf-fbar-h) + env(safe-area-inset-bottom, 0px));
}

@media (max-width: 1024px) {
	body.mcwf-fbar-on--tablet {
		--mcwf-fbar-space: calc(var(--mcwf-fbar-h) + env(safe-area-inset-bottom, 0px));
	}
}

@media (max-width: 767px) {
	body.mcwf-fbar-on--mobile {
		--mcwf-fbar-space: calc(var(--mcwf-fbar-h) + env(safe-area-inset-bottom, 0px));
	}
}

/* Empty block at the end of the page: the footer is never hidden behind the bar. */
.mcwf-fbar-spacer {
	display: block;
	height: var(--mcwf-fbar-space, 0px);
}

/* Other things fixed to the bottom of the screen sit above the bar. */
body.mcwf-fbar-on .mcwf-sticky-cart {
	bottom: var(--mcwf-fbar-space, 0px);
}

body.mcwf-fbar-on .mcwf-floating-cart {
	bottom: calc(24px + var(--mcwf-fbar-space, 0px));
}

html.mcwf-sticky-cart-visible body.mcwf-fbar-on .mcwf-floating-cart {
	bottom: calc(90px + var(--mcwf-fbar-space, 0px));
}

body.mcwf-fbar-on .mcwf-toasts {
	bottom: calc(24px + var(--mcwf-fbar-space, 0px));
}

@media (max-width: 767px) {
	html.mcwf-sticky-cart-visible body.mcwf-fbar-on .mcwf-floating-cart {
		bottom: calc(76px + var(--mcwf-fbar-space, 0px));
	}

	/* Toasts show at the top on phones. */
	body.mcwf-fbar-on .mcwf-toasts {
		bottom: auto;
	}
}

/* The bar's own cart replaces the floating cart button where the bar shows. */
body.mcwf-fbar-has-cart.mcwf-fbar-on--all .mcwf-floating-cart {
	display: none;
}

@media (max-width: 1024px) {
	body.mcwf-fbar-has-cart.mcwf-fbar-on--tablet .mcwf-floating-cart {
		display: none;
	}
}

@media (max-width: 767px) {
	body.mcwf-fbar-has-cart.mcwf-fbar-on--mobile .mcwf-floating-cart {
		display: none;
	}
}

/* -------------------------------------------------------------------------
 * The bar
 * ---------------------------------------------------------------------- */

.mcwf-fbar {
	position: fixed;
	right: 0;
	bottom: 0;
	left: 0;
	z-index: 9986;
	display: none;
	box-sizing: border-box;
	padding: 0 6px env(safe-area-inset-bottom, 0px);
	color: var(--mcwf-fbar-color, var(--mcwf-title));
	font-family: var(--mcwf-font, inherit);
	background: var(--mcwf-fbar-bg, var(--mcwf-surface));
	border-top: 1px solid var(--mcwf-border);
	border-radius: min(var(--mcwf-panel-radius), 18px) min(var(--mcwf-panel-radius), 18px) 0 0;
	box-shadow: 0 -4px 18px rgba(0, 0, 0, 0.08);
}

.mcwf-fbar--all {
	display: block;
}

@media (max-width: 1024px) {
	.mcwf-fbar--tablet {
		display: block;
	}
}

@media (max-width: 767px) {
	.mcwf-fbar--mobile {
		display: block;
	}
}

.mcwf-fbar .mcwf-fbar__list {
	display: flex;
	align-items: stretch;
	max-width: 760px;
	height: var(--mcwf-fbar-h, 62px);
	margin: 0 auto;
	padding: 0;
	list-style: none;
}

.mcwf-fbar .mcwf-fbar__cell {
	position: relative;
	display: flex;
	flex: 1 1 0;
	min-width: 0;
	margin: 0;
	padding: 0;
}

.mcwf-fbar .mcwf-fbar__cell::before,
.mcwf-fbar .mcwf-fbar__cell::marker {
	content: none;
}

/* Links and buttons look the same (button colours use the plugin's private variables). */
.mcwf-fbar .mcwf-fbar__item,
.mcwf-fbar .mcwf-fbar__item:visited,
.mcwf-fbar .mcwf-fbar__item:hover,
.mcwf-fbar .mcwf-fbar__item:focus {
	--_c: var(--mcwf-fbar-color, var(--mcwf-title));
	--_bg: transparent;
	--_p: 6px 2px 9px;
	--_fs: var(--mcwf-fbar-fs, 11px);
	--_fw: 500;
	--_lh: 1.2;

	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	align-items: center;
	justify-content: flex-end;
	gap: 4px;
	min-width: 0;
	margin: 0;
	padding: 6px 2px 9px;
	color: var(--mcwf-fbar-color, var(--mcwf-title));
	font-family: var(--mcwf-font, inherit);
	font-size: var(--mcwf-fbar-fs, 11px);
	font-weight: 500;
	line-height: 1.2;
	text-align: center;
	text-decoration: none;
	text-transform: none;
	letter-spacing: normal;
	background: transparent;
	border: 0;
	border-radius: var(--mcwf-btn-radius);
	box-shadow: none;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

.mcwf-fbar .mcwf-fbar__item.is-current {
	--_c: var(--mcwf-fbar-active, var(--mcwf-primary));

	color: var(--mcwf-fbar-active, var(--mcwf-primary));
	font-weight: 600;
}

.mcwf-fbar .mcwf-fbar__item:active .mcwf-fbar__icon {
	transform: scale(0.92);
}

.mcwf-fbar .mcwf-fbar__item:focus-visible {
	outline: 2px solid var(--mcwf-fbar-active, var(--mcwf-primary));
	outline-offset: -2px;
}

.mcwf-fbar .mcwf-fbar__icon {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	transition: transform 0.15s;
}

.mcwf-fbar .mcwf-fbar__icon .mcwf-icon,
.mcwf-fbar .mcwf-fbar__icon svg {
	width: 24px;
	height: 24px;
}

/* Own icon from the media library. */
.mcwf-fbar .mcwf-fbar__img {
	display: block;
	width: 24px;
	height: 24px;
	margin: 0;
	object-fit: contain;
	border-radius: 0;
}

/* Tinted: the picture's shape in the icon colour. */
.mcwf-fbar .mcwf-fbar__img--tint {
	background-color: currentColor;
	-webkit-mask: var(--mcwf-fbar-img) center / contain no-repeat;
	mask: var(--mcwf-fbar-img) center / contain no-repeat;
}

.mcwf-fbar .mcwf-fbar__cell--big .mcwf-fbar__img {
	width: 26px;
	height: 26px;
}

.mcwf-fbar .mcwf-fbar__label {
	display: block;
	max-width: 100%;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* Counters: cart items and wishlist. */
.mcwf-fbar .mcwf-cart-count,
.mcwf-fbar .mcwf-wishlist-count {
	position: absolute;
	top: -5px;
	inset-inline-end: -9px;
	display: flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	min-width: 17px;
	height: 17px;
	padding: 0 4px;
	color: var(--mcwf-primary-text);
	font-family: var(--mcwf-font, inherit);
	font-size: 10px;
	font-weight: 700;
	line-height: 1;
	background: var(--mcwf-fbar-active, var(--mcwf-primary));
	border: 2px solid var(--mcwf-fbar-bg, var(--mcwf-surface));
	border-radius: 999px;
}

.mcwf-fbar .mcwf-wishlist-count[data-count="0"] {
	display: none;
}

/* -------------------------------------------------------------------------
 * Big middle button
 * ---------------------------------------------------------------------- */

.mcwf-fbar .mcwf-fbar__cell--big .mcwf-fbar__icon {
	width: 58px;
	height: 58px;
	margin-top: -30px;
	color: var(--mcwf-fbar-middle-text, var(--mcwf-primary-text));
	background: var(--mcwf-fbar-middle, var(--mcwf-primary));
	border: 4px solid var(--mcwf-fbar-bg, var(--mcwf-surface));
	border-radius: 50%;
	box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
	box-sizing: border-box;
}

.mcwf-fbar .mcwf-fbar__cell--big .mcwf-fbar__icon .mcwf-icon,
.mcwf-fbar .mcwf-fbar__cell--big .mcwf-fbar__icon svg {
	width: 26px;
	height: 26px;
}

.mcwf-fbar .mcwf-fbar__cell--big .mcwf-cart-count,
.mcwf-fbar .mcwf-fbar__cell--big .mcwf-wishlist-count {
	top: -3px;
	inset-inline-end: -5px;
	color: var(--mcwf-fbar-middle, var(--mcwf-primary));
	background: var(--mcwf-fbar-middle-text, var(--mcwf-primary-text));
}

.mcwf-fbar .mcwf-fbar__cell--big .mcwf-fbar__item.is-current .mcwf-fbar__icon {
	box-shadow: 0 0 0 2px var(--mcwf-fbar-active, var(--mcwf-primary)), 0 6px 16px rgba(0, 0, 0, 0.18);
}

/* Without texts the icons sit in the middle of the bar. */
.mcwf-fbar.mcwf-fbar--no-labels .mcwf-fbar__item {
	justify-content: center;
	padding-bottom: 6px;
}

.mcwf-fbar--no-labels .mcwf-fbar__cell--big .mcwf-fbar__icon {
	margin-top: -26px;
}

@media (prefers-reduced-motion: reduce) {
	.mcwf-fbar .mcwf-fbar__icon {
		transition: none;
	}
}
