/* "Keep your key" (js/keep.js): the once-only welcome moment and #/key. Warm, safe and a little celebratory: this is
   the first moment a new helper belongs here, never a security chore. */

/* ---- the welcome moment ---- */
.kp-modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(80% 70% at 50% 30%, rgba(11, 74, 55, 0.45), rgba(8, 24, 19, 0.62)); backdrop-filter: blur(4px);
  animation: kp-in 0.3s ease-out; }
.kp-card { position: relative; width: min(540px, 100%); max-height: calc(100dvh - 32px); overflow: auto; overscroll-behavior: contain;
  padding: 30px 30px 18px; border-radius: 26px; text-align: center;
  background: radial-gradient(120% 60% at 50% 0%, #fdf3dc 0%, rgba(253, 243, 220, 0) 55%), #fff;
  box-shadow: 0 2px 6px rgba(11, 30, 24, 0.1), 0 40px 90px -20px rgba(11, 30, 24, 0.55);
  animation: kp-pop 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.15) both; }
.kp-top { position: relative; display: grid; place-items: center; margin: 2px auto 14px; width: 84px; height: 84px; }
/* a few warm sparks around the key, once */
.kp-top::before, .kp-top::after { content: ""; position: absolute; width: 8px; height: 8px; border-radius: 50%; background: var(--brass); opacity: 0;
  animation: kp-spark 1.4s 0.35s ease-out both; }
