/*
 * The theme of the sites that share this library: every visual value they use, and the only
 * stylesheet allowed to name a color or a font (a test holds every other stylesheet and view to that).
 *
 * In order:
 *   1. Fonts      - the vendored web fonts.
 *   2. Palette    - the raw values, named for what they are. Only this file reads them.
 *   3. Scales     - type, spacing, radii, focus and control sizes, the same in both themes.
 *   4. Light      - the semantic tokens, named for the job they do. Components use only these.
 *   5. Dark       - the same tokens with dark values; a test holds the two lists equal.
 *   6. Bootstrap  - Bootstrap's own variables and components, pointed at the semantic tokens.
 *
 * The theme is picked by the data-bs-theme attribute: "light" or "dark", written by the server
 * when the reader chose one, or by js/theme-mode.js from the computer's setting. A page with
 * neither (scripts off) is light.
 *
 * Color roles: accent (blue) is for actions, danger (red) for errors and anything that destroys,
 * warning (amber), success (green). The brand's orange and yellow are brand marks only and never
 * color a control: orange next to red reads as a warning.
 *
 * Bootstrap reads some colors as "r, g, b" numbers so it can add transparency. Those tokens come
 * in that form (--hn-...-rgb) and the color itself is built from them in section 4.
 */

/* 1. Fonts ------------------------------------------------------------------------------------ */

