/* ============================================================
   Dark mode
   Loaded only when the company has FeatureFlagType.CustomerPortalDarkMode on, and then only while the device is set
   to dark (App.razor links this file with media="(prefers-color-scheme: dark)"). Light mode never reads it, so
   nothing here can change how the portal looks in light.

   Layouts don't change, only colours. Most of the portal's colour already flows through custom properties: the
   --cp-* names (each declared where it is used with today's colour as its fallback, and defined only here), the
   Kendo and Bootstrap variables, the status pairs, and the brand tokens head.css publishes. So this file is mostly
   values. The rules after them cover the few colours still written into a selector.

   html:root, not :root: head.css (inlined after app.css) sets the brand tokens on :root, and the extra type
   selector wins over it whatever the order. Rules use the same prefix to outrank a component's scoped selector
   (.x[b-123]).
   ============================================================ */
html:root {
    color-scheme: dark;

    /* ---- Surfaces, lines and ink ---- */
    --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;

    /* ---- 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. ---- */
    --primaryColor: var(--primaryColorOnDark);
    --primaryTextColor: var(--primaryTextColorOnDark);
    --primaryColorInk: var(--primaryColorInkOnDark);
    --accentColor: var(--accentColorOnDark);
    --accentTextColor: var(--accentTextColorOnDark);
    --accentColorInk: var(--accentColorInkOnDark);

    /* ---- Telerik: the portal's own Kendo aliases, then Kendo 15'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, for .form-control and the few Bootstrap components the portal uses ---- */
    --bs-body-bg: var(--cp-surface);
    --bs-body-color: #d3d9d4;
    --bs-emphasis-color: var(--cp-ink);
    --bs-secondary-color: var(--cp-ink-muted);
    --bs-tertiary-bg: var(--cp-surface-alt);
    --bs-border-color: var(--cp-line);
    --bs-link-color: var(--cp-link);
}

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 wherever it shows. 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;
}

/* ---- Colours still written into a selector ---- */

/* Text drawn at 87% black. */
html:root .profile-component-card,
html:root .pop-out-items,
html:root .employer-entry {
    color: var(--kendo-body-text);
}

/* Dividers drawn as 8% black, which vanish on a dark card. */
html:root .terms-card .loan-details-section + .loan-details-section,
html:root .paid-in-full,
html:root .document-list li + li {
    border-color: var(--cp-line);
}

/* 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;
}

/* Store list pins: a dark disc on a light card becomes a light disc on a dark one. The map keeps Google's light
   tiles, so its pins (.property) stay as they are. */
html:root .store-pin:not(.store-pin-home):not(.store-pin-selected) {
    background-color: #d3d9d4;
    color: var(--cp-page);
}

/* Payment method tiles mix their ink toward a near-black; on dark, the accent's own dark-mode ink. */
html:root .pay-tile {
    --pay-ink: var(--accentColorInk, #c9d2e3);
}

html:root .pay-chip {
    color: var(--pay-ink);
}