.kp-top::before { left: -6px; top: 18px; box-shadow: 92px -10px 0 -1px var(--pine-2), 70px 74px 0 -2px #e9cf8c, -4px 58px 0 -2px var(--pine-2); }
.kp-top::after { right: -10px; top: 4px; width: 6px; height: 6px; background: #e9cf8c; box-shadow: -96px 60px 0 0 var(--brass), -40px -10px 0 -1px var(--pine-2); animation-delay: 0.5s; }
.kp-emblem { display: grid; place-items: center; width: 72px; height: 72px; border-radius: 50%; color: #fff;
  background: radial-gradient(circle at 35% 30%, #e9cf8c 0, var(--brass) 55%, #8a6418 100%);
  box-shadow: 0 0 0 5px #fff, 0 0 0 6px #ecdcb5, 0 14px 30px -10px rgba(116, 83, 15, 0.7); }
.kp-emblem svg { filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.15)); }
.kp-kicker { display: inline-flex; align-items: center; gap: 8px; margin: 0 0 8px; padding: 5px 13px; border-radius: 999px;
  background: var(--pine-wash); border: 1px solid #cfe5d8; color: var(--pine-deep); font: 700 0.76rem/1 var(--sans); letter-spacing: 0.08em; text-transform: uppercase; }
.kp-kicker::before { content: "✓"; font-weight: 700; color: var(--pine); }
.kp-card h2 { margin: 0 auto 10px; max-width: 18ch; font-size: clamp(1.55rem, 4.2vw, 2rem); line-height: 1.15; text-wrap: balance; }
.kp-card > p { margin: 0 auto; max-width: 42ch; color: var(--ink-2); line-height: 1.6; }

/* the three ways: the easiest one first and clear, two quiet alternatives side by side */
.kp-ways { list-style: none; margin: 22px 0 12px; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; text-align: left; }
.kp-ways li { display: grid; align-content: start; gap: 6px; padding: 12px; border-radius: 16px; background: #fff; border: 1px solid var(--line); }
.kp-ways li.kp-main { position: relative; grid-column: 1 / -1; padding: 14px; background: var(--pine-wash); border-color: #cfe5d8; }
.kp-tag { position: absolute; top: -9px; left: 16px; padding: 3px 9px; border-radius: 999px; background: var(--brass); color: #fff; font: 700 0.66rem/1.2 var(--sans); font-style: normal; letter-spacing: 0.06em; text-transform: uppercase; }
.kp-ways .btn { width: 100%; min-height: 46px; justify-content: center; }
.kp-ways li.kp-main .btn { min-height: 52px; font-size: 1.02rem; }
.kp-ways small { color: var(--ink-2); font-size: 0.82rem; line-height: 1.45; padding: 0 2px; }
.kp > p.small { margin: 6px 0 0; text-align: left; line-height: 1.5; }
.kp-later { display: block; margin: 10px auto 0; padding: 10px 16px; border: 0; background: none; color: var(--sub); font: 600 0.9rem/1 var(--sans); cursor: pointer; border-radius: 999px; }
.kp-later:hover { color: var(--ink); background: var(--wash); }

/* the optional email way */
.kp-email, .kp-lost { margin-top: 16px; padding: 16px; display: grid; gap: 8px; text-align: left; border-radius: 16px; background: var(--cream); border: 1px solid #ecdcb5; }
.kp-email[hidden], .kp-lost[hidden] { display: none; }
.kp-email > b, .kp-lost h2 { font: 600 1.05rem/1.3 var(--serif); color: var(--ink); margin: 0; }
.kp-email p, .kp-lost p { margin: 0; }
.kp-email-row { display: flex; flex-wrap: wrap; gap: 10px; }
.kp-email-row input { flex: 1 1 220px; min-height: 46px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line-strong); background: #fff; font: 400 1rem/1.3 var(--sans); }
.kp-email-row input:focus, .kp-restore input:focus { outline: 3px solid rgba(18, 107, 80, 0.2); border-color: var(--pine); }

/* ---- #/key ---- */
.kp-page { max-width: 640px; display: grid; gap: 14px; }
.kp-page > p { margin: 0; color: var(--ink-2); line-height: 1.65; font-size: 1.05rem; }
.kp-head { display: flex; align-items: center; gap: 16px; margin-bottom: 4px; }
.kp-head .kp-emblem { width: 56px; height: 56px; flex: none; box-shadow: 0 0 0 4px #fff, 0 0 0 5px #ecdcb5, 0 10px 22px -10px rgba(116, 83, 15, 0.7); }
.kp-head h1 { margin: 0; }
.kp-page .kp { padding: 18px; border-radius: 22px; background: #fff; border: 1px solid var(--line); box-shadow: 0 1px 2px rgba(20, 40, 59, 0.04), 0 22px 50px -34px rgba(20, 40, 59, 0.4); }
.kp-page .kp-ways { margin-top: 10px; }
/* bring your key: one calm card, a key field your password manager fills in, one big button */
.kp-restore { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; margin-top: 6px; padding: 18px; border-radius: 22px; background: var(--pine-wash); border: 1px solid #cfe5d8; }
.kp-restore input[type="password"] { min-width: 0; min-height: 52px; padding: 0 16px; border-radius: 14px; border: 1px solid var(--line-strong); background: #fff;
  font: 500 1rem/1.3 var(--mono, ui-monospace, monospace); letter-spacing: 0.04em; }
.kp-restore input[hidden] { display: none; }
.kp-restore .btn { min-height: 52px; padding-inline: 22px; }
.kp-restore p { grid-column: 1 / -1; margin: 0; }
.kp-restore p:empty { display: none; }
.kp-switch { margin-top: 10px; padding: 14px 16px; border-radius: 16px; border: 1px solid var(--line); background: #fff; }
.kp-switch > summary { cursor: pointer; font-weight: 600; color: var(--pine-deep); }
.kp-switch[open] > summary { margin-bottom: 10px; }
.kp-page > .btn-primary { justify-self: start; }

@media (max-width: 520px) {
  /* on a phone the welcome rises as a sheet from the bottom, within thumb's reach */
  .kp-modal { place-items: end center; padding: 0; }
  .kp-card { width: 100%; max-height: 92dvh; padding: 24px 18px 14px; border-radius: 26px 26px 0 0; animation: kp-sheet 0.4s cubic-bezier(0.2, 0.9, 0.3, 1) both; }
  .kp-ways { grid-template-columns: minmax(0, 1fr); }
  .kp-restore { grid-template-columns: minmax(0, 1fr); padding: 14px; }
  .kp-restore .btn { width: 100%; }
  .kp-head { gap: 12px; }
}

@keyframes kp-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes kp-pop { from { opacity: 0; transform: translateY(14px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes kp-sheet { from { transform: translateY(40px); opacity: 0.4; } to { transform: none; opacity: 1; } }
@keyframes kp-spark { 0% { opacity: 0; transform: scale(0.2); } 30% { opacity: 1; } 100% { opacity: 0.85; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .kp-modal, .kp-card, .kp-top::before, .kp-top::after { animation: none; } .kp-top::before, .kp-top::after { opacity: 0.85; } }