@font-face {
    font-family: "Inter";
    font-style: normal;
    font-display: swap;
    font-weight: 100 900;
    src: url("../lib/inter/inter-latin-ext-wght-normal.woff2") format("woff2-variations");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: "Inter";
    font-style: normal;
    font-display: swap;
    font-weight: 100 900;
    src: url("../lib/inter/inter-latin-wght-normal.woff2") format("woff2-variations");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: "Josefin Sans";
    font-style: normal;
    font-display: swap;
    font-weight: 600;
    src: url("../lib/josefin-sans/josefin-sans-latin-600-normal.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* 2. Palette ---------------------------------------------------------------------------------- */

:root {
    /* The brand, from the designer's palette. Orange and the blue fail as text on white (3.3:1 and
       3.8:1), so text and controls use the darker blues below; the gray passes, but body text uses
       the darker ink, which reads better in dense tables. */
    --hn-brand-yellow: #fee000;
    --hn-brand-orange: #e86724;
    --hn-brand-blue: #4c89a5;
    --hn-brand-cream: #f8f1e6;
    --hn-brand-gray: #555555;

    /* Blues: the brand blue darkened until it passes as text, and lightened for the dark theme. */
    --hn-blue-50: #eaf2f5;
    --hn-blue-200-rgb: 156, 199, 218;
    --hn-blue-250-rgb: 140, 195, 218;
    --hn-blue-300-rgb: 125, 180, 204;
    --hn-blue-700-rgb: 46, 103, 128;
    --hn-blue-800-rgb: 36, 85, 104;
    --hn-blue-900: #23343c;

    /* Grays, with a little of the brand blue in them. */
    --hn-white-rgb: 255, 255, 255;
    --hn-gray-50-rgb: 246, 247, 248;
    --hn-gray-100: #eef3f5;
    --hn-gray-150: #eceff1;
    --hn-gray-200: #d6dee2;
    --hn-gray-300: #b3bdc1;
    --hn-gray-400: #9aabb2;
    --hn-gray-500: #7d8a90;
    --hn-gray-550: #7f9097;
    --hn-gray-600: #5b6b70;
    --hn-gray-700: #4a555a;
    --hn-gray-900-rgb: 31, 42, 48;

    /* Inks: the dark theme's surfaces and its text. */
    --hn-ink-100-rgb: 228, 234, 237;
    --hn-ink-600: #33424a;
    --hn-ink-700: #252f34;
    --hn-ink-800: #1f292e;
    --hn-ink-850-rgb: 24, 32, 36;
    --hn-ink-900-rgb: 17, 23, 26;

    --hn-red-50: #fde8ea;
    --hn-red-200: #ffa6ad;
    --hn-red-300-rgb: 255, 138, 147;
    --hn-red-700-rgb: 163, 18, 31;
    --hn-red-800: #861019;
    --hn-red-950: #3a1d21;

    --hn-green-50: #e3f3e8;
    --hn-green-300-rgb: 127, 212, 156;
    --hn-green-700-rgb: 30, 107, 58;
    --hn-green-950: #16301f;

    --hn-amber-50: #fdf1d6;
    --hn-amber-300-rgb: 243, 197, 107;
    --hn-amber-800-rgb: 122, 74, 0;
    --hn-amber-950: #3a2c0f;

    --hn-shadow-on-light: 0 0.375rem 1.5rem rgba(31, 42, 48, 0.18);
    --hn-shadow-on-dark: 0 0.375rem 1.5rem rgba(0, 0, 0, 0.5);
    --hn-overlay-on-light: rgba(31, 42, 48, 0.4);
    --hn-overlay-on-dark: rgba(0, 0, 0, 0.6);

    /* The mark in a field that is not right, drawn in the two themes' reds. */
    --hn-invalid-red-700: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23a3121f'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23a3121f' stroke='none'/%3e%3c/svg%3e");
    --hn-invalid-red-300: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23ff8a93'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23ff8a93' stroke='none'/%3e%3c/svg%3e");

    /* A checkbox's tick and a radio's dot, drawn in white or in ink. */
    --hn-tick-white: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/%3e%3c/svg%3e");
    --hn-tick-ink: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%2311171a' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/%3e%3c/svg%3e");
    --hn-dot-white: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='2' fill='%23fff'/%3e%3c/svg%3e");
    --hn-dot-ink: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='2' fill='%2311171a'/%3e%3c/svg%3e");

    --hn-font-inter: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --hn-font-josefin: "Josefin Sans", var(--hn-font-inter);
}

/* 3. Scales ----------------------------------------------------------------------------------- */

:root {
    --hn-font-sans: var(--hn-font-inter);
    --hn-font-brand: var(--hn-font-josefin); /* the wordmark only */

    /* Sizes in rem, from the browser's 16-pixel base, so zoom and the reader's font size work. */
    --hn-font-size-xs: 0.75rem;       /* 12 px */
    --hn-font-size-sm: 0.8125rem;     /* 13 px: table headers, notes */
    --hn-font-size-body: 0.875rem;    /* 14 px */
    --hn-font-size-heading: 1rem;     /* 16 px: section headings */
    --hn-font-size-title: 1.25rem;    /* 20 px: the page's h1 */
    --hn-font-size-wordmark: 1.125rem;
    --hn-font-weight-normal: 400;
    --hn-font-weight-medium: 500;
    --hn-font-weight-semibold: 600;
    --hn-line-height-body: 1.5;
    --hn-line-height-tight: 1.25;

    --hn-space-1: 0.25rem;
    --hn-space-2: 0.5rem;
    --hn-space-3: 0.75rem;
    --hn-space-4: 1rem;
    --hn-space-5: 1.5rem;
    --hn-space-6: 2rem;

    --hn-radius-control: 0.25rem;
    --hn-radius-surface: 0.375rem;
    --hn-border-width: 1px;
    --hn-focus-width: 2px;
    --hn-focus-offset: 2px;

    /* The height of everything clicked or typed into: buttons, fields, menu items. A mouse can hit
       36 pixels; a finger gets 44. */
    --hn-control-height: 2.25rem;
    --hn-control-padding-x: 0.75rem;

    /* The top bar's height; anything that sticks below it takes its offset from here. */
    --hn-header-height: 3.25rem;
}

@media (pointer: coarse) {
    :root {
        --hn-control-height: 2.75rem;
    }
}

/* 4. Light ------------------------------------------------------------------------------------ */

:root,
[data-bs-theme="light"] {
    --hn-color-bg-rgb: var(--hn-gray-50-rgb);          /* behind everything */
    --hn-color-surface-rgb: var(--hn-white-rgb);       /* panels, menus, tables, bars */
    --hn-color-surface-alt: var(--hn-gray-100);        /* table headers, disabled fields */
    --hn-color-selected: var(--hn-blue-50);            /* a selected row or menu item */
    --hn-color-border: var(--hn-gray-200);             /* dividers and the edges of surfaces */
    --hn-color-border-strong: var(--hn-gray-500);      /* the edges of controls (3:1) */
    --hn-color-text-rgb: var(--hn-gray-900-rgb);
    --hn-color-text-muted: var(--hn-gray-600);
    --hn-color-link-rgb: var(--hn-blue-700-rgb);
    --hn-color-link-hover-rgb: var(--hn-blue-800-rgb);
    --hn-color-accent-rgb: var(--hn-blue-700-rgb);     /* the main action */
    --hn-color-accent-hover: rgb(var(--hn-blue-800-rgb));
    --hn-color-on-accent: rgb(var(--hn-white-rgb));
    --hn-color-focus: rgb(var(--hn-blue-700-rgb));
    --hn-color-indicator: rgb(var(--hn-blue-700-rgb)); /* marks the current menu entry */
    --hn-color-brand-mark: var(--hn-brand-yellow);
    --hn-color-danger-rgb: var(--hn-red-700-rgb);
    --hn-color-danger-hover: var(--hn-red-800);
    --hn-color-on-danger: rgb(var(--hn-white-rgb));
    --hn-color-danger-subtle: var(--hn-red-50);
    --hn-color-success-rgb: var(--hn-green-700-rgb);
    --hn-color-success-subtle: var(--hn-green-50);
    --hn-color-warning-rgb: var(--hn-amber-800-rgb);
    --hn-color-warning-subtle: var(--hn-amber-50);
    --hn-color-neutral: var(--hn-gray-700);            /* paused, off, not started */
    --hn-color-neutral-subtle: var(--hn-gray-150);
    --hn-color-overlay: var(--hn-overlay-on-light);          /* behind a dialog that needs an answer */
    --hn-shadow-raised: var(--hn-shadow-on-light);
    --hn-image-invalid: var(--hn-invalid-red-700);
    --hn-image-tick: var(--hn-tick-white);
    --hn-image-dot: var(--hn-dot-white);
}

/* The colors built from the "r, g, b" tokens; these lines hold for both themes. */
:root,
[data-bs-theme] {
    --hn-color-bg: rgb(var(--hn-color-bg-rgb));
    --hn-color-surface: rgb(var(--hn-color-surface-rgb));
    --hn-color-text: rgb(var(--hn-color-text-rgb));
    --hn-color-link: rgb(var(--hn-color-link-rgb));
    --hn-color-link-hover: rgb(var(--hn-color-link-hover-rgb));
    --hn-color-accent: rgb(var(--hn-color-accent-rgb));
    --hn-color-danger: rgb(var(--hn-color-danger-rgb));
    --hn-color-success: rgb(var(--hn-color-success-rgb));
    --hn-color-warning: rgb(var(--hn-color-warning-rgb));
}

/* 5. Dark ------------------------------------------------------------------------------------- */

[data-bs-theme="dark"] {
    --hn-color-bg-rgb: var(--hn-ink-900-rgb);
    --hn-color-surface-rgb: var(--hn-ink-850-rgb);
    --hn-color-surface-alt: var(--hn-ink-800);
    --hn-color-selected: var(--hn-blue-900);
    --hn-color-border: var(--hn-ink-600);
    --hn-color-border-strong: var(--hn-gray-550);
    --hn-color-text-rgb: var(--hn-ink-100-rgb);
    --hn-color-text-muted: var(--hn-gray-400);
    --hn-color-link-rgb: var(--hn-blue-250-rgb);
    --hn-color-link-hover-rgb: var(--hn-blue-200-rgb);
    --hn-color-accent-rgb: var(--hn-blue-300-rgb);
    --hn-color-accent-hover: rgb(var(--hn-blue-200-rgb));
    --hn-color-on-accent: rgb(var(--hn-ink-900-rgb));
    --hn-color-focus: var(--hn-brand-yellow);
    --hn-color-indicator: var(--hn-brand-yellow);
    --hn-color-brand-mark: var(--hn-brand-yellow);
    --hn-color-danger-rgb: var(--hn-red-300-rgb);
    --hn-color-danger-hover: var(--hn-red-200);
    --hn-color-on-danger: rgb(var(--hn-ink-900-rgb));
    --hn-color-danger-subtle: var(--hn-red-950);
    --hn-color-success-rgb: var(--hn-green-300-rgb);
    --hn-color-success-subtle: var(--hn-green-950);
    --hn-color-warning-rgb: var(--hn-amber-300-rgb);
    --hn-color-warning-subtle: var(--hn-amber-950);
    --hn-color-neutral: var(--hn-gray-300);
    --hn-color-neutral-subtle: var(--hn-ink-700);
    --hn-color-overlay: var(--hn-overlay-on-dark);
    --hn-shadow-raised: var(--hn-shadow-on-dark);
    --hn-image-invalid: var(--hn-invalid-red-300);
    --hn-image-tick: var(--hn-tick-ink);
    --hn-image-dot: var(--hn-dot-ink);
}

/* 6. Bootstrap -------------------------------------------------------------------------------- */

/* Bootstrap's variables, set on every element that names a theme so a light panel inside a dark
   page (the style page shows both) gets its own values. */
:root,
[data-bs-theme] {
    --bs-body-font-family: var(--hn-font-sans);
    --bs-body-font-size: var(--hn-font-size-body);
    --bs-body-font-weight: var(--hn-font-weight-normal);
    --bs-body-line-height: var(--hn-line-height-body);
    --bs-body-color: var(--hn-color-text);
    --bs-body-color-rgb: var(--hn-color-text-rgb);
    --bs-body-bg: var(--hn-color-bg);
    --bs-body-bg-rgb: var(--hn-color-bg-rgb);
    --bs-emphasis-color: var(--hn-color-text);
    --bs-emphasis-color-rgb: var(--hn-color-text-rgb);
    --bs-secondary-color: var(--hn-color-text-muted);
    --bs-secondary-bg: var(--hn-color-surface-alt);
    --bs-tertiary-color: var(--hn-color-text-muted);
    --bs-tertiary-bg: var(--hn-color-surface-alt);
    --bs-heading-color: var(--hn-color-text);
    --bs-code-color: var(--hn-color-text);
    --bs-border-width: var(--hn-border-width);
    --bs-border-color: var(--hn-color-border);
    --bs-border-color-translucent: var(--hn-color-border);
    --bs-border-radius: var(--hn-radius-control);
    --bs-border-radius-sm: var(--hn-radius-control);
    --bs-border-radius-lg: var(--hn-radius-surface);
    --bs-link-color: var(--hn-color-link);
    --bs-link-color-rgb: var(--hn-color-link-rgb);
    --bs-link-hover-color: var(--hn-color-link-hover);
    --bs-link-hover-color-rgb: var(--hn-color-link-hover-rgb);
    --bs-focus-ring-color: var(--hn-color-focus);
    --bs-box-shadow: var(--hn-shadow-raised);

    --bs-primary: var(--hn-color-accent);
    --bs-primary-rgb: var(--hn-color-accent-rgb);
    --bs-primary-text-emphasis: var(--hn-color-link);
    --bs-primary-bg-subtle: var(--hn-color-selected);
    --bs-primary-border-subtle: var(--hn-color-border);
    --bs-danger: var(--hn-color-danger);
    --bs-danger-rgb: var(--hn-color-danger-rgb);
    --bs-danger-text-emphasis: var(--hn-color-danger);
    --bs-danger-bg-subtle: var(--hn-color-danger-subtle);
    --bs-danger-border-subtle: var(--hn-color-border);
    --bs-success: var(--hn-color-success);
    --bs-success-rgb: var(--hn-color-success-rgb);
    --bs-success-text-emphasis: var(--hn-color-success);
    --bs-success-bg-subtle: var(--hn-color-success-subtle);
    --bs-success-border-subtle: var(--hn-color-border);
    --bs-warning: var(--hn-color-warning);
    --bs-warning-rgb: var(--hn-color-warning-rgb);
    --bs-warning-text-emphasis: var(--hn-color-warning);
    --bs-warning-bg-subtle: var(--hn-color-warning-subtle);
    --bs-warning-border-subtle: var(--hn-color-border);

    --bs-form-valid-color: var(--hn-color-success);
    --bs-form-valid-border-color: var(--hn-color-success);
    --bs-form-invalid-color: var(--hn-color-danger);
    --bs-form-invalid-border-color: var(--hn-color-danger);
}

/* Headings: Bootstrap's grow with the window, which suits a marketing page, not a work tool. */
h1, .h1 {
    font-size: var(--hn-font-size-title);
    font-weight: var(--hn-font-weight-semibold);
    line-height: var(--hn-line-height-tight);
}

h2, .h2 {
    font-size: var(--hn-font-size-heading);
    font-weight: var(--hn-font-weight-semibold);
    line-height: var(--hn-line-height-tight);
}

h3, .h3 {
    font-size: var(--hn-font-size-body);
    font-weight: var(--hn-font-weight-semibold);
    line-height: var(--hn-line-height-tight);
}

/* Focus: a solid ring in the focus color, in place of Bootstrap's faint glow, which is too pale to
   see against most backgrounds. The ring replaces the browser's outline; it never just hides it. */
:focus-visible,
.btn:focus-visible,
.btn-check:focus-visible + .btn,
.form-control:focus,
.form-select:focus,
.form-check-input:focus,
.dropdown-item:focus-visible {
    outline: var(--hn-focus-width) solid var(--hn-color-focus);
    outline-offset: var(--hn-focus-offset);
    box-shadow: none;
}

.btn {
    --bs-btn-padding-x: var(--hn-control-padding-x);
    --bs-btn-padding-y: 0;
    --bs-btn-font-size: var(--hn-font-size-body);
    --bs-btn-font-weight: var(--hn-font-weight-medium);
    --bs-btn-line-height: var(--hn-line-height-tight);
    --bs-btn-border-radius: var(--hn-radius-control);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--hn-space-2);
    min-height: var(--hn-control-height);
}

/* The main action: one per page or panel. */
.btn-primary {
    --bs-btn-font-weight: var(--hn-font-weight-semibold);
    --bs-btn-color: var(--hn-color-on-accent);
    --bs-btn-bg: var(--hn-color-accent);
    --bs-btn-border-color: var(--hn-color-accent);
    --bs-btn-hover-color: var(--hn-color-on-accent);
    --bs-btn-hover-bg: var(--hn-color-accent-hover);
    --bs-btn-hover-border-color: var(--hn-color-accent-hover);
    --bs-btn-active-color: var(--hn-color-on-accent);
    --bs-btn-active-bg: var(--hn-color-accent-hover);
    --bs-btn-active-border-color: var(--hn-color-accent-hover);
    --bs-btn-disabled-color: var(--hn-color-on-accent);
    --bs-btn-disabled-bg: var(--hn-color-accent);
    --bs-btn-disabled-border-color: var(--hn-color-accent);
}

/* Every other action. */
.btn-secondary {
    --bs-btn-color: var(--hn-color-text);
    --bs-btn-bg: var(--hn-color-surface);
    --bs-btn-border-color: var(--hn-color-border-strong);
    --bs-btn-hover-color: var(--hn-color-text);
    --bs-btn-hover-bg: var(--hn-color-surface-alt);
    --bs-btn-hover-border-color: var(--hn-color-border-strong);
    --bs-btn-active-color: var(--hn-color-text);
    --bs-btn-active-bg: var(--hn-color-selected);
    --bs-btn-active-border-color: var(--hn-color-border-strong);
    --bs-btn-disabled-color: var(--hn-color-text-muted);
    --bs-btn-disabled-bg: var(--hn-color-surface);
    --bs-btn-disabled-border-color: var(--hn-color-border);
}

/* An action that destroys or cannot be undone, and nothing else. */
.btn-danger {
    --bs-btn-font-weight: var(--hn-font-weight-semibold);
    --bs-btn-color: var(--hn-color-on-danger);
    --bs-btn-bg: var(--hn-color-danger);
    --bs-btn-border-color: var(--hn-color-danger);
    --bs-btn-hover-color: var(--hn-color-on-danger);
    --bs-btn-hover-bg: var(--hn-color-danger-hover);
    --bs-btn-hover-border-color: var(--hn-color-danger-hover);
    --bs-btn-active-color: var(--hn-color-on-danger);
    --bs-btn-active-bg: var(--hn-color-danger-hover);
    --bs-btn-active-border-color: var(--hn-color-danger-hover);
    --bs-btn-disabled-color: var(--hn-color-on-danger);
    --bs-btn-disabled-bg: var(--hn-color-danger);
    --bs-btn-disabled-border-color: var(--hn-color-danger);
}

.btn-link {
    --bs-btn-color: var(--hn-color-link);
    --bs-btn-hover-color: var(--hn-color-link-hover);
    --bs-btn-active-color: var(--hn-color-link-hover);
    --bs-btn-disabled-color: var(--hn-color-text-muted);
}

/* The chosen option in a set of segmented buttons (radio inputs styled as a button group). */
.btn-check:checked + .btn-secondary {
    color: var(--hn-color-on-accent);
    background-color: var(--hn-color-accent);
    border-color: var(--hn-color-accent);
    font-weight: var(--hn-font-weight-semibold);
}

.form-control,
.form-select {
    min-height: var(--hn-control-height);
    font-size: var(--hn-font-size-body);
    color: var(--hn-color-text);
    background-color: var(--hn-color-surface);
    border-color: var(--hn-color-border-strong);
}

.form-control:not(textarea) {
    padding-block: 0;
}

.form-select {
    padding-block: 0;
}

.form-control:disabled,
.form-select:disabled {
    background-color: var(--hn-color-surface-alt);
    border-color: var(--hn-color-border);
}

/* A field that is not right. ASP.NET and the validation scripts mark it input-validation-error;
   is-invalid is Bootstrap's own mark. */
.form-control.is-invalid,
.form-control.input-validation-error {
    padding-right: calc(var(--hn-control-padding-x) * 2 + 1rem);
    background-image: var(--hn-image-invalid);
    background-repeat: no-repeat;
    background-position: right var(--hn-control-padding-x) center;
    background-size: 1rem 1rem;
    border-color: var(--bs-form-invalid-border-color);
}

.form-check-input.input-validation-error {
    border-color: var(--bs-form-invalid-border-color);
}

.form-label {
    font-weight: var(--hn-font-weight-medium);
    margin-bottom: var(--hn-space-1);
}

/* Bootstrap's room for the box is for a smaller one, and leaves it almost touching its label. */
.form-check {
    padding-left: calc(1.125rem + var(--hn-space-2));
}

.form-check .form-check-input {
    margin-left: calc(-1.125rem - var(--hn-space-2));
    margin-top: 0.0625rem;
}

.form-check-input {
    width: 1.125rem;
    height: 1.125rem;
    background-color: var(--hn-color-surface);
    border-color: var(--hn-color-border-strong);
}

.form-check-input:checked {
    background-color: var(--hn-color-accent);
    border-color: var(--hn-color-accent);
}

.form-check-input:checked[type=checkbox] {
    --bs-form-check-bg-image: var(--hn-image-tick);
}

.form-check-input:checked[type=radio] {
    --bs-form-check-bg-image: var(--hn-image-dot);
}

.dropdown-menu {
    --bs-dropdown-font-size: var(--hn-font-size-body);
    --bs-dropdown-color: var(--hn-color-text);
    --bs-dropdown-bg: var(--hn-color-surface);
    --bs-dropdown-border-color: var(--hn-color-border);
    --bs-dropdown-border-radius: var(--hn-radius-surface);
    --bs-dropdown-padding-x: var(--hn-space-1);
    --bs-dropdown-padding-y: var(--hn-space-1);
    --bs-dropdown-divider-bg: var(--hn-color-border);
    --bs-dropdown-divider-margin-y: var(--hn-space-1);
    --bs-dropdown-link-color: var(--hn-color-text);
    --bs-dropdown-link-hover-color: var(--hn-color-text);
    --bs-dropdown-link-hover-bg: var(--hn-color-selected);
    --bs-dropdown-link-active-color: var(--hn-color-text);
    --bs-dropdown-link-active-bg: var(--hn-color-selected);
    --bs-dropdown-link-disabled-color: var(--hn-color-text-muted);
    --bs-dropdown-item-padding-x: var(--hn-control-padding-x);
    --bs-dropdown-item-padding-y: 0;
    --bs-dropdown-header-color: var(--hn-color-text-muted);
    --bs-dropdown-header-padding-x: var(--hn-control-padding-x);
    --bs-dropdown-header-padding-y: var(--hn-space-1);
    box-shadow: var(--hn-shadow-raised);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--hn-space-2);
    min-height: var(--hn-control-height);
    border-radius: var(--hn-radius-control);
}

