/* Desktop refresh (2026-09-24): shell. Rules apply outside phone mode only: prefix :root:not([data-phone="on"]) where a rule could reach the phone layout. */

/* ── The grouped sidebar ──────────────────────────────────────────────────────
   NavMenu.razor groups the 21 flat links under Day / Consult / Records and
   letters / More / Admin, and a group folds away. Phone mode hides the whole
   .sidebar column (app.css, [data-phone="on"] .sidebar), so none of this can
   reach the phone; every rule still carries the :not([data-phone="on"]) prefix,
   which states that, and which also lifts these to (0,3,0)+ so they outrank
   NavMenu's scoped rules ((0,2,0)-(0,3,0)) without !important.

   No colour is set anywhere in this sheet. The header's ink comes from the
   scoped .nav-section-label it also carries (the sidebar is dark green in both
   themes, which is why that rule may hold a literal and this one does not need
   to); everything drawn here uses currentColor. */

/* Header: a small sentence-case label with a fold chevron. Sentence case, not
   tracked caps — the phone's navigation labels lost theirs on 2026-09-19 for
   the same reason: these are words a vet scans, not decoration. Aligned with
   the link icons (px-3 + the link's own 1rem).

   44px tall by default, like the links (their scoped 2.75rem): the label and its
   padding come to about 32px, and app.css's TOUCH TARGETS rule wants 44 on a
   touch screen. Only the mouse tier below takes the floor away. */
:root:not([data-phone="on"]) .nav-group-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    width: 100%;
    min-height: 44px;
    margin: 0;
    padding: 0.6rem 1.5rem 0.3rem 2rem;
    background: none;
    border: 0;
    border-radius: 6px;
    text-align: left;
    font-family: var(--ed-ui);
    font-size: max(0.78rem, var(--ed-fs-floor, 0rem));
    font-weight: 600;
    line-height: 1.25;
    text-transform: none;
    letter-spacing: 0.01em;
    white-space: nowrap;
    cursor: pointer;
}

/* The first header clears the branding row the way the first link used to
   (the scoped .nav-item:first-of-type padding-top: 1rem it replaces). */
:root:not([data-phone="on"]) .nav > .nav-group:first-child > .nav-group-toggle {
    padding-top: 0.85rem;
}

:root:not([data-phone="on"]) .nav-group-label {
    overflow: hidden;
    text-overflow: ellipsis;
}

:root:not([data-phone="on"]) .nav-group-toggle:hover .nav-group-label {
    text-decoration: underline;
    text-underline-offset: 0.2em;
}

:root:not([data-phone="on"]) .nav-group-toggle:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: -2px;
}

/* Chevron: two currentColor borders, turned. Down = open, right = folded. */
:root:not([data-phone="on"]) .nav-group-chevron {
    flex-shrink: 0;
    width: 0.42rem;
    height: 0.42rem;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: translateY(-0.12rem) rotate(45deg);
    transition: transform 0.2s var(--ease-smooth);
}

:root:not([data-phone="on"]) .nav-group--closed .nav-group-chevron {
    transform: rotate(-45deg);
}

/* The group holding the page on screen cannot fold (aria-disabled): no hover
   underline, no pointer, and a dimmed chevron that still says "open". */
:root:not([data-phone="on"]) .nav-group-toggle[aria-disabled="true"] {
    cursor: default;
}

:root:not([data-phone="on"]) .nav-group-toggle[aria-disabled="true"]:hover .nav-group-label {
    text-decoration: none;
}

:root:not([data-phone="on"]) .nav-group-toggle[aria-disabled="true"] .nav-group-chevron {
    opacity: 0.4;
}

/* Folded. Display, not height: a folded group's links leave the tab order and
   the accessibility tree along with the screen. */
:root:not([data-phone="on"]) .nav-group--closed > .nav-group-items {
    display: none;
}

/* Every item in a group spaces the same. The scoped :first-of-type/:last-of-type
   rules (1rem above the first link, 1rem below the last) were written for ONE
   flat list; inside five group containers they would pad every group's ends. */
