/*
 * Tabler 1.7.0 themed through its own CSS variables, with no fork and no Sass.
 * Loaded after tabler.min.css and tokens.css. Tabler uses no @layer, so these rules win by order.
 *
 * Two kinds of variable, two places:
 * - the :root block below holds the variables Tabler declares once on the root;
 * - rules on .btn, .form-control, .form-switch and the like hold the variables Tabler
 *   declares again on the component itself: a value set on the root would never reach them.
 *
 * The var() references resolve on <html>, which carries data-bs-theme, so one block serves both themes. The block also
 * applies to any element that carries data-bs-theme (the dark band of the landing): Tabler resets its variables there.
 * No --tblr-*-rgb variable: they are deprecated and ignore any override.
 */
:root,
[data-bs-theme] {
    /* Action and states: Tabler derives its tints, shades and borders from these base colors */
    --tblr-primary: var(--brand);
    --tblr-primary-fg: var(--on-brand);
    --tblr-primary-darken: var(--brand-hover);
    --tblr-secondary: var(--ink-muted);
    --tblr-success: var(--success);
    --tblr-warning: var(--warning);
    --tblr-danger: var(--danger);
    --tblr-danger-fg: var(--surface-raised);
    --tblr-info: var(--info);
    --tblr-form-valid-color: var(--success);
    --tblr-form-valid-border-color: var(--success);
    --tblr-form-invalid-color: var(--danger);
    --tblr-form-invalid-border-color: var(--danger);

    /* Surfaces, text, borders and links */
    --tblr-body-bg: var(--surface);
    --tblr-bg-surface: var(--surface-raised);
    --tblr-bg-surface-secondary: var(--surface-sunken);
    --tblr-bg-forms: var(--surface-raised);
    --tblr-bg-forms-disabled: var(--surface-sunken);
    --tblr-body-color: var(--ink);
    --tblr-emphasis-color: var(--ink);
    --tblr-heading-color: var(--ink);
    --tblr-border-color: var(--line);
    --tblr-border-color-translucent: var(--line);
    --tblr-link-color: var(--brand);
    --tblr-link-hover-color: var(--brand-hover);

    /* Type: body 15/24 on the 4px grid, the one Fontsource family */
    --tblr-font-sans-serif: var(--font);
    --tblr-font-monospace: var(--font);
    --tblr-body-font-size: 15px;
    --tblr-body-line-height: 1.6;

    /* Page gutter: 16px at every width (Tabler drops to 8px below 992px, too tight on a phone) */
    --tblr-page-padding: var(--space-4);

    /*
     * Shapes and relief (docs/charte/README.md): three nested radii. A surface that holds controls (a card, a modal, a
     * popover) reads --radius-lg, 12px; a control or a box inside a surface (a button, a field, a menu, a toast) reads
     * --radius, 8px; a mark of 24px or less (a badge, a key, a checkbox) reads --radius-sm, 4px. What is round by nature
     * (an avatar, a dot) is --radius-round, which Tabler calls its pill. A button and a field keep --radius at every
     * size, where Tabler steps down and up. Flat controls, shadow-sm on cards, shadow-md on what floats.
     */
    --tblr-border-radius: var(--radius);
    --tblr-border-radius-sm: var(--radius-sm);
    --tblr-border-radius-lg: var(--radius-lg);
    --tblr-border-radius-xl: var(--radius-lg);
    --tblr-border-radius-xxl: var(--radius-lg);
    --tblr-border-radius-pill: var(--radius-round);
    --tblr-btn-input-sm-border-radius: var(--radius);
    --tblr-btn-input-lg-border-radius: var(--radius);
    --tblr-shadow-input: none;
    --tblr-shadow-card: var(--shadow-sm);
    --tblr-shadow-dropdown: var(--shadow-md);

    /* Focus ring: solid 2px, offset 2px (the width and offset are Tabler's own defaults) */
    --tblr-focus-ring-color: var(--focus);

    /* Checked boxes and switches fill with brand (Tabler's default, from --tblr-primary); the border matches the fill */
    --tblr-control-checked-border-color: var(--brand);

    /*
     * Control height, 40px: line-height + 2 x padding-y + 2 x border = 24 + 2 x 7 + 2 x 1.
     * Fields read these variables through their own --tblr-control-* ones; buttons read them below.
     */
    --tblr-btn-input-font-size: 15px;
    --tblr-btn-input-line-height: 24px;
    --tblr-btn-input-padding-y: 7px;
    --tblr-btn-input-padding-x: var(--space-3);
}

/*
 * Buttons: same height as fields (40px), weight 600, flat. The size variants keep their own
 * metrics (btn-sm 16 + 2 x 7 + 2 = 32px, btn-lg 48px), so the 40px metrics skip them.
 */
.btn {
    --tblr-btn-font-weight: 600;
    --tblr-btn-gradient: none;
    --tblr-btn-box-shadow: none;
}

.btn:not(.btn-sm, .btn-lg, .btn-xl) {
    --tblr-btn-padding-y: var(--tblr-btn-input-padding-y);
    --tblr-btn-font-size: var(--tblr-btn-input-font-size);
    --tblr-btn-line-height: var(--tblr-btn-input-line-height);
}

/*
 * The one main action of a view: brand, the warm color of the product, and brand-hover under the pointer.
 * Tabler reads it from --tblr-primary; nothing to repaint here.
 */

/* The segmented control writes its own corners (4, 6 or 8px by size): a control at every size */
.nav-segmented {
    --tblr-nav-radius: var(--radius);
}

/* A button is a control at every size, a badge a mark: Tabler gives the first its small or large step, the second the middle one */
.btn-sm,
.btn-lg,
.btn-group-sm > .btn,
.btn-group-lg > .btn {
    --tblr-btn-border-radius: var(--radius);
}

