/* ================================================================
   Boosty Help Menu — Frontend Widget
   ================================================================ */

/* ── CSS Variables (set inline by PHP) ── */
#bhm-root {
	--bhm-primary:     #ff6600;
	--bhm-card-bg:     #ff6600;
	--bhm-card-txt:    #ffffff;
	--bhm-bg:          #ffffff;
	--bhm-header:      #f5f5f5;
	--bhm-title-color: #222222;
	--bhm-tab-bg:      #f5f5f5;
	--bhm-tab-active:  #ff6600;
	--bhm-radius:      16px;
	--bhm-cols:        2;
	--bhm-panel-w:     380px;
	--bhm-anim:        .3s cubic-bezier(.4,0,.2,1);
}

/* ─────────────────────────────────────────────────────────────
   OVERLAY — lives OUTSIDE #bhm-root so it is never trapped
   inside root's stacking context and cannot block the panel.
   Visibility is driven by JS (.bhm-visible class).
   ───────────────────────────────────────────────────────────── */
#bhm-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0,0,0,.45);
	z-index: 999998;           /* just below root (999999) */
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity .3s cubic-bezier(.4,0,.2,1),
	            visibility .3s cubic-bezier(.4,0,.2,1);
}
#bhm-overlay.bhm-visible {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
}

/* ─────────────────────────────────────────────────────────────
   ROOT — always above overlay
   ───────────────────────────────────────────────────────────── */
#bhm-root {
	position: fixed;
	z-index: 999999;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
}

/* ── Corner positions ── */
#bhm-root.bhm-pos-bottom-right { bottom: 24px; right: 24px; align-items: flex-end;   flex-direction: column; }
#bhm-root.bhm-pos-bottom-left  { bottom: 24px; left:  24px; align-items: flex-start; flex-direction: column; }
#bhm-root.bhm-pos-top-right    { top:    24px; right: 24px; align-items: flex-end;   flex-direction: column-reverse; }
#bhm-root.bhm-pos-top-left     { top:    24px; left:  24px; align-items: flex-start; flex-direction: column-reverse; }

/* ── Center positions ── */
#bhm-root.bhm-pos-bottom-center {
	bottom: 24px;
	left: 50%;
	transform: translateX(-50%);
	align-items: center;
	flex-direction: column;
}
#bhm-root.bhm-pos-top-center {
	top: 24px;
	left: 50%;
	transform: translateX(-50%);
	align-items: center;
	flex-direction: column-reverse;
}
#bhm-root.bhm-pos-center-left {
	left: 24px;
	top: 50%;
	transform: translateY(-50%);
	align-items: flex-start;
	flex-direction: column;
}
#bhm-root.bhm-pos-center-right {
	right: 24px;
	top: 50%;
	transform: translateY(-50%);
	align-items: flex-end;
	flex-direction: column;
}

/* ─────────────────────────────────────────────────────────────
   PANEL
   ───────────────────────────────────────────────────────────── */
#bhm-panel {
	width: var(--bhm-panel-w);
	max-width: calc(100vw - 32px);
	background: var(--bhm-bg);
	border-radius: var(--bhm-radius);
	overflow: hidden;
	display: flex;
	flex-direction: column;
	margin-bottom: 12px;

	/* Animation — closed state */
	transform-origin: bottom right;
	transform: scale(.92) translateY(12px);
	opacity: 0;
	pointer-events: none;
	transition: transform var(--bhm-anim), opacity var(--bhm-anim);
}

/* Per-position transform origins */
#bhm-root.bhm-pos-bottom-left   #bhm-panel { transform-origin: bottom left; }
#bhm-root.bhm-pos-bottom-center #bhm-panel { transform-origin: bottom center; }
#bhm-root.bhm-pos-center-left   #bhm-panel { transform-origin: bottom left; }
#bhm-root.bhm-pos-center-right  #bhm-panel { transform-origin: bottom right; }

#bhm-root.bhm-pos-top-right  #bhm-panel,
#bhm-root.bhm-pos-top-center #bhm-panel {
	margin-bottom: 0; margin-top: 12px;
	transform-origin: top right;
	transform: scale(.92) translateY(-12px);
}
#bhm-root.bhm-pos-top-left #bhm-panel {
	margin-bottom: 0; margin-top: 12px;
	transform-origin: top left;
	transform: scale(.92) translateY(-12px);
}
#bhm-root.bhm-pos-top-center #bhm-panel { transform-origin: top center; }

