/* ============================================================
   LOGIN, in Leo's look (Nick, Oct 22 2026: "use Leo's design language
   here, complete with nice animations and transitions when logging in"),
   on the Mythril Version 1 scene
   ============================================================
   The Mythril scene full-bleed, Leo's Wash drifting softly along the top,
   and the Leo mark (the Lionheart lion in a navy circle with its glow) at
   the centre. Colours come from the shared tokens, so the door follows
   light and dark like the rest of the portal.
   The screen behaves like Leo does (css/leo.css): at rest the glow sits
   low; while Google's answer is checked the screen is .leo-thinking (the
   ring turns, the bloom brightens); when the portal says yes it is
   .leo-answered (one flare and a welcome), then .login-leaving lifts it
   away over the portal, which is already drawing underneath. The timings
   live in js/login-stage.js.

   Scoped to #loginScreen. The pending and connect screens still share
   .login-shell / .login-card from css/dashboard.css. */

#loginScreen.login-leo {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  overflow: hidden auto;
  color: var(--text-strong);
  background: var(--my-scene), var(--canvas);
  transition: opacity 680ms cubic-bezier(.4, 0, .2, 1) 160ms;
}

/* The Wash, taller than the Leo window's: it is the whole sky here. It
   drifts slowly at rest (Leo's window holds it still until he thinks). */
#loginScreen .login-bloom { height: min(58vh, 520px); opacity: .42; }
[data-theme="dark"] #loginScreen .login-bloom { opacity: .6; }
#loginScreen .login-bloom i { filter: blur(56px); animation-play-state: running; animation-duration: 16s; will-change: translate; }
#loginScreen .login-bloom i:nth-child(2) { animation-duration: 19s; }
#loginScreen .login-bloom i:nth-child(3) { animation-duration: 14s; }
#loginScreen .login-bloom i:nth-child(4) { animation-duration: 21s; }
#loginScreen.leo-thinking > .login-bloom { opacity: .7; }
[data-theme="dark"] #loginScreen.leo-thinking > .login-bloom { opacity: .9; }
#loginScreen.leo-thinking > .login-bloom i { animation-duration: 5s; }

.login-stage {
  will-change: transform, opacity;
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: transform 460ms cubic-bezier(.22, 1, .36, 1), opacity 360ms ease;
}

.login-mark { --s: 96px; margin-bottom: 30px; }
.login-leo:not(.leo-thinking):not(.leo-answered) .login-mark .leo-mk-ring { opacity: .5; animation: login-mk-rest 6s ease-in-out infinite; }
@keyframes login-mk-rest { 50% { opacity: .7; transform: scale(1.06); } }

.login-leo .login-title {
  font-family: var(--font-serif);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.1;
  color: var(--text-head);
  margin: 0;
}
.login-kicker {
  margin: 6px 0 0;
  font-size: 14px;
  color: var(--text-muted);
}

/* Presence: one line under the name says what is happening. */
.login-status {
  margin: 30px 0 18px;
  min-height: 20px;
  font-size: 14px;
  color: var(--text-body);
}
.login-status.login-status-swap { animation: login-status-in 340ms cubic-bezier(.22, 1, .36, 1) both; }
@keyframes login-status-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.login-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 44px;
  transition: opacity 300ms ease;
}
#loginScreen #googleSignInButton { margin-top: 0 !important; }
.login-leo.leo-thinking .login-actions,
.login-leo.leo-answered .login-actions { opacity: .35; pointer-events: none; }

/* The fallback button (only seen when Google's own button cannot render):
   clear glass over the scene. Google draws its own button when it can. */
