/* Sign-in screen, account modal and save notice. Built on the tokens in styles.css,
   so it follows the app's light/dark themes. Shape rule kept: containers 16px, controls 10px. */

html.gp-locked, html.gp-locked body { overflow: hidden; }

/* ---------- Full-screen PIN layer ---------- */
.gp-auth {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 32px 16px calc(32px + env(safe-area-inset-bottom));
  overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg); color: var(--text);
  animation: gp-fade-in .3s var(--ease);
}
.gp-auth.is-leaving { animation: gp-fade-out .22s var(--ease) forwards; }
.gp-auth-wash {
  position: absolute; inset: 0 0 auto 0; height: 460px; pointer-events: none;
  background:
    radial-gradient(760px 340px at 50% -12%, color-mix(in oklab, var(--accent) 12%, transparent), transparent 70%),
    radial-gradient(520px 260px at 88% -6%, color-mix(in oklab, var(--accent) 6%, transparent), transparent 70%);
}
.gp-auth-card {
  position: relative; width: 100%; max-width: 400px;
  padding: 40px 32px 28px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-md);
  text-align: center;
  animation: gp-rise .45s var(--ease) both;
}
.gp-auth-brand { display: grid; justify-items: center; gap: 10px; }
.gp-auth-mark { display: block; height: 24px; width: auto; }
.gp-auth-app { font-size: 15px; font-weight: 600; letter-spacing: -.01em; color: var(--text-2); }
.gp-auth-title {
  margin: 28px 0 0; padding-top: 28px; border-top: 1px solid var(--line);
  font-size: 22px; font-weight: 650; letter-spacing: -.022em; line-height: 1.2;
}
.gp-auth-form { margin-top: 22px; }
.gp-auth-msg {
  min-height: 44px; margin: 16px auto 0; max-width: 320px;
  font-size: 14px; line-height: 1.45; color: var(--text-3); text-wrap: balance;
}
.gp-auth-msg.is-error, .gp-acc-msg.is-error { color: var(--danger); }
/* lockout: a quiet panel with a lock, so it reads as a pause, not an error */
.gp-lock {
  display: inline-flex; align-items: center; gap: 10px; max-width: 100%;
  padding: 10px 14px; border-radius: 10px; text-align: left;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line);
}
.gp-lock .ic { font-size: 18px; flex: none; color: var(--text-3); }
.gp-acc-msg .gp-lock { display: flex; }

