/* ===========================================
   Themed tooltips (TASK-291)
   Replaces the browser's default (unstyled) title="" popups. Any element with a
   `data-tooltip="…"` attribute shows a token-styled bubble on hover / keyboard focus.
   Pure CSS, no JS. Token-only. Use INSTEAD of native `title` for help text.

     <button data-tooltip="Lift this user's mute.">Unmute</button>

   Notes:
   - The bubble is absolutely positioned relative to the element; an ancestor with
     non-visible overflow can clip it (same caveat as any CSS tooltip). For toolbars
     mid-content this is fine.
   - `data-tooltip-pos="bottom"` flips it below the element (for things near the top).
   =========================================== */

[data-tooltip] {
    position: relative;
}

[data-tooltip]::after,
[data-tooltip]::before {
    position: absolute;
    left: 50%;
    z-index: 1200;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--dur-fast) ease, transform var(--dur-fast) ease;
}

/* Bubble */
[data-tooltip]::after {
    content: attr(data-tooltip);
    bottom: calc(100% + 9px);
    transform: translateX(-50%) translateY(4px);
    width: max-content;
    max-width: 260px;
    padding: 7px 10px;
    /* matches the v2 .popover surface (surface + border + shadow-md) */
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-md);
    font-family: var(--font);
    font-size: 12px;
    font-weight: 400;
    line-height: 1.4;
    letter-spacing: normal;
    text-transform: none;
    white-space: normal;
    text-align: left;
}

/* Arrow */
[data-tooltip]::before {
    content: "";
    bottom: calc(100% + 4px);
    transform: translateX(-50%) translateY(4px);
    border: 5px solid transparent;
    border-top-color: var(--border);
}

[data-tooltip]:hover::after,
[data-tooltip]:hover::before,
[data-tooltip]:focus-visible::after,
[data-tooltip]:focus-visible::before {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Position variant — below the element (for triggers near the top edge) */
[data-tooltip-pos="bottom"]::after {
    bottom: auto;
    top: calc(100% + 9px);
}
[data-tooltip-pos="bottom"]::before {
    bottom: auto;
    top: calc(100% + 4px);
    border-top-color: transparent;
    border-bottom-color: var(--border);
}
