/* ============================================================
   Dark mode
   The loan application's counterpart of the portal's dark.css, behind the same flag
   (FeatureFlagType.CustomerPortalDarkMode). Only loaded in dark mode, so it can't affect light.
   The --cp-* tokens are defined only here; app.css uses them with the light colour as fallback.
   Keep the token block in step with the portal's dark.css.

   html:root outranks head.css's :root tokens and components' scoped selectors (.x[b-123]).
   ============================================================ */
html:root {
    color-scheme: dark;

    /* ---- Surfaces, lines and ink (as the portal's) ---- */
    --cp-page: #141816;
    --cp-surface: #1c211e;           /* BrandColor.DarkSurface: the brand's dark variants are measured against it */
    --cp-surface-alt: #242a26;
    --cp-line: #343c37;
    --cp-ink: #eef1ee;
    --cp-ink-muted: #a3aca6;
    --cp-warning-ink: #f0cf8a;
    --cp-link: #8ab4f8;

    /* ---- The loan application's own: a hover fill, slider and switch tracks, and the offer card's up/down ink ---- */
    --cp-hover: #2e3530;
    --cp-track: #4a534d;
    --cp-success-ink: #6fcf8f;
    --cp-caution-ink: #f0a06e;

    /* ---- Status pairs: same meaning, lighter ink on a deep tint ---- */
    --success: #6fcf8f;
    --success-bg: #1d3325;
    --warning: #e8b65a;
    --warning-bg: #372c16;
    --danger: #f08a84;
    --danger-bg: #3d1f1e;
    --field-border: #66706a;
    --focus-ring: 0 0 0 .1rem var(--cp-surface), 0 0 0 .25rem #6ea8fe;

    /* A hairline in place of most of the shadow: a dark shadow on a dark page reads as nothing. */
    --shadow-1: 0 0 0 1px var(--cp-line);
    --shadow-2: 0 0 0 1px var(--cp-line), 0 8px 24px -8px rgba(0, 0, 0, .6);

    /* ---- The brand, from head.css's dark variants: lightened until a button stands out from the card and until text
       in the colour reads on it. Without them (a head.css cached before they existed) these resolve to nothing and
       every use falls through to its own fallback, which is the light brand. The application also draws in
       Bootstrap's two, which head.css sets to the same light brand. ---- */
    --primaryColor: var(--primaryColorOnDark);
    --primaryTextColor: var(--primaryTextColorOnDark);
    --primaryColorInk: var(--primaryColorInkOnDark);
    --accentColor: var(--accentColorOnDark);
    --accentTextColor: var(--accentTextColorOnDark);
    --accentColorInk: var(--accentColorInkOnDark);
    --bs-primary: var(--primaryColorOnDark);
    --bs-secondary: var(--accentColorOnDark);

    /* ---- Telerik: the application's own Kendo aliases, then Kendo's base colours, from which it derives hover,
       active and subtle shades (its formulas flip direction for a dark base). ---- */
    --kendo-body-bg: var(--cp-surface);
    --kendo-body-text: #d3d9d4;
    --kendo-heading-text: var(--cp-ink);
    --kendo-subtle-text: var(--cp-ink-muted);
    --kendo-disabled-text: #737c76;
    --kendo-base-bg: var(--cp-surface-alt);
    --kendo-hover-bg: #2e3530;
    --kendo-selected-bg: #2e3530;
    --kendo-selected-text: var(--cp-ink);
    --kendo-button-bg: #2a302c;
    --kendo-button-text: #d3d9d4;
    --kendo-link-hover-text: var(--cp-ink);
    --kendo-color-app-surface: var(--cp-surface);
    --kendo-color-on-app-surface: #d3d9d4;
    --kendo-color-surface: var(--cp-surface);
    --kendo-color-surface-alt: var(--cp-surface-alt);
    --kendo-color-subtle: var(--cp-ink-muted);
    --kendo-color-border: rgba(255, 255, 255, .12);
    --kendo-color-border-alt: rgba(255, 255, 255, .2);
    --kendo-color-base: #2a302c;
    --kendo-color-on-base: #d3d9d4;

    /* ---- Bootstrap: its form controls, cards, tables and text utilities all read these ---- */
    --bs-body-bg: var(--cp-surface);
    --bs-body-color: #d3d9d4;
    --bs-emphasis-color: var(--cp-ink);
    --bs-secondary-color: var(--cp-ink-muted);
    --bs-secondary-bg: var(--cp-surface-alt);
    --bs-tertiary-bg: var(--cp-surface-alt);
    --bs-border-color: var(--cp-line);
    --bs-link-color: var(--cp-link);
    --bs-link-hover-color: var(--cp-ink);
    /* The select's chevron, drawn in the light ink. */
    --bs-form-select-bg-img: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23d3d9d4' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");

    /* The layout renderer's text fallback (SectionRenderer.razor.css), which nothing else in the application sets. */
    --font-color-2: var(--kendo-body-text);
}

