/*
 * The competitor report's form (#1866): its platforms are buttons that are on or off, each with the platform's own
 * icon beside its name — no checkbox.
 *
 * Filament draws a chosen toggle button filled with the primary colour, and on that fill a platform's mark is lost:
 * Facebook's blue disappears into it. So a chosen platform is a tinted button with a primary outline, where the mark
 * keeps its colour, and one left out is grey, mark included: on and off read at a glance, without a tick.
 *
 * Filament loads only its own compiled bundle and does NOT scan our Blade views, so these are `.ssmt-*` classes,
 * registered through FilamentAsset — same arrangement as social-content.css, and the same reason. Unlayered, so
 * they win over Filament's layered rules without `!important`.
 *
 * COLOUR RULE (#124): everything here comes from a design-system token; `CssTokensTest` fails the build on a hex.
 */

.ssmt-platform-toggles .fi-fo-toggle-buttons-input:checked + .fi-btn {
    background: color-mix(in srgb, var(--tew-color-primary) 18%, transparent);
    box-shadow: inset 0 0 0 1.5px var(--tew-color-primary);
    color: var(--tew-color-text);
}

.ssmt-platform-toggles .fi-fo-toggle-buttons-input:checked + .fi-btn:hover {
    background: color-mix(in srgb, var(--tew-color-primary) 26%, transparent);
}

/*
 * ⚠️ The rule above replaces Filament's `box-shadow`, and Filament draws its focus ring as a `box-shadow`, in a layer
 * that loses to it: without this a chosen button looked the same with and without keyboard focus (WCAG 2.4.7), and
 * on a fresh form every platform is chosen. An outline, as the other `.ssmt-*` focus rings, does not collide with it.
 */
.ssmt-platform-toggles .fi-fo-toggle-buttons-input:focus-visible + .fi-btn {
    outline: 2px solid var(--tew-color-focus-ring);
    outline-offset: 2px;
}

.ssmt-platform-toggles .fi-fo-toggle-buttons-input:not(:checked) + .fi-btn {
    color: var(--tew-color-text-muted);
}

/*
 * The mark's drawing only: it is decorative — the name beside it is what is read — so dimming it costs no contrast.
 * Not the «Ads» badge beside it, which is text on screen and has to keep its own.
 */
.ssmt-platform-toggles .fi-fo-toggle-buttons-input:not(:checked) + .fi-btn .ssmt-icon > svg {
    filter: grayscale(1);
    opacity: 0.45;
}

/*
 * Bars behind the report's figures (#1866), drawn when the switch above the tables is on (`.ssmt-bars-on`). A cell
 * carries its bar's length as `--ssmt-bar`, a share of the column's largest value across every table of the section;
 * no property, no bar.
 *
 * Behind the figure, not under it: a bar of its own under the number pushed the number up, off the line of the
 * brand's name. Anchored at the right, where the digits end, so it reads with them.
 *
 * ⚠️ The longest bar is the same length in every cell (4.5rem), not the cell's width: each client's table sizes its own
 * columns, and a bar as long as its cell would draw the same value two lengths in two tables. Hence the cell's
 * min-width, which keeps the longest bar inside it. In rem, so it grows with the text (WCAG 1.4.4).
 *
 * Inset from the row's top and bottom, so two long bars in a row read as two bars and not as one block; light enough
 * that the figure on it keeps its contrast, in both themes and on the owned brand's tinted row.
 */
.ssmt-bars-on .ssmt-bar {
    min-width: 6rem;
    background-image: linear-gradient(
        to left,
        transparent 0.75rem,
        color-mix(in srgb, var(--tew-color-primary) 24%, transparent) 0.75rem,
        color-mix(in srgb, var(--tew-color-primary) 24%, transparent) calc(0.75rem + 4.5rem * var(--ssmt-bar, 0)),
        transparent calc(0.75rem + 4.5rem * var(--ssmt-bar, 0))
    );
    background-position: center;
    background-repeat: no-repeat;
    background-size: 100% calc(100% - 0.5rem);
}
