/*
 * estate-motion.css: the one motion layer for the UmmahPass estate shell (Nov 3 2026). It loads last.
 *
 * What moves: the sign-in tab pill, the busy swap on a submit button, an error that settles in, a press,
 * a 2px hover lift with a fine pointer, one arrival fade per page, and the welcome next steps.
 * How: transform and opacity only, 100 to 250 ms, one ease-out curve (the --es-ease value in estate-shell.css).
 * What never moves: money (the payment confirmation moves once, an opacity fade, and nothing else; billing and
 * membership not at all), Arabic or any sacred text, the password field, the passkey button, anything typed,
 * and anything the keyboard drives. No shake, no bounce, no scale-in. The only loop is the busy ring, and only
 * while a request is in flight.
 *
 * Sacred text guard: every broad selector below carries :not(...) or :not(:has(...)) for [lang|="ar"] and
 * .font-arabic. A browser without :has() drops those rules whole, so the fallback is "nothing moves".
 */

/* ── 1. One owner. Colour, border and shadow changes are instant on these pages. Every inherited transition
      (Tailwind utilities, the old stylesheet, Alpine's inline ones) is switched off; each move below names
      its own property with !important so it is the only thing that runs. ── */
html body.v2-default *,html body.v2-default ::before,html body.v2-default ::after,
html body.es-body *,html body.es-body ::before,html body.es-body ::after,
html body.es-welcome *,html body.es-welcome ::before,html body.es-welcome ::after{transition-property:none!important}

/* The old sign-in entrance (card rise, seven staggered fields, logo) and the old welcome entrances
   (fadeUp, scaleIn, the claim-card shimmer) are retired. One authored moment per page, set below. */
html body.v2-default .auth-card,html body.v2-default .animate-field,html body.v2-default .logo-animate,
html body.es-welcome .page,html body.es-welcome .page *,
html body.es-welcome .page ::before,html body.es-welcome .page ::after{animation:none!important}

/* Old hover and press shifts that would now jump without a transition. */
html body.v2-default .btn-gold:active,
html body.es-welcome .enter-city-btn:hover,html body.es-welcome .upgrade-strip-btn:hover,
html body.es-welcome .upgrade-cta:hover,html body.es-welcome .v2-ue-next-card:hover{transform:none}

/* The busy ring holds still unless a request is in flight. */
html body.v2-default .btn-spinner{animation:none}

@keyframes es-fade{from{opacity:0}}
@keyframes es-rise{from{opacity:0;transform:translateY(8px)}}
@keyframes es-spin{to{transform:rotate(1turn)}}