/* Open state */
#bhm-root.bhm-open #bhm-panel {
	transform: scale(1) translateY(0);
	opacity: 1;
	pointer-events: auto;
}

/* Shadow */
#bhm-root[data-shadow="1"] #bhm-panel {
	box-shadow: 0 12px 40px rgba(0,0,0,.18), 0 2px 8px rgba(0,0,0,.10);
}

/* ── Panel Header ── */
.bhm-header {
	background: var(--bhm-header);
	padding: 16px 20px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-shrink: 0;
}
.bhm-header-title {
	font-size: 17px;
	font-weight: 700;
	color: var(--bhm-title-color);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.bhm-close {
	width: 28px; height: 28px;
	border-radius: 50%;
	border: none;
	background: rgba(0,0,0,.10);
	color: var(--bhm-title-color);
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
	display: flex; align-items: center; justify-content: center;
	transition: background .2s;
	flex-shrink: 0;
}
.bhm-close:hover { background: rgba(0,0,0,.18); }

/* ── Grid ── */
.bhm-grid {
	display: grid;
	grid-template-columns: repeat(var(--bhm-cols), 1fr);
	gap: 12px;
	padding: 16px;
}

/* ── Card ── */
.bhm-card {
	background: var(--bhm-card-bg);
	color: var(--bhm-card-txt);
	border-radius: calc(var(--bhm-radius) * .6);
	padding: 20px 12px 16px;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 10px;
	text-decoration: none;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	font-weight: 600;
	font-size: 13px;
	text-align: center;
	transition: transform .18s, opacity .18s, box-shadow .18s;
	cursor: pointer;
}
.bhm-card:hover {
	transform: translateY(-2px);
	box-shadow: 0 6px 18px rgba(0,0,0,.18);
	opacity: .92;
}
.bhm-card:active { transform: scale(.96); }
.bhm-card-icon { font-size: 32px; line-height: 1; }
.bhm-card-label { line-height: 1.3; }

/* ── Tab contents ── */
.bhm-tab-contents { background: var(--bhm-bg); }
.bhm-tab-content {
	display: none;
	padding: 18px 20px;
	font-size: 14px;
	color: #333;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	line-height: 1.6;
	border-top: 1px solid rgba(0,0,0,.06);
}
.bhm-tab-content.active { display: block; }
.bhm-tab-content p { margin: 0 0 8px; }
.bhm-tab-content a { color: var(--bhm-primary); }

/* ── Bottom tabs ── */
.bhm-tabs {
	display: flex;
	background: var(--bhm-tab-bg);
	border-top: 1px solid rgba(0,0,0,.06);
	flex-shrink: 0;
}
.bhm-tab-btn {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	padding: 10px 4px 8px;
	border: none;
	background: none;
	cursor: pointer;
	text-decoration: none;
	color: #777;
	transition: color .2s;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.bhm-tab-btn:hover  { color: var(--bhm-tab-active); }
.bhm-tab-btn.active { color: var(--bhm-tab-active); }
.bhm-tab-icon  { font-size: 20px; line-height: 1; }
.bhm-tab-label { font-size: 10px; font-weight: 600; line-height: 1; }

/* ── Trigger button ── */
#bhm-trigger {
	display: flex;
	align-items: center;
	gap: 7px;
	padding: 12px 20px;
	background: var(--bhm-primary);
	color: #fff;
	border: none;
	border-radius: var(--bhm-radius);
	cursor: pointer;
	font-size: 14px;
	font-weight: 700;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	box-shadow: 0 4px 16px rgba(0,0,0,.22);
	transition: transform .2s, box-shadow .2s, background .2s;
	white-space: nowrap;
	flex-shrink: 0;
}
#bhm-trigger:hover {
	transform: translateY(-2px) scale(1.03);
	box-shadow: 0 8px 24px rgba(0,0,0,.28);
}
#bhm-trigger:active { transform: scale(.97); }

.bhm-trigger-icon { font-size: 18px; line-height: 1; }
.bhm-trigger-text { font-size: 13px; }

