/* Flat and soft, everywhere.
 *
 * The design rule: no shadows, no outlines and no outline offsets, and soft rounded edges instead
 * of hard rules. The component stylesheets no longer draw any of them; this file is the guarantee
 * for everything the cleanup cannot reach (a third-party widget, a style a script sets, a
 * stylesheet with edits still waiting to be committed). It loads last, so it wins.
 *
 * Without an outline, keyboard focus has to be shown some other way, or the site stops being
 * usable by keyboard. Focus is a firmer edge, a thick underline or a darkening on the element
 * itself, never a ring around it: links and buttons take a thick underline and darken slightly,
 * ticked boxes take the brand edge and darken. Each is a change of at least 3:1 against what is behind it.
 * clients/web/tests/test_flat_soft_design.py keeps all of this true.
 */

/* ── Never a shadow, never an outline ────────────────────────────────── */

*,
*::before,
*::after {
    box-shadow: none !important;
    text-shadow: none !important;
    outline: none !important;
    outline-offset: 0 !important;
}

/* ── Focus: a firm edge or a thick underline ─────────────────────────── */

/* Text controls: a thick underline in the text's own colour. It contrasts with whatever the
 * element is filled with, because the text already must, and it moves nothing. */
a:focus-visible,
button:focus-visible,
summary:focus-visible,
[role="button"]:focus-visible,
[role="tab"]:focus-visible,
[role="menuitem"]:focus-visible,
[role="option"]:focus-visible,
input:is([type="button"], [type="submit"], [type="reset"]):focus-visible {
    text-decoration: underline 3px;
    text-underline-offset: 4px;
}

/* No background tint here: a link can be a solid button with white text, and a pale tint behind
 * white text would make it unreadable at exactly the moment it is focused. The underline carries
 * the contrast; the slight darkening also marks icon-only links, which have no text to underline. */
a:focus-visible,
summary:focus-visible,
[role="tab"]:focus-visible,
[role="menuitem"]:focus-visible,
[role="option"]:focus-visible {
    filter: brightness(0.88);
}

button:focus-visible,
[role="button"]:focus-visible,
input:is([type="button"], [type="submit"], [type="reset"]):focus-visible {
    border-color: var(--ifinsta-primary) !important;
    filter: brightness(0.88);
}

/* A box you tick has no fill to tint and no text to underline, so it takes the brand edge and
 * darkens. (A browser's own checkbox ignores the edge; the darkening still shows.) */
input:is([type="checkbox"], [type="radio"], [type="range"], [type="file"]):focus-visible {
    border-color: var(--ifinsta-primary) !important;
    filter: brightness(0.7) saturate(1.5);
}

[tabindex]:not([tabindex="-1"], input, select, textarea, button, a, summary):focus-visible {
    text-decoration: underline 3px;
    text-underline-offset: 4px;
    filter: brightness(0.88);
}

/* ── Soft separation ─────────────────────────────────────────────────── */

hr {
    border: 0;
    border-block-start: 1px solid var(--ifinsta-border-soft);
}
