/* Desktop refresh (2026-09-24): caseview. Rules apply outside phone mode only: prefix :root:not([data-phone="on"]) where a rule could reach the phone layout. */

/* Every selector here carries :root:not([data-phone="on"]) — CaseViewDesktopRefreshTests
   enforces it. That makes each one (0,3,0): it beats CaseView.razor.css's scoped
   .cv-x[b-xxx] (0,2,0) INCLUDING that sheet's own media tiers, so any rule that must leave
   a tier alone is fenced by a media query of its own here rather than trusting the cascade.
   Phone mode never matches, so css/phone/caseview.css keeps the case screen it has. */

/* ── Tool rail: the patient said once ────────────────────────────────────────
   The 2026-07-11 safety rule is that each action says which patient it writes to. The
   rail used to meet it by suffixing " for Cyanne" to every button; now the lead-in says
   it once, immediately before the buttons, and each button's aria-label still names the
   patient. All non-phone widths, because the suffixes are gone at all of them. Same face
   and size as the buttons so it reads as the start of the row, eucalypt and heavier so it
   reads as the row's subject rather than another action.

   It is the rail's only visible patient cue, so it never clips: the rail's own rule for
   its pills (CaseView.razor.css), a pill wider than its row breaks its own text rather
   than pushing sideways. No nowrap: its flex basis is its one-line width, so it stays on
   one line whenever that fits, and only a name wider than the whole rail wraps, down to
   a break inside the word if it has to. */
:root:not([data-phone="on"]) .cv-rail-lead {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    max-width: 100%;
    padding-right: 0.15rem;
    font-family: var(--ed-ui);
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.3;
    overflow-wrap: anywhere;
    color: var(--ed-eucalypt);
}

/* At <=900px the rail is a one-row scroll strip (CaseView.razor.css). A lead-in that
   scrolled away with the first chip would leave the rest anonymous, so it sticks to the
   strip's left edge on an opaque paper ground and the chips pass beneath it.

   Capped at 40% of the strip so a long name cannot crowd out every chip, and it wraps
   inside the cap instead of clipping: clipped, "Charlie Richardson" read "For Charlie
   Richa" at 375px, and "Max Johnson" and "Max Johnston" read alike. Two lines still fit
   the 44px chips.

   The strip's start scroll padding is the same cap. Focus only scrolls a chip that lies
   outside the scrollport less that padding, so without it Shift+Tab back to a chip under
   the lead-in scrolled nothing and focused a button no one could see (WCAG 2.2 2.4.11).
   One custom property, so the cap and the padding cannot drift apart. */
@media (max-width: 900px) {
    :root:not([data-phone="on"]) .cv-toolrail {
        --cv-rail-lead-cap: 40%;
        scroll-padding-inline-start: var(--cv-rail-lead-cap);
    }

    :root:not([data-phone="on"]) .cv-rail-lead {
        position: sticky;
        left: 0;
        z-index: 1;
        max-width: var(--cv-rail-lead-cap);
        padding-right: 0.5rem;
        background: var(--ed-paper);
    }
}

/* ── Compact masthead ────────────────────────────────────────────────────────
   Measured on master at 1366x768 (desktop refresh spec): an 85px name (5rem at the 17px
   root) and the timeline starting at 517px. Now: the kicker on one line, the name at
   2.7rem (45.9px) with the byline — owner, opened date, status, active mark, Edit
   details — beside it on the same baseline, and the rail, its labels no longer suffixed,
   in two rows. Computed from these values, not yet measured: the timeline starts at about
   330px at 1366x768 with the ConsultStepper showing and no presenting complaint; a
   complaint adds its lines.

   From 641px up only: the <=640px non-phone tier (a phone that has not opted into phone
   mode) keeps the clamp and spacing CaseView.razor.css already gives it.

   A flex-wrap row rather than a grid so each piece falls to its own line when it does not
   fit: a long name or owner pushes the byline under the name instead of squeezing it
   into a column. The sprig shrinks and the kicker, name and byline keep clear of it. */
@media (min-width: 641px) {
    :root:not([data-phone="on"]) .cv-masthead {
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        column-gap: 1.1rem;
        row-gap: 0.3rem;
        padding: 0.25rem 0 0.9rem;
        margin-bottom: 1.25rem;
    }

    /* One line at desktop widths: less tracking buys the width. It may still wrap on a
       narrow window rather than clip — the weight rides at the end of this line, and a
       dose is worked out from it. */
    :root:not([data-phone="on"]) .cv-kicker {
        flex: 0 0 100%;
        min-width: 0;
        margin-bottom: 0;
        padding-right: 3.25rem;
        letter-spacing: 0.14em;
    }

    :root:not([data-phone="on"]) .cv-headline {
        flex: 0 1 auto;
        min-width: 0;
        max-width: calc(100% - 3.25rem);
        font-size: 2.7rem;
        line-height: 1.05;
        margin: 0;
    }

    :root:not([data-phone="on"]) .cv-byline {
        flex: 1 1 auto;
        min-width: 0;
        padding-right: 3.25rem;
        gap: 0.3rem 0.6rem;
    }

    :root:not([data-phone="on"]) .cv-toolrail {
        flex: 0 0 100%;
        min-width: 0;
        margin-top: 0.55rem;
    }

    :root:not([data-phone="on"]) .cv-botanical {
        top: 0;
        width: 42px;
        height: 56px;
        opacity: 0.45;
    }

    /* The presenting complaint sits between the masthead and the timeline; its 2.5rem
       tail was the last big gap above the record. */
    :root:not([data-phone="on"]) .cv-standfirst {
        margin-bottom: 1.5rem;
    }
}
