/* The app-wide read-only look (owner decision 2026-12-02): a read-only field reads as a label with its
   value under it, not as a field to fill in. No underline, no spin arrows, no calendar/clock/dropdown
   icon, no primary-colour focus line, no typing hint; the value keeps full text contrast and stays
   selectable and copyable. Keyboard focus shows a thin neutral line, so a keyboard user can still
   see where they are (a read-only field stays focusable — Tab + Ctrl+C is how a keyboard copies);
   read-only-fields.js, imported by AppLayout, tells keyboard focus from a click or tap.
   Global (unscoped) rules, so each host <link>s this file AFTER MudBlazor.min.css — an RCL cannot
   inject a <link> (the keyboard-focus.css precedent).

   Which fields: every Text-variant (underlined) MudBlazor input that is read-only. MudBlazor draws a
   read-only field exactly like an editable one and marks it differently per component, so the
   selector below has one arm per marker:
     1. text, numeric and multi-line fields: their own <input>/<textarea> carries `readonly`;
     2. selects (and autocompletes): `.mud-select-input.mud-readonly` on the input root — never the
        `readonly` attribute, which a select's inner input always carries;
     3. date/time pickers: the `.app-picker-read-only` frame AppDatePicker/AppTimePicker render
        (Forms/ReadOnlyPickerFrame.cs) — a picker's input is also `readonly` whatever its state,
        which is why arm 1 skips everything inside a `.mud-picker`. A raw MudDatePicker therefore
        never gets this look: use the App* pickers.
   Outlined and filled fields keep their box on purpose: the only read-only one is the calendar feed
   link on the Integrations page, a copy box the owner chose to keep as it is.

   Every rule repeats the same :is() list (no CSS nesting, to stay within what the oldest supported
   WebView understands); keep the copies identical. Its specificity, (0,5,1), outranks every
   MudBlazor input rule it overrides — order in the head is a second line of defence, not the first. */

/* The resting and hover underline. */
:is(
    .mud-input.mud-input-text:not(.mud-select-input):not(.mud-picker *):has(> input[readonly], > textarea[readonly]),
    .mud-input.mud-input-text.mud-select-input.mud-readonly,
    .app-picker-read-only .mud-input.mud-input-text
).mud-input-underline::before {
    border-bottom-color: transparent;
}

/* The focus line: neutral, and only for keyboard focus — a click or tap shows nothing. Not
   :focus-visible: Chromium matches it on a read-only text input after a click too, so the keyboard
   is recognised by read-only-fields.js, which marks such a field `data-keyboard-focus`. An error
   keeps MudBlazor's red line — a read-only field can still carry one. */
:is(
    .mud-input.mud-input-text:not(.mud-select-input):not(.mud-picker *):has(> input[readonly], > textarea[readonly]),
    .mud-input.mud-input-text.mud-select-input.mud-readonly,
    .app-picker-read-only .mud-input.mud-input-text
).mud-input-underline:not(.mud-input-error)::after {
    transform: scaleX(0);
    border-bottom: 1px solid var(--mud-palette-action-default);
}

:is(
    .mud-input.mud-input-text:not(.mud-select-input):not(.mud-picker *):has(> input[readonly], > textarea[readonly]),
    .mud-input.mud-input-text.mud-select-input.mud-readonly,
    .app-picker-read-only .mud-input.mud-input-text
).mud-input-underline:not(.mud-input-error):has(> :is(input, textarea)[data-keyboard-focus])::after {
    transform: scaleX(1);
}

/* Spin arrows and icon adornments (the picker's calendar/clock, the select's dropdown arrow) promise
   an interaction that is not there. A text adornment — a unit such as "g" — is part of the value
   and stays. */
:is(
    .mud-input.mud-input-text:not(.mud-select-input):not(.mud-picker *):has(> input[readonly], > textarea[readonly]),
    .mud-input.mud-input-text.mud-select-input.mud-readonly,
    .app-picker-read-only .mud-input.mud-input-text
) > :is(.mud-input-numeric-spin, .mud-input-adornment:has(> .mud-input-adornment-icon-button, > .mud-input-adornment-icon)) {
    display: none;
}

/* The value is text to read and copy: the I-beam cursor, never the picker's or select's pointer.
   MudBlazor puts `user-select: none` on the input control around most fields; Chromium ignores it
   inside an <input>, but other engines need not (the later iOS phase runs WebKit), so the read-only
   value opts back in explicitly. */
:is(
    .mud-input.mud-input-text:not(.mud-select-input):not(.mud-picker *):has(> input[readonly], > textarea[readonly]),
    .mud-input.mud-input-text.mud-select-input.mud-readonly,
    .app-picker-read-only .mud-input.mud-input-text
),
:is(
    .mud-input.mud-input-text:not(.mud-select-input):not(.mud-picker *):has(> input[readonly], > textarea[readonly]),
    .mud-input.mud-input-text.mud-select-input.mud-readonly,
    .app-picker-read-only .mud-input.mud-input-text
) > :is(input, textarea) {
    cursor: text;
    user-select: text;
}

/* No typing hint ("h:mm", "m:ss") on a field nobody can type in: an empty read-only field shows
   nothing under its label. */
:is(
    .mud-input.mud-input-text:not(.mud-select-input):not(.mud-picker *):has(> input[readonly], > textarea[readonly]),
    .mud-input.mud-input-text.mud-select-input.mud-readonly,
    .app-picker-read-only .mud-input.mud-input-text
) > :is(input, textarea)::placeholder {
    opacity: 0;
}

/* The label always sits on top, as MudBlazor places it for a filled field: an empty read-only field
   would otherwise show its label where the value goes, where it reads AS the value. The transform
   is MudBlazor's own shrink (_inputlabel.scss, `.mud-shrink ~ label`) — keep it in step on an upgrade. */
:is(
    .mud-input.mud-input-text:not(.mud-select-input):not(.mud-picker *):has(> input[readonly], > textarea[readonly]),
    .mud-input.mud-input-text.mud-select-input.mud-readonly,
    .app-picker-read-only .mud-input.mud-input-text
) ~ label.mud-input-label.mud-input-label-inputcontrol {
    transform: translate(0, 1.5px) scale(0.75);
    transform-origin: top left;
    max-width: calc(100% / 0.75);
}

/* ...in the text colour, never the primary focus colour; an error keeps its own. */
:is(
    .mud-input.mud-input-text:not(.mud-select-input):not(.mud-picker *):has(> input[readonly], > textarea[readonly]),
    .mud-input.mud-input-text.mud-select-input.mud-readonly,
    .app-picker-read-only .mud-input.mud-input-text
) ~ label.mud-input-label.mud-input-label-inputcontrol:not(.mud-input-error) {
    color: var(--mud-palette-text-primary);
}

/* The App* pickers' frame (Forms/ReadOnlyPickerFrame.cs) generates no box of its own, so the picker
   still lays out as a direct child of whatever contains it. */
.app-picker {
    display: contents;
}
