/*
 * Pulse design tokens (control/plans/ui-cleanup.md, section 3). Plain CSS custom properties with no Radzen or Blazor
 * dependency, so they carry over to any later front end. Defining them changes nothing on its own: only the new Pulse
 * Next experience (css/pulse-next.css, under html.pnx) reads them for now; the classic UI never does.
 * Two themes: light (below) and dark ([data-theme="dark"] at the end). The new UI sets data-theme on <html> from the
 * user's Theme choice (System, Light, Dark; js/pulse-next.js); the classic UI ignores it.
 */

:root {
    /* Spacing: the only gaps allowed. */
    --pu-space-1: 4px;
    --pu-space-2: 8px;
    --pu-space-3: 12px;
    --pu-space-4: 16px;
    --pu-space-5: 24px;
    --pu-space-6: 32px;

    /* Page gutter: 24px from 1280px up, 16px below (set in the media queries of pulse-next.css). */
    --pu-gutter: var(--pu-space-5);

    /* Density. */
    --pu-row-h: 36px;
    --pu-control-h: 32px;
    --pu-header-h: 48px;
    --pu-title-row-h: 40px;

    /* Detail pane (page frame side slot): docked from 1600px, wider from 2240px (pulse-next.css). */
    --pu-pane-w: clamp(380px, 28vw, 640px);
    --pu-pane-w-2xl: clamp(640px, 30vw, 820px);

    /* Type: IBM Plex Sans for the interface, Plex Mono for code, ids and logs. One scale, two working weights (500, 600). */
    --pu-font: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --pu-mono: 'IBM Plex Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
    --pu-text-2xs: 11px;            /* overlines, badges */
    --pu-text-xs: 12px;             /* column headers, meta, status bar */
    --pu-text-sm: 13px;             /* secondary text, chips, captions */
    --pu-text-base: 14px;           /* body, controls, rows */
    --pu-text-md: 16px;             /* card titles (clearly above the 14px body) */
    --pu-text-lg: 18px;             /* dialog titles */
    --pu-text-xl: 22px;             /* page titles */
    --pu-text-display: 28px;        /* stat values */
    --pu-leading: 1.45;
    --pu-leading-tight: 1.2;
    --pu-tracking-title: -.012em;   /* titles and big numbers sit a touch tighter */
    --pu-tracking-overline: .08em;  /* uppercase section labels */
    --pu-font-body: var(--pu-text-base);
    --pu-font-small: 12.5px;
    --pu-font-title: var(--pu-text-xl);

    /* Reading width: prose and form columns only; grids, lists and logs are fluid. */
    --pu-measure: 72ch;

    /* Shape: small radii read as precise; nothing larger than 12px (dialogs). */
    --pu-radius-xs: 4px;            /* badges, kbd, tags */
    --pu-radius-sm: 6px;            /* buttons, inputs, menu items */
    --pu-radius: 8px;               /* cards, grids, popovers */
    --pu-radius-card: 8px;
    --pu-radius-lg: 12px;           /* dialogs, the palette */

    /* Motion: opacity, colour and transform in place only, never height or layout (design rule 6). */
    --pu-curve: cubic-bezier(.2, .7, .2, 1);
    --pu-dur-fast: .12s;
    --pu-dur: .18s;
    --pu-dur-slow: .28s;

    /* Brand: the IMAGINiT Pulse blue of the classic top bar (#014766) and a small scale derived from it. */
    --pu-brand: #014766;
    --pu-brand-strong: #01364E;     /* pressed; the line under the brand bar */
    --pu-brand-600: #075E86;        /* the action blue, in the brand family: 7.1:1 with white */
    --pu-brand-tint: #E6EFF4;       /* active nav, selected rows and chips */
    --pu-brand-tint-line: #BCD3DF;
    --pu-brand-ink: #014766;        /* brand-coloured text on light surfaces (8.6:1 on the tint) */
    --pu-brand-strip: #014766;      /* the accent strip of top bar variant B */
    --pu-logo-line: #09476E;        /* the logo asset's own colours (img/PulseLogoIconTextSm.png) */
    --pu-logo-word: #D63036;

    /*
     * Top bar variant, the one switch: 1 = A, a solid brand-blue bar like the classic UI (default);
     * 0 = B, a light bar with a 3px brand strip on top. Every --pu-bar-* token mixes its A and B values by it.
     */
    --pu-bar-solid: 1;

    /* Colour: light theme, brand-blue accents, colour only for status. */
    --pu-ink: #0E1A22;
    --pu-ink-2: #4A5A66;
    --pu-ink-3: #5E6D79;
    --pu-ink-4: #9AA8B3;
    --pu-placeholder: #6B7A86;
    --pu-ground: #F4F6F8;
    --pu-surface: #FFFFFF;
    --pu-raised: #FFFFFF;           /* popovers, menus, dialogs, toasts */
    --pu-line: #E3E8EC;
    --pu-line-2: #EEF2F5;
    --pu-border: #D5DCE2;
    --pu-border-hover: #C2CCD4;
    --pu-border-strong: #AEBBC5;
    --pu-hover: #F7F9FA;
    --pu-hover-2: #F2F5F7;
    --pu-soft: #EDF1F4;
    --pu-switch-off: #8A99A6;
    --pu-seg-on: #FFFFFF;           /* the selected option of a segmented control */
    --pu-action: var(--pu-brand-600);
    --pu-action-hover: var(--pu-brand);
    --pu-action-ink: var(--pu-brand-600);  /* action-coloured text: links, icons */
    --pu-action-ink-hover: var(--pu-brand);
    --pu-on-action: #FFFFFF;
    --pu-blue: #0096D5;             /* the light accent: focus rings, progress, running */
    --pu-focus-ring: rgba(0, 150, 213, .18);
    --pu-sky: var(--pu-brand-tint);
    --pu-sky-line: var(--pu-brand-tint-line);
    --pu-sky-chip: #7FA9BF;
    --pu-sky-ink: var(--pu-brand-ink);
    --pu-tip-bg: #0E1A22;
    --pu-tip-ink: #FFFFFF;
    --pu-skel-a: #EDF1F4;
    --pu-skel-b: #F6F8FA;
    --pu-bar-idle: #C9D5DD;
    --pu-scrim: rgba(14, 26, 34, .18);
    --pu-scrim-strong: rgba(9, 30, 44, .48);
    /* Elevation: a hairline plus a soft, short shadow; cards barely lift, popovers float, dialogs float highest. */
    --pu-shadow-card: 0 1px 2px rgba(16, 40, 56, .05);
    --pu-shadow-raise: 0 1px 2px rgba(16, 40, 56, .06), 0 4px 12px rgba(16, 40, 56, .07);
    --pu-shadow-pop: 0 12px 32px rgba(14, 26, 34, .14), 0 2px 6px rgba(14, 26, 34, .06);
    --pu-shadow-dialog: 0 24px 64px rgba(9, 30, 44, .22), 0 4px 12px rgba(9, 30, 44, .08);
    --pu-shadow-sm: 0 1px 2px rgba(14, 26, 34, .14);
    --pu-surface-2: #F8FAFB;        /* table and card heads, status bars: a step off the surface */
    --pu-row-hover: #F3F7FA;        /* a cool, barely-blue row hover */
    --pu-row-selected: var(--pu-brand-tint);
    --pu-selected-bar: var(--pu-brand-600);

    /* Status: each text colour passes AA on its tint. */
    --pu-ok: #18794A;
    --pu-ok-bg: #E6F4EC;
    --pu-run: #00719F;
    --pu-run-bg: #E3F2FA;
    --pu-wait: #4F5F6B;
    --pu-wait-bg: #EDF1F4;
    --pu-warn: #8A5200;
    --pu-warn-bg: #FDF3E1;
    --pu-warn-line: #F3DFB9;
    --pu-warn-ink: #5C3700;
    --pu-err: #B42318;
    --pu-err-bg: #FDECEA;
    --pu-err-ink: #7A1A12;
    --pu-err-line: #F0C2BD;
    --pu-err-row: #FDF3F2;
    --pu-err-row-hover: #FBE9E7;
    --pu-err-solid: #C93A2F;        /* count badges (white text, 4.9:1); was dark-only, so the light badges had no fill */

    /* Top bar values for variant A (solid brand); variant B uses the plain surface tokens. */
    --pu-bar-a-bg: var(--pu-brand);
    --pu-bar-a-line: var(--pu-brand-strong);
    --pu-bar-a-ink: #FFFFFF;
    --pu-bar-a-ink-2: #C9DCE6;
    --pu-bar-a-control: #0C5272;
    --pu-bar-a-control-hover: #125E80;
    --pu-bar-a-control-line: #4A7C95;
    --pu-bar-a-control-ink-2: #D3E2EA;
    --pu-bar-a-focus: #FFFFFF;

    /* The bar's character: a hairline of light along its top edge, a soft shadow onto the page below, the heartbeat
       mark in the light accent, and an environment badge (amber outside production). */
    --pu-bar-sheen: rgba(255, 255, 255, .07);
    --pu-bar-drop: 0 1px 0 rgba(1, 40, 58, .55), 0 2px 10px -4px rgba(1, 40, 58, .35);
    --pu-bar-mark: #6CCBF5;
    --pu-bar-overline: #A9C7D6;
    --pu-env-bg: #F5B544;
    --pu-env-ink: #2E1E00;
    --pu-env-staging-bg: #C4B5FD;
    --pu-env-staging-ink: #24124F;
    --pu-env-local-line: rgba(255, 255, 255, .42);
    --pu-env-local-ink: #FFFFFF;
}

