/* Help panel, pop-up dialogs, messages (toasts) and the update bar.
   Goes with: js/ui/dom.js. */

#scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 40;
}
#scrim.open {
  display: block;
}
.help {
  display: none;
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%,-50%);
  width: min(560px,calc(100vw - 32px));
  max-height: min(80vh,720px);
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--line);
  padding: 20px 22px;
  z-index: 42;
  border-radius: 18px;
  box-shadow: 0 18px 55px rgba(28,32,26,.16);
}
.help.open {
  display: block;
}
.help h2 {
  margin: 0 0 4px;
}
.help h3 {
  font-size: 15px;
  margin: 16px 0 4px;
}
.help p,
.help li {
  font-size: 14px;
  color: var(--ink2);
  line-height: 1.55;
  margin: 0 0 6px;
}
.help ul {
  padding-left: 18px;
  margin: 0;
}
#toast button {
  margin-left: 12px;
  background: transparent;
  border: 1px solid currentColor;
  color: inherit;
  border-radius: 6px;
  padding: 3px 10px;
  font: inherit;
  cursor: pointer;
}
#toast.show {
  opacity: 1;
  pointer-events: auto;
}
#toast {
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(30,35,29,.18);
}
#mdlg {
  position: fixed;
  inset: 0;
  z-index: 100001;   /* above the PIN screen, which can ask to confirm */
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.45);
  padding: 20px;
}
#mdlg.open {
  display: flex;
}
/* Cover the whole screen even when iPhone's keyboard or toolbars change the
   visible area, and keep the page behind still. */
#mdlg {
  min-height: 100vh;
  min-height: 100lvh;
  overscroll-behavior: contain;
}
html.dialog-open,
html.dialog-open body {
  overflow: hidden;
}
/* With a typing box, sit near the top so the keyboard doesn't cover it. */
#mdlg.with-input {
  align-items: flex-start;
  padding-top: calc(env(safe-area-inset-top,0px) + 12vh);
}
/* PINs show as dots without being password fields (see dom.js). */
.pin,
#mdlg input.secret {
  -webkit-text-security: disc;
  text-security: disc;
}
#mdlg .mbox {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 16px;
  width: 100%;
  max-width: 420px;
  max-height: 85vh;
  overflow: auto;
  padding: 20px;
  box-shadow: 0 20px 50px rgba(0,0,0,.3);
}
#mdlg h3 {
  margin: 0 0 10px;
  font-size: 18px;
}
#mdlg .mmsg {
  white-space: pre-line;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--ink2);
  margin: 0;
}
#mdlg input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin-top: 14px;
  font: inherit;
  font-size: 16px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
}
#mdlg input[hidden],
#mdlg h3[hidden],
#mdlg button[hidden] {
  display: none;
}
#mdlg .mact {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
}
#mdlg .mact button {
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
}
#mdlg .mact .mok {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
#mdlg .mact .mok.danger {
  background: #b42318;
  border-color: #b42318;
}
.update-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(84px + env(safe-area-inset-bottom));
  z-index: 60;
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px 10px 16px;
  box-shadow: 0 8px 30px rgba(0,0,0,.18);
  width: min(440px,calc(100vw - 24px));
  box-sizing: border-box;
  font-size: 14px;
}
.update-bar span {
  flex: 1;
  min-width: 0;
  line-height: 1.35;
}
.update-bar .btn {
  flex: none;
  white-space: nowrap;
}
.update-bar[hidden] {
  display: none;
}
@media screen and (max-width:700px) {
  .help {
    transition: transform .2s ease;
    top: auto;
    bottom: 0;
    transform: translateX(-50%);
    width: 100vw;
    max-height: 85vh;
    padding-bottom: calc(20px + env(safe-area-inset-bottom,0px));
  }
}
#toast {
  position: fixed;
  top: calc(env(safe-area-inset-top,0px) + 14px);
  max-width: calc(100vw - 32px);
  text-align: center;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 16px;
  font-size: 14px;
  opacity: 0;
  transition: opacity .25s;
  pointer-events: none;
  z-index: 100002;   /* messages show over dialogs and the PIN screen */
}
@media (display-mode: standalone) {
  #toast {
    top: calc(env(safe-area-inset-top,0px) + 14px);
  }
}
@media screen and (max-width:700px) {
  #toast {
    top: auto;
    bottom: calc(84px + env(safe-area-inset-bottom,0px));
  }
}