html:root body {
    background-color: var(--cp-page);
    color: var(--kendo-body-text);
}

/* ---- The company logo ----
   Logos are made for a light page, and one drawn in dark ink on a transparent background would vanish on a dark
   header, so the logo sits on a small light plate. content-box, so the plate goes around the logo at its usual height
   instead of shrinking it. */
html:root .client-logo {
    box-sizing: content-box;
    padding: .25rem .5rem;
    border-radius: var(--radius-md, 6px);
    background-color: #fff;
}

/* ---- The application's layout ----
   Layout themes and author-picked backgrounds arrive as inline styles (LayoutRenderer and the section, box and
   region renderers). In dark mode the backgrounds give way to the dark surfaces and the brand colours to their dark
   variants; !important is what outranks an inline style. initial makes a custom property invalid, so var() falls
   back to the frame's own (already dark) colour. */
html:root .lal-flow {
    --primaryColor: var(--primaryColorOnDark) !important;
    --primaryTextColor: var(--primaryTextColorOnDark) !important;
    --primaryColorInk: var(--primaryColorInkOnDark) !important;
    --accentColor: var(--accentColorOnDark) !important;
    --accentTextColor: var(--accentTextColorOnDark) !important;
    --accentColorInk: var(--accentColorInkOnDark) !important;
    --sectionColor: initial !important;
    --sectionTextColor: initial !important;
    background-color: transparent !important;
    color: inherit !important;
}

html:root .lal-section-colored.lal-frame-card {
    background-color: var(--cp-surface) !important;
    color: var(--kendo-body-text) !important;
}

html:root .lal-section-colored.lal-frame-filled {
    background-color: var(--cp-surface-alt) !important;
    color: var(--kendo-body-text) !important;
}

html:root .lal-section-colored.lal-frame-plain,
html:root .lal-region[style] {
    background-color: transparent !important;
    color: inherit !important;
}

html:root .lal-box-filled {
    background-color: var(--cp-surface-alt) !important;
    color: inherit !important;
}

/* A frame's light-grey edge glows on a dark page. */
html:root .lal-frame-card,
html:root .lal-frame-filled {
    border-color: var(--cp-line);
}

/* ---- Colours still written into a selector ---- */

/* The Kendo drop-down's chevron, drawn in near-black. */
html:root .k-dropdownlist .k-input-inner {
    background-image: var(--bs-form-select-bg-img);
}

/* Form controls with their own borders. */
html:root .k-checkbox {
    border-color: var(--field-border);
}

html:root .k-radio {
    border-color: var(--field-border) !important;
    background-color: var(--cp-surface-alt) !important;
}

html:root .text-dark {
    color: var(--cp-ink) !important;
}

/* Blazor's error bar keeps its yellow, so its text stays dark. */
html:root #blazor-error-ui {
    color: #212529;
}
