/**
 * Mobile Bottom Bar by Hòa Sinh Media - the bar and its menu drawer.
 *
 * Single source of truth: this file styles the bar on the front-end and in
 * the admin live preview. Colours, visibility and the reserved space are
 * driven by custom properties:
 *
 *   --hsmbb-bg / --hsmbb-fg / --hsmbb-label   colours, printed from the settings
 *   --hsmbb-display                           "flex" below the breakpoint, unset above
 *   --hsmbb-safe-bottom / --hsmbb-safe-top    device safe areas (overridden in the preview)
 *   --hsmbb-z-index                           stacking order of the bar, 999 unless a theme sets it
 */

.hsmbb {
	--hsmbb-bg: #ffffff;
	--hsmbb-fg: #1d2327;
	--hsmbb-label: var(--hsmbb-fg);
	--hsmbb-badge-bg: #7cb82f;
	--hsmbb-badge-fg: #ffffff;
	--hsmbb-safe-bottom: env(safe-area-inset-bottom, 0px);

	position: fixed;
	right: 0;
	bottom: 0;
	left: 0;
	/* Above page content and sticky elements, below modals and lightboxes. */
	z-index: var(--hsmbb-z-index, 999);
	display: var(--hsmbb-display, none);
	align-items: flex-end;
	box-sizing: border-box;
	margin: 0;
	padding: 9px 4px calc(8px + var(--hsmbb-safe-bottom));
	border: 0;
	background: var(--hsmbb-bg);
	box-shadow: 0 -1px 0 rgba(0, 0, 0, 0.08), 0 -4px 14px rgba(0, 0, 0, 0.05);
	color: var(--hsmbb-fg);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
	line-height: 1.2;
	transition: background-color 0.2s;
}

/* Floating: detached from the edges, rounded, with a drop shadow. */
.hsmbb--floating {
	right: 12px;
	bottom: max(12px, calc(6px + var(--hsmbb-safe-bottom)));
	left: 12px;
	padding-bottom: 8px;
	border-radius: 20px;
	box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.05);
}

/* Buttons: links and <button>s share the same look, whatever the theme does. */
.hsmbb .hsmbb__item {
	position: relative;
	display: flex;
	flex: 1 1 0;
	flex-direction: column;
	align-items: center;
	justify-content: flex-end;
	gap: 4px;
	box-sizing: border-box;
	width: auto;
	min-width: 0;
	height: auto;
	min-height: 44px;
	margin: 0;
	padding: 0 2px;
	border: 0;
	border-radius: 0;
	background: none;
	box-shadow: none;
	color: inherit;
	font: inherit;
	letter-spacing: normal;
	text-align: center;
	text-decoration: none;
	text-transform: none;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
	transition: opacity 0.15s;
}

.hsmbb .hsmbb__item:hover,
.hsmbb .hsmbb__item:focus {
	background: none;
	box-shadow: none;
	color: inherit;
	text-decoration: none;
}

.hsmbb .hsmbb__item:active {
	opacity: 0.6;
}

