$modal-size: 600px;

.aw-page-modal {
    @apply bg-surface;
    display: flex;

    /* reset page styles */
    padding: 0;
    margin: 0;
    max-width: 100%;

    overflow: auto;
    overscroll-behavior: contain;

    position: fixed;
    inset: 0;
    z-index: 100;

    scrollbar-color: rgba(var(--c-surface-rgb), 0.6) rgba(var(--c-on-surface-rgb), 0.15);

    &__dialog {
        @apply bg-surface;
        min-height: 100%;
        width: 100%;
    }

    &__header {
        display: flex;
        align-items: flex-start;
        padding: theme('spacing.8', 2rem) theme('spacing.8', 2rem) 0;
    }

    &__title {
        text-align: center; /* too much pain to align left because of buttons */
        font-family: theme('fontFamily.body', inherit);
        font-size: theme('fontSize.lg', 1.125rem);
        line-height: theme('spacing.8', 2rem);
        margin: 0;
        flex-grow: 1;
        flex-shrink: 1;
    }

    &__header-btn {
        display: block;
        width: theme('spacing.8', 2rem);
        height: theme('spacing.8', 2rem);
        /* border-radius: theme('borderRadius.default', 0.125rem); */

        span {
            width: theme('spacing.8', 2rem);
            height: theme('spacing.8', 2rem);
            display: flex;
            align-items: center;
            justify-content: center;
        }

        transition: 60ms background-color;

        &:hover {
            @apply text-accent;
        }
    }

    &__body {
        padding: theme('spacing.8', 2rem);
    }

    &__body--buttons {
        padding-bottom: theme('spacing.2', 0.5rem);
    }

    &__buttons {
        @apply bg-surface;
        padding: theme('spacing.2', 0.5rem) theme('spacing.8', 2rem) theme('spacing.4', 1rem);

        position: sticky;
        bottom: 0;
    }
}

@screen md {
    .aw-page-modal {
        &--default {
            @apply bg-overlay;
            padding: theme('spacing.10', 2.5rem) theme('spacing.10', 2.5rem) 0;
        }

        &--aside {
            @apply bg-overlay;
            overflow: auto;
            align-items: stretch;
            justify-content: flex-end;
        }

        &__dialog--default {
            min-height: inherit;
            width: $(modal-size);
            max-width: 100%;
            margin: auto;
        }

        &__dialog--aside {
            display: flex;
            flex-direction: column;

            min-height: 100%;
            width: $(modal-size);
            max-width: 100%;
            margin-left: auto;
            overflow: auto;
        }

        &__header {
            padding: theme('spacing.8', 2rem) theme('spacing.10', 2.5rem) 0;
        }

        &__header--fullscreen {
            @apply bg-surface;

            padding-top: theme('spacing.3', 0.75rem);
            padding-bottom: theme('spacing.3', 0.75rem);
            border-bottom-width: 1px;

            position: sticky;
            left: 0;
            right: 0;
            top: 0;
            z-index: 100;
        }

        &__body {
            padding: theme('spacing.8', 2rem) theme('spacing.10', 2.5rem) theme('spacing.10', 2.5rem);
        }

        &__body--fullscreen {
            width: theme('container.maxWidth');
            max-width: 100%;
            margin-left: auto;
            margin-right: auto;
        }

        &__body--small {
            width: theme('container.smallWidth', $(modal-size));
        }

        &__body--large {
            width: 100%;
        }

        &__body--aside {
            flex-grow: 1;
            overflow: auto;
            padding-top: theme('spacing.2', 0.5rem);
        }

        &__body--buttons {
            padding-bottom: theme('spacing.2', 0.5rem);
        }
    }
}
