/* Add-to-Home-Screen install flow UI.
   Rendered as fixed-position DOM on top of the Flutter canvas — kept
   independent of Flutter so it works before/after the engine boots. */

#pwa-install-root {
  position: fixed;
  inset: 0;
  z-index: 999999;
  pointer-events: none;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#pwa-install-root .pwa-banner,
#pwa-install-root .pwa-overlay-card {
  pointer-events: auto;
}

.pwa-banner {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  max-width: 420px;
  margin: 0 auto;
  background: linear-gradient(180deg, #1a1a2e, #151526);
  border: 1px solid #2a2a45;
  border-radius: 18px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  padding: 16px 34px 16px 14px;
  display: none;
  gap: 12px;
  align-items: center;
  color: #ececf7;
  transform: translateY(12px);
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.pwa-banner.pwa-visible {
  display: flex;
  transform: translateY(0);
  opacity: 1;
}

.pwa-banner-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(255, 179, 0, 0.18);
}

.pwa-banner-body {
  flex: 1;
  min-width: 0;
}

.pwa-banner-title {
  font-weight: 800;
  font-size: 0.95rem;
  margin: 0 0 2px;
}

.pwa-banner-sub {
  font-size: 0.8rem;
  color: #b8b8d0;
  margin: 0;
  line-height: 1.35;
}

.pwa-banner-actions {
  flex-shrink: 0;
}

.pwa-btn {
  border: none;
  border-radius: 10px;
  padding: 9px 14px;
  font-weight: 800;
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
}

.pwa-btn-primary {
  background: linear-gradient(135deg, #ffb300, #cc8800);
  color: #16110a;
}

.pwa-banner-close,
.pwa-overlay-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  color: #b8b8d0;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  padding: 6px;
}

.pwa-banner.pwa-warning {
  border-color: rgba(226, 91, 91, 0.4);
}

.pwa-banner.pwa-warning .pwa-banner-title {
  color: #ffb4b4;
}

/* iOS instructional overlay (bottom sheet on mobile, centered on wider screens) */
.pwa-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(9, 9, 22, 0.72);
  display: none;
  align-items: flex-end;
  justify-content: center;
}

.pwa-overlay-backdrop.pwa-visible {
  display: flex;
}

.pwa-overlay-card {
  width: 100%;
  max-width: 440px;
  background: linear-gradient(180deg, #1a1a2e, #151526);
  border: 1px solid #2a2a45;
  border-radius: 22px 22px 0 0;
  padding: 22px 22px calc(22px + env(safe-area-inset-bottom));
  color: #ececf7;
  position: relative;
  box-shadow: 0 -20px 50px rgba(0, 0, 0, 0.5);
  animation: pwa-slide-up 0.3s ease;
}

@media (min-width: 480px) {
  .pwa-overlay-backdrop {
    align-items: center;
  }
  .pwa-overlay-card {
    border-radius: 22px;
    margin-bottom: 24px;
  }
}

@keyframes pwa-slide-up {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.pwa-overlay-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.pwa-overlay-header img {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  box-shadow: 0 0 0 1px rgba(255, 179, 0, 0.18);
}

.pwa-overlay-title {
  font-weight: 900;
  font-size: 1.05rem;
  margin: 0;
}

.pwa-overlay-sub {
  color: #b8b8d0;
  font-size: 0.85rem;
  margin: 0 0 18px;
}

.pwa-steps {
  display: grid;
  gap: 14px;
  margin: 0 0 4px;
  padding: 0;
  list-style: none;
}

.pwa-step {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 12px;
  align-items: center;
}

.pwa-step-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(255, 179, 0, 0.1);
  border: 1px solid rgba(255, 179, 0, 0.24);
  display: grid;
  place-items: center;
  color: #ffb300;
}

.pwa-step-text {
  font-size: 0.88rem;
  line-height: 1.4;
  color: #ececf7;
}

.pwa-step-text strong {
  color: #ffffff;
}

.pwa-overlay-dismiss {
  margin-top: 18px;
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid #2a2a45;
  color: #b8b8d0;
  font-weight: 700;
  cursor: pointer;
}

/* One-time, minimal acknowledgement for users already in standalone mode */
.pwa-toast {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  left: 50%;
  transform: translate(-50%, -8px);
  background: rgba(26, 26, 46, 0.94);
  border: 1px solid rgba(255, 179, 0, 0.28);
  color: #ffb300;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.8rem;
  font-weight: 700;
  opacity: 0;
  display: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.pwa-toast.pwa-visible {
  display: block;
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 380px) {
  .pwa-banner {
    flex-wrap: wrap;
  }
  .pwa-banner-actions {
    width: 100%;
  }
  .pwa-banner-actions .pwa-btn {
    width: 100%;
  }
}