.dropdown-header {
    font-size: var(--hn-font-size-xs);
    font-weight: var(--hn-font-weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* The top bar's menus. */
.navbar {
    --bs-navbar-padding-y: 0;
    --bs-navbar-color: var(--hn-color-text-muted);
    --bs-navbar-hover-color: var(--hn-color-text);
    --bs-navbar-active-color: var(--hn-color-text);
    --bs-navbar-brand-color: var(--hn-color-text);
    --bs-navbar-brand-hover-color: var(--hn-color-text);
    --bs-navbar-nav-link-padding-x: var(--hn-control-padding-x);
    --bs-navbar-toggler-border-color: var(--hn-color-border-strong);
    --bs-navbar-toggler-focus-width: var(--hn-focus-width);
}

/* Tables are dense: numbers line up in columns, and rows are short. */
.table {
    --bs-table-color: var(--hn-color-text);
    --bs-table-bg: var(--hn-color-surface);
    --bs-table-border-color: var(--hn-color-border);
    --bs-table-hover-color: var(--hn-color-text);
    --bs-table-hover-bg: var(--hn-color-surface-alt);
    --bs-table-active-color: var(--hn-color-text);
    --bs-table-active-bg: var(--hn-color-selected);
    font-variant-numeric: tabular-nums;
}

.table > :not(caption) > * > * {
    padding: var(--hn-space-2) var(--hn-space-3);
}

.table > thead {
    --bs-table-bg: var(--hn-color-surface-alt);
    --bs-table-color: var(--hn-color-text-muted);
    font-size: var(--hn-font-size-sm);
    white-space: nowrap;
}

.table > thead th {
    font-weight: var(--hn-font-weight-semibold);
}

.alert {
    --bs-alert-padding-x: var(--hn-space-4);
    --bs-alert-padding-y: var(--hn-space-3);
    --bs-alert-border-radius: var(--hn-radius-surface);
    border-left-width: 0.25rem;
}

.alert-primary {
    border-left-color: var(--hn-color-accent);
}

.alert-success {
    border-left-color: var(--hn-color-success);
}

.alert-warning {
    border-left-color: var(--hn-color-warning);
}

.alert-danger {
    border-left-color: var(--hn-color-danger);
}
