/*
 * FB-08 Tooltip — app/components/ui/tooltip_component.rb
 *
 * --color-ink fill, white --text-xs — the ONE sanctioned light-on-dark
 * surface. --radius-xs, 8px (--space-2) padding, 6px arrow, 250ms open
 * delay. CSS-only: :hover/:focus-within show the bubble after a delay;
 * :focus-within (rather than :focus) so a focused element nested inside
 * the trigger block still triggers it. Desktop only — hidden below
 * --bp-md and for any touch-capable pointer, since touch has no hover.
 */

:root {
  /* Component-local — not part of the shared token set. */
  --tooltip-open-delay: 250ms;
}

.ui-tooltip {
  position: relative;
  display: inline-flex;
}

.ui-tooltip__bubble {
  position: absolute;
  bottom: calc(100% + var(--space-2));
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-popover);
  width: max-content;
  max-width: 240px;
  padding: var(--space-2);
  background: var(--color-ink);
  color: var(--color-on-accent);
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  line-height: var(--text-xs--line-height);
  border-radius: var(--radius-xs);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--duration-fast) var(--ease-out);
  transition-delay: 0s;
}

.ui-tooltip__bubble::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--color-ink);
}

.ui-tooltip:hover .ui-tooltip__bubble,
.ui-tooltip:focus-within .ui-tooltip__bubble {
  opacity: 1;
  visibility: visible;
  transition-delay: var(--tooltip-open-delay);
}

/* Desktop only — hidden below --bp-md, and for any touch-capable pointer
   (a hybrid laptop/tablet with both mouse and touch keeps it, since
   any-hover reports true if *any* input mechanism can hover). */
@media (max-width: 767px), (any-hover: none) {
  .ui-tooltip__bubble {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ui-tooltip__bubble {
    transition: none;
  }
}