:root:not([data-phone="on"]) .nav-group-items > .nav-item {
    padding-top: 0;
    padding-bottom: 0.5rem;
}

/* ── Mouse density (>= 901px AND a fine pointer) ──────────────────────────────
   Tighter rows so Day and Consult — plus the three folded headers under them —
   fit a 768px-high screen without scrolling, with the branding row and the
   Collapse row both on screen: 2.25rem links (38px at the 17px root) on a
   2.5px rhythm and ~32px headers, against the 47px + 8.5px the flat list used.

   A mouse only. Width alone is not "desktop": a landscape iPad is 1133-1366px
   wide with a coarse pointer, and the vet taps it one-handed; it keeps the 44px
   rows the TOUCH TARGETS rule in app.css asks for, as does everything <= 900px.
   A 901-1024px window with a mouse is a laptop, not a tablet, so it gets the
   density (TOUCH TARGETS calls its roomier targets there harmless, not needed,
   and here they would push Consult below the fold). */
@media (min-width: 901px) and (pointer: fine) {
    :root:not([data-phone="on"]) .nav-group-toggle {
        min-height: 0;
    }

    :root:not([data-phone="on"]) .nav-group-items > .nav-item {
        padding-bottom: 0.15rem;
    }

    :root:not([data-phone="on"]) .nav-group-items > .nav-item a {
        height: 2.25rem;
        line-height: 2.25rem;
        padding-top: 0;
        padding-bottom: 0;
    }

    :root:not([data-phone="on"]) .nav-sidebar .nav-collapse-item {
        padding-top: 0.3rem;
        padding-bottom: 0.3rem;
    }

    :root:not([data-phone="on"]) .nav-sidebar .nav-collapse-btn {
        height: 2.25rem;
    }
}

/* ── Icon-only rail (the Collapse button, >= 641px) ───────────────────────────
   No room for a label: each header becomes a thin separator between icon
   groups, and every group's tools show, folded or not, so nothing is left
   unreachable behind a fold. All of it is here, none in markup, because the
   collapsed flag outlives this media query: narrow the window below 641px and
   the same sidebar is the drop-down menu, whose full headers must fold. */
@media (min-width: 641px) {
    :root:not([data-phone="on"]) .nav-sidebar--collapsed .nav-group--closed > .nav-group-items {
        display: block;
    }

    /* visibility: hidden, not display: none, takes the header out of the tab
       order and the accessibility tree while its box keeps the gap. The width
       is stated: a <button> with width: auto is fit-content, not stretched,
       and with its label and chevron hidden that is 0px. */
    :root:not([data-phone="on"]) .nav-sidebar--collapsed .nav-group-toggle {
        visibility: hidden;
        pointer-events: none;
        width: calc(100% - 1.8rem);
        height: 1px;
        min-height: 0;
        margin: 0.45rem 0.9rem;
        padding: 0;
        border-radius: 0;
    }

    /* The line itself: a child may be visible inside a hidden parent. It keeps
       the header's ink (the scoped .nav-section-label), so no colour is set. */
    :root:not([data-phone="on"]) .nav-sidebar--collapsed .nav-group-toggle::before {
        content: "";
        visibility: visible;
        width: 100%;
        height: 1px;
        background: currentColor;
        opacity: 0.3;
    }

    :root:not([data-phone="on"]) .nav-sidebar--collapsed .nav-group-label,
    :root:not([data-phone="on"]) .nav-sidebar--collapsed .nav-group-chevron {
        display: none;
    }

    /* A rule above the first icon separates nothing: keep the space, drop the line. */
    :root:not([data-phone="on"]) .nav-sidebar--collapsed .nav > .nav-group:first-child > .nav-group-toggle {
        margin-top: 0.85rem;
        padding-top: 0;
    }

    :root:not([data-phone="on"]) .nav-sidebar--collapsed .nav > .nav-group:first-child > .nav-group-toggle::before {
        visibility: hidden;
    }
}
