/* Installable app UI: install banner, update toast, offline bar and the offline page. */

/* ---------- Install banner ---------- */
.pwa-banner[hidden], .pwa-toast[hidden], .pwa-offline[hidden], [data-pwa-help][hidden], [data-pwa-open][hidden], [data-pwa-install][hidden] { display: none !important; }
.pwa-banner {
  position: fixed; z-index: 90; left: max(16px, env(safe-area-inset-left)); bottom: max(16px, env(safe-area-inset-bottom));
  width: min(400px, calc(100vw - 32px)); display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 14px 14px 16px; border-radius: var(--radius-lg, 24px);
  background: var(--panel-strong, #fff); color: var(--text, #1f2433);
  border: 1px solid var(--panel-border, rgba(20, 40, 50, .12)); box-shadow: var(--shadow-lg, 0 16px 40px rgba(0, 0, 0, .18));
  -webkit-backdrop-filter: blur(18px) saturate(1.4); backdrop-filter: blur(18px) saturate(1.4);
  animation: pwa-in .3s var(--ease, ease-out);
}
.pwa-icon { width: 48px; height: 48px; border-radius: 12px; flex: none; }
.pwa-body { flex: 1; min-width: 0; font-size: .92rem; }
.pwa-body strong { font-family: var(--font-display, inherit); font-size: 1rem; }
.pwa-msg { margin: 4px 0 0; color: var(--text-muted, #5a6b73); line-height: 1.45; }
.pwa-steps { margin: 6px 0 0; padding-left: 1.2em; color: var(--text-muted, #5a6b73); line-height: 1.6; }
.pwa-chip { display: inline-flex; align-items: center; gap: 4px; padding: 0 8px; border-radius: 8px; background: var(--muted-bg, rgba(20, 40, 50, .07)); color: var(--text, inherit); font-weight: 600; vertical-align: baseline; }
.pwa-chip .icon { width: 14px; height: 14px; }
.pwa-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.pwa-close { width: 32px; height: 32px; flex: none; margin: -4px -4px 0 0; }
@keyframes pwa-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* Phones: sit above the floating tab bar */
@media (max-width: 760px) {
  .pwa-banner { left: 12px; right: 12px; width: auto; bottom: calc(12px + env(safe-area-inset-bottom)); }
  .has-tabbar .pwa-banner { bottom: calc(var(--tabbar-h, 64px) + env(safe-area-inset-bottom) + 24px); }
}

/* ---------- Update toast and offline bar ---------- */
.pwa-toast {
  position: fixed; z-index: 125; left: 50%; transform: translateX(-50%); top: calc(env(safe-area-inset-top) + 12px);
  display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; border-radius: var(--radius-pill, 999px);
  background: var(--panel-strong, #fff); color: var(--text, #1f2433); border: 1px solid var(--panel-border, rgba(20, 40, 50, .12));
  box-shadow: var(--shadow-lg, 0 16px 40px rgba(0, 0, 0, .18)); font-size: .9rem; max-width: calc(100vw - 24px);
}
.pwa-offline {
  position: fixed; z-index: 124; left: 0; right: 0; top: 0; padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
  text-align: center; font-size: .85rem; font-weight: 600; background: var(--warning-bg, #fbefd8); color: var(--warning, #9a6512);
  border-bottom: 1px solid var(--line, rgba(20, 40, 50, .1));
}

/* Footer text-style button */
.link-btn { all: unset; cursor: pointer; display: block; color: inherit; font: inherit; text-decoration: underline; text-underline-offset: 3px; }
.link-btn:focus-visible { outline: 2px solid var(--brand-500, #7d57e6); outline-offset: 2px; border-radius: 4px; }
button.nav-link { width: 100%; background: none; border: 0; font: inherit; text-align: left; cursor: pointer; }

/* Never offer installation inside the installed app */
.standalone [data-pwa-open], .standalone .pwa-banner { display: none !important; }

/* ---------- Offline page ---------- */
.offline-body {
  margin: 0; min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  padding-top: max(24px, env(safe-area-inset-top)); padding-bottom: max(24px, env(safe-area-inset-bottom));
  background: var(--bg, #e9ecf2); color: var(--text, #1f2433); font-family: var(--font-body, system-ui, sans-serif);
}
.offline-card {
  max-width: 420px; text-align: center; padding: 36px 28px; border-radius: var(--radius-lg, 24px);
  background: var(--panel-strong, #fff); border: 1px solid var(--panel-border, rgba(20, 40, 50, .12)); box-shadow: var(--shadow-lg, 0 16px 40px rgba(0, 0, 0, .18));
}
.offline-logo { border-radius: 18px; margin-bottom: 8px; }
.offline-card h1 { margin: 8px 0 8px; font-family: var(--font-display, inherit); font-size: 1.6rem; }
.offline-card p { margin: 0 0 12px; line-height: 1.55; color: var(--text-muted, #5a6b73); }
.offline-note { font-size: .9rem; }
.offline-btn {
  min-height: 44px; padding: 0 24px; border: 0; border-radius: 14px; cursor: pointer; font: inherit; font-weight: 600;
  background: var(--brand-600, #6338cf); color: #fff;
}
:root[data-theme="dark"] .offline-btn { color: #14092e; }
.offline-btn:hover { background: var(--brand-700, #4b27a8); }
.offline-btn:focus-visible { outline: 3px solid var(--brand-300, #c9b8f5); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) { .pwa-banner { animation: none; } }
@media print { .pwa-banner, .pwa-toast, .pwa-offline { display: none !important; } }
