/* ── Tooltip (icon-only buttons) — ported from the reference app.css ──────
   Opt in by adding  data-tooltip="Label"  to any element. The bubble shows
   on mouse hover AND keyboard focus (focus-visible), so it never sticks after a
   mouse click; on touch screens only on a long press (Js/Tooltip.js, Kelly
   2026-10-07). Appears BELOW the element by default; add
   data-tooltip-pos="top" to flip it above (use for elements near the bottom
   of the screen, e.g. floating action buttons).

   WARNING (deviation from the reference): the reference guarded its
   position:relative against Tailwind positioning utilities; this app has no
   Tailwind, so the rule applies unconditionally — do NOT decorate elements
   that rely on their own absolute/fixed positioning (an inline `position:`
   still wins). MudBlazor components keep MudTooltip; this system is for
   plain HTML buttons.

   The Profile "Show Tooltips" toggle (TooltipSettingsService) suppresses all
   bubbles by putting .fc-tooltips-off on the app root (MainLayout).

   Tokens: colour/type/elevation map 1:1 onto tokens.css. The bubble gap uses
   --space-1 (8px); the arrow gap subtracts the 5px arrow border from that same
   token so the tip stays flush with the bubble if the token ever changes. The
   remaining literals (6px radius, 6px padding, 5px arrow, 1.2 line-height,
   0.2px tracking) have NO token whose value matches — --radius-sm is 8px and
   --text-xs-lh is 18px, so substituting either would resize the bubble. */

[data-tooltip] { position: relative; }

[data-tooltip]::after,
[data-tooltip]::before {
    position: absolute;
    left: 50%;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    /* v3.1 never defines --fc-z-tooltip (v3.0.2's z-scale was not ported and tokens are report-only), so
       without a fallback this computed to z-index:auto and a bubble could paint under neighbouring
       positioned elements. 10000 = v3.0.2's tooltip layer (the top one). */
    z-index: var(--fc-z-tooltip, 10000);
    transition: opacity 0.12s ease, transform 0.12s ease;
}
/* Bubble */
[data-tooltip]::after {
    content: attr(data-tooltip);
    top: calc(100% + var(--space-1));
    transform: translateX(-50%) translateY(-2px);
    background: var(--color-text-primary);
    color: var(--color-surface-default);
    font-family: var(--font-body);
    font-size: var(--text-xs-size);
    font-weight: var(--fw-normal);
    line-height: 1.2;
    letter-spacing: 0.2px;
    white-space: nowrap;
    padding: 6px var(--space-1);
    border-radius: 6px;
    box-shadow: var(--elevation-md);
}
/* Arrow */
[data-tooltip]::before {
    content: "";
    top: calc(100% + var(--space-1) - 5px);
    transform: translateX(-50%) translateY(-2px);
    border: 5px solid transparent;
    border-bottom-color: var(--color-text-primary);
}
/* Top variant — bubble + arrow above the element */
[data-tooltip][data-tooltip-pos="top"]::after {
    top: auto;
    bottom: calc(100% + var(--space-1));
    transform: translateX(-50%) translateY(2px);
}
[data-tooltip][data-tooltip-pos="top"]::before {
    top: auto;
    bottom: calc(100% + var(--space-1) - 5px);
    border: 5px solid transparent;
    border-bottom-color: transparent;
    border-top-color: var(--color-text-primary);
}
/* Reveal, with a small delay: keyboard focus everywhere, mouse hover only where a real hover exists.
   On touch screens a tap counts as a hover (iOS keeps it until the next tap), so the bubble opened on
   every tap and stayed (Kelly, 2026-10-07: tooltips on iOS only on a long press). There a long press
   shows it instead: Js/Tooltip.js adds .fc-tip-show while the finger is held. */
[data-tooltip]:focus-visible::after,
[data-tooltip]:focus-visible::before,
[data-tooltip].fc-tip-show::after,
[data-tooltip].fc-tip-show::before {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
    transition-delay: 0.15s;
}
@media (hover: hover) {
    [data-tooltip]:hover::after,
    [data-tooltip]:hover::before {
        opacity: 1;
        visibility: visible;
        transform: translateX(-50%) translateY(0);
        transition-delay: 0.15s;
    }
}
/* Touch: holding a control to read its tip must not select text or open the iOS callout. */
@media (hover: none) {
    [data-tooltip] {
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }
}

