/* ============================================================================
   DigitalKiddo Maths — PWA Floating Install Card + Manual-Install Modal + Toast
   Uses the existing design tokens (--primary, --accent, --radius, etc.).
   All classes are namespaced with `dk-install*` / `dk-pwa*` to avoid clashes.
   Hidden by default; JS reveals it only when appropriate.
   ========================================================================== */

/* --- Floating install card --------------------------------------------- */
.dk-install-card {
  position: fixed;
  z-index: 3000;
  right: 20px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 20px);
  width: 330px;
  max-width: calc(100vw - 32px);
  padding: 1.15rem 1.15rem 1.2rem;
  border-radius: var(--radius, 20px);
  background: linear-gradient(135deg, #6c63ff 0%, #7b74ff 45%, #4ecdc4 135%);
  box-shadow: 0 22px 50px -14px rgba(76, 40, 130, 0.55),
              0 0 0 1px rgba(255, 255, 255, 0.14) inset;
  color: #fff;
  overflow: hidden;
  display: none;                 /* JS toggles to `block` when it should show */
}
.dk-install-card.dk-show {
  display: block;
  animation: dkCardIn .5s cubic-bezier(.22, 1, .36, 1) both;
}
@keyframes dkCardIn {
  from { opacity: 0; transform: translateY(26px) scale(.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
/* subtle sheen */
.dk-install-card::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(circle at 15% 12%, rgba(255,255,255,.20), transparent 48%);
  pointer-events: none;
}

.dk-install-head {
  display: flex;
  align-items: center;
  gap: .8rem;
  margin-bottom: .6rem;
  padding-right: 1.8rem;         /* leave room for the ✕ */
}
.dk-install-icon {
  flex: 0 0 auto;
  width: 52px; height: 52px;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.16);
  display: grid; place-items: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}
.dk-install-icon img { width: 40px; height: 40px; border-radius: 10px; }

.dk-install-title {
  font-family: 'Fredoka One', cursive;
  font-size: 1.05rem;
  line-height: 1.2;
  margin: 0;
  color: #fff;
}
.dk-install-sub {
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: .84rem;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.92);
  margin: 0 0 1rem;
}

.dk-install-btn {
  display: inline-flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 1rem;
  color: #4a3fd0;
  background: var(--accent, #ffd93d);
  border: none;
  border-radius: 999px;
  padding: .8rem 1.5rem;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(255, 217, 61, 0.4);
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
  white-space: nowrap;
}
.dk-install-btn:hover { transform: translateY(-2px); box-shadow: 0 12px 26px rgba(255, 217, 61, 0.55); filter: brightness(1.03); }
.dk-install-btn:active { transform: translateY(0); }

.dk-install-close {
  position: absolute;
  top: 9px; right: 10px;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: .9rem;
  line-height: 1;
  display: grid; place-items: center;
  cursor: pointer;
  transition: background .2s ease, transform .2s ease;
}
.dk-install-close:hover { background: rgba(255, 255, 255, 0.32); transform: rotate(90deg); }

/* --- Responsive: keep clear of the bottom safe area on tablet / mobile --- */
@media (max-width: 768px) {
  .dk-install-card {
    right: 12px;
    left: 12px;
    width: auto;
    max-width: none;
    /* Sit above the bottom safe area / navigation on touch devices. */
    bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  }
}

/* ========================================================================== */
/*  Manual-install modal (Safari / iOS / unsupported browsers)                */
/* ========================================================================== */
.dk-pwa-modal {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(30, 22, 60, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.dk-pwa-modal.dk-show { display: flex; animation: dkFade .25s ease both; }
@keyframes dkFade { from { opacity: 0; } to { opacity: 1; } }

.dk-pwa-dialog {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: var(--radius-lg, 28px);
  padding: 1.6rem 1.5rem 1.7rem;
  box-shadow: 0 30px 70px -18px rgba(40, 20, 90, 0.6);
  animation: dkPop .3s cubic-bezier(.22,1,.36,1) both;
  position: relative;
}
@keyframes dkPop { from { opacity: 0; transform: scale(.94) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }

.dk-pwa-dialog h3 {
  font-family: 'Fredoka One', cursive;
  font-size: 1.3rem;
  color: var(--dark, #2d3436);
  margin: 0 0 .3rem;
  text-align: center;
}
.dk-pwa-dialog .dk-pwa-lead {
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: .9rem;
  color: var(--gray-600, #636e72);
  text-align: center;
  margin: 0 0 1.15rem;
}

.dk-pwa-steps { display: flex; flex-direction: column; gap: .7rem; }
.dk-pwa-step {
  display: flex;
  align-items: center;
  gap: .8rem;
  background: var(--gray-100, #f1f2f6);
  border-radius: var(--radius-sm, 12px);
  padding: .75rem .9rem;
}
.dk-pwa-step-num {
  flex: 0 0 auto;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--primary, #6c63ff);
  color: #fff;
  font-family: 'Fredoka One', cursive;
  font-size: .9rem;
  display: grid; place-items: center;
}
.dk-pwa-step-text {
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: .9rem;
  color: var(--dark, #2d3436);
  line-height: 1.35;
}
.dk-pwa-step-text .dk-pwa-ico { font-size: 1.15rem; vertical-align: -2px; }

.dk-pwa-close {
  margin-top: 1.3rem;
  width: 100%;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: .95rem;
  color: #fff;
  background: var(--primary, #6c63ff);
  border: none;
  border-radius: 999px;
  padding: .8rem;
  cursor: pointer;
  transition: filter .2s ease, transform .15s ease;
}
.dk-pwa-close:hover { filter: brightness(1.06); transform: translateY(-1px); }

/* ========================================================================== */
/*  Success toast                                                             */
/* ========================================================================== */
.dk-pwa-toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 20px);
  z-index: 5000;
  display: flex;
  align-items: center;
  gap: .55rem;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: .92rem;
  color: #fff;
  background: linear-gradient(120deg, #26de81, #20bf6b);
  padding: .8rem 1.25rem;
  border-radius: 999px;
  box-shadow: 0 14px 34px -8px rgba(38, 222, 129, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease, transform .3s cubic-bezier(.22,1,.36,1);
}
.dk-pwa-toast.dk-show { opacity: 1; transform: translate(-50%, 0); }