.hsmbb .hsmbb__item:focus-visible {
	border-radius: 8px;
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.hsmbb__icon {
	position: relative;
	display: flex;
	flex: none;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	border-radius: 50%;
}

.hsmbb__icon .hsmbb-icon {
	display: block;
	width: 29px;
	height: 29px;
	max-width: none;
	margin: 0;
}

.hsmbb__icon .hsmbb-icon--image {
	width: 28px;
	height: 28px;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	object-fit: contain;
}

.hsmbb__label {
	display: block;
	max-width: 100%;
	overflow: hidden;
	color: var(--hsmbb-label);
	font-size: 12.5px;
	font-weight: 500;
	line-height: 1.2;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.hsmbb__badge {
	position: absolute;
	top: -5px;
	right: -10px;
	box-sizing: border-box;
	min-width: 18px;
	height: 18px;
	padding: 0 5px;
	border-radius: 9px;
	background: var(--hsmbb-badge-bg);
	color: var(--hsmbb-badge-fg);
	font-size: 11px;
	font-weight: 600;
	line-height: 18px;
	text-align: center;
}

.hsmbb__badge[hidden] {
	display: none;
}

/* Center: the middle button rises out of the bar as a circle. */
.hsmbb__item--featured .hsmbb__icon {
	width: 56px;
	height: 56px;
	margin-top: -30px;
	background: var(--hsmbb-bg);
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}

.hsmbb__item--featured .hsmbb__badge {
	top: 4px;
	right: 2px;
}

/* Menu drawer ----------------------------------------------------------- */

.hsmbb-drawer {
	--hsmbb-safe-top: env(safe-area-inset-top, 0px);

	position: fixed;
	inset: 0;
	/* Above the WordPress toolbar (99999), like any modal. */
	z-index: 100000;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
	line-height: 1.4;
}

.hsmbb-drawer[hidden] {
	display: none;
}

.hsmbb-drawer__overlay {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.45);
	animation: hsmbb-fade 0.2s ease-out;
}

.hsmbb-drawer__panel {
	position: absolute;
	top: 0;
	bottom: 0;
	left: 0;
	display: flex;
	flex-direction: column;
	box-sizing: border-box;
	width: 78%;
	max-width: 360px;
	padding-top: var(--hsmbb-safe-top);
	background: #ffffff;
	box-shadow: 4px 0 20px rgba(0, 0, 0, 0.2);
	color: #1d2327;
	animation: hsmbb-slide 0.22s ease-out;
}

.hsmbb-drawer__panel:focus {
	outline: 0;
}

.hsmbb-drawer__header {
	display: flex;
	flex: none;
	align-items: center;
	padding: 8px 8px 8px 18px;
	border-bottom: 1px solid #eeeeee;
}

.hsmbb-drawer__title {
	flex: 1;
	min-width: 0;
	overflow: hidden;
	font-size: 15px;
	font-weight: 700;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.hsmbb-drawer .hsmbb-drawer__close {
	display: flex;
	flex: none;
	align-items: center;
	justify-content: center;
	width: 44px;
	min-width: 0;
	height: 44px;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: none;
	box-shadow: none;
	color: #1d2327;
	cursor: pointer;
}

.hsmbb-drawer .hsmbb-drawer__close:hover,
.hsmbb-drawer .hsmbb-drawer__close:focus {
	background: none;
	color: #1d2327;
}

.hsmbb-drawer__close svg {
	width: 24px;
	height: 24px;
}

.hsmbb-drawer__nav {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding-bottom: env(safe-area-inset-bottom, 0px);
	-webkit-overflow-scrolling: touch;
}

.hsmbb-drawer .hsmbb-drawer__menu,
.hsmbb-drawer .hsmbb-drawer__menu ul {
	margin: 0;
	padding: 0;
	list-style: none;
}

.hsmbb-drawer .hsmbb-drawer__menu li {
	margin: 0;
	padding: 0;
	list-style: none;
}

.hsmbb-drawer .hsmbb-drawer__menu a {
	display: flex;
	align-items: center;
	box-sizing: border-box;
	min-height: 48px;
	padding: 8px 18px;
	border: 0;
	border-bottom: 1px solid #f0f0f1;
	background: none;
	color: #1d2327;
	font-size: 15px;
	font-weight: 400;
	line-height: 1.3;
	text-decoration: none;
	text-transform: none;
}

.hsmbb-drawer .hsmbb-drawer__menu a:active {
	background: #f6f7f7;
}

.hsmbb-drawer .hsmbb-drawer__menu ul a {
	padding-left: 34px;
	color: #50575e;
}

.hsmbb-drawer .hsmbb-drawer__menu ul ul a {
	padding-left: 50px;
}

.hsmbb-drawer .hsmbb-drawer__close:focus-visible,
.hsmbb-drawer .hsmbb-drawer__menu a:focus-visible {
	outline: 2px solid #2271b1;
	outline-offset: -2px;
}

@keyframes hsmbb-fade {
	from {
		opacity: 0;
	}
}

@keyframes hsmbb-slide {
	from {
		transform: translateX(-100%);
	}
}

/* The page behind an open drawer does not scroll. */
html.hsmbb-drawer-open,
html.hsmbb-drawer-open body {
	overflow: hidden;
}

@media print {
	.hsmbb,
	.hsmbb-drawer {
		display: none !important;
	}
}

@media (prefers-reduced-motion: reduce) {
	.hsmbb,
	.hsmbb .hsmbb__item {
		transition: none;
	}

	.hsmbb-drawer__overlay,
	.hsmbb-drawer__panel {
		animation: none;
	}
}
