/* Loaded only for the RemUI login page. The existing Moodle forms remain intact. */
body#page-login-index {
    isolation: isolate;
    background: radial-gradient(ellipse at 8% 12%, rgba(134, 105, 204, .35), transparent 50%),
        radial-gradient(ellipse at 94% 80%, rgba(115, 84, 183, .3), transparent 50%), #241a3d !important;
}

/* Code-native artwork also works without JavaScript; it never intercepts a click. */
body#page-login-index::before,
body#page-login-index::after {
    content: "";
    position: fixed;
    z-index: 0;
    pointer-events: none;
}

body#page-login-index::before {
    inset: -24px;
    background: url("pix/login-constellation.svg") center / cover no-repeat;
    opacity: .8;
    transform: translate3d(var(--capsha-shift-x, 0px), var(--capsha-shift-y, 0px), 0);
    transition: transform .65s cubic-bezier(.2, .7, .2, 1);
}

body#page-login-index::after {
    top: 0;
    left: 0;
    width: 560px;
    height: 560px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(184, 156, 239, .16), transparent 68%);
    opacity: 0;
    transform: translate3d(calc(var(--capsha-pointer-x, 50vw) - 50%), calc(var(--capsha-pointer-y, 50vh) - 50%), 0);
    transition: opacity .4s ease;
}

body#page-login-index.capsha-login-pointer-active::after {
    opacity: 1;
}

body#page-login-index #page-wrapper {
    position: relative;
    z-index: 1;
}

body#page-login-index #page-wrapper,
body#page-login-index #page,
body#page-login-index #page-content,
body#page-login-index #region-main-box,
body#page-login-index #region-main {
    background: transparent !important;
}

body#page-login-index .login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 24px;
    width: 100%;
    height: auto !important;
    min-height: 100vh;
    min-height: 100svh;
    padding: clamp(20px, 4vw, 56px);
    box-sizing: border-box;
}

body#page-login-index .login-container {
    position: relative !important;
    inset: auto !important;
    width: 100% !important;
    max-width: 480px !important;
    flex: 0 0 auto;
    order: 1 !important;
    align-self: center;
    padding: clamp(24px, 3.5vw, 44px) !important;
    margin: 20px auto !important;
    border: 1px solid #e7e1f1;
    border-radius: 24px !important;
    background: #fff !important;
    box-shadow: 0 28px 90px rgba(12, 6, 28, .28), 0 3px 12px rgba(12, 6, 28, .12);
    color: #231d35;
    overflow: visible !important;
    animation: none !important;
    box-sizing: border-box;
}

body#page-login-index .login-container::before {
    content: "";
    position: absolute;
    inset: 0 32px auto;
    height: 3px;
    border-radius: 0 0 4px 4px;
    background: linear-gradient(90deg, #5a49a8, #b3a1e2);
}

body#page-login-index .login-container .logo-area {
    display: flex;
    position: static;
    justify-content: center;
    margin-bottom: 24px;
    padding: 0;
}

body#page-login-index .login-container .logo-area img {
    max-width: 100%;
    max-height: 64px;
    object-fit: contain;
}

body#page-login-index .loginform {
    display: flex;
    flex-direction: column;
    gap: 24px !important;
    min-width: 0;
    overflow-wrap: anywhere;
}

body#page-login-index .login-welcome-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px !important;
    padding-bottom: 5px;
    text-align: center !important;
}

body#page-login-index .login-welcome-wrapper h1,
body#page-login-index .login-welcome-wrapper h2 {
    width: 100%;
    margin: 0;
    color: #231d35;
    font-size: clamp(1.5rem, 2.6vw, 1.95rem);
    font-weight: 750;
    line-height: 1.2;
    letter-spacing: -.035em;
    text-wrap: balance;
}

/* Hide the legacy introductory sentence before progressive enhancement finishes. */
body#page-login-index .login-welcome-wrapper > p {
    display: none;
}

