/*
 * Sign-in intro (L1c). The overlay exists only when the server allowed it and is shown ONLY under html.rm-intro (set by js/auth-intro.js).
 * The timeline stays paused on its static first frame until the script adds html.rm-intro-go (DOMContentLoaded + fonts, capped), so the hold is not eaten by loading.
 * Only transform / opacity / clip-path are animated; the real page underneath never moves. Colours: the band tokens from appkit.css (they follow --rm-accent).
 *
 * TUNING: the two blocks right below (mobile, then desktop) are the ONLY places with the timing. hold = the still moment, move = the travel.
 * Total = hold + move. js/auth-intro.js reads both from the computed style for its safety timeout (hold + move + 700ms), so nothing else needs to change.
 */
html.rm-intro {
    --rm-intro-hold: 600ms;   /* MOBILE hold */
    --rm-intro-move: 1100ms;  /* MOBILE move */
    --rm-intro-in: 450ms;     /* the content's gentle fade/rise-in, inside the hold (keep <= hold) */
    --rm-intro-ease: cubic-bezier(.65, 0, .35, 1);   /* ease-in-out for all movement */
}

@media (min-width: 760px) {
    html.rm-intro {
        --rm-intro-hold: 700ms;   /* DESKTOP hold */
        --rm-intro-move: 1300ms;  /* DESKTOP move */
    }
}

/* Later loads in the same tab (refresh, back/forward, revisit): the short version, set by js/auth-intro.js. Same on mobile and desktop. */
html.rm-intro.rm-intro-short {
    --rm-intro-hold: 0ms;     /* SHORT hold */
    --rm-intro-move: 500ms;   /* SHORT move */
    --rm-intro-in: 0ms;
}

.auth-intro {
    display: none;
    pointer-events: none;
}

/* ---------- Mobile: a full-screen splash shrinks into the top band ---------- */
html.rm-intro .auth-intro {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 200;
    overflow: hidden;
    color: #fff;
    background: linear-gradient(160deg, var(--auth-band-a), var(--auth-band-b));
    pointer-events: none;
    animation: rm-intro-m var(--rm-intro-move) var(--rm-intro-ease) var(--rm-intro-hold) both;
}

html.rm-intro .auth-intro-bg {
    display: none;
}

html.rm-intro .auth-intro-inner {
    padding: calc(22px + env(safe-area-inset-top)) 22px 0;
    animation: rm-intro-m-in var(--rm-intro-move) var(--rm-intro-ease) var(--rm-intro-hold) both;
}

html.rm-intro .auth-intro-content {
    animation: rm-intro-rise var(--rm-intro-in) ease-out both;
}

/* --rm-intro-band is the measured band edge (js/auth-intro.js); 170px is the last-resort fallback. */
@keyframes rm-intro-m {
    0% { clip-path: inset(0 0 0 0); opacity: 1; }
    85% { opacity: 1; }
    100% { clip-path: inset(0 0 calc(100% - var(--rm-intro-band, 170px)) 0); opacity: 0; }
}

@keyframes rm-intro-m-in {
    from { transform: translateY(22vh); }
    to { transform: none; }
}

@keyframes rm-intro-rise {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: none; }
}

/*
 * ---------- Desktop: a solid panel covers the whole shell, holds, then slides left into the resting 46% band ----------
 * Three layers, all moved by transform, so it is a panel sliding and not a wipe: the panel (.auth-intro-bg, full shell width, its right edge travels from 100% to 46%),
 * the content (.auth-intro-inner, from centred to its resting left spot at the same speed, so it stays centred in the shrinking panel), and the form behind (fades in over the last 40% of the move).
 * 46% / 54% are the panel's own flex bases in appkit.css (.auth-band 46%, .auth-main 54%; border-box everywhere, no gap, so the split is exact).
 * The content starts centred: (54% / 2) / 46% = 58.7% of its own width.
 */
@media (min-width: 760px) {
    .auth-shell {
        position: relative;
    }

    html.rm-intro .auth-intro {
        position: absolute;
        background: none;
        animation: rm-intro-fade calc(var(--rm-intro-move) * .12) linear calc(var(--rm-intro-hold) + var(--rm-intro-move) * .88) both;
    }

    html.rm-intro .auth-intro-bg {
        display: block;
        position: absolute;
        inset: 0;
        background: linear-gradient(160deg, var(--auth-band-a), var(--auth-band-b));
        animation: rm-intro-d-bg var(--rm-intro-move) var(--rm-intro-ease) var(--rm-intro-hold) both;
    }

    html.rm-intro .auth-intro-inner {
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        width: 46%;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        justify-content: center;
        padding: 40px;
        animation: rm-intro-d-in var(--rm-intro-move) var(--rm-intro-ease) var(--rm-intro-hold) both;
    }

    html.rm-intro .auth-main {
        animation: rm-intro-d-form calc(var(--rm-intro-move) * .4) ease-out calc(var(--rm-intro-hold) + var(--rm-intro-move) * .6) both;
    }
}

@keyframes rm-intro-fade {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes rm-intro-d-bg {
    from { transform: none; }
    to { transform: translateX(-54%); }
}

@keyframes rm-intro-d-in {
    from { transform: translateX(58.7%); }
    to { transform: none; }
}

@keyframes rm-intro-d-form {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Waiting for the page to be visually ready: the first frame stays still. */
html.rm-intro:not(.rm-intro-go) .auth-intro,
html.rm-intro:not(.rm-intro-go) .auth-intro *,
html.rm-intro:not(.rm-intro-go) .auth-main {
    animation-play-state: paused;
}

@media (prefers-reduced-motion: reduce) {
    html.rm-intro .auth-intro {
        display: none;
    }

    html.rm-intro .auth-main {
        animation: none;
    }
}
