/* Sign-in surface of the anonymous Razor Pages (Pages/Shared/_AuthLayout.cshtml).
   Layout: the large SCHEU logo on the left, the white card on the right in front of the SCHEU bars, the legal links
   at the bottom. Logo and card are centred vertically and every position scales with the viewport.
   On load the stage builds up: navy glow, the pale echo bars and the red bars wipe in along their diagonal, the logo
   assembles (letters rise one by one, the top bars glide in from the top right, the bottom bars from the bottom
   left), then the card rises. After that the bars drift slowly. Tokens come from portal-ui.css. */

.ff-auth-body {
    min-height: 100vh;
    margin: 0;
    background: #15263a;
    color: #fff;
    font-family: var(--sd-font-family);
}

.ff-auth {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(440px, 36vw);
    grid-template-rows: minmax(0, 1fr) auto;
    gap: var(--sd-space-6);
    min-height: 100vh;
    min-height: 100dvh;
    padding: clamp(24px, 3vw, 56px) clamp(24px, 6vw, 140px);
    overflow: hidden;
    background: linear-gradient(160deg, #22384e 0%, #15263a 100%);
}

/* ---------- Stage: glow and brand bars ---------- */

.ff-auth-stage {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

.ff-auth-stage::before {
    position: absolute;
    inset: 0;
    background: radial-gradient(70vw 60vh at 72% 45%, #2c4866 0%, rgba(44, 72, 102, 0) 70%);
    content: "";
    animation: ff-auth-glow 1.2s ease-out both;
}

.ff-auth-bars,
.ff-auth-echo {
    position: absolute;
    height: auto;
}

.ff-auth-echo {
    top: calc(50% - 12vh);
    right: -28vw;
    width: min(150vh, 120vw);
    fill: rgba(255, 255, 255, 0.045);
    animation:
        ff-auth-build 1.1s 0.15s cubic-bezier(0.65, 0, 0.35, 1) both,
        ff-auth-drift 18s 1.6s ease-in-out infinite alternate-reverse;
}

.ff-auth-bars {
    top: calc(50% - 30vh);
    right: -40vw;
    width: min(140vh, 110vw);
    filter: drop-shadow(0 4vh 6vh rgba(8, 16, 26, 0.45));
    animation:
        ff-auth-build 1.2s 0.4s cubic-bezier(0.65, 0, 0.35, 1) both,
        ff-auth-drift 14s 1.8s ease-in-out infinite alternate;
}

/* The bars appear with a diagonal wipe from the bottom-left corner, along the direction of the SCHEU bars. */
@keyframes ff-auth-build {
    from {
        clip-path: polygon(0 100%, 0 100%, 0 100%);
        transform: translate(-3vw, 3vw);
    }
    to {
        clip-path: polygon(0 100%, 0 -120%, 220% 100%);
        transform: none;
    }
}

@keyframes ff-auth-glow {
    from {
        opacity: 0;
    }
}

@keyframes ff-auth-drift {
    to {
        transform: translate(14px, -14px);
    }
}

/* ---------- Brand: the large logo assembles ---------- */

.ff-auth-brand {
    position: relative;
    z-index: 1;
    grid-column: 1;
    grid-row: 1;
    align-self: center;
    justify-self: start;
    display: inline-flex;
    color: #fff;
    border-radius: var(--sd-r-sm);
}

.ff-auth-brand svg {
    display: block;
    width: clamp(220px, 24vw, 560px);
    height: auto;
    overflow: visible;
}

.ff-auth-letter,
.ff-auth-mark {
    transform-box: fill-box;
    transform-origin: center;
}

.ff-auth-letter {
    animation: ff-auth-letter 0.6s calc(0.55s + var(--i) * 0.07s) var(--sd-ease) both;
}

.ff-auth-mark--top {
    animation: ff-auth-mark-top 0.8s 0.85s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.ff-auth-mark--bottom {
    animation: ff-auth-mark-bottom 0.8s 0.95s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes ff-auth-letter {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
}

@keyframes ff-auth-mark-top {
    from {
        opacity: 0;
        transform: translate(28px, -28px);
    }
}

@keyframes ff-auth-mark-bottom {
    from {
        opacity: 0;
        transform: translate(-28px, 28px);
    }
}

.ff-auth-brand:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 6px;
}

/* ---------- Card ---------- */

.ff-auth-main {
    position: relative;
    z-index: 1;
    grid-column: 2;
    grid-row: 1;
    display: grid;
    align-items: center;
    justify-items: center;
}

.ff-auth-panel {
    display: grid;
    gap: var(--sd-space-5);
    width: 440px;
    max-width: 100%;
    padding: 40px 40px 30px;
    border-radius: 20px;
    background: #fff;
    color: var(--sd-navy);
    box-shadow: 0 50px 100px rgba(6, 14, 24, 0.55);
    animation: ff-auth-card 0.8s 1.1s var(--sd-ease) both;
}

@keyframes ff-auth-card {
    from {
        opacity: 0;
        transform: translateY(18px);
    }
}


.ff-auth-heading h1 {
    margin: 0;
    color: var(--sd-navy);
    font-size: 1.875rem;
    font-weight: 500;
    letter-spacing: -0.02em;
    line-height: 1.15;
}

.ff-auth-heading p {
    margin: 10px 0 0;
    color: var(--sd-ink);
    font-size: var(--sd-fs-md);
}

.ff-auth-panel > .alert {
    margin: 0;
}

/* ---------- Legal links ---------- */

.ff-auth-legal {
    position: relative;
    z-index: 1;
    display: flex;
    flex-wrap: wrap;
    gap: var(--sd-space-2) 22px;
    grid-column: 1 / -1;
    grid-row: 2;
    font-size: var(--sd-fs-sm);
    animation: ff-auth-glow 0.6s 1.4s ease-out both;
}

.ff-auth-legal a {
    color: #c9d4df;
    text-decoration: none;
}

.ff-auth-legal a:hover {
    color: #fff;
    text-decoration: underline;
}

.ff-auth-legal a:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 3px;
}

/* ---------- Form ---------- */

.ff-auth-form {
    display: grid;
    gap: var(--sd-space-4);
}

.ff-auth-password .form-control {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.ff-auth-password .btn {
    min-width: 44px;
    border: 0;
    border-radius: 0 var(--sd-r-md) var(--sd-r-md) 0;
    background: var(--sd-fill);
    color: var(--sd-muted);
}

.ff-auth-password .btn:hover {
    background: var(--sd-fill-2);
    color: var(--sd-navy);
}

.ff-auth-code {
    font-size: var(--sd-fs-lg);
    letter-spacing: 0.3em;
}

.ff-auth-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--sd-space-2) var(--sd-space-4);
}

.ff-auth-row .form-check {
    margin: 0;
}

.ff-auth-consents {
    display: grid;
    gap: var(--sd-space-2);
}

.ff-auth-consents .form-check {
    margin: 0;
}

.ff-auth-consents .form-check-label {
    font-size: var(--sd-fs-sm);
}

.ff-auth-form .form-check-input:checked {
    border-color: var(--sd-navy);
    background-color: var(--sd-navy);
}

.ff-auth-submit {
    margin-top: var(--sd-space-1);
    font-size: var(--sd-fs-md);
}

.ff-auth-field-error,
.ff-auth-errors {
    color: var(--sd-rose-ink);
    font-size: var(--sd-fs-sm);
}

.ff-auth-field-error:empty,
.ff-auth-errors.validation-summary-valid {
    display: none;
}

.ff-auth-errors ul {
    margin: 0;
    padding: 12px 16px 12px 32px;
    border-radius: var(--sd-r-card);
    background: var(--sd-rose);
}

.validation-error {
    white-space: pre-wrap;
    word-wrap: break-word;
}

.ff-auth-key {
    display: grid;
    gap: var(--sd-space-1);
    padding: 14px 16px;
    border-radius: var(--sd-r-card);
    background: var(--sd-fill);
}

.ff-auth-key span {
    color: var(--sd-muted);
    font-size: var(--sd-fs-sm);
    font-weight: 500;
}

.ff-auth-key code {
    color: var(--sd-navy);
    font-size: var(--sd-fs-md);
    letter-spacing: 0.08em;
    overflow-wrap: anywhere;
}

/* ---------- Secondary row ---------- */

.ff-auth-alt {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--sd-space-2) var(--sd-space-3);
    padding-top: var(--sd-space-4);
    border-top: 1px solid var(--sd-line);
    color: var(--sd-ink);
    font-size: var(--sd-fs-sm);
}

.ff-auth-dev {
    padding-top: var(--sd-space-4);
    border-top: 1px dashed var(--sd-line-2);
}

/* ---------- Smaller screens ---------- */

@media (max-width: 991.98px) {
    .ff-auth {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto minmax(0, 1fr) auto;
        gap: var(--sd-space-5);
    }

    .ff-auth-brand {
        grid-row: 1;
    }

    .ff-auth-brand svg {
        width: 140px;
    }

    .ff-auth-main {
        grid-column: 1;
        grid-row: 2;
    }

    .ff-auth-legal {
        grid-row: 3;
    }

    .ff-auth-legal {
        justify-content: center;
    }

    .ff-auth-echo {
        display: none;
    }

    /* The bars are wider than the screen here. As an element they would cross the viewport edge, so the stage
       paints them as a clipped background with the same gradient, shadow, build-up and drift. */
    .ff-auth-bars {
        display: none;
    }

    .ff-auth-stage::after {
        position: absolute;
        inset: 0;
        content: "";
        background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 72.98 22.55'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' y1='1' x2='1' y2='0'%3E%3Cstop offset='0' stop-color='%23f01422'/%3E%3Cstop offset='.55' stop-color='%23e30613'/%3E%3Cstop offset='1' stop-color='%23a8040d'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cg fill='url(%23g)'%3E%3Cpath d='M0 22.55 22.71 0h11.03L11.02 22.55Z'/%3E%3Cpath d='M17.04 22.55 39.75 0h33.23L50.1 22.55Z'/%3E%3C/g%3E%3C/svg%3E") no-repeat 0 2vh / 220vw auto;
        filter: drop-shadow(0 4vh 6vh rgba(8, 16, 26, 0.45));
        animation:
            ff-auth-build 1.2s 0.4s cubic-bezier(0.65, 0, 0.35, 1) both,
            ff-auth-drift 14s 1.8s ease-in-out infinite alternate;
    }
}

@media (max-width: 575.98px) {
    .ff-auth {
        padding: max(24px, env(safe-area-inset-top)) max(var(--sd-gutter), env(safe-area-inset-right))
                 max(24px, env(safe-area-inset-bottom)) max(var(--sd-gutter), env(safe-area-inset-left));
    }

    .ff-auth-main {
        justify-items: stretch;
    }

    .ff-auth-panel {
        width: 100%;
        padding: 28px 20px 22px;
    }

    .ff-auth-heading h1 {
        font-size: 1.625rem;
    }
}

/* Reduced motion: no wipe, no drift, no rise, the logo does not move. Stage, logo, card and links only fade in. */
@media (prefers-reduced-motion: reduce) {
    .ff-auth-stage::before,
    .ff-auth-echo,
    .ff-auth-bars,
    .ff-auth-letter,
    .ff-auth-mark,
    .ff-auth-panel,
    .ff-auth-legal,
    .ff-auth-stage::after {
        animation: sd-fade 0.3s ease both !important;
    }
}

/* Touch screens: the links of the card and the legal links are at least 44 px high. */
@media (pointer: coarse) {
    .ff-auth-panel .sd-link,
    .ff-auth-legal a {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
    }

    .ff-auth-legal {
        gap: 0 22px;
    }
}