body#page-login-index .capsha-login-brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: #5a49a8;
    max-width: 100%;
    font-size: .61rem;
    font-weight: 750;
    line-height: 1.5;
    letter-spacing: .11em;
    text-transform: uppercase;
}

body#page-login-index .capsha-login-brand::before,
body#page-login-index .capsha-login-brand::after {
    content: "";
    flex: 0 0 14px;
    height: 2px;
    background: currentColor;
}

body#page-login-index .login-container .login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin: 0;
}

body#page-login-index .login-form .form-group {
    margin: 0;
}

body#page-login-index .login-form label:not(.sr-only):not(.visually-hidden) {
    display: block;
    margin-bottom: 9px;
    color: #443b55;
    font-size: .83rem;
    font-weight: 650;
    line-height: 1.5;
}

body#page-login-index .login-form .form-control {
    width: 100%;
    max-width: 100%;
    min-height: 54px;
    padding: 14px 16px;
    border: 1px solid #dcd5e7;
    border-radius: 10px;
    background: #fbfafd;
    color: #231d35;
    box-shadow: none;
    font: inherit;
    font-size: .95rem;
    box-sizing: border-box;
    transition: border-color .2s ease, box-shadow .2s ease;
}

body#page-login-index .login-form .form-control:focus {
    border-color: #5a49a8;
    background: #fff;
    outline: 3px solid rgba(90, 73, 168, .16);
    outline-offset: 1px;
}

body#page-login-index .login-form .password-field-eye input {
    padding-inline-end: 48px;
}

body#page-login-index .login-form .show-password-icon {
    top: 17px;
    right: auto;
    inset-inline-end: 16px;
    color: #6a6178;
}

body#page-login-index .login-form-forgotpassword {
    text-align: end;
}

body#page-login-index .login-form-forgotpassword a {
    color: #514092;
    font-size: .8rem;
    font-weight: 650;
    text-underline-offset: 4px;
}

body#page-login-index .login-container #loginbtn {
    width: 100%;
    min-height: 54px;
    border: 1px solid #5a49a8;
    border-radius: 10px;
    background: #5a49a8;
    color: #fff;
    box-shadow: 0 5px 16px rgba(90, 73, 168, .18);
    font: inherit;
    font-size: .95rem;
    font-weight: 700;
    transition: background .2s ease, box-shadow .2s ease;
}

body#page-login-index .login-container #loginbtn:hover:not(:disabled) {
    border-color: #443385;
    background: #443385;
    box-shadow: 0 8px 22px rgba(90, 73, 168, .24);
}

body#page-login-index .login-container a:focus-visible,
body#page-login-index .login-container button:focus-visible {
    outline: 3px solid #9a83d7;
    outline-offset: 4px;
}

body#page-login-index .login-identityproviders {
    padding-top: 24px;
    border-top: 1px solid #e7e1f1;
}

body#page-login-index .login-identityproviders .login-heading,
body#page-login-index .capsha-login-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px !important;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

body#page-login-index .login-identityprovider-btn-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 12px !important;
}

body#page-login-index a.login-identityprovider-btn {
    display: inline-flex;
    flex: 1 1 150px;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-width: 0;
    min-height: 50px;
    padding: 12px 16px;
    border: 1px solid #dcd5e7 !important;
    border-radius: 10px;
    background: #fff;
    color: #443b55;
    font-size: .85rem;
    font-weight: 650;
    text-decoration: none;
    box-sizing: border-box;
}

body#page-login-index a.login-identityprovider-btn:hover {
    border-color: #a494cc !important;
    background: #f7f4fc;
}

body#page-login-index .login-identityprovider-btn img {
    flex: 0 0 24px;
    object-fit: contain;
}

body#page-login-index .capsha-login-provider-guide {
    display: flex;
    flex: 1 1 150px;
    flex-direction: column;
    align-items: stretch;
    min-width: 0;
}

