/* ─────────────────────────────────────────────────────────────────────────
   MoreMarket animated login (users/login.blade.php)
   One page layer (#login-page: dusk construction backdrop, headline, worker,
   sign-in card) above a transition background (.mm-login-next). The worker
   pushes the page layer — js/login-scene.js (GSAP) moves it; this file only
   lays it out. Without GSAP nothing moves and a successful sign-in simply
   fades the page out (see "CSS fallback").
   ───────────────────────────────────────────────────────────────────────── */

.mm-login {
    --ml-red: #D92228;
    --ml-red-hover: #b20015;
    --ml-ink: #111827;
    --ml-muted: #6b7280;
    --ml-line: #e5e7eb;
    --ml-night: #0a101c;
    --ml-field: #eef3fb;
    --ml-focus: 0 0 0 3px rgba(217, 34, 40, .28);

    position: relative;
    isolation: isolate;
    overflow: hidden;
    display: flex;
    /* viewport minus the slim auth header + footer (minimal_chrome) */
    min-height: max(640px, calc(100vh - 140px));
    background: var(--ml-night);
}

/* ── Behind the page: the transition background ─────────────────────────── */
.mm-login-next {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}
.mm-login-next svg { display: block; width: 100%; height: 100%; }

.mm-login-next-status {
    position: absolute;
    left: 50%;
    top: 20%;
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    margin: 0;
    padding: .7rem 1.2rem;
    transform: translate(-50%, -50%);
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    background: rgba(10, 16, 28, .55);
    border-radius: 999px;
    opacity: 0;
    transition: opacity .35s ease;
}
.mm-login-next-status i { color: #4ade80; font-size: 1.15rem; }
.mm-login.is-leaving .mm-login-next-status { transition-delay: .75s; }
.mm-login[data-state="success"] .mm-login-next-status { opacity: 1; }

/* ── The page layer the worker pushes ───────────────────────────────────── */
.mm-login-page {
    position: relative;
    z-index: 1;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1.25rem;
    background: var(--ml-night);
}

/* While it is shoved away, its leading edge catches the light like the edge of a slab */
.mm-login-page::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 3;
    width: 5px;
    background: linear-gradient(180deg, rgba(255, 244, 214, .2), #fff7e6 45%, rgba(255, 244, 214, .2));
    box-shadow: 0 0 34px 10px rgba(255, 214, 150, .55);
    opacity: 0;
    transition: opacity .3s ease;
    pointer-events: none;
}
.mm-login.is-leaving .mm-login-page::before { opacity: 1; }
.mm-login.is-leaving .mm-login-page { box-shadow: -50px 0 90px rgba(0, 0, 0, .55); }

/* The worker is lifted in here for the final shove */
.mm-login-actors {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
}

/* ── Header logo: a little larger on the sign-in page (layout default 46px / 38px) ── */
body.login-page .mm-auth-header .container-xl { min-height: 76px; }
body.login-page .mm-auth-header img { height: 58px; }
@media (max-width: 575.98px) {
    body.login-page .mm-auth-header .container-xl { min-height: 64px; }
    body.login-page .mm-auth-header img { height: 46px; }
}

/* ── Backdrop ────────────────────────────────────────────────────────────── */
.mm-site-backdrop {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}
.mm-site-backdrop svg { display: block; width: 100%; height: 100%; }

.bd-beacon { animation: bd-beacon 1.6s steps(1, end) infinite; }
@keyframes bd-beacon { 50% { opacity: .15; } }

/* ── Stage: headline + worker | card ─────────────────────────────────────── */
.mm-login-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 1120px;
    display: grid;
    grid-template-columns: 1fr minmax(360px, 420px);
    align-items: center;
}

/* As tall as the card: the headline floats at the top, the worker stands at the bottom */
.mm-login-visual {
    position: relative;
    align-self: stretch;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-end;
    gap: 1.5rem;
    min-width: 0;
}

.mm-login-tagline {
    position: absolute;
    top: 3.25rem;
    left: 0;
    margin: 0;
    max-width: 22rem;
    font-size: .98rem;
    line-height: 1.55;
    color: rgba(255, 255, 255, .8);
}

.mm-login-tagline span {
    display: block;
    margin-bottom: .75rem;
    font-family: 'Poppins', 'Inter', system-ui, sans-serif;
    font-size: clamp(1.7rem, 2.6vw, 2.35rem);
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: .01em;
    text-transform: uppercase;
    color: #fff;
    max-width: 13ch;
}

