/*
 * IBASTOM – floating WhatsApp button + message panel (mu-plugin ibastom-whatsapp-button).
 * Button: bottom-left – the cookie banner and its "ניהול הסכמה" tab use the bottom-right corner; the accessibility
 * toolbar's toggle sits on the left edge, higher up. It stays on screen while scrolling; whatsapp.js only lifts it
 * above the cookie banner (--ibs-wa-lift), moves it to the right while the accessibility toolbar is open over it,
 * and hides it under an open site menu or while it would cover the focused field.
 * Panel: next to the button from 600px, a bottom sheet below that (kept above the phone keyboard, --ibs-wa-kb).
 * Colours: white glyph on #128c7e = 4.1:1 (graphic); white text on #0b6e63 = 6.2:1; the white ring keeps the
 * button's edge visible on dark grounds.
 */

/* Room for the button at the end of every page and in front of focused fields (no permanent overlap). */
html:root { scroll-padding-bottom: 96px; }
@media (max-width: 1279px) {
	body .ibs-site-footer { padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
}

/* ---------- Floating button (a link without JS, a button with JS) ---------- */
body .ibs-wa,
body .ibs-wa:hover,
body .ibs-wa:focus {
	position: fixed;
	left: max(16px, env(safe-area-inset-left));
	right: auto;
	bottom: max(16px, env(safe-area-inset-bottom));
	z-index: 9000; /* above page headers (≤ 60), below the accessibility toolbar (9999) and the cookie banner */
	display: grid;
	place-items: center;
	box-sizing: border-box;
	width: 56px;
	height: 56px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: #128c7e;
	color: #fff;
	font: inherit;
	text-decoration: none;
	cursor: pointer;
	box-shadow: 0 0 0 2px #fff, 0 4px 14px rgba(0, 0, 0, .28);
	transform: translateY(calc(-1 * var(--ibs-wa-lift, 0px)));
	transition: transform .2s ease, opacity .2s ease;
}
body .ibs-wa:hover { background: #0e7268; }
body .ibs-wa.is-flipped { left: auto; right: max(16px, env(safe-area-inset-right)); }
body .ibs-wa svg { width: 30px; height: 30px; fill: currentColor; pointer-events: none; }

/* Focus: white gap + dark ring, so it shows on light and on dark grounds alike. */
body .ibs-wa:focus { outline: none; }
body .ibs-wa:focus-visible { outline: 3px solid #111418; outline-offset: 3px; box-shadow: 0 0 0 3px #fff, 0 4px 14px rgba(0, 0, 0, .28); }

/* Visible name on hover / keyboard focus: a dark pill beside the button (it is the button's accessible name). */
.ibs-wa__label {
	position: absolute;
	left: calc(100% + 10px);
	top: 50%;
	transform: translateY(-50%);
	padding: 6px 12px;
	border-radius: 999px;
	background: #111418;
	color: #fff;
	font-family: inherit; font-weight: 600; font-size: 15px; line-height: 1.3;
	white-space: nowrap;
	opacity: 0;
	clip-path: inset(50%);
	pointer-events: none;
	transition: opacity .15s ease;
}
.ibs-wa.is-flipped .ibs-wa__label { left: auto; right: calc(100% + 10px); }
body .ibs-wa:focus-visible .ibs-wa__label { opacity: 1; clip-path: none; }
@media (hover: hover) {
	body .ibs-wa:hover .ibs-wa__label { opacity: 1; clip-path: none; }
}
html.ibs-wa-open .ibs-wa__label { opacity: 0; clip-path: inset(50%); }
.ibs-wa__new { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Hidden: transparent and not clickable, but still in the tab order – keyboard focus brings it back at once. */
body .ibs-wa.is-tucked { opacity: 0; pointer-events: none; }
body .ibs-wa.is-tucked:focus-visible { opacity: 1; pointer-events: auto; }

/* ---------- Panel ---------- */
.ibs-wa-panel {
	position: fixed;
	z-index: 10001; /* over the accessibility toolbar's toggle while open (closing brings it back) */
	left: calc(max(16px, env(safe-area-inset-left)) + 68px);
	bottom: calc(max(16px, env(safe-area-inset-bottom)) + var(--ibs-wa-lift, 0px) + var(--ibs-wa-kb, 0px));
	box-sizing: border-box;
	width: min(360px, calc(100vw - 100px));
	max-height: calc(var(--ibs-wa-vh, 100dvh) - 32px);
	overflow-y: auto;
	overscroll-behavior: contain;
	display: grid;
	gap: 10px;
	padding: 20px 20px 16px;
	border: 1px solid #dcdfe4;
	border-radius: 14px;
	background: #fff;
	color: #111418;
	text-align: start;
	box-shadow: 0 12px 40px rgba(0, 0, 0, .28);
}
.ibs-wa-panel[hidden] { display: none; }
@media (max-width: 599px) {
	.ibs-wa-panel {
		left: max(8px, env(safe-area-inset-left));
		right: max(8px, env(safe-area-inset-right));
		bottom: calc(max(8px, env(safe-area-inset-bottom)) + var(--ibs-wa-lift, 0px) + var(--ibs-wa-kb, 0px));
		width: auto;
		max-height: calc(var(--ibs-wa-vh, 100dvh) - 16px);
		padding: 18px 16px 14px;
	}
	html.ibs-wa-open body .ibs-wa { opacity: 0; pointer-events: none; } /* the sheet covers its corner */
}

body .ibs-wa-panel .ibs-wa-panel__title {
	margin: 0;
	padding-inline-end: 44px; /* room for the close button */
	color: #111418;
	font-family: inherit; font-weight: 700; font-size: 18px; line-height: 1.4;
}
body .ibs-wa-panel .ibs-wa-panel__ask { margin: 0; color: #111418; font-family: inherit; font-weight: 400; font-size: 16px; line-height: 1.5; }
body .ibs-wa-panel .ibs-wa-panel__label { margin: 4px 0 0; color: #111418; font-family: inherit; font-weight: 600; font-size: 15px; line-height: 1.4; }
body .ibs-wa-panel .ibs-wa-panel__msg {
	box-sizing: border-box;
	width: 100%;
	min-height: 96px;
	max-height: 40vh;
	margin: 0;
	padding: 10px 12px;
	border: 1px solid #8a919c;
	border-radius: 8px;
	background: #fff;
	color: #111418;
	font-family: inherit; font-weight: 400; font-size: 16px; line-height: 1.5; /* 16px: no zoom on iOS */
	resize: vertical;
	transition: none;
}
body .ibs-wa-panel .ibs-wa-panel__msg:focus { outline: 3px solid #111418; outline-offset: 1px; border-color: #111418; box-shadow: none; }
body .ibs-wa-panel .ibs-wa-panel__go,
body .ibs-wa-panel .ibs-wa-panel__go:hover,
body .ibs-wa-panel .ibs-wa-panel__go:focus {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	box-sizing: border-box;
	width: 100%;
	min-height: 48px;
	margin: 4px 0 0;
	padding: 10px 16px;
	border: 0;
	border-radius: 999px;
	background: #0b6e63;
	color: #fff;
	font-family: inherit; font-weight: 700; font-size: 16px; line-height: 1.3;
	text-decoration: none;
	cursor: pointer;
}
body .ibs-wa-panel .ibs-wa-panel__go:hover { background: #085a51; }
body .ibs-wa-panel .ibs-wa-panel__go svg { flex: none; width: 22px; height: 22px; fill: currentColor; }
body .ibs-wa-panel .ibs-wa-panel__note { margin: 0; color: #535a64; font-family: inherit; font-weight: 400; font-size: 14px; line-height: 1.4; text-align: center; }
body .ibs-wa-panel .ibs-wa-panel__close,
body .ibs-wa-panel .ibs-wa-panel__close:hover,
body .ibs-wa-panel .ibs-wa-panel__close:focus {
	position: absolute;
	top: 8px;
	inset-inline-end: 8px;
	display: grid;
	place-items: center;
	width: 44px;
	height: 44px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: #111418;
	cursor: pointer;
}
body .ibs-wa-panel .ibs-wa-panel__close:hover { background: #f0f1f3; }
body .ibs-wa-panel .ibs-wa-panel__close svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
body .ibs-wa-panel :is(.ibs-wa-panel__go, .ibs-wa-panel__close):focus { outline: none; }
body .ibs-wa-panel :is(.ibs-wa-panel__go, .ibs-wa-panel__close):focus-visible { outline: 3px solid #111418; outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
	body .ibs-wa, .ibs-wa__label { transition: none; }
}
@media (forced-colors: active) {
	body .ibs-wa { border: 2px solid ButtonText; }
	body .ibs-wa:focus-visible, body .ibs-wa-panel :focus-visible { outline-color: Highlight; }
	.ibs-wa-panel { border: 2px solid CanvasText; }
}
@media print {
	body .ibs-wa, .ibs-wa-panel { display: none; }
}