@media (prefers-reduced-motion:no-preference){

  /* ── 2. Sign-in tabs: the pill slides under the chosen label, 150 ms. A keyboard choice jumps. ── */
  html body.v2-default .es-tabs::before{transition:transform 150ms cubic-bezier(.2,.8,.2,1)!important}
  html body.v2-default .es-tabs:has(:focus-visible)::before{transition:none!important}

  /* ── 3. Submit: label and busy line cross-fade in one grid cell (no layout shift). The ring turns only while busy. ── */
  html body.v2-default .es-submit>span{transition:opacity 160ms cubic-bezier(.2,.8,.2,1)!important}
  html body.v2-default .es-submit.is-loading .btn-spinner{animation:es-spin 700ms linear infinite}

  /* ── 4. An error settles in: opacity and 4px, 200 ms, once. Never a shake. ── */
  html body.v2-default .es-alert:not(:has([lang|="ar"],.font-arabic)){transition:opacity 200ms cubic-bezier(.2,.8,.2,1),transform 200ms cubic-bezier(.2,.8,.2,1)!important}
  @starting-style{
    html body.v2-default .es-alert:not(:has([lang|="ar"],.font-arabic)){opacity:0;transform:translateY(4px)}
  }

  /* ── 5. Press: scale(0.97) in 100 ms, released in 160 ms. Pointer only: a keyboard press (:focus-visible)
        does not move. Not on the payment confirmation, billing or membership (they carry no hook class here),
        and not on the passkey button. ── */
  html body.v2-default :is(.btn-gold,.btn-primary,button[type="submit"],.social-btn,.es-btn):not(#passkey-login-btn),
  html body.es-body:not(.es-remap) .es-btn,
  html body.es-body:not(.es-remap) .es-switch-track,
  html body.es-welcome :is(.v2-ue-next-card,.action-btn,.action-btn-ghost,.enter-city-btn):not(:has([lang|="ar"],.font-arabic)){transition:transform 160ms cubic-bezier(.2,.8,.2,1)!important}

  html body.v2-default :is(.btn-gold,.btn-primary,button[type="submit"],.social-btn,.es-btn):not(#passkey-login-btn):active:not(:focus-visible):not(:disabled),
  html body.es-body:not(.es-remap) .es-btn:active:not(:focus-visible):not(:disabled),
  html body.es-body:not(.es-remap) .es-switch:active:not(:has(input:focus-visible)) .es-switch-track,
  html body.es-welcome :is(.v2-ue-next-card,.action-btn,.action-btn-ghost,.enter-city-btn):not(:has([lang|="ar"],.font-arabic)):active:not(:focus-visible){transform:scale(.97);transition-duration:100ms!important}

  /* Hover lift, 2px, only with a mouse or trackpad, only on primary buttons and on cards that are links.
     Not on error pages (calm), not on money pages. Kept less specific than the press, so a press wins. */
  @media (hover:hover) and (pointer:fine){
    html body.v2-default :where(.btn-gold,.btn-primary,button[type="submit"]:not(.btn-secondary):not(.btn-ghost)):not(#passkey-login-btn):not(:disabled):hover,
    html body.es-body:has(.es-panel--consent,.es-panel--prefs) .es-btn--primary:hover,
    html body.es-welcome a.v2-ue-next-card:not(:has([lang|="ar"],.font-arabic)):hover{transform:translateY(-2px)}
  }

  /* ── 6. Email preference switch: the knob slides 150 ms under a pointer; a keyboard toggle jumps.
        The track colour changes at once (estate-shell.css). ── */
  html body.es-body .es-switch-track::after{transition:transform 150ms cubic-bezier(.2,.8,.2,1)!important}
  html body.es-body .es-switch input:focus-visible+.es-switch-track::after{transition:none!important}

  /* ── 7. Arrival, once per page. Opacity only, 200 ms: error and status pages, email preferences, and the
        payment confirmation (its one permitted move). The consent screen is quicker, 150 ms.
        "backwards" fill: the from-frame holds only before the start; once done, the rule lets go, and a
        browser without animation support shows the panel at once. Nothing starts hidden in plain CSS. ── */
  html body.es-body .es-enter:not(:has([lang|="ar"],.font-arabic)){animation:es-fade 200ms cubic-bezier(.2,.8,.2,1) backwards}
  html body.es-body .es-panel--consent.es-enter:not(:has([lang|="ar"],.font-arabic)){animation-duration:150ms}

  /* ── 8. /welcome next steps: each card rises 8px and fades in, 250 ms, 40 ms apart, four beats at most
        (a fifth card shares the fourth beat). ── */
  html body.es-welcome .es-stagger>:not([lang|="ar"],.font-arabic):not(:has([lang|="ar"],.font-arabic)){animation:es-rise 250ms cubic-bezier(.2,.8,.2,1) backwards!important;animation-delay:var(--es-beat,0ms)!important}
  html body.es-welcome .es-stagger>:nth-child(2){--es-beat:40ms}
  html body.es-welcome .es-stagger>:nth-child(3){--es-beat:80ms}
  html body.es-welcome .es-stagger>:nth-child(n+4){--es-beat:120ms}
}

/* ── Reduced motion: nothing slides, scales, lifts or turns. The tab pill and the switch knob jump.
      State changes that carry meaning keep a 100 ms opacity fade so they do not flash. Nothing stays hidden. ── */
@media (prefers-reduced-motion:reduce){
  html body.v2-default .es-submit>span{transition:opacity 100ms linear!important}
  html body.v2-default .es-alert:not(:has([lang|="ar"],.font-arabic)){transition:opacity 100ms linear!important}
  @starting-style{
    html body.v2-default .es-alert:not(:has([lang|="ar"],.font-arabic)){opacity:0}
  }
  html body.es-body .es-enter:not(:has([lang|="ar"],.font-arabic)){animation:es-fade 100ms linear backwards}
  html body.es-welcome .es-stagger>:not([lang|="ar"],.font-arabic):not(:has([lang|="ar"],.font-arabic)){animation:es-fade 100ms linear backwards!important}
}
