/* =============================================================================
   TOOLTIPS: the one look for every MudTooltip in the app (STYLE_GUIDE §24)

   MudBlazor's default is a fixed grey bubble in 12px type with no width limit. It ignores the
   light/dark theme, and long text (clause wording especially) runs the width of the screen in
   tiny type. Pages patched that one at a time: inline max-width/padding wrappers, white cards that
   stayed white in dark mode, smaller fonts. This file replaces all of that with one card:

     - light mode: white card, dark ink, hairline border, soft shadow
     - dark mode:  raised dark surface (one step above the cards), light ink, deeper shadow
     - same type size, padding, radius and width cap for a one-word label and a 600-word clause,
       so long text wraps into a readable column instead of stretching across the page

   Pages should not restyle the bubble. Give a tooltip Text="..." (plain) or <TooltipContent>
   (rich) and let this file draw the card; TooltipStandardGuardTests fails the PR gate on the
   patterns this replaced.

   The tokens live on .mud-tooltip itself, not :root. A custom property that references another
   (var(--primary-text-color)) is resolved where it is declared, so declared on :root it would keep
   the light value on a .dark-mode body. Declared here, it resolves on the tooltip element, which
   sits under <body class="dark-mode"> (MudPopoverProvider renders inside body).
   ============================================================================= */

.mud-tooltip {
    --tooltip-bg: var(--secondary-bg-color, #fff);
    --tooltip-text: var(--primary-text-color, #000);
    --tooltip-muted-text: var(--secondary-text-color, rgba(0, 0, 0, 0.6));
    --tooltip-border: var(--border-color, #e2e8f0);
    --tooltip-shadow: 0 10px 28px rgba(15, 23, 42, 0.12), 0 2px 6px rgba(15, 23, 42, 0.08);
    --tooltip-max-width: 440px;
    --tooltip-radius: 8px;

    /* Never wider than the window, less a gutter, on a phone. !important because MudBlazor's popover
       script writes style="max-width: none" onto every popover each time it positions one, and only an
       !important rule outranks an inline style. Without it, clause wording runs the width of the screen. */
    max-width: min(var(--tooltip-max-width), calc(100vw - 24px)) !important;
    padding: 8px 12px;
    border-radius: var(--tooltip-radius);
    font-size: 0.8125rem;
    font-weight: 400;
    line-height: 1.5;
    letter-spacing: normal;
    /* MudBlazor centres the text, which is fine on one line and hard to read on ten. Short labels
       shrink-wrap, so left-aligning changes nothing for them. */
    text-align: left;
    /* Breaks only a word too long for the line (a URL, a long reference), so numbers in a rich
       tooltip's table never split. */
    overflow-wrap: break-word;
}

.dark-mode .mud-tooltip {
    /* #26272d: one step above the #1c1d22 cards, so a tooltip over a card reads as on top of it. */
    --tooltip-bg: var(--tertiary-bg-color, #26272d);
    --tooltip-border: rgba(255, 255, 255, 0.14);
    --tooltip-shadow: 0 10px 28px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.4);
}

/* Colours apply to the default tooltip only. A tooltip given a Color (Error, say) keeps
   MudBlazor's filled theme colour, which carries meaning. */
.mud-tooltip.mud-tooltip-default {
    color: var(--tooltip-text);
    background-color: var(--tooltip-bg);
    border: 1px solid var(--tooltip-border);
    box-shadow: var(--tooltip-shadow);
}

/* The arrow is the card's colour, with a 1px drop shadow standing in for the border. The filter is
   applied before MudBlazor's rotate, so the outline turns with the arrow for every placement. */
.mud-tooltip.mud-tooltip-default.mud-tooltip-arrow::after {
    border-color: var(--tooltip-bg) transparent transparent transparent;
    filter: drop-shadow(0 1px 0 var(--tooltip-border));
}

/* A plain Text="..." tooltip keeps the line breaks in its text, so clause wording that is written
   in paragraphs or numbered sub-clauses reads that way. MudBlazor renders Text straight into the
   bubble but wraps TooltipContent in a <div class="d-block">, where the markup's own indentation and
   newlines must keep collapsing. TooltipStandardTests pins that structure. */
.mud-tooltip {
    white-space: pre-line;
}

.mud-tooltip > .d-block {
    white-space: normal;
}

/* Supporting copy inside rich content: the "how this is worked out" note under a breakdown. */
.mud-tooltip .tooltip-note {
    color: var(--tooltip-muted-text);
}
