/*
 * The installable app and lite mode (Phase 8.1, docs/modules/pwa.md): the offline bar, the update toast, the menu
 * items ("Install app", lite mode), the iOS hint, the Save-Data hint, the offline page and the admin's icon preview.
 * Linked at the end of <body> (resources/views/partials/pwa/ui.php): nothing here is needed for the first paint.
 */

/* ---------- Offline bar: fixed (no layout shift), above the mobile bottom bar ---------- */
.pwa-bar {
  position: fixed;
  right: 0;
  bottom: calc(57px + env(safe-area-inset-bottom, 0px));
  left: 0;
  z-index: var(--z-toast);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-2) var(--space-3);
  padding: var(--space-2) var(--space-4);
  background: var(--bg-inverse);
  color: var(--text-inverse);
  font-size: var(--text-sm);
  text-align: center;
}

.pwa-bar .link-button {
  color: inherit;
}

@media (min-width: 768px) {
  .pwa-bar {
    bottom: 0;
  }
}

/* ---------- Update toast and the Save-Data hint (inside .toasts) ---------- */
.pwa-toast .pwa-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.toast.pwa-toast .btn {
  margin: 0;
}

.pwa-toast > div {
  flex: 1;
}

/* ---------- Menu items: drawer and footer ---------- */
.pwa-menu-button {
  width: 100%;
  border: 0;
  background: none;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  text-align: start;
  cursor: pointer;
}

.footer-col .pwa-menu-button {
  width: auto;
  padding: 0;
  color: var(--text-muted);
}

.footer-col .pwa-menu-button:hover {
  color: var(--text);
}

.pwa-state {
  display: inline-block;
  margin-inline-start: var(--space-2);
  padding: 0 var(--space-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-full);
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.6;
}

[aria-pressed="true"] > .pwa-state {
  border-color: var(--success);
  background: var(--success-soft);
  color: var(--success);
}

.pwa-menu-note {
  color: var(--text-subtle);
  font-size: var(--text-xs);
}

/* ---------- iOS "Add to Home Screen" ---------- */
.pwa-ios-steps {
  display: grid;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding-inline-start: var(--space-5);
}

/* ---------- The offline page ---------- */
.pwa-offline {
  max-width: 640px;
  padding-block: var(--space-10);
}

.pwa-offline > * + *,
.pwa-offline-saved > * + * {
  margin-top: var(--space-4);
}

.pwa-offline-saved h2 {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-lg);
}

.pwa-offline-more {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.pwa-offline-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: var(--space-4);
  border-radius: var(--radius-full);
  background: var(--warning-soft);
  color: var(--warning);
}

.pwa-offline-icon .icon {
  width: 28px;
  height: 28px;
}

.pwa-offline-saved {
  margin-top: var(--space-8);
}

.pwa-saved-list {
  display: grid;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding: 0;
  list-style: none;
}

.pwa-saved-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-1) var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.pwa-saved-state {
  color: var(--text-subtle);
  font-size: var(--text-xs);
  font-weight: 600;
}

.pwa-saved-state.is-offline {
  color: var(--success);
}

/* (Lite mode's note for a left-out picture, .lite-img, is in the head of lite pages: App\Support\Lite::css().) */

/* ---------- Admin → Settings → App: the icons as launchers show them ---------- */
.pwa-preview {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-6);
  margin-bottom: var(--space-3);
}

.pwa-preview figure {
  display: grid;
  justify-items: center;
  gap: var(--space-2);
  margin: 0;
}

.pwa-preview img {
  width: 96px;
  height: 96px;
  background: repeating-conic-gradient(var(--bg-muted) 0 25%, var(--surface) 0 50%) 50% / 16px 16px;
}

.pwa-preview figcaption {
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.pwa-preview-round img {
  border-radius: 50%;
}

.pwa-preview-squircle img {
  border-radius: 26%;
}

.pwa-preview-ios img {
  border-radius: 22.5%;
}

.pwa-preview-title {
  margin-top: var(--space-6);
  font-size: var(--text-sm);
}

.pwa-shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-5);
  margin: var(--space-3) 0 var(--space-4);
  padding: 0;
  list-style: none;
}

.pwa-shortcuts li {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
}
