/* ==========================================================================
   PWA layer — install banner, update prompt, offline bar, iOS instructions.
   Additive only; injected by js/pwa.js. Matches the app's dark theme.
   ========================================================================== */

/* Landscape notch insets (top/bottom are already handled by --safe-top/bottom).
   Scoped to the installed app so the normal browser view is untouched. */
@media (display-mode: standalone) {
  .app-header { padding-left: calc(12px + env(safe-area-inset-left, 0px));
                padding-right: calc(12px + env(safe-area-inset-right, 0px)); }
}

/* ── shared banner (install / update) ── */
.pwa-banner {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 100000;
  width: min(440px, calc(100vw - 24px));
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--bg-elevated, #1a2230);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 12px 40px rgba(0,0,0,0.5), 0 0 0 1px rgba(0,0,0,0.2);
  color: var(--text-primary, #e8edf2);
  animation: pwa-slide-up 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}
body.pwa-is-offline .pwa-banner { bottom: calc(52px + env(safe-area-inset-bottom, 0px)); }

@keyframes pwa-slide-up {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

.pwa-banner-ico {
  flex-shrink: 0;
  width: 40px; height: 40px;
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(59,130,246,0.12);
  box-shadow: inset 0 0 0 1px rgba(59,130,246,0.25);
}
.pwa-banner-ico svg { width: 22px; height: 22px; }

.pwa-banner-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.pwa-banner-txt strong { font-size: 13.5px; font-weight: 600; }
.pwa-banner-txt span { font-size: 12px; color: var(--text-secondary, #9aa7b4); line-height: 1.35; }

.pwa-btn {
  flex-shrink: 0;
  padding: 8px 16px;
  border-radius: 10px;
  border: none;
  background: var(--accent-primary, #3b82f6);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
}
.pwa-btn:hover { filter: brightness(1.08); }
.pwa-btn:active { transform: scale(0.96); }

.pwa-close {
  flex-shrink: 0;
  width: 26px; height: 26px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.06);
  color: var(--text-muted, #6b7785);
  font-size: 18px; line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.pwa-close:hover { background: rgba(255,255,255,0.12); color: var(--text-primary, #e8edf2); }

.pwa-update { border-color: rgba(74,222,128,0.35); }
.pwa-update .pwa-update-btn { background: var(--success, #22c55e); }
.pwa-update .pwa-later-btn {
  background: transparent;
  color: var(--text-secondary, #9aa7b4);
  box-shadow: inset 0 0 0 1px var(--border-color, rgba(255,255,255,0.1));
}
.pwa-update .pwa-later-btn:hover { background: rgba(255,255,255,0.06); color: var(--text-primary, #e8edf2); }

/* ── offline bar ── */
.pwa-offline-bar {
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  z-index: 99999;
  padding: 8px 14px calc(8px + env(safe-area-inset-bottom, 0px));
  text-align: center;
  font-size: 12px;
  font-weight: 500;
  color: #0f1419;
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
  animation: pwa-slide-up 0.3s ease both;
}

/* ── iOS instructions modal ── */
.pwa-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100001;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  animation: pwa-fade 0.25s ease both;
}
@keyframes pwa-fade { from { opacity: 0; } to { opacity: 1; } }

.pwa-modal {
  width: min(440px, 100%);
  max-height: 85vh;
  overflow-y: auto;
  background: var(--bg-secondary, #141b24);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  padding: 22px 20px;
  color: var(--text-primary, #e8edf2);
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  animation: pwa-slide-up 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.pwa-modal h3 { margin: 0 0 12px; font-size: 17px; font-weight: 700; }
.pwa-modal p { margin: 0 0 18px; font-size: 14px; line-height: 1.5; color: var(--text-secondary, #9aa7b4); }
.pwa-steps { margin: 0 0 18px; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; }
.pwa-steps li { font-size: 14px; line-height: 1.45; color: var(--text-secondary, #9aa7b4); }
.pwa-steps strong { color: var(--text-primary, #e8edf2); }
.pwa-share {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 5px;
  background: var(--accent-primary, #3b82f6); color: #fff;
  font-size: 12px; vertical-align: middle;
}
.pwa-modal .pwa-btn { width: 100%; padding: 12px; font-size: 14px; }

/* Desktop: dock banners bottom-right instead of centered full width */
@media (min-width: 768px) {
  .pwa-banner { left: auto; right: 20px; transform: none; }
  @keyframes pwa-slide-up-desktop { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
  .pwa-banner { animation-name: pwa-slide-up-desktop; }
  .pwa-modal-overlay { align-items: center; }
}

@media (prefers-reduced-motion: reduce) {
  .pwa-banner, .pwa-offline-bar, .pwa-modal-overlay, .pwa-modal { animation: none !important; }
}
