/*
 * The firm's palette, promoted from the login page to the whole product.
 * Fase 1 de [docs/layout-plan.md](../../../../docs/layout-plan.md) — D1, D2,
 * D7, D8, D12, D13.
 *
 * `auth.css` established these values and recorded how: sampling
 * `precapp/img/apple-touch-icon.png`, the firm's own lockup, gives `#001f4e`
 * for 27.416 of its 32.400 pixels, and `base.html`'s `theme-color` has
 * declared that same value since it was written. Until this file existed the
 * APPLICATION agreed with neither - it rendered in Bootstrap's default
 * `#0d6efd`, not by choice but because nothing had ever overridden it.
 *
 * ---------------------------------------------------------------------------
 * READ THIS BEFORE EDITING: half of this file is not optional.
 * ---------------------------------------------------------------------------
 *
 * Custom properties and NOT a recompiled Bootstrap (D8, owner 2026-09-22).
 * The catch, measured as F15 of the plan: **overriding `--bs-primary` retints
 * three utilities and leaves twenty-two rules blue.** Bootstrap 5.3.0 reads
 * `--bs-primary-rgb` for `.bg-primary`, `.text-primary` and `.border-primary`
 * - and hardcodes `#0d6efd` everywhere else: the button, the links, every
 * focus ring on a form control, pagination, accordion, nav-pills, list-group,
 * progress and `.text-bg-primary`.
 *
 * Setting only the two variables at the top of this file therefore ships a
 * navy navbar above blue buttons and blue focus rings, which reads as a
 * half-finished theme rather than as a choice. **§2 below is what makes D1
 * true, and deleting any of it leaves that piece blue with no error anywhere.**
 * `test_layout_invariants.py::TestOverridesDoBootstrap` is the guard.
 *
 * **Valid for Bootstrap 5.3.0 and pinned to it.** The list in §2 was derived
 * by reading the build `base.html` loads; a version bump can move a literal
 * into a variable or the reverse, so the test asserts the pinned version too.
 * Bumping Bootstrap means re-deriving this file.
 */


/* ==========================================================================
   1. The tokens
   ========================================================================== */

:root {
    /* ---- The mark ---- */

    /* The mark's ground, and the application's primary.
       White on it is 16,08:1, against the 4,50:1 the blue it replaces scraped
       past with zero margin. */
    --bs-primary: #001f4e;
    --bs-primary-rgb: 0, 31, 78;

    /* `--bs-blue` is what Bootstrap's own `$blue` becomes. Overridden so a
       screen reaching for `var(--bs-blue)` does not reintroduce the default
       by the back door; nothing in this project does today. */
    --bs-blue: #001f4e;

    /* The lighter navy `auth.css` uses as its gradient's far end. Here it is
       the hover/active step: a near-black primary has nowhere DARKER to go on
       hover, so it goes lighter, which is the opposite of what Bootstrap does
       with `#0d6efd` and the reason §2's button block is written out in full. */
    --marca-navy-claro: #0a3d82;
    --marca-navy-escuro: #00163a;

    /* The mark's own accent. NEVER a surface behind body text (D2): it is
       6,91:1 against the navy and 2,33:1 against white, so it reads as a rule,
       an icon or a focus ring, and text on it does not. */
    --marca-ouro: #e59a3c;
    --marca-ouro-rgb: 229, 154, 60;

    /* ---- Shape (D12) ----
       Three radii. `50%` stays outside the scale: a circle is not a corner
       size, and every `border-radius: 50%` in this project is an avatar or a
       numbered badge. */
    --raio-sm: .25rem;
    --raio: .5rem;
    --raio-lg: 1rem;

    /* ---- Elevation (D13) ----
       Three shadows, in Bootstrap's own geometry with the colour changed:
       `rgba(0, 31, 78, …)` and not `rgba(0, 0, 0, …)`, because a neutral-black
       shadow on a page whose accent is navy reads as grime. A focus ring is
       not an elevation and is not here - Bootstrap owns that one. */
    --sombra-sm: 0 .125rem .25rem rgba(0, 31, 78, .075);
    --sombra: 0 .5rem 1rem rgba(0, 31, 78, .12);
    --sombra-lg: 0 1rem 3rem rgba(0, 31, 78, .175);

    /* ---- The quiet section header (D3, plan §5.2) ----
       Named rather than inlined because three stylesheets need the same two
       values: `app.css` for `.card-header`, `forms.css` for `.section-header`,
       and `ajuda.css` once fase 4 rescopes it.

       **A literal, and NOT `var(--bs-tertiary-bg)`.** It was that until the
       owner reviewed the pilot on 22/09/2026 and asked for a darker header;
       `--bs-tertiary-bg` is `#f8f9fa`, the same value as `--bs-light`, and
       against a white card body it separates by only 1,05:1 - which is why it
       read as "no header" rather than as a quiet one.

       `#e8ebef` is white with 9% of the mark's navy mixed in, so the grey
       carries the brand's cast instead of being neutral. Measured: 1,20:1
       against the white card body (visible as a band), 12,90:1 under the body
       text and 13,45:1 under the navy icon. It is one step darker than
       Bootstrap's `--bs-tertiary-bg` and lands beside its `--bs-secondary-bg`
       (`#e9ecef`), which is the neutral version of the same step.

       **This is why removing a `bg-light` class from a header is no longer a
       no-op** - those 34 headers get darker too, which is the intended
       outcome and not a side effect. */
    --secao-fundo: #e8ebef;
    --secao-linha: var(--bs-border-color);
}