.badge {
    --tblr-badge-border-radius: var(--radius-sm);
}

/* Fields: line-strong border, brand on focus, ink-faint for placeholder and disabled text */
.form-control,
.form-select {
    --tblr-control-border-color: var(--line-strong);
    --tblr-control-focus-border-color: var(--brand);
    --tblr-control-placeholder-color: var(--ink-faint);
    --tblr-control-disabled-color: var(--ink-faint);
}

/* Tabler draws the focus ring of a field inside the border (offset -1px); the charte wants 2px outside */
.form-control:focus,
.form-select:focus {
    --tblr-focus-ring-offset: 2px;
}

/*
 * A focused validated control keeps the focus ring: Tabler colors it with a blend of the state
 * color and the page background (about 2:1 on surface in the light theme), and the charte asks
 * for 3:1 on every control. Width, style and offset stay Tabler's, which already match the other
 * controls. The border carries the valid or invalid state. Same specificity as Tabler's rules,
 * (0,3,0) and (0,4,0) with .was-validated, and loaded after them.
 */
:is(.form-control, .form-select, .form-check-input):is(.is-valid, .is-invalid):focus,
.was-validated :is(.form-control, .form-select, .form-check-input):is(:valid, :invalid):focus {
    outline-color: var(--focus);
}

.form-check-input {
    /* Tabler declares the corner of a checkbox on the input itself: a mark */
    --tblr-form-check-border-radius: var(--radius-sm);
    --tblr-form-check-icon-color: var(--on-brand);
}

/* Switch, 34 x 20px; the knob is surface-raised, never a literal white */
.form-switch {
    --tblr-form-switch-width: 34px;
    --tblr-form-switch-height: 20px;
    --tblr-form-switch-bg: var(--line-strong);
    --tblr-form-switch-focus-color: var(--surface-raised);
    --tblr-form-switch-checked-color: var(--surface-raised);
    --tblr-form-switch-disabled-color: var(--ink-faint);
}

.form-switch .form-check-input {
    --tblr-form-switch-color: var(--surface-raised);
}

/* AI variant of the switch: the track turns to the color of the AI once checked */
.form-switch-ai {
    --tblr-control-checked-bg: var(--ai);
    --tblr-control-checked-border-color: var(--ai);
}

/* Tooltip: ink bubble, surface text. Tabler's own pair is a pair of greys that bypasses the tokens. */
.tooltip {
    --tblr-tooltip-bg: var(--ink);
    --tblr-tooltip-color: var(--surface);
}

/* Focus: solid ring on every control, in both themes */
:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

/* Active entry of the vertical menu: a raised surface, ink text, the icon in brand. The layout puts .active on the link itself, where Tabler styles .nav-item.active > .nav-link, so without this rule
   the current page looks like the rest. Hover and focus keep the same pair, and the link gets no text-decoration. */
.navbar-vertical .navbar-nav .nav-link.active {
    background: var(--surface-raised);
    color: var(--ink);
    text-decoration: none;
}

/* The current choice of a toggle (a group of links, one per choice): the same pair as the current entry of the menu */
.btn-group > .btn.active {
    background: var(--brand-soft);
    color: var(--brand);
    text-decoration: none;
}

/* The current page of a pagination says where the person is, it does not invite a click: the pair of the current menu entry, not the
   brand fill that Tabler gives it (the brand fill is for the one action of a view) */
.pagination .page-item.active .page-link {
    background: var(--brand-soft);
    border-color: transparent;
    color: var(--brand);
}

/* Pretitle: a line above the page title that holds a link (the way back), not a label. Tabler sets it in capitals with
   spaced letters; the charte keeps capitals for the column headers of a table, never for a sentence. Size and colour stay
   Tabler's (small, ink-muted through --tblr-secondary). */
.page-pretitle {
    text-transform: none;
    letter-spacing: normal;
}

/* The breadcrumb leads back: discreet links, like the way to the previous and next object. The colour of the brand stays
   on the links of the page itself. */
.page-pretitle a {
    color: var(--ink-muted);
}

.page-pretitle a:hover,
.page-pretitle a:focus-visible {
    color: var(--ink);
}

/* A badge in the page title (« Par défaut » beside the name of a library): Tabler sizes a badge in em, so it would grow with the title */
.page-title .badge {
    font-size: 0.75rem;
    vertical-align: middle;
}

/* Titles: the one family, tight. A page title at 700, a card or section title at 600. */
h1,
.page-title {
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* A card or section title sits at 20 px or less: at that size tight letters hurt the reading, so it keeps the family's own spacing */
h2,
h3,
.card-title {
    font-weight: 600;
}

/* Digits keep one width where numbers stack in a column (a table) or change in place (a count, an amount: each component
   says so). In a sentence or a line of meta they take their own width: « 12 mars », never « 1 2 mars ». */
.table {
    font-variant-numeric: tabular-nums;
}

/* Capitals with spaced letters stay on the column headers of a table. Tabler also sets them on the label of a figure and on
   the word between two ways to sign in: both read as text. */
.subheader,
.hr-text {
    text-transform: none;
    letter-spacing: normal;
}

/* « ou », in lower case, needs the size of a line of meta to hold between its two rules */
.hr-text {
    font-size: 0.8125rem;
}

/* The browser's own surfaces follow the palette */
::selection {
    background: var(--brand-soft);
    color: var(--ink);
}

input,
textarea {
    caret-color: var(--brand);
}

/* Tabler Icons outline at 1.5px: Iconify puts stroke-width="2" on an inner group, so let it inherit */
.icon {
    stroke-width: 1.5;
}

.icon [stroke-width] {
    stroke-width: inherit;
}
