/* ------------------------------------------------------------------
   THE PHONE APP LOCK (FO_APP_LOCK; #fo_lock in
   R/dot-fo_login_lock_ui.R, driven by inst/www/fo_lock.js)
   The screen a phone shows when its device token alone may no longer
   sign it in: the app's name, why it is locked, the normal sign-in and
   Sign out. Opaque, over everything on the page except the connection
   card (#fo_connection_lost, z-index 100000), which fo_connection.js
   does not draw while the lock screen is up. The same panel without its
   buttons is the wait (data-fo-lock-mode="cover"): a page the server
   ended, or back after too long, until it reloads or the server answers.
   Only the design tokens of fo-tokens.css, in the page's theme. Centred
   and symmetric, so the right-to-left page needs nothing of its own.
   ------------------------------------------------------------------ */

#fo_lock {
  --fo-lock-ground: var(--fo-surface-muted);
  --fo-lock-surface: var(--fo-surface);
  --fo-lock-text: var(--fo-text);
  --fo-lock-muted: var(--fo-text-muted);
  --fo-lock-accent: var(--fo-brand);
  --fo-lock-border: var(--fo-card-border);
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: max(16px, env(safe-area-inset-top, 0px))
           max(16px, env(safe-area-inset-right, 0px))
           max(16px, env(safe-area-inset-bottom, 0px))
           max(16px, env(safe-area-inset-left, 0px));
  overflow-y: auto;
  /* Opaque at once, with no fade: the page under it never shows through. */
  background-color: var(--fo-lock-ground);
  color: var(--fo-lock-text);
}
#fo_lock[hidden],
#fo_lock [hidden] {
  display: none !important;
}
/* On a page before sign-in the landing page is dark unless the visitor
   picked light (R/app_ui.R, the landing page's theme): so is the lock.
   The app's own dark theme comes with the tokens themselves. */
html:not([data-fo-landing-theme="light"]):not([data-bs-theme="light"]) body:not([data-app-state="authenticated"]) #fo_lock {
  --fo-lock-ground: var(--fo-landing-surface);
  --fo-lock-surface: var(--fo-landing-tile-bg);
  --fo-lock-text: var(--fo-landing-text);
  --fo-lock-muted: var(--fo-landing-text-muted);
  --fo-lock-accent: var(--fo-landing-accent);
  --fo-lock-border: var(--fo-landing-glass-border);
}
#fo_lock .fo-lock-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 380px;
  margin: auto;
  padding: 28px 32px;
  border: 1px solid var(--fo-lock-border);
  border-radius: var(--fo-landing-radius-card);
  background: var(--fo-lock-surface);
  box-shadow: var(--fo-landing-glass-shadow);
  text-align: center;
  outline: none;
}
#fo_lock .fo-lock-mark {
  width: 40px;
  height: 40px;
  fill: none;
  stroke: var(--fo-lock-accent);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#fo_lock .fo-lock-title {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--fo-lock-text);
}
#fo_lock .fo-lock-status {
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
  color: var(--fo-lock-muted);
}
/* The unlock key's button (its own step): nothing while it is empty. */
#fo_lock .fo-lock-unlock-slot {
  width: 100%;
}
#fo_lock .fo-lock-unlock-slot:empty {
  display: none;
}
#fo_lock .fo-lock-password {
  width: 100%;
  min-height: 44px;
  margin-top: 4px;
}
/* The unlock key's Unlock, the main choice (inst/www/fo_unlock_key.js),
   and the password as the second one under it: that script swaps the
   password's btn-primary for fo-lock-second while the slot offers the
   key. An outline in the lock's own colours. */
#fo_lock .fo-lock-unlock {
  min-height: 48px;
}
#fo_lock .fo-lock-password.fo-lock-second {
  color: var(--fo-lock-text);
  background: transparent;
  border: 1px solid var(--fo-lock-muted);
}
#fo_lock .fo-lock-password.fo-lock-second:hover,
#fo_lock .fo-lock-password.fo-lock-second:focus-visible,
#fo_lock .fo-lock-password.fo-lock-second:active {
  color: var(--fo-lock-text);
  background: transparent;
  border-color: var(--fo-lock-accent);
}
#fo_lock .fo-lock-sign-out {
  min-height: 44px;
  color: var(--fo-lock-accent);
}
/* The wait: the name and the status line only. */
#fo_lock[data-fo-lock-mode="cover"] .fo-lock-password,
#fo_lock[data-fo-lock-mode="cover"] .fo-lock-sign-out,
#fo_lock[data-fo-lock-mode="cover"] .fo-lock-unlock-slot {
  display: none !important;
}
/* While the lock is up the page under it does not scroll, and neither the
   Help Mode pill (custom.css, body::before) nor Shiny's notifications nor
   a shinyalert dialog, at the lock's own z-index, show through. */
body.fo-locked {
  overflow: hidden;
}
body.fo-locked::before {
  content: none !important;
}
body.fo-locked #shiny-notification-panel,
body.fo-locked .sweet-overlay,
body.fo-locked .sweet-alert {
  display: none !important;
}
