/* Shared geometry for user-facing forms. Field content stays left-aligned;
   only the form surface is centered in its available page or viewport. */

:where(
    .auth-wrapper,
    .auth-form-wrapper,
    .payment-wrapper,
    .payment-form-container,
    .tenant-container,
    .tenant-form,
    .user-settings,
    .ops-shell,
    .settings-form,
    .hub-request-form,
    .req-form-grid
) {
    margin-inline: auto;
}

:where(
    .auth-form,
    .payment-form,
    .tenant-form,
    .settings-form,
    .hub-request-form,
    .ops-card__body > form,
    .req-form-grid,
    .page > .card > form
) {
    width: 100%;
    max-width: 100%;
}

/* Every floating form uses the viewport center on desktop and mobile. */
:where(
    #eventForm,
    #studentInviteForm,
    #teacherInviteForm,
    .version-form,
    .version-detail-panel,
    .version-board .comment-list-panel
) {
    top: 50% !important;
    right: auto !important;
    bottom: auto !important;
    left: 50% !important;
    margin: 0 !important;
    max-height: min(88dvh, 760px) !important;
    transform-origin: center !important;
}

:where(#eventForm, #studentInviteForm, #teacherInviteForm):not(.show),
.version-form:not(.is-open),
.version-detail-panel:not(.is-open) {
    transform: translate(-50%, -50%) scale(.96) !important;
}

:where(#eventForm, #studentInviteForm, #teacherInviteForm).show,
.version-form.is-open,
.version-detail-panel.is-open,
.version-board .comment-list-panel.is-open {
    transform: translate(-50%, -50%) scale(1) !important;
}

:where(
    dialog.hub-request-dialog,
    dialog.version-flow-delete-dialog
) {
    position: fixed !important;
    top: 50% !important;
    right: auto !important;
    bottom: auto !important;
    left: 50% !important;
    margin: 0 !important;
    max-height: min(88dvh, 760px) !important;
    transform: translate(-50%, -50%) !important;
    transform-origin: center !important;
}

dialog.hub-request-dialog .hub-request-dialog-card {
    max-height: min(88dvh, 760px);
}

@media (min-width: 769px) {
    .settings-card > .settings-form { margin-inline: auto; }

    .ops-card__body > form { width: min(100%, 1080px); margin-inline: auto; }
    .req-form-card > .req-form-grid { width: min(100%, 980px); }
}

@media (max-width: 768px) {
    :where(
        #eventForm,
        #studentInviteForm,
        #teacherInviteForm,
        .version-form,
        .version-detail-panel,
        .version-board .comment-list-panel
    ) {
        width: min(94vw, 560px) !important;
        max-height: 92dvh !important;
    }

    :where(
        dialog.hub-request-dialog,
        dialog.version-flow-delete-dialog
    ) {
        max-height: 92dvh !important;
    }

    dialog.hub-request-dialog .hub-request-dialog-card { max-height: 92dvh; }

    :where(
        .auth-form-wrapper,
        .payment-form-container,
        .tenant-form,
        .settings-form,
        .hub-request-form,
        .ops-card__body > form,
        .req-form-grid
    ) {
        margin-inline: auto;
    }
}
