/* ===========================================================================
   app-tooltip - hover label for a control that carries no readable text
   ===========================================================================
   The native title bubble waits about a second before it appears, which on an
   icon-only control reads as nothing happening at all, and its delay cannot be
   changed from CSS or JS. So the text lives in data-tooltip and the bubble is
   ours: 120ms in, and gone the moment the pointer leaves.

   Two renderings, one look. The top bar uses the ::after below, which is all it
   needs. The sidebar cannot: .app-nav__item is overflow:hidden and sits inside
   the scrolling .app-nav__content, so a pseudo-element is clipped away twice
   over - app_nav.js therefore moves a single .app-tooltip element on the body
   and positions it beside the hovered item.

   Add data-tooltip to the control, never alongside a title - two bubbles would
   stack. --below places the ::after under the control; the default puts it to
   the right.
   ======================================================================== */

.app-tooltip,
[data-tooltip]::after {
	padding: var(--spacing-xs) var(--spacing-sm);
	border-radius: var(--radius-sm);
	background: var(--text-primary);
	color: var(--bg-primary);
	font-family: var(--font-family-primary);
	font-size: var(--font-body-md-size);
	font-weight: var(--font-weight-semibold);
	line-height: 1.4;
	white-space: nowrap;
	pointer-events: none;
}

/* ── The free-standing bubble (sidebar, placed by app_nav.js) ───────────── */
.app-tooltip {
	position: fixed;
	z-index: 1200;
	top: 0;
	left: 0;
	opacity: 0;
	visibility: hidden;
	transform: translateX(-4px);
	transition: opacity 180ms ease, transform 180ms ease, visibility 0s linear 180ms;
}

.app-tooltip--visible {
	opacity: 1;
	visibility: visible;
	transform: translateX(0);
	transition: opacity 180ms ease, transform 180ms ease;
}

/* ── The pseudo-element (top bar) ───────────────────────────────────────── */
[data-tooltip] {
	position: relative;
}

[data-tooltip]::after {
	content: attr(data-tooltip);
	position: absolute;
	z-index: 120;
	top: 50%;
	left: calc(100% + var(--spacing-sm));
	transform: translateY(-50%);
	opacity: 0;
	visibility: hidden;
	/* Hidden immediately on leave; the delay applies only on the way in. */
	transition: opacity 80ms ease, visibility 0s linear 80ms;
}

[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after {
	opacity: 1;
	visibility: visible;
	transition: opacity 80ms ease 120ms, visibility 0s linear 120ms;
}

/* Under the control, for a horizontal bar with no room beside it. */
[data-tooltip].app-tooltip--below::after {
	top: calc(100% + var(--spacing-xs));
	left: 50%;
	transform: translateX(-50%);
}

/* The sidebar's items render through the free-standing bubble; suppress the
   pseudo-element there so the two never both appear. */
.app-nav [data-tooltip]::after {
	content: none;
}

/* An empty data-tooltip means the label never arrived (a missing language key);
   an empty bubble is worse than none. */
[data-tooltip=""]::after {
	content: none;
}