/*
 * Dark theme: a cool slate ground in the brand's hue, raised surfaces a step lighter, the brand bar a darker brand blue.
 * Text passes AA (4.5:1) on every surface it sits on; status keeps its hues on dark tints.
 */
:root[data-theme="dark"] {
    --pu-brand-strong: #042A3C;
    --pu-brand-600: #0A6C99;
    --pu-brand-tint: #123447;
    --pu-brand-tint-line: #24506B;
    --pu-brand-ink: #8FCBEA;
    --pu-brand-strip: #2C8DBF;
    --pu-logo-line: #8FCBEA;
    --pu-logo-word: #F0646A;

    --pu-ink: #E6EDF2;
    --pu-ink-2: #A9B8C3;
    --pu-ink-3: #93A4B1;
    --pu-ink-4: #5F7180;
    --pu-placeholder: #8C9DAA;
    --pu-ground: #0E161C;
    --pu-surface: #151F27;
    --pu-raised: #1B2731;
    --pu-line: #26343F;
    --pu-line-2: #1F2C36;
    --pu-border: #364855;
    --pu-border-hover: #4A5F6E;
    --pu-border-strong: #5A7080;
    --pu-hover: #1B2731;
    --pu-hover-2: #22303B;
    --pu-soft: #22303B;
    --pu-switch-off: #5A6B78;
    --pu-seg-on: #364855;
    --pu-action-hover: #0B5C82;
    --pu-action-ink: #5CB8E6;
    --pu-action-ink-hover: #8FCBEA;
    --pu-blue: #33AEE6;
    --pu-focus-ring: rgba(51, 174, 230, .3);
    --pu-sky-chip: #2F6F92;
    --pu-tip-bg: #2A3A47;
    --pu-tip-ink: #E6EDF2;
    --pu-skel-a: #1F2C36;
    --pu-skel-b: #283844;
    --pu-bar-idle: #3A4C59;
    --pu-scrim: rgba(0, 0, 0, .45);
    --pu-scrim-strong: rgba(0, 0, 0, .62);
    --pu-shadow-card: 0 1px 2px rgba(0, 0, 0, .25);
    --pu-shadow-raise: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 16px rgba(0, 0, 0, .3);
    --pu-shadow-pop: 0 12px 32px rgba(0, 0, 0, .5), 0 2px 6px rgba(0, 0, 0, .3);
    --pu-shadow-dialog: 0 24px 64px rgba(0, 0, 0, .6), 0 0 0 1px rgba(255, 255, 255, .04);
    --pu-shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
    --pu-surface-2: #18232C;
    --pu-row-hover: #1A2630;
    --pu-selected-bar: #5CB8E6;

    --pu-ok: #5DD39A;
    --pu-ok-bg: #10301F;
    --pu-run: #6CC4EE;
    --pu-run-bg: #0F2D3F;
    --pu-wait: #AAB8C3;
    --pu-wait-bg: #22303B;
    --pu-warn: #F2B65C;
    --pu-warn-bg: #3A2A0F;
    --pu-warn-line: #6B4E1E;
    --pu-warn-ink: #F7D29A;
    --pu-err: #FF8A80;
    --pu-err-bg: #3D1A17;
    --pu-err-ink: #FFC2BC;
    --pu-err-line: #7A3A33;
    --pu-err-row: #2A1716;
    --pu-err-row-hover: #351C1A;
    --pu-err-solid: #C93A2F;

    --pu-bar-a-bg: #06344B;
    --pu-bar-a-line: #0B425E;
    --pu-bar-a-ink-2: #B5CCD9;
    --pu-bar-a-control: #0B4360;
    --pu-bar-a-control-hover: #0F4E6E;
    --pu-bar-a-control-line: #2F6584;
    --pu-bar-a-control-ink-2: #C3D6E1;
    --pu-bar-sheen: rgba(255, 255, 255, .05);
    --pu-bar-drop: 0 1px 0 rgba(0, 0, 0, .5), 0 2px 12px -4px rgba(0, 0, 0, .6);
    --pu-bar-overline: #9DBDCD;
}

