/*
    The operator site only. riho is drawn in fixed pixels for a large desktop, so on a smaller or
    scaled-up screen the frame and the content are zoomed down in steps; a phone keeps riho's own.
*/
:root {
    --ssp-zoom: 1;
}

@media (min-width: 992px) and (max-width: 1599.98px), (min-width: 992px) and (max-height: 899.98px) {
    :root {
        --ssp-zoom: .9;
    }
}

@media (min-width: 992px) and (max-width: 1439.98px), (min-width: 992px) and (max-height: 799.98px) {
    :root {
        --ssp-zoom: .8;
    }
}

@media (min-width: 992px) and (max-width: 1299.98px), (min-width: 992px) and (max-height: 699.98px) {
    :root {
        --ssp-zoom: .75;
    }
}

/* Not the root, nor a modal: the plugins that hang off body or a modal (select2, the drag helper,
   notify, swal) place themselves by page coordinates, which a zoomed ancestor would throw off. */
.page-wrapper.compact-wrapper .page-header,
.page-wrapper.compact-wrapper .page-body-wrapper div.sidebar-wrapper,
.page-wrapper.compact-wrapper .page-body-wrapper .page-body,
.ssp-login .ssp-login-card,
.error-wrapper > .container {
    zoom: var(--ssp-zoom);
}

/* A zoomed element keeps percentages of the window but shrinks viewport units with it, so each
   size riho takes in vh or vw is divided back out. */
.page-wrapper .page-header {
    max-width: calc(100vw / var(--ssp-zoom));
}

.page-wrapper.compact-wrapper .page-body-wrapper div.sidebar-wrapper .sidebar-main .sidebar-links {
    height: calc(100vh / var(--ssp-zoom) - 79px);
}

/* The page itself never scrolls: the frame is one window tall and the content takes what riho's
   header margin leaves, with the same gap below the card as beside it. */
.page-wrapper.compact-wrapper .page-body-wrapper {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
}

/* With the container's 12px, the mockup's 24px beside and under the card and 22px over the title.
   While the content scrolls, the scrollbar takes its width out of the right padding (--ssp-sbw,
   measured by riho-blazor.js) so the gap beside the card stays even. */
.page-wrapper.compact-wrapper .page-body-wrapper .page-body {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    min-height: 0;
    padding: 22px max(0px, calc(12px - var(--ssp-sbw, 0px))) 12px 12px;
    overflow: auto;
    scrollbar-width: thin;
}

/* The mockup's title sits flush with the card under it, not in riho's strip bled over the padding. */
.page-wrapper.compact-wrapper .page-body-wrapper .page-title {
    margin: 0 0 18px;
    padding: 0;
}

/* .page-body is the scroller, not this. No minimum width: a narrow window reflows the screen,
   and only a wide table scrolls sideways, in its box. */
.page-wrapper.compact-wrapper #pjax-content {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    min-width: 0;
    padding-bottom: calc(var(--bs-gutter-x, 1.5rem) * .5);
}

.page-wrapper.compact-wrapper #pjax-content > * {
    flex-shrink: 0;
}

/* A screen of several blocks keeps their natural height and scrolls; the last one takes what a
   short screen leaves. */
.page-wrapper.compact-wrapper #pjax-content > :last-child {
    flex-grow: 1;
}

/* A screen of one card under its title - a list, an editor - fits the window: the card takes the
   rest of it and scrolls its own body. */
.page-wrapper.compact-wrapper #pjax-content > .page-title + .card:last-child,
.page-wrapper.compact-wrapper #pjax-content > .page-title + .row:last-child:has(> .col-12:only-child > .card) {
    flex: 1 1 0;
    min-height: 16rem;
    margin-bottom: 0;
}

.page-wrapper.compact-wrapper #pjax-content > .page-title + .row:last-child > .col-12:only-child:has(> .card) {
    display: flex;
    flex-direction: column;
}

.page-wrapper.compact-wrapper #pjax-content > .page-title + .row:last-child > .col-12:only-child > .card {
    flex: 1 1 0;
    min-height: 0;
    margin-bottom: 0;
}

.page-wrapper.compact-wrapper #pjax-content > .page-title + .card:last-child > .card-body,
.page-wrapper.compact-wrapper #pjax-content > .page-title + .row:last-child > .col-12:only-child > .card > .card-body {
    min-height: 0;
    overflow: auto;
}

/* In that card a grid scrolls its rows and keeps its pager at the bottom (the scroll box is
   Grid.razor's, the footer Pager.razor's). The body still scrolls as a whole once the window is too short. */
.page-wrapper.compact-wrapper #pjax-content > .page-title + .card:last-child > .card-body:has(> .ssp-grid:last-child),
.page-wrapper.compact-wrapper #pjax-content > .page-title + .row:last-child > .col-12:only-child > .card > .card-body:has(> .ssp-grid:last-child),
.page-wrapper.compact-wrapper #pjax-content > .page-title + .card:last-child > .card-body > .ssp-grid:last-child,
.page-wrapper.compact-wrapper #pjax-content > .page-title + .row:last-child > .col-12:only-child > .card > .card-body > .ssp-grid:last-child,
.page-wrapper.compact-wrapper #pjax-content > .page-title + .card:last-child > .card-body > .ssp-grid:last-child > .dataTables_wrapper,
.page-wrapper.compact-wrapper #pjax-content > .page-title + .row:last-child > .col-12:only-child > .card > .card-body > .ssp-grid:last-child > .dataTables_wrapper {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    min-height: 0;
}

.page-wrapper.compact-wrapper #pjax-content > .page-title + .card:last-child > .card-body:has(> .ssp-grid:last-child) > :not(.ssp-grid),
.page-wrapper.compact-wrapper #pjax-content > .page-title + .row:last-child > .col-12:only-child > .card > .card-body:has(> .ssp-grid:last-child) > :not(.ssp-grid),
.page-wrapper.compact-wrapper #pjax-content > .page-title + .card:last-child > .card-body > .ssp-grid:last-child > .dataTables_wrapper > :not(.ssp-grid-scroll),
.page-wrapper.compact-wrapper #pjax-content > .page-title + .row:last-child > .col-12:only-child > .card > .card-body > .ssp-grid:last-child > .dataTables_wrapper > :not(.ssp-grid-scroll) {
    flex-shrink: 0;
}

.page-wrapper.compact-wrapper #pjax-content > .page-title + .card:last-child > .card-body > .ssp-grid:last-child .ssp-grid-scroll,
.page-wrapper.compact-wrapper #pjax-content > .page-title + .row:last-child > .col-12:only-child > .card > .card-body > .ssp-grid:last-child .ssp-grid-scroll {
    flex: 1 1 0;
    min-height: 160px;
}
