/* The instant custom tooltip (js/ui/tip/controlTooltip.js + tipContent.js): the composed title
   as structure — heading with keycaps, term/description rows, bullets, the disabled-reason note.
   Fixed-position and pointer-events:none, so it never eats hover. */
#app-tooltip {
    position: fixed;
    z-index: 100003;
    max-width: 380px;
    padding: 7px 10px;
    font-size: 12px;
    /* Roomy enough that a keycap — half again the type size — never collides with the line
       above when a combo wraps inside running prose ("… (Shift+click: without theme)"). */
    line-height: 1.75;
    color: var(--text-main);
    background: var(--bg-info);
    /* A tooltip often carries a URL or a file name, which has no space to break at: without
       this it runs past max-width and the mask clips it mid-token. */
    overflow-wrap: anywhere;
    /* Outlined in the accent, like the desktop's QToolTip (theme.cpp %ACCENT_RING%): what sets a
       tooltip apart from the panel behind it. */
    border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border-main));
    border-radius: 6px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
    pointer-events: none;
    opacity: 0;
    /* The sand as a mask on the box itself (the scroll dissolve's coprime dot grids,
       animations/reveal/reveal.css): a tooltip re-points and tracks the cursor, so motes would
       strand. A transition, not keyframes, so re-pointing re-aims from wherever the grain is.
       --dissolve: 1 = pure grain, 0 = solid (registered in reveal.css); 120% overlaps the dots
       outright. Origin top-left, where controlTooltip.js anchors the box at the cursor. */
    --dissolve: 1;
    transform: translate(3px, 6px) scale(0.96);
    transform-origin: top left;
    /* Leaving (the rule a transition goes TO): the alpha eases in, holding while the grain opens,
       so the tip comes apart instead of merely fading. */
    transition: opacity 190ms cubic-bezier(0.55, 0, 1, 0.45),
                transform 150ms cubic-bezier(0.16, 1, 0.3, 1),
                --dissolve 190ms ease-out;
    -webkit-mask-image:
        radial-gradient(circle at 50% 50%, #000 max(0%, calc(120% - var(--dissolve) * 160%)),
                        transparent max(0%, calc(128% - var(--dissolve) * 160%))),
        radial-gradient(circle at 50% 50%, #000 max(0%, calc(120% - var(--dissolve) * 140%)),
                        transparent max(0%, calc(128% - var(--dissolve) * 140%))),
        radial-gradient(circle at 50% 50%, #000 max(0%, calc(120% - var(--dissolve) * 125%)),
                        transparent max(0%, calc(128% - var(--dissolve) * 125%)));
    mask-image:
        radial-gradient(circle at 50% 50%, #000 max(0%, calc(120% - var(--dissolve) * 160%)),
                        transparent max(0%, calc(128% - var(--dissolve) * 160%))),
        radial-gradient(circle at 50% 50%, #000 max(0%, calc(120% - var(--dissolve) * 140%)),
                        transparent max(0%, calc(128% - var(--dissolve) * 140%))),
        radial-gradient(circle at 50% 50%, #000 max(0%, calc(120% - var(--dissolve) * 125%)),
                        transparent max(0%, calc(128% - var(--dissolve) * 125%)));
    /* Three cell sizes at three phases: one lattice alone lines its dots up into
       joining rectangles, which is exactly what stops it reading as sand. */
    -webkit-mask-size: 4px 4px, 7px 7px, 11px 11px;
    mask-size: 4px 4px, 7px 7px, 11px 11px;
    -webkit-mask-position: 0 0, 2px 3px, 5px 1px;
    mask-position: 0 0, 2px 3px, 5px 1px;
    -webkit-mask-composite: source-over;   /* legacy spelling of "union" */
    mask-composite: add;
}
/* Once the real motes have flown for it (surfaceIn), mask, transition and offset step aside for
   good: `.dust-driven` is permanent (js/ui/motion.js). Reduced motion never sets it. */
#app-tooltip.dust-driven {
    transition: none;
    transform: none;
    --dissolve: 0;
    -webkit-mask-image: none;
    mask-image: none;
}
/* ARRIVING: opaque by 100ms — a sweep must never wait to read it — and what you watch
   for the rest is the sand closing up. */
#app-tooltip.visible {
    opacity: 1;
    transform: none;
    --dissolve: 0;
    transition: opacity 100ms ease, transform 150ms cubic-bezier(0.16, 1, 0.3, 1),
                --dissolve 220ms ease;
}
/* Heading: the control's name, with its shortcut pinned to the right of the same row. */
.tip-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    justify-content: space-between;
}
/* min-width:0 — a flex item refuses to shrink below its longest word, which for a URL
   heading is the whole string. */
.tip-title { font-weight: 600; min-width: 0; }
.tip-keys { display: inline-flex; align-items: center; gap: 6px; flex: none; }
/* A third bigger than the prose, not double: at 21px the caps dwarfed the sentence and a combo
   in running text wrapped onto its own line. */
.tip-key {
    display: inline-block;
    font: inherit;
    font-size: 14px;
    line-height: 1;
    font-weight: 600;
    padding: 3px 6px;
    min-width: 12px;
    text-align: center;
    color: var(--text-key);
    background: var(--bg-container);
    border: 1px solid var(--border-main);
    border-bottom-width: 2px;
    border-radius: 5px;
    white-space: nowrap;
    vertical-align: middle;   /* centred on the sentence it sits in, not on its baseline */
}
.tip-plus { font-size: 13px; color: var(--text-shortcut); margin: 0 3px; vertical-align: middle; }
/* Keycap shake (controlTooltip.js): one nudge as the tooltip appears; movement only, same colours. */
@keyframes keycapShake {
    0%, 100% { transform: none; }
    15% { transform: translateX(-3px) rotate(-3deg); }
    38% { transform: translateX(3px) rotate(3deg); }
    62% { transform: translateX(-2px) rotate(-2deg); }
    84% { transform: translateX(2px) rotate(1.5deg); }
}
.tip-key.key-shake {
    animation: keycapShake 0.32s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}
@media (prefers-reduced-motion: reduce) {
    /* No grain either — a half-sanded tooltip is a surprise, not motion. It shows and
       hides solid, and `visible` still owns which of the two it is. */
    #app-tooltip {
        transition: none; transform: none; --dissolve: 0;
        -webkit-mask-image: none; mask-image: none;
    }
    .tip-key.key-shake { animation: none; }
}
/* Rows: "term — description" pairs from the title, as an aligned two-column grid — the
   term and its description are direct grid children, so every row shares the columns. */
.tip-rows {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 2px 10px;
    margin-top: 5px;
    max-width: 100%;
}
.tip-term { font-weight: 600; padding-left: 12px; text-indent: -12px; }
/* Rows read as a bullet list (the app writes them with a "•" marker), while the grid keeps
   the descriptions in one column. The marker rides the term so a wrapped term still lines up. */
.tip-term::before { content: '•'; color: var(--text-muted); padding-right: 6px; }
.tip-desc { color: var(--text-info); }
.tip-bullets { margin: 5px 0 0; padding-left: 15px; }
.tip-bullets li { margin: 1px 0; }
.tip-line { margin-top: 4px; }
/* Hints (a parenthesised line, a subtitle) sit back; the disabled reason is a warning. */
.tip-hint { margin-top: 4px; color: var(--text-muted); }
.tip-note { margin-top: 5px; color: var(--warning); }
.tip-head + .tip-rows, .tip-head + .tip-bullets { margin-top: 5px; }