body#page-login-index .capsha-login-provider-guide > .login-identityprovider-btn {
    flex: 0 0 auto;
    width: 100%;
}

body#page-login-index .capsha-login-help-link {
    align-self: center;
    max-width: 100%;
    min-height: 44px;
    padding: 8px 4px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: #514092;
    font: inherit;
    font-size: .78rem;
    font-weight: 600;
    line-height: 1.5;
    text-align: center;
    text-decoration: underline;
    text-underline-offset: 4px;
    white-space: normal;
    cursor: pointer;
}

body#page-login-index .capsha-login-help-link:hover {
    color: #382671;
}

body#page-login-index .capsha-login-help-link:disabled {
    cursor: progress;
    opacity: .7;
}

body#page-login-index .capsha-login-help-error {
    margin: 0;
    color: #9a2634;
    font-size: .8rem;
    line-height: 1.5;
    text-align: center;
}

/* Scope the guide to its native Moodle modal, leaving other RemUI dialogs untouched. */
body#page-login-index .capsha-login-guide-modal .modal-dialog {
    width: calc(100% - 32px);
    max-width: 680px;
    margin: 24px auto;
    height: auto;
    max-height: calc(100vh - 48px);
    max-height: calc(100dvh - 48px);
}

body#page-login-index .capsha-login-guide-modal .modal-content {
    max-height: calc(100vh - 48px);
    max-height: calc(100dvh - 48px);
    border: 1px solid #e7e1f1;
    border-radius: 20px;
    background: #fff;
    color: #231d35;
    box-shadow: 0 24px 80px rgba(12, 6, 28, .25);
    overflow: hidden;
}

body#page-login-index .capsha-login-guide-modal .modal-header,
body#page-login-index .capsha-login-guide-modal .modal-footer {
    flex-shrink: 0;
    padding: 18px clamp(18px, 4vw, 28px);
    border-color: #e7e1f1;
    background: #fff;
}

body#page-login-index .capsha-login-guide-modal .modal-title {
    flex: 1;
    min-width: 0;
    color: #231d35;
    font-size: clamp(1.15rem, 3vw, 1.45rem);
    font-weight: 750;
    line-height: 1.3;
    letter-spacing: -.025em;
    white-space: normal;
    overflow: visible;
    text-wrap: balance;
}

body#page-login-index .capsha-login-guide-modal .modal-header {
    align-items: center;
    justify-content: space-between;
}

body#page-login-index .capsha-login-guide-modal .modal-header [data-action="hide"] {
    flex-shrink: 0;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    margin-inline-start: 12px;
    color: #514092;
    opacity: 1;
}

body#page-login-index .capsha-login-guide-modal .modal-body {
    padding: 24px clamp(18px, 4vw, 28px);
    overflow-y: auto;
    overscroll-behavior: contain;
}

body#page-login-index .capsha-login-guide {
    font-size: .92rem;
    line-height: 1.65;
    overflow-wrap: anywhere;
}

body#page-login-index .capsha-guide-intro {
    margin: 0 0 22px;
    color: #60566f;
}

body#page-login-index .capsha-guide-steps {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

body#page-login-index .capsha-guide-steps li {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 18px;
    border: 1px solid #ebe5f4;
    border-radius: 14px;
    background: #faf8fd;
}

body#page-login-index .capsha-guide-steps li > div {
    min-width: 0;
}

body#page-login-index .capsha-guide-number {
    display: inline-flex;
    flex: 0 0 30px;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #5a49a8;
    color: #fff;
    font-size: .8rem;
    font-weight: 700;
}

body#page-login-index .capsha-guide-steps h3 {
    margin: 2px 0 7px;
    color: #302644;
    font-size: .96rem;
    font-weight: 700;
    line-height: 1.5;
}

body#page-login-index .capsha-guide-steps p {
    margin: 0;
    color: #53495f;
}