/* Horizontal alignment — keeps a tooltip inside an overflow:hidden media box
   when its button sits in a corner/edge. "end" pins the bubble's right edge
   to the button and opens leftward; "start" pins the left edge and opens rightward. */
[data-tooltip][data-tooltip-align="end"]::after    { left: auto; right: 0;    transform: translateX(0) translateY(-2px); }
[data-tooltip][data-tooltip-align="end"]::before   { left: auto; right: 12px; transform: translateX(0) translateY(-2px); }
[data-tooltip][data-tooltip-align="start"]::after  { left: 0;               transform: translateX(0) translateY(-2px); }
[data-tooltip][data-tooltip-align="start"]::before { left: 12px;            transform: translateX(0) translateY(-2px); }
[data-tooltip][data-tooltip-align="end"]:focus-visible::after,
[data-tooltip][data-tooltip-align="end"]:focus-visible::before,
[data-tooltip][data-tooltip-align="end"].fc-tip-show::after,
[data-tooltip][data-tooltip-align="end"].fc-tip-show::before,
[data-tooltip][data-tooltip-align="start"]:focus-visible::after,
[data-tooltip][data-tooltip-align="start"]:focus-visible::before,
[data-tooltip][data-tooltip-align="start"].fc-tip-show::after,
[data-tooltip][data-tooltip-align="start"].fc-tip-show::before { transform: translateX(0) translateY(0); }
@media (hover: hover) {
    [data-tooltip][data-tooltip-align="end"]:hover::after,
    [data-tooltip][data-tooltip-align="end"]:hover::before,
    [data-tooltip][data-tooltip-align="start"]:hover::after,
    [data-tooltip][data-tooltip-align="start"]:hover::before { transform: translateX(0) translateY(0); }
}

/* MudBlazor buttons (MudIconButton etc.) — Kelly, 2026-09-30: "ALL icon-buttons MUST HAVE A TOOLTIP".
   MudBlazor's .mud-ripple clips the button (overflow:hidden) and styles its own ::after
   (width/height 100%, a radial-gradient ripple), so a data-tooltip on a MudIconButton never showed:
   measured on the Sign In ✕ — nothing on hover. Let the bubble out and undo the ripple's sizing on
   tooltip-carrying MudBlazor buttons only. (0,2,x) beats MudBlazor's (0,1,x) rules. */
.mud-button-root[data-tooltip] { overflow: visible; }
.mud-button-root[data-tooltip]::after {
    width: auto;
    height: auto;
    background-image: none;
}
/* Profile "Show Tooltips" OFF — suppress every bubble */
.fc-tooltips-off [data-tooltip]::after,
.fc-tooltips-off [data-tooltip]::before {
    display: none !important;
}

/* ── KEPT FROM MAIN ──────────────────────────────────────────────
   Rules 3.2 does not have. Appended after its stylesheet so they still win on equal
   specificity, exactly as they did before the import. */
/* Reveal on hover / keyboard focus, with a small delay */
[data-tooltip]:hover::after,
[data-tooltip]:hover::before,
[data-tooltip]:focus-visible::after,
[data-tooltip]:focus-visible::before {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
    transition-delay: 0.15s;
}
[data-tooltip][data-tooltip-align="end"]:hover::after,
[data-tooltip][data-tooltip-align="end"]:hover::before,
[data-tooltip][data-tooltip-align="end"]:focus-visible::after,
[data-tooltip][data-tooltip-align="end"]:focus-visible::before,
[data-tooltip][data-tooltip-align="start"]:hover::after,
[data-tooltip][data-tooltip-align="start"]:hover::before,
[data-tooltip][data-tooltip-align="start"]:focus-visible::after,
[data-tooltip][data-tooltip-align="start"]:focus-visible::before { transform: translateX(0) translateY(0); }
