/* Phone bottom navigation (a full-width bar), floating cart and "Added to your cart" toast. */

/* ---- Toast (top of the screen, just under the admin bar) ---- */
.insaf-toast { position: fixed; z-index: 120; top: calc(var(--wp-admin--admin-bar--height, 0px) + 12px); left: 50%; display: flex; align-items: center; gap: 14px; width: max-content; max-width: calc(100vw - 24px); padding: 11px 16px; border-radius: 12px; color: #fff; background: #0f3d2e; font-size: 14px; font-weight: 500; line-height: 1.3; opacity: 0; visibility: hidden; transform: translate(-50%, -12px); transition: opacity .2s ease, transform .2s ease, visibility 0s linear .2s; }
.insaf-toast.is-on { opacity: 1; visibility: visible; transform: translate(-50%, 0); transition: opacity .2s ease, transform .2s ease; }
.insaf-toast__msg::before { content: ""; display: inline-block; width: 16px; height: 16px; margin-right: 8px; vertical-align: -3px; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat; }
.insaf-toast__view { flex: none; color: #fff; text-decoration: underline; text-decoration-color: rgba(255, 255, 255, .55); text-underline-offset: 3px; }
.insaf-toast__view:hover { text-decoration-color: #fff; }
.insaf-toast a:focus-visible { outline: 2px solid #fff; outline-offset: 3px; border-radius: 4px; }
html.insaf-minicart-open .insaf-toast { display: none; }

/* ---- Floating cart: a tab on the right edge, halfway down the screen. Hidden while the cart is empty, or while the cart drawer or the menu is open ----  Half-screen height uses svh (the screen with the browser bars showing): a plain 50% follows the visible height, which changes in steps when a phone browser shows or hides its address bar, so the tab jumped while scrolling up. */
.insaf-floatcart { position: fixed; z-index: 62; top: 50%; top: 50svh; right: 0; display: flex; flex-direction: column; align-items: stretch; min-width: 72px; overflow: hidden; border: 1px solid rgba(15, 61, 46, .14); border-right: 0; border-radius: 14px 0 0 14px; color: var(--insaf-btn-buy-bg, #0f3d2e); background: #fff; box-shadow: -4px 8px 22px rgba(15, 40, 28, .16); font-size: 12px; font-weight: 500; line-height: 1.2; text-align: center; text-decoration: none; translate: 0 -50%; transition: box-shadow .2s ease; }
.insaf-floatcart__top { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 10px 8px 12px; color: #fff; background: var(--insaf-btn-buy-bg, #0f3d2e); }
.insaf-floatcart[hidden] { display: none; }
.insaf-floatcart:hover { box-shadow: -4px 10px 26px rgba(15, 40, 28, .26); }
.insaf-floatcart:focus-visible { outline: 2px solid #0f3d2e; outline-offset: 3px; }
.insaf-floatcart__n { font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.insaf-floatcart__t { padding: 8px 10px 9px 12px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.insaf-floatcart.is-bump, .insaf-bottomnav__count.is-bump { animation: insaf-fc-bump .45s ease; }
@keyframes insaf-fc-bump { 0% { transform: scale(1); } 40% { transform: scale(1.12); } 100% { transform: scale(1); } }
html.insaf-minicart-open .insaf-floatcart, html.insaf-menu-open .insaf-floatcart { display: none; }
/* The phone menu fills the screen, so the bottom bar steps aside instead of covering the menu's last button. */
html.insaf-menu-open .insaf-bottomnav { visibility: hidden; }

/* ---- Bottom navigation: phones only ---- */
.insaf-bottomnav { display: none; }
@media (max-width: 767px) {
	/* Room for the fixed bars at the bottom of a phone. It is kept as a variable and given to the FOOTER (see below), so the dark footer runs down behind the bars instead of leaving a pale strip under it. */
	body.insaf-has-bottomnav { --insaf-bottom-space: calc(64px + env(safe-area-inset-bottom, 0px)); }
	/* A light, quiet bar: white with a fine top line, grey icons and labels, the current page in the site green on a soft pill, labels always visible,
	   64px tall, every tap target well over 44px. Colours come from Theme Settings (empty = these defaults). */
	.insaf-bottomnav { position: fixed; z-index: 60; right: 0; bottom: 0; left: 0; display: flex; padding: 0 4px env(safe-area-inset-bottom, 0px); background: var(--insaf-bnav-bg, #fff); box-shadow: inset 0 1px 0 rgba(15, 61, 46, .12), 0 -4px 18px rgba(15, 40, 28, .08); transition: transform .25s ease, visibility 0s linear 0s; }
	.insaf-bottomnav__item { position: relative; display: flex; flex: 1 1 0; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-width: 0; height: 64px; padding: 0 2px; color: var(--insaf-bnav-fg, #47524b); font-size: 12px; font-weight: 500; letter-spacing: 0; line-height: 1; text-decoration: none; -webkit-tap-highlight-color: transparent; }
	.insaf-bottomnav__item + .insaf-bottomnav__item::before { content: ""; position: absolute; top: 50%; left: 0; width: 1px; height: 28px; background: rgba(15, 61, 46, .12); transform: translateY(-50%); }
	.insaf-bottomnav__item.is-current { color: var(--insaf-bnav-accent, var(--insaf-green-dark)); font-weight: 600; }
	.insaf-bottomnav__item:focus-visible { outline: 2px solid var(--insaf-bnav-accent, var(--insaf-green-dark)); outline-offset: -4px; border-radius: 14px; }
	.insaf-bottomnav__icon { position: relative; display: grid; place-items: center; width: 56px; height: 30px; border-radius: 999px; transition: color .2s ease; }
	/* The current page: no pill behind it. The icon takes the site green with a soft tint inside the outline (the same tint at 18%), the label is green and a little heavier. */
	.insaf-bottomnav__item.is-current:not(.insaf-bottomnav__item--whatsapp) .insaf-bottomnav__icon svg { fill: color-mix(in srgb, var(--insaf-bnav-accent, var(--insaf-green-dark)) 18%, transparent); stroke-width: 2; }
	.insaf-bottomnav__item--cart.is-current .insaf-bottomnav__icon svg path:first-child { fill: none; }
	.insaf-bottomnav__icon svg { display: block; }
	.insaf-bottomnav__count { position: absolute; top: -5px; right: 4px; min-width: 16px; padding: 0 4px; border-radius: 8px; color: #fff; background: var(--insaf-bnav-accent, var(--insaf-green-dark)); font-size: 10.5px; font-weight: 600; letter-spacing: 0; line-height: 16px; text-align: center; box-shadow: 0 0 0 2px var(--insaf-bnav-bg, #fff); }
	.insaf-bottomnav__count.is-empty { display: none; }
	/* A product page's sticky buy bar takes the bar's place while it is showing. */
	body.insaf-sticky-on .insaf-bottomnav { visibility: hidden; transform: translateY(100%); transition: transform .25s ease, visibility 0s linear .25s; }
	/* Clear of the bar: back to top sits just above it. */
	body.insaf-has-bottomnav:not(.insaf-sticky-on) .insaf-back-to-top { bottom: calc(64px + 14px + env(safe-area-inset-bottom, 0px)); }
}
@media (prefers-reduced-motion: reduce) {
	.insaf-toast, .insaf-toast.is-on, .insaf-bottomnav, .insaf-floatcart { transition: none; }
	.insaf-floatcart.is-bump, .insaf-bottomnav__count.is-bump { animation: none; }
}

@media (max-width: 339px) { .insaf-bottomnav__item { font-size: 10px; } }

/* ---- "You unlocked it" message: slides in from the top once, leaves by itself (tap to close) ---- */
.insaf-goal { position: fixed; z-index: 130; top: calc(var(--wp-admin--admin-bar--height, 0px) + 66px); left: 50%; display: flex; align-items: center; gap: 12px; box-sizing: border-box; width: max-content; max-width: calc(100vw - 24px); padding: 10px 18px 10px 10px; border-radius: 999px; color: #fff; background: var(--insaf-btn-buy-bg, #0f3d2e); background: linear-gradient(135deg, var(--insaf-btn-buy-bg, #0f3d2e), color-mix(in srgb, var(--insaf-btn-buy-bg, #0f3d2e) 70%, var(--insaf-green))); box-shadow: 0 14px 34px rgba(10, 30, 20, .3), inset 0 0 0 1px rgba(255, 255, 255, .12); font-size: 14.5px; font-weight: 500; line-height: 1.3; opacity: 0; visibility: hidden; transform: translate(-50%, -18px) scale(.94); transition: opacity .25s ease, transform .35s cubic-bezier(.2, .9, .3, 1.25), visibility 0s linear .35s; cursor: pointer; }
.insaf-goal.is-on { opacity: 1; visibility: visible; transform: translate(-50%, 0) scale(1); transition: opacity .25s ease, transform .35s cubic-bezier(.2, .9, .3, 1.25); }
.insaf-goal__icon { display: grid; flex: none; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: #fff; }
/* Two pictures sit in the circle; the message says which one is shown: the delivery van for free delivery, the gift box for the gift. */
.insaf-goal__icon .insaf-gift-ico--van { display: none; }
.insaf-goal[data-type="delivery"] .insaf-goal__icon .insaf-gift-ico--van { display: block; }
.insaf-goal[data-type="delivery"] .insaf-goal__icon .insaf-gift-ico:not(.insaf-gift-ico--van) { display: none; }
@media (prefers-reduced-motion: reduce) { .insaf-goal, .insaf-goal.is-on { transition: opacity .2s ease; transform: translate(-50%, 0); } }
/* With the cart drawer open the message sits just under the drawer's heading, so the close button stays free. */
html.insaf-minicart-open .insaf-goal { top: calc(var(--wp-admin--admin-bar--height, 0px) + 76px); max-width: min(calc(100vw - 24px), 420px); }

/* ---- Phones: the floating cart becomes a bar above the bottom menu ----
   Once the cart has something in it, a slim green bar sits above the bottom menu: how many things, the total, and one clear button, "View cart"
   (it opens the cart drawer, which has the Checkout button). It is the same element as the side pill on wider screens, so it is filled in and
   hidden by the same code (the count and total follow every change). It steps aside while the cart drawer or the menu is open, and on a product
   page while the sticky buy bar is showing. */
.insaf-floatcart__go { display: none; }
@media (max-width: 767px) {
	.insaf-floatcart { top: auto; right: auto; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); left: 50%; width: min(300px, calc(100% - 24px)); min-width: 0; height: 54px; flex-direction: row; align-items: center; justify-content: space-between; gap: 10px; padding: 0 7px 0 16px; border: 0; border-radius: 16px; color: #fff; background: var(--insaf-btn-buy-bg, #0f3d2e); box-shadow: 0 8px 24px rgba(15, 40, 28, .3); font-size: 15px; translate: -50% 0; }
	body.insaf-has-bottomnav .insaf-floatcart { bottom: calc(64px + 10px + env(safe-area-inset-bottom, 0px)); }
	.insaf-floatcart__top { flex-direction: row; gap: 8px; padding: 0; background: none; }
	.insaf-floatcart svg { width: 22px; height: 22px; }
	.insaf-floatcart__n { font-size: 15px; font-weight: 600; line-height: 1.2; }
	.insaf-floatcart__t { padding: 0; font-size: 15px; font-weight: 600; opacity: .95; }
	.insaf-floatcart__t:not(:empty)::before { content: "\00b7"; margin-right: 10px; opacity: .7; }
	.insaf-floatcart__go { display: inline-flex; align-items: center; height: 40px; margin-left: auto; padding: 0 18px; border-radius: 12px; color: var(--insaf-btn-buy-bg, #0f3d2e); background: #fff; font-size: 15px; font-weight: 700; white-space: nowrap; }
	.insaf-floatcart:focus-visible { outline: 2px solid #fff; outline-offset: -4px; }
	body.insaf-sticky-on .insaf-floatcart { display: none; }
	/* Room for the bar, so it never covers the last thing on the page; "back to top" and the message sit above it. */
	html.insaf-cartbar body:not(.insaf-sticky-on) { --insaf-bottom-space: calc(64px + 10px + 54px + 16px + env(safe-area-inset-bottom, 0px)); }
	html.insaf-cartbar body:not(.insaf-has-bottomnav):not(.insaf-sticky-on) { --insaf-bottom-space: calc(12px + 54px + 16px + env(safe-area-inset-bottom, 0px)); }
	html.insaf-cartbar body.insaf-has-bottomnav:not(.insaf-sticky-on) .insaf-back-to-top { bottom: calc(64px + 10px + 54px + 14px + env(safe-area-inset-bottom, 0px)); }
	html.insaf-cartbar body:not(.insaf-has-bottomnav):not(.insaf-sticky-on) .insaf-back-to-top { bottom: calc(12px + 54px + 14px + env(safe-area-inset-bottom, 0px)); }
	/* The wishlist message ("Saved") also sits above the bar instead of covering its button. */
	html.insaf-cartbar body:not(.insaf-sticky-on) .insaf-wish-toast { bottom: calc(64px + 10px + 54px + 12px + env(safe-area-inset-bottom, 0px)); }
	html.insaf-cartbar body:not(.insaf-has-bottomnav):not(.insaf-sticky-on) .insaf-wish-toast { bottom: calc(12px + 54px + 12px + env(safe-area-inset-bottom, 0px)); }
	/* "Added to your cart" now appears just above the bar (the bar carries the "View cart" button), instead of at the top of the screen. */
	.insaf-toast { top: auto; bottom: calc(64px + 10px + 54px + 12px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 12px); }
	body:not(.insaf-has-floatcart) .insaf-toast { bottom: calc(64px + 12px + env(safe-area-inset-bottom, 0px)); }
	body:not(.insaf-has-bottomnav) .insaf-toast { bottom: calc(12px + 54px + 12px + env(safe-area-inset-bottom, 0px)); }
	body:not(.insaf-has-bottomnav):not(.insaf-has-floatcart) .insaf-toast { bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
	.insaf-toast.is-on { transform: translate(-50%, 0); }
	body.insaf-has-floatcart .insaf-toast__view { display: none; }
}

/* Small phones: the bar keeps just what fits (count, total, button): never a clipped button at 320-360px. */
@media (max-width: 767px) {
	.insaf-floatcart { gap: 8px; padding-left: 12px; }
	.insaf-floatcart__w { display: none; }
	.insaf-floatcart__top { flex: none; }
	.insaf-floatcart__t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
	.insaf-floatcart__go { flex: none; padding: 0 14px; }
}
/* Tablets: the side pill used to sit on the category row's arrow; it waits above the WhatsApp button instead. */
@media (min-width: 768px) and (max-width: 1023px) {
	.insaf-floatcart { top: auto; bottom: 156px; translate: none; }
}

/* With the phone menu open, the fixed buy / checkout bars step aside (they sat above the menu and could be tapped through it). */
html.insaf-menu-open .insaf-sticky, html.insaf-menu-open .insaf-co-bar, html.insaf-menu-open body.woocommerce-cart .wc-proceed-to-checkout { visibility: hidden; }

/* The gift and van pictures are plain outline icons (same family as the cart and wish list); they take this colour. */
.insaf-goal__icon { color: var(--insaf-green-dark, #02864a); }

/* ---- Floating WhatsApp button: where it stands ----
   Bottom right on every screen (its own style attribute says 22px from the right, 30px from the bottom); the back-to-top button stands above it (44px button + gap = 58px).
   Whatever bar takes the bottom of the screen (the product page's buy bar, a phone's bottom bar, the cart bar, the cart and checkout bars), the button and back-to-top
   both step up above it, keeping the order. The back-to-top positions below are the old ones plus 58px. */
body.insaf-has-wa .insaf-back-to-top { bottom: 88px; }
html body.insaf-sticky-on .insaf-wa-float { bottom: 84px !important; }
html body.insaf-has-wa.insaf-sticky-on .insaf-back-to-top { bottom: 142px; }
@media (max-width: 767px) {
	.insaf-wa-float { right: 14px !important; bottom: calc(14px + env(safe-area-inset-bottom, 0px)) !important; }
	body.insaf-has-bottomnav:not(.insaf-sticky-on) .insaf-wa-float { bottom: calc(64px + 14px + env(safe-area-inset-bottom, 0px)) !important; }
	html.insaf-cartbar body.insaf-has-bottomnav:not(.insaf-sticky-on) .insaf-wa-float { bottom: calc(64px + 10px + 54px + 14px + env(safe-area-inset-bottom, 0px)) !important; }
	html.insaf-cartbar body:not(.insaf-has-bottomnav):not(.insaf-sticky-on) .insaf-wa-float { bottom: calc(12px + 54px + 14px + env(safe-area-inset-bottom, 0px)) !important; }
	html body.insaf-sticky-on .insaf-wa-float { bottom: 84px !important; }
	body.woocommerce-cart .insaf-wa-float, body.woocommerce-checkout .insaf-wa-float { bottom: calc(86px + env(safe-area-inset-bottom, 0px)) !important; }

	body.insaf-has-wa .insaf-back-to-top { bottom: calc(14px + 58px + env(safe-area-inset-bottom, 0px)); }
	body.insaf-has-wa.insaf-has-bottomnav:not(.insaf-sticky-on) .insaf-back-to-top { bottom: calc(64px + 14px + 58px + env(safe-area-inset-bottom, 0px)); }
	html.insaf-cartbar body.insaf-has-wa.insaf-has-bottomnav:not(.insaf-sticky-on) .insaf-back-to-top { bottom: calc(64px + 10px + 54px + 14px + 58px + env(safe-area-inset-bottom, 0px)); }
	html.insaf-cartbar body.insaf-has-wa:not(.insaf-has-bottomnav):not(.insaf-sticky-on) .insaf-back-to-top { bottom: calc(12px + 54px + 14px + 58px + env(safe-area-inset-bottom, 0px)); }
	html body.insaf-has-wa.insaf-sticky-on .insaf-back-to-top { bottom: 142px; }
	body.insaf-has-wa.woocommerce-cart .insaf-back-to-top, body.insaf-has-wa.woocommerce-checkout .insaf-back-to-top { bottom: calc(86px + 58px + env(safe-area-inset-bottom, 0px)); }
}

/* Phones: the round WhatsApp button steps aside while the product page's own Add to cart / Buy now buttons are on screen (class set by single-product-sticky.js). */
@media (max-width: 767px) {
	html body.insaf-buy-in-view .insaf-wa-float { opacity: 0 !important; visibility: hidden !important; pointer-events: none !important; }
}

/* Tablets (768-991px) still get the fixed Checkout / Place order bar, so the WhatsApp button and back-to-top lift above it like on phones. */
@media (min-width: 768px) and (max-width: 991px) {
	body.woocommerce-cart .insaf-wa-float, body.woocommerce-checkout .insaf-wa-float { bottom: calc(86px + env(safe-area-inset-bottom, 0px)) !important; }
	body.insaf-has-wa.woocommerce-cart .insaf-back-to-top, body.insaf-has-wa.woocommerce-checkout .insaf-back-to-top { bottom: calc(86px + 58px + env(safe-area-inset-bottom, 0px)); }
}