body#page-login-index .capsha-guide-note {
    margin: 20px 0 0;
    padding-inline-start: 14px;
    border-inline-start: 3px solid #a18acb;
    color: #60566f;
    font-size: .83rem;
}

body#page-login-index .capsha-login-guide-modal .capsha-guide-close {
    min-height: 44px;
    min-width: 100px;
    border: 1px solid #5a49a8;
    border-radius: 9px;
    background: #5a49a8;
    color: #fff;
    font-weight: 650;
}

body#page-login-index .capsha-login-guide-modal .capsha-guide-close:hover {
    background: #443385;
    border-color: #443385;
}

body#page-login-index .capsha-login-guide-modal .modal-body:focus-visible {
    outline: 3px solid #9a83d7;
    outline-offset: -4px;
}

body#page-login-index .capsha-login-guide-modal button:focus-visible {
    outline: 3px solid #9a83d7;
    outline-offset: 3px;
}

@media (max-width: 420px) {
    body#page-login-index .capsha-guide-steps li {
        gap: 10px;
        padding: 14px 12px;
    }
}

body#page-login-index .login-instructions,
body#page-login-index .login-signup,
body#page-login-index .login-container #guestlogin {
    font-size: .88rem;
    line-height: 1.7;
    color: #60566f;
}

body#page-login-index .login-container .btn-secondary {
    min-height: 48px;
    border: 1px solid #dcd5e7;
    border-radius: 10px;
    background: #f7f4fc;
    color: #514092;
    white-space: normal;
}

body#page-login-index .cookies-section {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px 20px !important;
    padding: 20px 0 0;
    border-top: 1px solid #e7e1f1;
    font-size: .75rem;
}

body#page-login-index .capsha-login-registration {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 20px;
    border: 1px solid #e7e1f1;
    border-radius: 14px;
    background: #f8f6fc;
    text-align: center;
}

body#page-login-index .capsha-login-registration-prompt {
    margin: 0;
    color: #60566f;
    font-size: .85rem;
    line-height: 1.6;
}

body#page-login-index .login-container .capsha-login-registration-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 48px;
    padding: 12px 16px;
    border: 1px solid #b7a8d8;
    border-radius: 10px;
    background: #fff;
    color: #514092;
    font-size: .9rem;
    font-weight: 700;
    line-height: 1.5;
    white-space: normal;
    text-decoration: none;
    box-sizing: border-box;
    transition: background .2s ease, border-color .2s ease, box-shadow .2s ease;
}

body#page-login-index .login-container .capsha-login-registration-link:hover {
    border-color: #5a49a8;
    background: #f0ebf8;
    color: #443385;
    box-shadow: 0 3px 12px rgba(90, 73, 168, .1);
}

body#page-login-index .cookies-section > a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    color: #514092;
}

body#page-login-index .login-description-container {
    position: relative !important;
    inset: auto !important;
    width: 100% !important;
    max-width: 500px;
    max-height: none;
    order: 2;
    padding: 24px;
    text-align: center;
    overflow: visible;
    box-sizing: border-box;
}

body#page-login-index .login-description-content {
    color: #f4effb !important;
}

body#page-login-index .login-description-content :is(h1, h2, h3, p) {
    color: inherit;
}

@media (max-width: 800px) {
    body#page-login-index .login-wrapper {
        gap: 16px;
        padding: 20px 16px;
    }

    body#page-login-index::before {
        background-position: 15% center;
    }
}

@media (prefers-reduced-motion: reduce) {
    body#page-login-index::before,
    body#page-login-index::after,
    body#page-login-index .login-container * {
        animation: none !important;
        transition: none !important;
    }
}

@media (hover: none), (pointer: coarse), (prefers-reduced-motion: reduce) {
    body#page-login-index::before {
        transform: none;
    }

    body#page-login-index::after {
        display: none;
    }
}

@media (forced-colors: active) {
    body#page-login-index::before,
    body#page-login-index::after {
        display: none;
    }
}