/* ==========================================================================
   2. What Bootstrap hardcodes (F15) - 22 rules that do NOT follow §1
   ========================================================================== */

/*
 * 2.1 Links.
 *
 * **`a` reads `--bs-link-color-rgb`, not `--bs-link-color`**, and that is the
 * trap this block exists for: setting the hex alone changes nothing an
 * operator can see. Both are set, because `--bs-link-color` is still read by
 * `.link-primary` and by components that compose it.
 *
 * **Navy links need their underline, and they have it.** Measured: `#001f4e`
 * against the body's `#212529` is **1,04:1** - a navy link is indistinguishable
 * from body text by colour alone, which is a WCAG 1.4.1 failure when colour is
 * the only cue. Bootstrap's Reboot already ships `a { text-decoration:
 * underline }`, so the non-colour cue is present and this is safe. **Anything
 * that removes that underline from body prose puts the failure back**, which is
 * why `.text-decoration-none` belongs on nav items and cards, never on a link
 * inside a paragraph.
 */
:root {
    --bs-link-color: #001f4e;
    --bs-link-color-rgb: 0, 31, 78;
    --bs-link-hover-color: #0a3d82;
    --bs-link-hover-color-rgb: 10, 61, 130;

    /* The ring Bootstrap paints via `.focus-ring` and a few components. The
       per-component rings are §2.3, because they are written as literal
       `box-shadow`s and do not read this. */
    --bs-focus-ring-color: rgba(0, 31, 78, .25);

    /* The `-subtle` / `-emphasis` triple. Not used by this plan's own design -
       `.secao-alerta` is `danger` - but a `bg-primary-subtle` anywhere would
       otherwise render Bootstrap blue against a navy page. Derived by the same
       mix Bootstrap uses on $primary: tint 80% for the bg, tint 60% for the
       border, shade 60% for the text. Emphasis on bg-subtle is 12,89:1. */
    --bs-primary-bg-subtle: #ccd2dc;
    --bs-primary-border-subtle: #99a5b8;
    --bs-primary-text-emphasis: #000c1f;
}

/*
 * 2.1b Amarelo e ciano como TEXTO.
 *
 * Bootstrap tem `-text-emphasis` para os dois, e o do ciano serve: `#055160`
 * dá 8,93:1 sobre o branco do card e 7,47:1 sobre o `--secao-fundo`.
 *
 * **O do amarelo NÃO serve, e é por isso que este bloco existe.** O
 * `$warning-text-emphasis` do Bootstrap é `shade-color($warning, 40%)` =
 * `#997404`, que dá **4,33:1** sobre o branco — abaixo dos 4,50:1 que a AA
 * pede para texto normal — e **3,62:1** sobre o `--secao-fundo`, que é pior
 * ainda porque o fundo é mais escuro. Trocar `text-warning` por
 * `text-warning-emphasis` corrigiria de 1,63:1 para 4,33:1 e **continuaria
 * reprovando**, que é a pior espécie de conserto: parece feito.
 *
 * `#856404` é o mesmo cálculo do Bootstrap com dois passos a mais — shade 48%,
 * o menor escurecimento que passa nos DOIS fundos: 5,49:1 sobre o branco e
 * 4,59:1 sobre o `--secao-fundo`. Não é uma cor nova: é a cor do Bootstrap
 * levada até onde ela precisava ir.
 *
 * Os `-emphasis` são variáveis, então redefini-las conserta `.text-*-emphasis`
 * em todo lugar de uma vez — inclusive nos lugares que ainda não existem.
 */
:root {
    --bs-warning-text-emphasis: #856404;
}

