/* ═══════════════════════════════════════════════════════════════════════
   ZAP STUDIO — PWA layer
   Install banner, update pill, offline badge, iOS install sheet.
   Scoped to .zap-* so the studio's own stylesheet stays untouched.
   ═══════════════════════════════════════════════════════════════════════ */

#app { animation: zapBootIn .34s cubic-bezier(.22,.61,.36,1) both; }
@keyframes zapBootIn { from { opacity: 0; transform: scale(1.012); } to { opacity: 1; transform: none; } }

.zap-veil {
  position: fixed; inset: 0; z-index: 9000;
  background: #000;
  display: flex; align-items: center; justify-content: center;
  transition: opacity .28s ease, visibility .28s;
  animation: zapVeilOut .3s ease 2.2s forwards;   /* failsafe if JS never runs */
}
@keyframes zapVeilOut { to { opacity: 0; visibility: hidden; pointer-events: none; } }
.zap-veil.gone { opacity: 0; visibility: hidden; pointer-events: none; }
.zap-veil-mark {
  width: 68px; height: 68px; border-radius: 18px;
  background: var(--metal-grad, linear-gradient(180deg,#fff,#8E94A0));
  -webkit-mask: url("../icons/icon.svg") center/contain no-repeat;
  mask: url("../icons/icon.svg") center/contain no-repeat;
  background-color: #C8CDD6;
  animation: zapPulse 1.5s ease-in-out infinite;
}
@keyframes zapPulse { 0%,100% { opacity: .45; transform: scale(.96); } 50% { opacity: 1; transform: scale(1); } }

/* ─── shared surface ─────────────────────────────────────────────── */
.zap-surface {
  background: rgba(18,18,21,.92);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border: 1px solid var(--bd-2, rgba(255,255,255,.12));
  border-radius: 18px;
  box-shadow: 0 18px 48px rgba(0,0,0,.62), inset 0 1px 0 rgba(255,255,255,.07);
}

/* ─── install banner ─────────────────────────────────────────────── */
.zap-install {
  position: fixed; left: 12px; right: 12px; z-index: 8000;
  bottom: calc(var(--tabs-h, 68px) + var(--sa-b, 0px) + 12px);
  display: flex; align-items: center; gap: 12px;
  padding: 12px 12px 12px 14px;
  transform: translateY(140%);
  transition: transform .42s cubic-bezier(.22,1.2,.36,1), opacity .3s;
  opacity: 0; pointer-events: none;
}
.zap-install.show { transform: none; opacity: 1; pointer-events: auto; }
.zap-install-icon {
  width: 42px; height: 42px; flex: 0 0 42px; border-radius: 12px;
  background: #000 center/cover no-repeat url("../icons/icon-192.png");
  border: 1px solid var(--bd-2, rgba(255,255,255,.12));
}
.zap-install-body { flex: 1; min-width: 0; }
.zap-install-title { font-size: 13.5px; font-weight: 700; color: var(--t1, #E8EAEE); letter-spacing: -.01em; }
.zap-install-sub {
  font-size: 11.5px; color: var(--t3, #5A606C); margin-top: 2px; line-height: 1.35;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.zap-install-btn {
  flex: 0 0 auto; height: 34px; padding: 0 15px; border: 0; border-radius: 11px;
  font: inherit; font-size: 12.5px; font-weight: 800; letter-spacing: .01em;
  color: #08090B; background: var(--metal-grad, linear-gradient(180deg,#fff,#8E94A0));
  cursor: pointer; transition: transform .12s ease, filter .2s;
}
.zap-install-btn:active { transform: scale(.94); filter: brightness(1.1); }
.zap-install-x {
  position: absolute; top: -9px; right: -6px; width: 26px; height: 26px; border-radius: 50%;
  background: #17171A; border: 1px solid var(--bd-2, rgba(255,255,255,.12));
  color: var(--t2, #8E94A0); font-size: 15px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center; padding: 0;
}

/* ─── status pills (update / offline) ────────────────────────────── */
.zap-pill {
  position: fixed; z-index: 8000;
  top: calc(var(--sa-t, 0px) + 8px);
  left: 50%; transform: translate(-50%, -180%);
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px 8px 14px; border-radius: 999px;
  font-size: 12px; font-weight: 600; color: var(--t1, #E8EAEE);
  transition: transform .38s cubic-bezier(.22,1.1,.36,1);
  max-width: calc(100vw - 24px);
}
.zap-pill.show { transform: translate(-50%, 0); }
.zap-pill.offline { padding: 8px 14px; color: var(--t2, #8E94A0); font-size: 11.5px; }
.zap-pill-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success, #10B981); flex: 0 0 7px; }
.zap-pill.offline .zap-pill-dot { background: var(--danger, #EF4444); }
.zap-pill-btn {
  border: 0; border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 11.5px; font-weight: 800;
  color: #08090B; background: var(--metal-grad, linear-gradient(180deg,#fff,#8E94A0)); cursor: pointer;
}
.zap-pill-btn:active { transform: scale(.95); }
.zap-pill.spin .zap-pill-dot { animation: zapPulse 1s ease-in-out infinite; }

/* ─── iOS / manual install sheet ─────────────────────────────────── */
.zap-modal {
  position: fixed; inset: 0; z-index: 8500;
  background: rgba(0,0,0,.72);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .26s ease;
}
.zap-modal.show { opacity: 1; pointer-events: auto; }
.zap-modal-card {
  width: 100%; max-width: 520px;
  margin: 0 12px calc(12px + var(--sa-b, 0px));
  padding: 20px 20px 16px;
  transform: translateY(30px); transition: transform .34s cubic-bezier(.22,1.1,.36,1);
  max-height: 80vh; overflow-y: auto;
}
.zap-modal.show .zap-modal-card { transform: none; }
.zap-modal h3 { font-size: 16px; font-weight: 800; color: var(--t1, #E8EAEE); letter-spacing: -.01em; }
.zap-modal p { font-size: 13px; line-height: 1.55; color: var(--t2, #8E94A0); margin-top: 10px; }
.zap-steps { margin: 14px 0 4px; display: grid; gap: 10px; }
.zap-step {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 13px; border-radius: 13px;
  background: rgba(255,255,255,.035); border: 1px solid var(--bd, rgba(255,255,255,.07));
  font-size: 13px; color: var(--t1, #E8EAEE);
}
.zap-step b {
  width: 21px; height: 21px; flex: 0 0 21px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; color: #08090B; background: var(--metal-grad, #C8CDD6);
}
.zap-modal-foot { display: flex; gap: 10px; margin-top: 16px; }
.zap-modal-foot button {
  flex: 1; height: 44px; border: 0; border-radius: 13px; font: inherit; font-weight: 800; font-size: 13.5px;
  cursor: pointer; color: var(--t1, #E8EAEE); background: rgba(255,255,255,.06);
}
.zap-modal-foot button.primary { color: #08090B; background: var(--metal-grad, linear-gradient(180deg,#fff,#8E94A0)); }
.zap-modal-foot button:active { transform: scale(.97); }

/* ─── app-mode (installed) polish ─────────────────────────────────── */
.zap-installed .zap-install { display: none; }
.zap-standalone body { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.zap-standalone #app { padding-top: 0; }

@media (prefers-reduced-motion: reduce) {
  #app { animation: none; }
  .zap-install, .zap-pill, .zap-modal-card, .zap-veil { transition: none; }
  .zap-veil-mark, .zap-pill.spin .zap-pill-dot { animation: none; }
}