/* The worker stands on the card's ground line, gloves level with its left edge */
.login-scene {
    width: min(318px, 100%);
    aspect-ratio: 300 / 400;
    margin-right: -4px;
}
.mm-worker { display: block; width: 100%; height: 100%; overflow: visible; }
.mm-worker .wk-eye-shut,
.mm-worker .wk-effort { opacity: 0; }

/* ── Right: form card ────────────────────────────────────────────────────── */
.mm-login-form-wrap {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 2.25rem 2.25rem 1.75rem;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 40px 90px -30px rgba(0, 0, 0, .7), 0 0 0 1px rgba(255, 255, 255, .06);
    transition: box-shadow .25s ease;
}
/* Pushed on: a red edge glow while he strains, brighter when the page refuses */
.mm-login-form-wrap.is-strained {
    box-shadow: 0 40px 90px -30px rgba(0, 0, 0, .7), 0 0 0 2px rgba(217, 34, 40, .35), -12px 0 40px -6px rgba(217, 34, 40, .45);
}
.mm-login-form-wrap.is-refused {
    box-shadow: 0 40px 90px -30px rgba(0, 0, 0, .7), 0 0 0 2px var(--ml-red), 0 0 60px 4px rgba(217, 34, 40, .55);
}

.mm-login-title {
    margin: 0 0 .3rem;
    font-size: 1.7rem;
    font-weight: 800;
    letter-spacing: -.02em;
    color: var(--ml-ink);
}

.mm-login-sub { margin: 0 0 1.5rem; font-size: .9rem; color: var(--ml-muted); }

.mm-login-form fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }

.mm-field { margin-bottom: 1rem; }

.mm-input-wrap { position: relative; }
.mm-input-icon {
    position: absolute;
    top: 50%;
    left: .95rem;
    transform: translateY(-50%);
    font-size: 1rem;
    color: #4b5563;
    pointer-events: none;
}

.mm-input {
    display: block;
    width: 100%;
    height: 48px;
    padding: 0 .9rem 0 2.7rem;
    font-size: .95rem;
    color: var(--ml-ink);
    background: var(--ml-field);
    border: 1px solid #d5deeb;
    border-radius: 8px;
    transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.mm-input::placeholder { color: #6b7280; }
.mm-input:focus { outline: none; background: #fff; border-color: var(--ml-ink); box-shadow: var(--ml-focus); }
.mm-input[aria-invalid="true"] { border-color: var(--ml-red); }
.mm-input:disabled { color: #6b7280; }

.mm-input-pw .mm-input { padding-right: 3rem; }
.mm-pw-toggle {
    position: absolute;
    top: 50%;
    right: 4px;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #4b5563;
    font-size: 1.1rem;
    cursor: pointer;
}
.mm-pw-toggle:hover { color: var(--ml-ink); background: rgba(17, 24, 39, .06); }
.mm-pw-toggle:focus-visible { outline: none; box-shadow: var(--ml-focus); color: var(--ml-ink); }

.mm-field-error { margin: .35rem 0 0; font-size: .8rem; color: var(--ml-red-hover); }

.mm-link-sm,
.mm-login-support a {
    font-size: .8rem;
    font-weight: 600;
    color: var(--ml-red);
    text-decoration: none;
    border-radius: 3px;
}
.mm-link-sm:hover,
.mm-login-support a:hover { color: var(--ml-red-hover); text-decoration: underline; }
.mm-link-sm:focus-visible,
.mm-login-support a:focus-visible { outline: none; box-shadow: var(--ml-focus); }

.mm-form-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: .2rem 0 1.25rem;
}
.mm-check { display: flex; align-items: center; gap: .55rem; }
.mm-check input {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--ml-red);
    cursor: pointer;
}
.mm-check input:focus-visible { outline: none; box-shadow: var(--ml-focus); border-radius: 4px; }
.mm-check label { font-size: .86rem; color: #374151; cursor: pointer; }

.mm-btn-primary,
.mm-btn-outline {
    width: 100%;
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .55rem;
    font-size: .95rem;
    font-weight: 700;
    border-radius: 8px;
    text-decoration: none;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}

/* Primary: a darker red sweeps in from the left on hover — the push, in miniature */
.mm-btn-primary {
    position: relative;
    overflow: hidden;
    isolation: isolate;
    color: #fff;
    background: var(--ml-red);
    border: 1px solid var(--ml-red);
}
.mm-btn-primary::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    background: var(--ml-red-hover);
    transform: translateX(-101%);
    transition: transform .35s cubic-bezier(.65, 0, .35, 1);
}
.mm-btn-primary:hover:not(:disabled)::before,
.mm-btn-primary:focus-visible::before { transform: translateX(0); }
.mm-btn-primary:focus-visible { outline: none; box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--ml-red); }
.mm-btn-primary:disabled { cursor: progress; opacity: .94; }

.mm-btn-spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, .4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: ml-spin .7s linear infinite;
}
.mm-btn-primary[aria-busy="true"] .mm-btn-spinner { display: inline-block; }
@keyframes ml-spin { to { transform: rotate(360deg); } }

