@layer uniform.components {
.u-tooltip {
  position: relative;
  display: inline-flex;
  max-width: 100%;
  vertical-align: middle;
}

.u-tooltip > :first-child { min-width: 0; }

.u-tooltip > :last-child {
  position: absolute;
  bottom: 100%;
  left: 50%;
  z-index: 100;
  display: none;
  width: max-content;
  max-width: 240px;
  margin-bottom: var(--u-space-1);
  padding: var(--u-space-1) var(--u-space-2);
  background: var(--u-color-text-default);
  color: var(--u-color-bg-surface);
  box-shadow: var(--u-shadow-float);
  font-family: var(--u-font-sans);
  font-size: var(--u-font-size-caption);
  font-weight: 400;
  line-height: var(--u-line-height-caption);
  text-align: start;
  white-space: normal;
  translate: -50% 0;
}

/* Covers the gap on both sides, so the pointer can cross it whichever way the label flips. */
.u-tooltip > :last-child::after {
  content: "";
  position: absolute;
  inset: calc(-1 * var(--u-space-1)) 0;
}

.u-tooltip:hover > :last-child,
.u-tooltip:has(:focus-visible) > :last-child { display: block; }

@media (hover: none) {
  .u-tooltip:focus-within > :last-child { display: block; }
}

.u-tooltip[data-dismissed] > :last-child { display: none; }

/* Fixed and anchored, the label escapes the overflow of tables, cards and dialogs. */
@supports (position-area: block-start) and (anchor-scope: all) {
  .u-tooltip {
    anchor-name: --u-tooltip;
    anchor-scope: --u-tooltip;
  }

  .u-tooltip > :last-child {
    position: fixed;
    position-anchor: --u-tooltip;
    position-area: block-start;
    position-try-fallbacks: flip-block, block-start span-inline-end, block-start span-inline-start;
    inset: auto;
    translate: none;
  }
}
}