/* Open state: rotate icon slightly */
#bhm-root.bhm-open #bhm-trigger .bhm-trigger-icon {
	display: inline-block;
	transform: rotate(15deg);
	transition: transform .3s;
}

/* ── Pulse animation on trigger (idle) ── */
@keyframes bhm-pulse {
	0%, 100% { box-shadow: 0 4px 16px rgba(0,0,0,.22); }
	50%       { box-shadow: 0 4px 24px rgba(0,0,0,.35), 0 0 0 8px rgba(255,102,0,.12); }
}
#bhm-root:not(.bhm-open) #bhm-trigger {
	animation: bhm-pulse 3s ease-in-out infinite;
}

/* ── Inline shortcode trigger ── */
.bhm-inline-trigger {
	transition: transform .2s, box-shadow .2s;
}
.bhm-inline-trigger:hover {
	transform: translateY(-2px) scale(1.03);
	box-shadow: 0 8px 24px rgba(0,0,0,.28);
}

/* ─────────────────────────────────────────────────────────────
   RESPONSIVE / MOBILE — COMPACT (default)
   Trigger stays as a pill in its corner. Panel expands to
   near-full viewport width. Other floating buttons stay usable.
   ───────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
	#bhm-root.bhm-pos-bottom-right { bottom: 16px; right: 16px; }
	#bhm-root.bhm-pos-bottom-left  { bottom: 16px; left:  16px; }
	#bhm-root.bhm-pos-top-right    { top:    16px; right: 16px; }
	#bhm-root.bhm-pos-top-left     { top:    16px; left:  16px; }
	#bhm-root.bhm-pos-bottom-center { bottom: 16px; }
	#bhm-root.bhm-pos-top-center    { top:    16px; }
	#bhm-root.bhm-pos-center-left   { left:  16px; }
	#bhm-root.bhm-pos-center-right  { right: 16px; }

	/* Center-left/right become bottom on small screens */
	#bhm-root.bhm-pos-center-left,
	#bhm-root.bhm-pos-center-right {
		top: auto;
		bottom: 16px;
		transform: none;
		flex-direction: column;
	}

	#bhm-panel {
		width: calc(100vw - 32px);
		max-width: calc(100vw - 32px);
		border-radius: var(--bhm-radius);
		max-height: 80vh;
		overflow-y: auto;
	}

	.bhm-grid { padding: 12px; gap: 10px; }
}

/* ─────────────────────────────────────────────────────────────
   RESPONSIVE / MOBILE — FULL-WIDTH BAR (opt-in)
   ───────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
	#bhm-root[data-mobile="bar"].bhm-pos-bottom-right,
	#bhm-root[data-mobile="bar"].bhm-pos-bottom-left,
	#bhm-root[data-mobile="bar"].bhm-pos-bottom-center,
	#bhm-root[data-mobile="bar"].bhm-pos-center-left,
	#bhm-root[data-mobile="bar"].bhm-pos-center-right {
		bottom: 0; left: 0; right: 0;
		top: auto;
		transform: none;
		align-items: stretch;
		flex-direction: column;
	}
	#bhm-root[data-mobile="bar"].bhm-pos-top-right,
	#bhm-root[data-mobile="bar"].bhm-pos-top-left,
	#bhm-root[data-mobile="bar"].bhm-pos-top-center {
		top: 0; left: 0; right: 0;
		bottom: auto;
		transform: none;
		align-items: stretch;
		flex-direction: column-reverse;
	}
	#bhm-root[data-mobile="bar"] #bhm-panel {
		width: 100%;
		max-width: 100%;
		border-radius: var(--bhm-radius) var(--bhm-radius) 0 0;
		transform-origin: bottom center;
		margin: 0;
	}
	#bhm-root[data-mobile="bar"].bhm-pos-top-right  #bhm-panel,
	#bhm-root[data-mobile="bar"].bhm-pos-top-left   #bhm-panel,
	#bhm-root[data-mobile="bar"].bhm-pos-top-center #bhm-panel {
		border-radius: 0 0 var(--bhm-radius) var(--bhm-radius);
		transform-origin: top center;
		margin: 0;
	}
	#bhm-root[data-mobile="bar"] #bhm-trigger {
		border-radius: 0;
		justify-content: center;
		padding: 14px 20px;
		width: 100%;
	}
}
