.local-mathewplugin-nav {
    margin-inline: 0.5rem;
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
}

/* Ghost control: inherit the theme's ink without restyling its navigation. */
.local-mathewplugin-nav__button {
    --mathewplugin-icon-size: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border: 0;
    border-radius: 0.375rem;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.25rem;
    text-decoration: none;
    white-space: nowrap;
}

.local-mathewplugin-nav__button:hover,
.local-mathewplugin-nav__button:focus-visible {
    background: rgba(127, 127, 127, 0.12);
    color: inherit;
    text-decoration: none;
}

.local-mathewplugin-nav__button:active {
    background: rgba(127, 127, 127, 0.2);
}

.local-mathewplugin-nav__button:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.local-mathewplugin-nav[hidden],
.local-mathewplugin-menu-link[hidden] {
    display: none;
}

.local-mathewplugin-nav__icon {
    display: block;
    flex: 0 0 var(--mathewplugin-icon-size);
    width: var(--mathewplugin-icon-size);
    height: var(--mathewplugin-icon-size);
    fill: currentColor;
}

.local-mathewplugin-nav__label {
    white-space: nowrap;
}

.local-mathewplugin-menu-link {
    --mathewplugin-icon-size: 16px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.local-mathewplugin-sso--dashboard {
    max-width: 900px;
    /* Moodle 4.5 and 5.2 do not share a flex-gap utility. */
    gap: 1rem;
}

.local-mathewplugin-sso__copy {
    min-width: 0;
}

.local-mathewplugin-sso__dismiss {
    top: 0.5rem;
    inset-inline-end: 0.5rem;
}

.local-mathewplugin-sso__button {
    gap: 0.45rem;
}

.local-mathewplugin-setup-status {
    margin: 1rem 0;
}

.local-mathewplugin-setup-status__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
}

.local-mathewplugin-setup-status__item p {
    margin: 0.35rem 0 0;
}

.local-mathewplugin-setup-status__badge {
    margin-bottom: 0.45rem;
}

.local-mathewplugin-environment-field {
    margin-bottom: 1rem;
    width: min(100%, 32rem);
}

.local-mathewplugin-environment-field label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.local-mathewplugin-environment-select {
    width: 100%;
}

.local-mathewplugin-scope-field {
    margin-bottom: 1rem;
}

.local-mathewplugin-scope-field label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.local-mathewplugin-scope-select {
    width: min(100%, 640px);
}

.dropdown-menu .local-mathewplugin-action {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 1.5rem;
    white-space: nowrap;
}

.dropdown-menu .local-mathewplugin-action--activity {
    border-top: 1px solid #dee2e6;
}

.dropdown-menu .local-mathewplugin-action .icon {
    width: 1.125rem;
    height: 1.125rem;
    margin: 0;
    flex: 0 0 1.125rem;
    object-fit: contain;
}

/*
 * Mathew's expanded view remains a standard mod_lti embed. The body class is
 * added only for an exact Mathew module with an explicit expanded preference,
 * keeping every selector below isolated from unrelated Moodle pages and LTIs.
 */
body.local-mathewplugin-expanded-lti {
    --local-mathewplugin-lti-top: 0px;
}

body.local-mathewplugin-expanded-lti #page.drawers .main-inner,
body.local-mathewplugin-expanded-lti #page .main-inner {
    width: 100%;
    max-width: none;
    padding-top: 0;
    padding-right: 0;
    padding-left: 0;
}

/* The course index and navbar replace the redundant activity breadcrumb/title. */
body.local-mathewplugin-expanded-lti #page-header {
    display: none;
}

body.local-mathewplugin-expanded-lti #page-content,
body.local-mathewplugin-expanded-lti #region-main-box,
body.local-mathewplugin-expanded-lti #region-main {
    width: 100%;
    max-width: none;
    margin: 0;
    padding-right: 0;
    padding-left: 0;
}

body.local-mathewplugin-expanded-lti #page-content {
    padding-bottom: 0 !important;
}

body.local-mathewplugin-expanded-lti #region-main {
    border: 0;
    border-radius: 0;
}

body.local-mathewplugin-expanded-lti iframe.lti-iframe,
body.local-mathewplugin-expanded-lti iframe#contentframe,
body.local-mathewplugin-expanded-lti iframe[name="contentframe"] {
    display: block;
    width: 100% !important;
    height: calc(100vh - var(--local-mathewplugin-lti-top)) !important;
    border: 0;
}

@supports (height: 100dvh) {
    body.local-mathewplugin-expanded-lti iframe.lti-iframe,
    body.local-mathewplugin-expanded-lti iframe#contentframe,
    body.local-mathewplugin-expanded-lti iframe[name="contentframe"] {
        height: calc(100dvh - var(--local-mathewplugin-lti-top)) !important;
    }
}

@media (max-width: 767.98px) {
    .local-mathewplugin-sso__actions {
        width: 100%;
    }

    .local-mathewplugin-sso__button {
        width: 100%;
        justify-content: center;
    }

    .local-mathewplugin-nav {
        margin-left: 0.3rem;
    }

}