/*
 * 2.2 Buttons.
 *
 * Every one of these is a variable Bootstrap reads inside `.btn-primary`, so
 * the override is a redeclaration and not a new rule.
 *
 * **Hover goes LIGHTER and active goes darker**, which inverts Bootstrap's own
 * arrangement. Bootstrap darkens `#0d6efd` by 7,5% on hover; `#001f4e` is
 * already near-black, so darkening it produces no visible feedback at all.
 * White on the hover navy is 10,49:1 and on the active navy 17,86:1, so both
 * states stay comfortably legible.
 */
.btn-primary {
    --bs-btn-bg: #001f4e;
    --bs-btn-border-color: #001f4e;
    --bs-btn-hover-bg: var(--marca-navy-claro);
    --bs-btn-hover-border-color: var(--marca-navy-claro);
    --bs-btn-active-bg: var(--marca-navy-escuro);
    --bs-btn-active-border-color: var(--marca-navy-escuro);
    --bs-btn-disabled-bg: #001f4e;
    --bs-btn-disabled-border-color: #001f4e;
}

.btn-outline-primary {
    --bs-btn-color: #001f4e;
    --bs-btn-border-color: #001f4e;
    --bs-btn-hover-bg: #001f4e;
    --bs-btn-hover-border-color: #001f4e;
    --bs-btn-active-bg: #001f4e;
    --bs-btn-active-border-color: #001f4e;
    --bs-btn-disabled-color: #001f4e;
    --bs-btn-disabled-border-color: #001f4e;
}

/*
 * 2.3 Form controls.
 *
 * These are the only overrides in this file that are NEW RULES rather than
 * redeclared variables: Bootstrap writes the focus ring as a literal
 * `box-shadow` on each selector, with no variable in between. The selectors
 * are copied exactly, so specificity matches and source order decides - which
 * is why `tokens.css` must load after `bootstrap.min.css` (the link order is
 * asserted by `test_layout_invariants.py`).
 *
 * This is the block an operator notices most: it is the glow around every
 * field on every form in the system.
 */
.form-control:focus,
.form-select:focus,
.form-check-input:focus {
    border-color: var(--marca-navy-claro);
    box-shadow: 0 0 0 .25rem rgba(0, 31, 78, .25);
}

.form-check-input:checked,
.form-check-input[type=checkbox]:indeterminate {
    background-color: #001f4e;
    border-color: #001f4e;
}

.form-range::-webkit-slider-thumb { background-color: #001f4e; }
.form-range::-moz-range-thumb { background-color: #001f4e; }

.form-range:focus::-webkit-slider-thumb {
    box-shadow: 0 0 0 1px #fff, 0 0 0 .25rem rgba(0, 31, 78, .25);
}
.form-range:focus::-moz-range-thumb {
    box-shadow: 0 0 0 1px #fff, 0 0 0 .25rem rgba(0, 31, 78, .25);
}

.nav-link:focus-visible {
    box-shadow: 0 0 0 .25rem rgba(0, 31, 78, .25);
}

/*
 * 2.4 Components whose active/focus state is a variable.
 *
 * `.dropdown-menu` covers `.dropdown-menu-dark` too: the dark variant
 * redeclares the same variable, and the navbar's user menu is the one that
 * matters here.
 */
.dropdown-menu { --bs-dropdown-link-active-bg: #001f4e; }
.dropdown-menu-dark { --bs-dropdown-link-active-bg: #001f4e; }
.nav-pills { --bs-nav-pills-link-active-bg: #001f4e; }
.progress, .progress-stacked { --bs-progress-bar-bg: #001f4e; }

.list-group {
    --bs-list-group-active-bg: #001f4e;
    --bs-list-group-active-border-color: #001f4e;
}

.pagination {
    --bs-pagination-active-bg: #001f4e;
    --bs-pagination-active-border-color: #001f4e;
    --bs-pagination-focus-box-shadow: 0 0 0 .25rem rgba(0, 31, 78, .25);
}

.accordion {
    --bs-accordion-btn-focus-box-shadow: 0 0 0 .25rem rgba(0, 31, 78, .25);
}

.btn-close {
    --bs-btn-close-focus-shadow: 0 0 0 .25rem rgba(0, 31, 78, .25);
}

/*
 * `.text-bg-primary` is the one Bootstrap writes as a literal `RGBA()` with
 * `!important`, so the override needs `!important` to match it. The colour
 * pairing is unchanged - white text, primary ground - only the primary moves.
 */
.text-bg-primary {
    background-color: RGBA(0, 31, 78, var(--bs-bg-opacity, 1)) !important;
}