.mm-btn-outline { color: var(--ml-ink); background: #fff; border: 1px solid #d1d5db; }
.mm-btn-outline:hover { border-color: var(--ml-ink); color: var(--ml-ink); background: #f9fafb; }
.mm-btn-outline:focus-visible { outline: none; box-shadow: var(--ml-focus); }

.mm-login-divider {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin: 1.4rem 0 .9rem;
    font-size: .78rem;
    color: var(--ml-muted);
}
.mm-login-divider::before,
.mm-login-divider::after { content: ''; flex: 1; height: 1px; background: var(--ml-line); }

.mm-login-support { margin: 1.25rem 0 0; font-size: .8rem; color: var(--ml-muted); text-align: center; }
.mm-login-support a { white-space: nowrap; }

.mm-login-alert {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    margin-bottom: 1.1rem;
    padding: .75rem .9rem;
    font-size: .86rem;
    color: #7f1d1d;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-left: 4px solid var(--ml-red);
    border-radius: 8px;
}
.mm-login-alert:focus { outline: none; }
.mm-login-alert i { color: var(--ml-red); margin-top: .1rem; }
.mm-login-alert-title { display: block; margin-bottom: .1rem; color: var(--ml-red-hover); }
/* Only without GSAP: with it, the whole page does the shaking */
.mm-login:not(.is-gsap) .mm-login-alert.is-shaking { animation: ml-shake .4s ease; }

@keyframes ml-shake {
    0%, 100% { transform: translateX(0); }
    25%      { transform: translateX(-6px); }
    75%      { transform: translateX(6px); }
}

/* ── CSS fallback (no GSAP): a confirmed sign-in fades the page away ────── */
.mm-login:not(.is-gsap)[data-state="success"] .mm-login-page {
    opacity: 0;
    transition: opacity .6s ease .2s;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 991.98px) {
    .mm-login-page { align-items: flex-start; padding-top: 1.5rem; }
    .mm-login-card { grid-template-columns: 1fr; max-width: 520px; }
    /* Compact scene: the worker stands on the card's top edge, the headline beside him */
    .mm-login-visual { flex-direction: row; align-items: flex-end; justify-content: flex-start; gap: 1rem; }
    .login-scene { order: -1; flex: none; width: 150px; margin: 0 0 -6px; }
    .mm-login-tagline { position: static; align-self: center; margin: 0; font-size: .9rem; }
    .mm-login-tagline span { font-size: 1.5rem; margin-bottom: .4rem; }
}

@media (max-width: 767.98px) {
    /* mobile.css reserves room for the bottom nav, which minimal_chrome pages don't render */
    body.login-page { padding-bottom: env(safe-area-inset-bottom) !important; }
    .mm-login { min-height: 0; }
    .mm-login-page { padding: .75rem 12px 1.5rem; }
    .login-scene { width: 108px; }
    .mm-login-visual { gap: .75rem; }
    .mm-login-tagline { font-size: .8rem; line-height: 1.45; }
    .mm-login-tagline span { font-size: 1.15rem; }
    .mm-login-form-wrap { padding: 1.6rem 1.15rem 1.4rem; border-radius: 14px; }
    .mm-login-title { font-size: 1.45rem; }
    .mm-login-sub { margin-bottom: 1.2rem; }
    /* 16px stops iOS zooming into focused inputs */
    .mm-input { font-size: 16px; }
    .mm-login-next-status { font-size: .9rem; top: 34%; }
}

@media (max-width: 359.98px) {
    .mm-form-row { flex-wrap: wrap; gap: .5rem; }
}

/* ── Reduced motion: no ambient or looping movement ──────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .bd-beacon { animation: none; }
    .mm-btn-primary::before { transition: none; }
    .mm-btn-spinner { animation-duration: 1.5s; }
    .mm-login .mm-login-alert.is-shaking { animation: none; }
    .mm-login-next-status { transition-delay: 0s !important; }
}