/*
 * The top bar tokens: color-mix weighted by --pu-bar-solid (1 gives the A value, 0 the B value). They resolve against
 * the theme in effect, since custom properties are computed after the cascade.
 */
:root {
    --pu-bar-w: calc(var(--pu-bar-solid) * 100%);
    --pu-bar-bg: color-mix(in srgb, var(--pu-bar-a-bg) var(--pu-bar-w), var(--pu-surface));
    --pu-bar-line: color-mix(in srgb, var(--pu-bar-a-line) var(--pu-bar-w), var(--pu-line));
    --pu-bar-ink: color-mix(in srgb, var(--pu-bar-a-ink) var(--pu-bar-w), var(--pu-ink));
    --pu-bar-ink-2: color-mix(in srgb, var(--pu-bar-a-ink-2) var(--pu-bar-w), var(--pu-ink-2));
    --pu-bar-control: color-mix(in srgb, var(--pu-bar-a-control) var(--pu-bar-w), var(--pu-ground));
    --pu-bar-control-hover: color-mix(in srgb, var(--pu-bar-a-control-hover) var(--pu-bar-w), var(--pu-surface));
    --pu-bar-control-line: color-mix(in srgb, var(--pu-bar-a-control-line) var(--pu-bar-w), var(--pu-border));
    --pu-bar-control-ink-2: color-mix(in srgb, var(--pu-bar-a-control-ink-2) var(--pu-bar-w), var(--pu-ink-3));
    --pu-bar-focus: color-mix(in srgb, var(--pu-bar-a-focus) var(--pu-bar-w), var(--pu-blue));
    --pu-bar-avatar: color-mix(in srgb, var(--pu-bar-a-control) var(--pu-bar-w), var(--pu-brand-tint));
    --pu-bar-avatar-ink: color-mix(in srgb, var(--pu-bar-a-ink) var(--pu-bar-w), var(--pu-brand-ink));
    --pu-bar-avatar-line: color-mix(in srgb, var(--pu-bar-a-control-line) var(--pu-bar-w), var(--pu-brand-tint-line));
    --pu-bar-strip: calc((1 - var(--pu-bar-solid)) * 3px);
    --pu-bar-mark-ink: color-mix(in srgb, var(--pu-bar-mark) var(--pu-bar-w), var(--pu-logo-line));
    --pu-bar-overline-ink: color-mix(in srgb, var(--pu-bar-overline) var(--pu-bar-w), var(--pu-ink-3));
    --pu-bar-sheen-mix: color-mix(in srgb, var(--pu-bar-sheen) var(--pu-bar-w), transparent);
}
