/* PWA: "Add to Home Screen" sheet + mobile polish. Used with js/pwa.js. */

/* ---------- Install sheet: modal bottom sheet over a dimmed backdrop ---------- */

.install-backdrop {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  background: var(--scrim);
  animation: installFadeIn 0.25s ease backwards;
}
.install-backdrop.out {
  animation: installFadeOut 0.28s ease forwards;
  pointer-events: none;
}

.install-sheet {
  width: 100%;
  padding: var(--s-xs) var(--s-lg) calc(var(--safe-bottom) + var(--s-lg));
  background: var(--surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: 0 -8px 30px rgba(26, 28, 34, 0.12);
  outline: none;
  touch-action: none; /* the sheet is dragged down to dismiss; it has nothing to scroll */
  transition: transform 0.3s var(--ease-out);
  /* backwards, not both: after the entrance the drag's inline transform must apply */
  animation: installUp 0.42s var(--ease-out) backwards;
}
.install-sheet.dragging {
  transition: none;
}
.install-backdrop.out .install-sheet {
  animation: installDown 0.28s cubic-bezier(0.4, 0, 1, 1) forwards;
}

.install-grabber {
  width: 36px;
  height: 5px;
  margin: 0 auto var(--s-md);
  border-radius: 3px;
  background: var(--border-strong);
}

.install-head {
  display: flex;
  align-items: center;
  gap: var(--s-sm);
}
.install-icon {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  border-radius: 12px;
  object-fit: cover;
  background: var(--bg);
  box-shadow: 0 0 0 1px var(--border), var(--sh-soft);
}
.install-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.2px;
  line-height: 1.25;
  text-wrap: balance;
}
.install-text {
  margin: var(--s-sm) 0 0;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text-2);
  text-wrap: pretty;
}

.install-steps {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: var(--s-sm);
  padding: 10px var(--s-sm);
  border-radius: var(--r-md);
  background: var(--surface-muted);
  font-size: 13px;
  font-weight: 600;
}
.install-step {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.install-glyph {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  color: var(--accent);
  font-size: 17px;
  box-shadow: var(--sh-soft);
}
/* Safari's "Add to Home Screen" glyph: a plus inside a rounded square. */
.install-glyph.boxed ion-icon {
  box-sizing: content-box;
  font-size: 11px;
  padding: 1px;
  border: 1.5px solid currentColor;
  border-radius: 4px;
}
.install-next {
  font-size: 13px;
  color: var(--text-3);
}

.install-actions {
  display: flex;
  gap: var(--s-xs);
  margin-top: var(--s-lg);
}
.install-actions .btn {
  flex: 1;
  height: 52px;
}

@keyframes installFadeIn {
  from {
    opacity: 0;
  }
}
@keyframes installFadeOut {
  to {
    opacity: 0;
  }
}
@keyframes installUp {
  from {
    transform: translateY(100%);
  }
}
@keyframes installDown {
  to {
    transform: translateY(100%);
  }
}

/* ---------- Mobile polish ---------- */

/* No double-tap zoom anywhere in the app. base.css only covers .pressable, and WebKit resets
   touch-action at every scroll container, so it's set per element. :where() keeps the
   specificity at zero, so any screen's own touch-action (e.g. none on a drag area) wins. */
:where(#device, #device *) {
  touch-action: manipulation;
}

/* Long-pressing a button (e.g. a template card) shouldn't open iOS's image/link preview. */
:where(#device) :where(button, [role='button']) {
  -webkit-touch-callout: none;
}

/* 100dvh fallback (iOS < 15.4): pwa.js sets --vh from innerHeight only when dvh is unsupported. */
@supports not (height: 100dvh) {
  #stage {
    min-height: calc(var(--vh, 1vh) * 100);
  }
  #device {
    height: calc(var(--vh, 1vh) * 100);
  }
  @media (min-width: 760px) and (min-height: 720px) {
    #device {
      height: min(874px, calc(var(--vh, 1vh) * 100 - 48px));
    }
  }
}