.login-leo .login-btn-primary {
  width: 280px;
  max-width: 100%;
  min-height: 44px;
  background: var(--my-glass);
  color: var(--text-strong);
  border-radius: var(--my-r);
  box-shadow: inset 0 0 0 1px var(--my-glass-line), var(--my-glass-shadow);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  backdrop-filter: blur(18px) saturate(1.4);
  padding: 0 18px;
  letter-spacing: 0;
  font-weight: 600;
}
.login-leo .login-btn-primary:hover { background: color-mix(in oklab, var(--surface) 86%, transparent); }
html.my-solid .login-leo .login-btn-primary { background: var(--surface); -webkit-backdrop-filter: none; backdrop-filter: none; }

.login-leo .login-error {
  max-width: 340px;
  margin-top: 14px;
  padding: 0;
  background: none;
  border: 0;
  color: var(--red-ink);
  text-align: center;
}

.login-note {
  margin: 22px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-muted);
}

.login-leo .login-skip { margin-top: 16px; }

.login-leo .login-footer {
  position: absolute;
  left: 0; right: 0; bottom: max(18px, env(safe-area-inset-bottom));
  margin: 0;
  z-index: 1;
  text-align: center;
  font-size: 12px;
  color: var(--text-faint);
}

/* ---- Arriving: the bloom comes up, then the mark, then each line ---- */
.login-leo .login-bloom { animation: login-fade-in 1400ms ease backwards; }
.login-leo .login-stage > * { animation: login-rise 720ms cubic-bezier(.22, 1, .36, 1) backwards; }
.login-leo .login-stage > .login-mark { animation-name: login-mark-in; animation-duration: 900ms; }
.login-leo .login-stage > :nth-child(2) { animation-delay: 140ms; }
.login-leo .login-stage > :nth-child(3) { animation-delay: 200ms; }
.login-leo .login-stage > :nth-child(4) { animation-delay: 280ms; }
.login-leo .login-stage > :nth-child(5) { animation-delay: 340ms; }
.login-leo .login-stage > :nth-child(n+6) { animation-delay: 420ms; }
.login-leo .login-footer { animation: login-fade-in 900ms ease 500ms backwards; }
@keyframes login-fade-in { from { opacity: 0; } }
@keyframes login-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes login-mark-in { from { opacity: 0; transform: scale(.82); filter: blur(4px); } to { opacity: 1; transform: none; filter: none; } }

/* ---- Answered: the mark flares (css/leo.css .leo-answered) and settles a
   touch larger while the welcome shows ---- */
.login-mark { transition: scale 600ms cubic-bezier(.22, 1, .36, 1); }
.login-leo.leo-answered .login-mark { scale: 1.08; }
#loginScreen.leo-answered > .login-bloom { animation: login-bloom-done 1.6s cubic-bezier(.22, 1, .36, 1) both; }
@keyframes login-bloom-done { 0% { opacity: 1; filter: brightness(1.12); } 100% { opacity: .68; filter: none; } }

/* ---- Leaving: the stage lifts and fades, the scene goes last ---- */
#loginScreen.login-leaving { opacity: 0; pointer-events: none; }
.login-leaving .login-stage { opacity: 0; transform: translateY(-18px) scale(.98); }
.login-leaving .login-footer { opacity: 0; transition: opacity 240ms ease; }

@media (max-width: 640px) {
  #loginScreen.login-leo { padding: 28px 16px 56px; }
  .login-mark { --s: 80px; margin-bottom: 24px; }
  .login-leo .login-title { font-size: 26px; }
  .login-status { margin-top: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  #loginScreen .login-bloom,
  #loginScreen .login-bloom i,
  .login-mark .leo-mk-ring,
  .login-leo:not(.leo-thinking):not(.leo-answered) .login-mark .leo-mk-ring,
  .login-leo .login-stage > *,
  .login-leo .login-footer,
  .login-status.login-status-swap { animation: none !important; }
  .login-stage, .login-mark { transition: none; transform: none !important; }
  .login-leo.leo-answered .login-mark { scale: none; }
  #loginScreen.leo-answered > .login-bloom { animation: none; }
  #loginScreen.login-leo { transition: opacity 200ms linear; }
}
