/* pwa.css: the look of the app's versions, updates and installing
 * (src/pwa/): the bar over the page's foot, and the sheets for What's new
 * and Install Fianka. It uses app.css's colour tokens, so it follows the
 * theme. */

/* The bar: over the page's foot, centred, never moving the page. */
.pwa-bar {
  position: fixed;
  z-index: 50;
  inset-inline: 0;
  bottom: calc(16px + env(safe-area-inset-bottom));
  margin-inline: auto;
  width: fit-content;
  max-width: calc(100% - 32px);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 10px 12px 10px 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 8px 28px var(--shadow);
}
.pwa-bar p {
  margin: 0;
  flex: 1 1 7em;
}

/* The bar's buttons stay together, at the right, the main one last. */
.pwa-actions {
  display: flex;
  gap: 8px;
  margin-inline-start: auto;
}

/* On a phone the bar sits at the top, clear of the composer and the
   browser's own toolbar, and its buttons are smaller. */
@media (max-width: 699px) {
  .pwa-bar {
    bottom: auto;
    top: calc(8px + env(safe-area-inset-top));
    width: calc(100% - 16px);
    max-width: none;
    padding: 10px 10px 10px 14px;
  }
  .pwa-actions .btn {
    padding-block: 6px;
    font-size: 14px;
  }
}

/* The sheets: a box in the middle, scrolling inside when tall. */
.pwa-sheet {
  width: min(560px, calc(100% - 32px));
  max-height: calc(100% - 64px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 16px 48px var(--shadow);
}
.pwa-sheet::backdrop {
  background: rgba(0, 0, 0, 0.4);
}
.pwa-sheet > div {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 22px 22px;
}
.pwa-sheet header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.pwa-sheet h2 {
  margin: 0;
  font: 600 20px var(--display);
}
.pwa-sheet h3,
.pwa-sheet h4 {
  margin: 0;
  font: 600 16px var(--display);
}
.pwa-sheet ul,
.pwa-sheet ol {
  margin: 0;
  padding-inline-start: 1.4em;
  line-height: 1.5;
}
.pwa-sheet li + li {
  margin-top: 6px;
}
.pwa-sheet details {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.pwa-sheet summary {
  cursor: pointer;
  font-weight: 500;
  min-height: 32px;
}
.pwa-sheet details[open] > summary {
  margin-bottom: 8px;
}
.install {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.install section + section {
  margin-top: 12px;
}
.install .btn {
  align-self: flex-start;
}
.install .muted {
  margin: 0;
  font-size: 14px;
}
.installed {
  margin: 0;
  padding: 12px;
  border-radius: 12px;
  background: var(--soft);
}
.glyph .icon {
  width: 18px;
  height: 18px;
  vertical-align: -3px;
  margin-inline-end: 4px;
}
.news .muted {
  font: 400 14px var(--sans);
}

/* The sign-up and upgrade modals (ui/gate.ts). */
.gate {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.gate p,
.gate label {
  margin: 0;
}
.gate label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
}
.gate-actions,
.gate-period {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.gate-period .btn[aria-pressed='true'] {
  border-color: var(--accent);
  font-weight: 600;
}
.plans {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}
.plan {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
}
.plan p {
  margin: 0;
}
.plan .price {
  font: 600 24px var(--display);
}
.plan .btn {
  margin-top: auto;
}

/* The ask dialogs (ui/dialog.ts): a small confirm or prompt box; a bottom
 * sheet on a phone. */
.ask {
  width: min(440px, calc(100% - 32px));
  transition:
    opacity 0.15s,
    transform 0.15s,
    overlay 0.15s allow-discrete,
    display 0.15s allow-discrete;
}
.ask form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
  padding: 20px 22px 18px;
}
.ask h2 {
  margin: 0;
  font: 600 20px var(--display);
}
.ask p {
  margin: 0;
  line-height: 1.5;
}
.ask-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}
.ask::backdrop {
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(3px);
  transition:
    opacity 0.15s,
    overlay 0.15s allow-discrete,
    display 0.15s allow-discrete;
}
.ask:not([open]),
.ask:not([open])::backdrop {
  opacity: 0;
}
.ask:not([open]) {
  transform: scale(0.96);
}
@starting-style {
  .ask[open] {
    opacity: 0;
    transform: scale(0.96);
  }
  .ask[open]::backdrop {
    opacity: 0;
  }
}
.btn.primary.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
@media (prefers-reduced-motion: reduce) {
  .ask,
  .ask::backdrop {
    transition: none;
  }
}
@media (max-width: 699px) {
  .ask {
    width: 100%;
    max-width: none;
    margin: auto 0 0;
    border-radius: 18px 18px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .ask:not([open]) {
    transform: translateY(24px);
  }
  @starting-style {
    .ask[open] {
      transform: translateY(24px);
    }
  }
}
