/*
 * Sticky mobile action bar (a theme part, loaded on every page by inc/assets.php).
 *
 * Fixed to the bottom of the screen below 900px. When it's on, <body> gets the
 * class has-mbar (inc/tokens.php), which adds space at the bottom of the page
 * so the bar never covers the footer. Source: the builder's ".mbar" CSS.
 *
 * Variables: --mbar-h (bar height; the chat button sits above it).
 */

:root { --mbar-h: 74px; }

.mbar {
	position: fixed;
	inset: auto 0 0;
	z-index: 50;
	display: flex;
	gap: 6px;
	padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
	background: var(--surface);
	border-top: 1px solid var(--line);
	box-shadow: 0 -10px 24px -14px rgb(0 0 0 / 0.3);
	/*
	 * iPhone Safari can leave a fixed bar stranded mid-screen after its toolbar collapses or the page
	 * is opened from another app. Its own compositing layer makes Safari re-anchor it to the screen bottom.
	 */
	transform: translateZ(0);
	-webkit-transform: translateZ(0);
	will-change: transform;
}

.mbar__item {
	display: flex;
	flex: 1;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 3px;
	min-height: 52px;
	border-radius: 14px;
	color: var(--ink);
	font-size: 12px;
	font-weight: 700;
	text-decoration: none;
}

.mbar__item .ico { width: 22px; height: 22px; }

.mbar__item.main {
	flex: 1.35;
	background: var(--primary);
	color: var(--on-primary);
	font-size: 13px;
}

.mbar__item.alert { color: var(--accent-2); }

/* Look F's accent-2 is a soft pastel (too faint as text on white): dark text on a pastel pill instead. */
.look-f .mbar__item.alert { background: color-mix(in srgb, var(--accent-2) 32%, var(--surface)); color: var(--ink); }

/* Room for the bar at the bottom of the page. */
body.has-mbar { padding-bottom: calc(var(--mbar-h) + env(safe-area-inset-bottom)); }

@media (min-width: 900px) {
	.mbar { display: none; }
	body.has-mbar { padding-bottom: 0; }
}

/* The Chat slot is a <button>: strip the browser's button look so it matches the links. */
button.mbar__item { padding: 0; border: 0; background: none; font-family: inherit; cursor: pointer; }

/* ---------- Open now on the bar (Clinic → Header, logo, footer and mobile bar → Mobile bar: Show open or closed) ---------- */
/* open-status.js puts clinic-is-open / clinic-is-closed on <body>; nothing shows before it has run. .open-dot is defined in header.css. */

.mbar { flex-wrap: wrap; }

/* Strip: a slim line above the buttons. */
.mbar__strip {
	display: none;
	flex: 0 0 100%;
	align-items: center;
	justify-content: center;
	gap: 8px;
	margin: -2px 0 4px;
	padding: 0 0 7px;
	border-bottom: 1px solid var(--line);
	color: var(--ink);
	font-size: 12.5px;
	font-weight: 700;
	line-height: 1.2;
}

body.clinic-is-open .mbar__strip,
body.clinic-is-closed .mbar__strip { display: flex; }

:root:has(.mbar--status-strip) { --mbar-h: 104px; }

/* Dot: a glowing green dot on the Call icon, and "Open now" in place of "Call" while open. */
.mbar__ico { position: relative; display: grid; }
.mbar__ico .open-dot { position: absolute; top: -3px; right: -6px; box-sizing: border-box; width: 11px; height: 11px; border: 2px solid var(--surface); display: none; }
body.clinic-is-open .mbar__ico .open-dot { display: block; }

.mbar__lbl--open { display: none; }
body.clinic-is-open .mbar__item--status .mbar__lbl { display: none; }
body.clinic-is-open .mbar__item--status .mbar__lbl--open { display: inline; color: color-mix(in srgb, #16a34a 72%, var(--ink)); }

/* Line: a tiny status line under the label. The bar is always this much taller, so the page never jumps when the text appears. */
.mbar--status-line .mbar__item--status { min-height: 64px; }
:root:has(.mbar--status-line) { --mbar-h: 86px; }

.mbar__sub { min-height: 11px; font-size: 10.5px; font-weight: 700; line-height: 1; opacity: 0.8; }
body.clinic-is-open .mbar__sub { color: color-mix(in srgb, #16a34a 72%, var(--ink)); opacity: 1; }

/* A clinic that takes emergencies or after-hours care (Clinic → Details / Emergency): the Call dot is always on and pulsing, never "closed". */
.mbar__item--always .mbar__ico .open-dot { display: block; background: #22c55e; opacity: 1; }
@media (prefers-reduced-motion: no-preference) {
	.mbar__item--always .mbar__ico .open-dot { animation: open-pulse 2.4s ease-out infinite; }
}