/* ---------- PIN cells (one real input laid over four drawn cells) ---------- */
.gp-pin { position: relative; width: 100%; max-width: 272px; margin: 0 auto; }
.gp-pin-cells { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.gp-cell {
  position: relative; height: 64px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--surface-3); border: 1.5px solid var(--line-strong);
  transition: border-color .2s, box-shadow .2s, background-color .2s, opacity .2s;
}
/* the filled dot */
.gp-cell::after {
  content: ""; width: 14px; height: 14px; border-radius: 999px; background: var(--text);
  transform: scale(0); transition: transform .22s var(--ease-pop), background-color .2s;
}
.gp-cell.is-filled::after { transform: scale(1); }
/* the caret in the next empty cell */
.gp-cell::before {
  content: ""; position: absolute; left: 50%; top: 50%; width: 2px; height: 26px; margin: -13px 0 0 -1px;
  border-radius: 2px; background: var(--accent); opacity: 0;
}
.gp-pin.is-focused .gp-cell.is-active { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.gp-pin.is-focused .gp-cell.is-active::before { animation: gp-caret 1.1s steps(1) infinite; }
.gp-pin.is-error .gp-cell { border-color: var(--danger); background: color-mix(in oklab, var(--danger) 6%, var(--surface-3)); box-shadow: none; }
.gp-pin.is-error .gp-cell::after { background: var(--danger); }
.gp-pin.is-error .gp-cell::before { opacity: 0; animation: none; }
/* a field marked wrong stays red as a whole, including the cell with the caret */
.gp-pin.is-error.is-focused .gp-cell.is-active { border-color: var(--danger); box-shadow: 0 0 0 4px var(--danger-soft); }
.gp-pin.is-error.is-focused .gp-cell.is-active::before { background: var(--danger); animation: gp-caret 1.1s steps(1) infinite; }
.gp-pin.is-shaking .gp-pin-cells { animation: gp-shake .44s var(--ease); }
.gp-pin.is-checking .gp-cell::after { animation: gp-pulse .9s var(--ease) infinite; }
.gp-pin.is-checking .gp-cell:nth-child(2)::after { animation-delay: .1s; }
.gp-pin.is-checking .gp-cell:nth-child(3)::after { animation-delay: .2s; }
.gp-pin.is-checking .gp-cell:nth-child(4)::after { animation-delay: .3s; }
.gp-pin.is-disabled .gp-cell { opacity: .5; background: var(--surface-2); }
.gp-pin-input {
  position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%;
  margin: 0; padding: 0; border: 0; outline: none; opacity: 0;
  background: transparent; color: transparent; caret-color: transparent;
  font-size: 16px; /* stops iOS zooming in on focus */
  cursor: text;
}
.gp-pin-input:disabled { cursor: not-allowed; }

/* compact cells, used in the account modal */
.gp-pin-sm { max-width: 216px; margin: 0; }
.gp-pin-sm .gp-pin-cells { gap: 8px; }
.gp-pin-sm .gp-cell { height: 48px; border-radius: 10px; }
.gp-pin-sm .gp-cell::after { width: 11px; height: 11px; }
.gp-pin-sm .gp-cell::before { height: 20px; margin-top: -10px; }

/* ---------- Account modal (sits on the app's .dialog) ---------- */
.gp-account { width: min(400px, calc(100vw - 32px)); }
.gp-acc { padding: 20px 24px 22px; outline: none; }
.gp-acc:focus, .gp-acc:focus-visible { outline: none; }
.gp-acc-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-right: -8px; }
.gp-acc-close { width: 36px; height: 36px; }
.gp-acc-who {
  display: flex; align-items: center; gap: 12px; margin-top: 14px;
  padding: 12px 14px; border-radius: 12px; background: var(--surface-2);
}
.gp-acc-who p { font-size: 15px; color: var(--text-2); min-width: 0; overflow-wrap: anywhere; }
.gp-acc-who strong { color: var(--text); font-weight: 600; }
.gp-avatar {
  width: 38px; height: 38px; flex: none; border-radius: 999px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-ink); font-weight: 650; font-size: 16px;
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--accent) 22%, transparent);
}
.gp-acc-menu { display: grid; gap: 2px; margin: 12px -8px 0; }
.gp-acc-row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 0 12px;
  border-radius: 10px; text-align: left; font-size: 15px; font-weight: 550; color: var(--text);
  transition: background .2s, color .2s;
}
.gp-acc-row .ic { font-size: 19px; color: var(--text-3); }
.gp-acc-row .gp-acc-chev { margin-left: auto; font-size: 15px; }
.gp-acc-row:hover { background: var(--surface-2); }
.gp-acc-row:hover .ic { color: var(--text-2); }
.gp-acc-form { display: grid; gap: 16px; margin-top: 18px; }
.gp-acc-field label { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.gp-acc-actions { margin-top: 4px; }
.gp-acc-actions .btn[disabled] { opacity: .55; cursor: default; }
.gp-acc-msg { font-size: 14px; line-height: 1.45; color: var(--text-2); }
.gp-acc-msg:empty { display: none; }
.gp-acc-note:not(:empty) { margin-top: 14px; }
.gp-acc-msg.is-ok { color: var(--accent-ink); }

/* ---------- Quiet save notice ---------- */
.gp-notice {
  position: fixed; left: 50%; top: 72px; z-index: 70;
  display: inline-flex; align-items: center; gap: 10px; max-width: calc(100vw - 32px);
  height: 38px; padding: 0 16px 0 14px; border-radius: 999px;
  background: var(--toast-bg); color: var(--toast-text); box-shadow: var(--shadow-lg);
  font-size: 13.5px; font-weight: 550; white-space: nowrap;
  opacity: 0; pointer-events: none; transform: translate(-50%, -8px);
  transition: opacity .25s var(--ease), transform .3s var(--ease);
}
.gp-notice.is-shown { opacity: 1; transform: translate(-50%, 0); }
.gp-notice-dot {
  width: 8px; height: 8px; border-radius: 999px; flex: none;
  background: color-mix(in oklab, var(--toast-text) 55%, transparent);
  animation: gp-pulse 1.4s var(--ease) infinite;
}
.gp-notice.is-error .gp-notice-dot { background: var(--danger); animation: none; }
.gp-notice-text { overflow: hidden; text-overflow: ellipsis; }

/* ---------- Motion ---------- */
@keyframes gp-shake {
  0%, 100% { transform: none; }
  18% { transform: translateX(-8px); }
  36% { transform: translateX(7px); }
  54% { transform: translateX(-5px); }
  72% { transform: translateX(3px); }
  88% { transform: translateX(-1px); }
}
@keyframes gp-caret { 0% { opacity: 1; } 50% { opacity: 0; } }
@keyframes gp-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes gp-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes gp-fade-out { to { opacity: 0; } }
@keyframes gp-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Phones ---------- */
@media (max-width: 639px) {
  /* Sit in the upper part of the screen, clear of the number pad. */
  .gp-auth { justify-content: flex-start; padding-top: max(9vh, calc(40px + env(safe-area-inset-top))); }
  .gp-auth-card { max-width: 360px; padding: 0 8px; background: transparent; border: 0; box-shadow: none; }
  .gp-auth-title { font-size: 22px; margin-top: 32px; padding-top: 0; border-top: 0; }
  .gp-auth-form { margin-top: 24px; }
  .gp-cell { height: 66px; }
  .gp-notice { top: 64px; }
  .gp-acc { padding: 18px 20px 20px; }
  .gp-acc-actions .btn { flex: 1 1 0; }
}
@media (max-height: 520px) and (max-width: 639px) {
  .gp-auth { padding-top: 24px; }
}
