/* Tooltip (brandbook "Tooltips"): a short explanation that floats next to
   what it explains. One look for both kinds the module's JS opens:

   - the field tooltip, .mm-tooltip, from templates/form/
     fieldset--with-tooltip.html.twig: an info-icon trigger at the end of the
     legend; the module's js/tooltip.js shows it on hover and focus by
     dropping .visually-hidden, and Popper places it and its arrow
     ([data-popper-arrow], side from data-popper-placement);
   - the term explanation, .mamaney-term__pop, inside a glossary term
     (.mamaney-term: the wallet's templates/components/_term.html.twig and
     the module's TermTooltipEnricher in the document preview). The term
     reads as brandbook .mm-term: text colour, dotted underline, a small info
     icon after it. The module's js/document-term-tooltip.js opens it
     (.is-open on hover, keyboard focus or tap; Escape closes it) and fixes
     the pop at viewport coordinates. No ancestor may be a containing block
     for fixed boxes (no container-type, transform or filter on a card, a
     dialog or the page column): the action row queries its own frame for
     that reason (action-row.css).

   Every page loads this file (mamaney_theme/global): terms show on the
   wallet, in previews and in dialogs opened from anywhere. */

/* -- The box ----------------------------------------------------------- */

.mm-tooltip,
.mamaney-term__pop {
  width: max-content;
  max-width: min(280px, calc(100vw - 2 * var(--mm-space-4)));
  padding: var(--mm-space-3) 14px;
  border: 1px solid var(--mm-line);
  border-radius: var(--mm-radius-card);
  background: var(--mm-surface);
  box-shadow: var(--mm-shadow-overlay);
  color: var(--mm-text);
  font: 400 14px/1.45 var(--mm-sans);
  font-style: normal;
  letter-spacing: normal;
  text-align: left;
  text-transform: none;
  white-space: normal;
}

/* -- Field tooltip ----------------------------------------------------- */

/* Popper sets position, top and left inline; the box only needs a layer
   above the field around it and inside the dialog. */
.mm-tooltip {
  z-index: 40;
}

/* Hidden (.visually-hidden) it is a 1 px clip, never the box above. */
.mm-tooltip.visually-hidden {
  padding: 0;
  border: 0;
  box-shadow: none;
}

.mm-tooltip__arrow,
.mm-tooltip__arrow::before {
  position: absolute;
  width: 10px;
  height: 10px;
}

/* The wrapper is Popper's to place; only the rotated square shows, its two
   outer edges carrying the box's line. */
.mm-tooltip__arrow {
  visibility: hidden;
}

.mm-tooltip__arrow::before {
  content: '';
  visibility: visible;
  transform: rotate(45deg);
  border: 1px solid var(--mm-line);
  background: var(--mm-surface);
}

.mm-tooltip[data-popper-placement^='top'] > .mm-tooltip__arrow {
  bottom: -6px;
}

.mm-tooltip[data-popper-placement^='bottom'] > .mm-tooltip__arrow {
  top: -6px;
}

.mm-tooltip[data-popper-placement^='left'] > .mm-tooltip__arrow {
  right: -6px;
}

.mm-tooltip[data-popper-placement^='right'] > .mm-tooltip__arrow {
  left: -6px;
}

.mm-tooltip[data-popper-placement^='top'] > .mm-tooltip__arrow::before {
  border-top: 0;
  border-left: 0;
}

.mm-tooltip[data-popper-placement^='bottom'] > .mm-tooltip__arrow::before {
  border-right: 0;
  border-bottom: 0;
}

.mm-tooltip[data-popper-placement^='left'] > .mm-tooltip__arrow::before {
  border-bottom: 0;
  border-left: 0;
}

.mm-tooltip[data-popper-placement^='right'] > .mm-tooltip__arrow::before {
  border-top: 0;
  border-right: 0;
}

/* The trigger: the info icon at the end of the legend, a 24 x 24 target in
   the term's quiet colour. */
.mm-tooltip-trigger {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-left: var(--mm-space-1);
  border-radius: 50%;
  color: var(--mm-counter);
  vertical-align: middle;
  cursor: help;
}

.mm-tooltip-trigger:hover {
  color: var(--mm-primary);
}

.mm-tooltip-trigger:focus-visible {
  outline: none;
  box-shadow: var(--mm-focus);
}

.mm-tooltip-trigger__icon {
  width: 18px;
  height: 18px;
}

/* -- Glossary term ----------------------------------------------------- */

.mamaney-term {
  display: inline;
  cursor: help;
}

.mamaney-term:focus-visible {
  outline: none;
  border-radius: var(--mm-radius-tag);
  box-shadow: var(--mm-focus);
}

/* The phrase: brandbook .mm-term. The wallet's macro also prints .mm-term
   on it; the preview's enricher prints the phrase class only. */
.mm-term,
.mamaney-term__phrase {
  color: var(--mm-text);
  text-decoration: underline dotted;
  text-decoration-color: var(--mm-counter);
  text-underline-offset: 3px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.mamaney-term:hover .mamaney-term__phrase,
.mamaney-term.is-open .mamaney-term__phrase {
  text-decoration-style: solid;
}

/* A term and the punctuation right after it (_term.html.twig explain()):
   the icon is a break opportunity, so without this the full stop could
   start the next line. The explanation inside sets white-space back. */
.mm-term-glue {
  white-space: nowrap;
}

.mamaney-term__badge {
  display: inline-block;
  width: 15px;
  height: 15px;
  margin-left: 2px;
  color: var(--mm-counter);
  vertical-align: -2px;
}

/* The explanation: fixed at the viewport coordinates the module's JS
   writes, shown while the term is open. Above the navigation bars and the
   dialog it may sit in. */
.mamaney-term__pop {
  position: fixed;
  z-index: 110;
  display: none;
  width: 280px;
}

.mamaney-term.is-open .mamaney-term__pop {
  display: block;
}

.mamaney-term__title {
  display: block;
  margin-bottom: var(--mm-space-1);
  font-weight: 600;
}

.mamaney-term__body {
  display: block;
}

/* A term whose snippet is missing is flagged, never dropped. */
.mamaney-term--missing .mamaney-term__phrase {
  background: var(--mm-danger-surface);
  text-decoration-color: var(--mm-danger);
}

.mamaney-term--missing .mamaney-term__badge {
  color: var(--mm-danger);
}

.mamaney-term--missing .mamaney-term__pop {
  border-color: var(--mm-danger);
}
