/* Keep the browser document stationary. Long lists, forms and articles have
   their own bounded reading area, including while the software keyboard is up. */
@media screen {
    html.app-viewport,
    html.app-viewport body {
        box-sizing: border-box;
        height: 100dvh !important;
        min-height: 0 !important;
        overflow: clip !important;
        overscroll-behavior: none;
    }

    .app-viewport body:has(> main),
    .app-viewport body:has(> #adminMain) {
        display: flex;
        flex-direction: column;
    }

    .app-viewport body > main:not(.stage),
    .app-viewport #adminMain,
    .app-viewport #mainContainer {
        min-height: 0 !important;
        overflow-y: auto;
        overscroll-behavior-y: contain;
    }

    .app-viewport body > main:not(.stage),
    .app-viewport #adminMain {
        flex: 1 1 auto;
    }

    .app-viewport #mainContainer {
        height: min(100%, var(--djq-viewport-height, 100dvh));
        align-items: safe center !important;
    }

    .app-viewport #mainContainer:has(#authModal[style*="display: block"] #homeChoices:not([style*="display: none"])) {
        overflow: clip;
    }

    .app-viewport #onboardingModal {
        position: fixed !important;
        top: var(--djq-viewport-offset-top, 0px) !important;
        height: var(--djq-viewport-height, 100dvh);
        min-height: 0;
        overflow-y: auto;
        align-items: safe center !important;
    }

    .app-viewport #adminMain > .session-header { flex: none; }
    .app-viewport #adminMain > .glass:has(#tableContainer) {
        display: flex;
        flex-direction: column;
        min-height: 0;
        overflow-y: auto;
    }
    .app-viewport #tableContainer { overflow-y: auto; }
    .app-viewport .site-header { flex: none; }

    .landing-demo { touch-action: none; user-select: none; }
    .landing-demo img { -webkit-user-drag: none; }
}

/* Short landscape screens put the actions beside the preview. */
@media screen and (orientation: landscape) and (max-height: 700px) {
    #authModal:has(#homeChoices:not([style*="display: none"])) {
        padding: 0 !important;
    }
    #authModal:has(#homeChoices:not([style*="display: none"])) .dj-home-container,
    #authModal:has(#homeChoices:not([style*="display: none"])) .dj-home-content,
    #authModal:has(#homeChoices:not([style*="display: none"])) .dj-home-content > div {
        display: contents;
    }
    #authModal:has(#homeChoices:not([style*="display: none"])) :is(.dj-home-logo-wrap, .partner-logos-mobile) {
        display: none !important;
    }
    #authModal:has(#homeChoices:not([style*="display: none"])) #homeChoices:not([style*="display: none"]) {
        display: grid;
        height: 100svh;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-template-rows: 1fr 1fr;
        gap: 0.5rem;
        align-items: end;
        justify-items: center;
        max-width: 40rem;
        margin: auto;
    }
    #authModal:has(#homeChoices:not([style*="display: none"])) #homeChoices .landing-demo-preview {
        display: grid;
        grid-row: span 2;
        align-self: center;
        justify-items: center;
    }
    #authModal:has(#homeChoices:not([style*="display: none"])) #homeChoices .landing-demo {
        width: min(100%, 40svh);
        height: auto;
    }
    #authModal:has(#homeChoices:not([style*="display: none"])) #homeChoices > :last-child { align-self: start; margin: 0; }
}
