/* Overrides for leandown's hover tooltips.
 *
 * Loaded after node_modules/@leandown/mdbook/dist/leandown.css (see the
 * additional-css order in book.toml), so equal-specificity rules here win. */

:root {
  /* Deliberately `em`, not `rem`: mdbook sets `html { font-size: 62.5% }` so that
     1rem = 10px, which silently shrinks leandown's `0.95rem` tooltip text to
     9.5px (its stylesheet assumes a normal 16px root). Tooltips are appended straight
     to <body>, and never nested inside one another, so `em` resolves against
     mdbook's body text — 1em is 16px here — and cannot compound.

     Everything inside the tooltip (prose, type signatures, inline code) is sized
     in `em` by leandown, so this one value scales the whole popup. */
  --lait-tooltip-font-size: 1em;

  /* Bigger text in the same box just wraps type signatures earlier, so give the
     popup some more room to keep roughly the original characters per line. */
  --lait-tooltip-max-width: 480px;
}

.lean-tooltip {
  font-size: var(--lait-tooltip-font-size);

  /* The runtime assigns `max-width` as an *inline* style — floating-ui's `size`
     middleware caps it at min(320px, availableWidth) — and inline styles beat
     stylesheet rules at any specificity, hence `!important`. The viewport clamp
     preserves what that cap was there for: not overflowing a narrow window. */
  max-width: min(var(--lait-tooltip-max-width), calc(100vw - 24px)) !important;
}
