/* WhiteBridge "Install app" prompt.

   Two rules drive every decision here:

   1. It has to read as an APP install in the first half-second. That means the
      native smart-app-banner idiom people already know from iOS and Android —
      a squircle app tile, the app's name, a "Free" meta line and a GET-style
      pill — plus, on the roomier placements, a literal picture of the icon
      sitting on a phone home screen.
   2. It has to be WhiteBridge, not a generic card. Tokens are lifted from
      public/css/app.css: #EAECF0 hairlines, 16px card radius, 8px control
      radius, #2337E0 / #1A2BC8, #101828 ink, #475467 / #667085 muted. */

.wb-ip {
  --wb-ip-accent: #2337E0;
  --wb-ip-accent-dark: #1A2BC8;
  --wb-ip-ink: #101828;
  --wb-ip-muted: #475467;
  --wb-ip-dim: #667085;
  --wb-ip-line: #EAECF0;
  --wb-ip-card-radius: 16px;
  --wb-ip-shadow: 0 12px 32px rgba(16, 24, 40, .16), 0 1px 3px rgba(16, 24, 40, .06);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--wb-ip-ink);
  -webkit-font-smoothing: antialiased;
}

.wb-ip[hidden] { display: none !important; }
.wb-ip * { box-sizing: border-box; }

/* ---------- the app tile ----------
   The PNG is already a finished app icon (brand mark on WhiteBridge blue), so
   it fills the tile edge to edge like a real home-screen icon instead of
   floating inside a coloured box. */

.wb-ip-tile {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--wb-ip-accent);
  box-shadow: 0 2px 6px rgba(16, 24, 40, .18), inset 0 0 0 1px rgba(255, 255, 255, .14);
}
.wb-ip-tile img { width: 100%; height: 100%; display: block; }

/* ---------- app identity block ---------- */

.wb-ip-app { min-width: 0; flex: 1 1 auto; }
.wb-ip-appname {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -.01em;
  color: var(--wb-ip-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wb-ip-appmeta {
  margin: 1px 0 0;
  font-size: 12px;
  line-height: 1.35;
  color: var(--wb-ip-dim);
}

/* ---------- GET-style pill ---------- */

.wb-ip-get {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 9px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--wb-ip-accent);
  color: #fff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: .07em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s ease;
}
.wb-ip-get:hover { background: var(--wb-ip-accent-dark); color: #fff; }
.wb-ip-get:focus-visible { outline: 2px solid var(--wb-ip-accent); outline-offset: 2px; }
.wb-ip-get--block {
  width: 100%;
  min-height: 44px;
  border-radius: 8px;
  font-size: 13px;
}

.wb-ip-close {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #98A2B3;
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.wb-ip-close:hover { background: #F2F4F7; color: var(--wb-ip-muted); }
.wb-ip-close:focus-visible { outline: 2px solid var(--wb-ip-accent); outline-offset: 1px; }

/* ---------- home-screen preview ----------
   The clearest "this is an app" signal: the icon shown where it actually ends
   up, beside dimmed neighbour tiles so it reads as a phone home screen rather
   than a logo on a coloured panel. */

.wb-ip-home {
  margin: 16px 0 0;
  padding: 16px 14px 12px;
  border-radius: 14px;
  background: linear-gradient(160deg, #EEF1FF 0%, #DCE2FF 100%);
  border: 1px solid #D5DCFF;
}
.wb-ip-home-row {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 18px;
}
.wb-ip-home-app { width: 64px; text-align: center; }
.wb-ip-home-app .wb-ip-tile { margin: 0 auto; }
.wb-ip-home-label {
  margin: 6px 0 0;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.2;
  color: #344054;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wb-ip-home-ghost {
  width: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: .42;
}
.wb-ip-home-ghost span {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .72);
}
.wb-ip-home-ghost b {
  margin: 6px 0 0;
  width: 34px;
  height: 7px;
  border-radius: 4px;
  background: rgba(255, 255, 255, .72);
}
.wb-ip-home-caption {
  margin: 12px 0 0;
  font-size: 11.5px;
  line-height: 1.35;
  color: #4B5A9B;
  text-align: center;
}

/* ---------- iOS Share -> Add to Home Screen steps ---------- */

.wb-ip-steps { margin: 16px 0 0; padding: 0; list-style: none; counter-reset: wb-ip-step; }
.wb-ip-steps li {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border: 1px solid var(--wb-ip-line);
  border-radius: 10px;
  background: #FCFCFD;
  font-size: 13.5px;
  line-height: 1.35;
  color: var(--wb-ip-muted);
}
.wb-ip-steps li + li { margin-top: 8px; }
.wb-ip-steps b { color: var(--wb-ip-ink); font-weight: 600; }
.wb-ip-num {
  flex: 0 0 auto;
  counter-increment: wb-ip-step;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--wb-ip-accent);
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.wb-ip-num::before { content: counter(wb-ip-step); }
.wb-ip-glyph {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--wb-ip-accent);
}
.wb-ip-glyph svg { width: 16px; height: 16px; display: block; }

/* ---------- v01 top bar / v03 bottom bar (smart-banner idiom) ---------- */

.wb-ip-bar {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 2147483000;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 14px;
  background: #fff;
  border-bottom: 1px solid var(--wb-ip-line);
  box-shadow: 0 1px 3px rgba(16, 24, 40, .08);
  animation: wb-ip-slide-down .28s ease both;
}
.wb-ip-bar--top { top: 0; padding-top: calc(10px + env(safe-area-inset-top)); }
/* Smart banners keep the meta on one line; wrapping makes the bar look like a
   generic notification instead. */
.wb-ip-bar .wb-ip-appmeta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wb-ip-bar--bottom {
  bottom: 0;
  top: auto;
  border-bottom: 0;
  border-top: 1px solid var(--wb-ip-line);
  box-shadow: 0 -1px 3px rgba(16, 24, 40, .08);
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  animation-name: wb-ip-slide-up;
}

/* ---------- v02 iOS share sheet ---------- */

.wb-ip-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2147483000;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  background: #fff;
  border-radius: 20px 20px 0 0;
  box-shadow: var(--wb-ip-shadow);
  animation: wb-ip-slide-up .3s ease both;
}
.wb-ip-sheet-head { display: flex; align-items: center; gap: 12px; }
.wb-ip-sheet .wb-ip-appname { font-size: 16px; white-space: normal; }

/* ---------- v04 inline card ---------- */

.wb-ip-card {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 24px auto;
  padding: 18px;
  max-width: 720px;
  background: #fff;
  border: 1px solid var(--wb-ip-line);
  border-radius: var(--wb-ip-card-radius);
  box-shadow: 0 1px 3px rgba(16, 24, 40, .05);
}

/* ---------- v05 floating pill ---------- */

.wb-ip-fab {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 2147483000;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px 8px 8px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: var(--wb-ip-ink);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  box-shadow: var(--wb-ip-shadow);
  animation: wb-ip-pop .3s ease both;
}
.wb-ip-fab .wb-ip-tile { width: 36px; height: 36px; border-radius: 9px; }
.wb-ip-fab-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.25; }
.wb-ip-fab-text i { font-style: normal; font-size: 10.5px; font-weight: 500; color: var(--wb-ip-dim); }

/* ---------- v06 / v07 / v08 modal ---------- */

.wb-ip-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(16, 24, 40, .55);
  animation: wb-ip-fade .2s ease both;
}
.wb-ip-modal {
  width: 100%;
  max-width: 380px;
  padding: 24px 22px 22px;
  background: #fff;
  border-radius: 20px;
  box-shadow: var(--wb-ip-shadow);
  animation: wb-ip-pop .26s ease both;
}
.wb-ip-modal-head { display: flex; align-items: center; gap: 13px; }
.wb-ip-modal .wb-ip-appname { font-size: 16px; }
.wb-ip-modal .wb-ip-title {
  margin: 16px 0 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -.01em;
}
.wb-ip-modal-actions { margin-top: 18px; display: grid; gap: 8px; }
.wb-ip-later {
  border: 0;
  background: transparent;
  color: var(--wb-ip-dim);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 8px;
  cursor: pointer;
}
.wb-ip-later:hover { color: var(--wb-ip-ink); }

/* ---------- v09 toast ---------- */

.wb-ip-toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 2147483000;
  display: flex;
  align-items: center;
  gap: 11px;
  max-width: 420px;
  margin: 0 auto;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--wb-ip-line);
  border-radius: 14px;
  box-shadow: var(--wb-ip-shadow);
  animation: wb-ip-slide-up .28s ease both;
}
.wb-ip-toast .wb-ip-tile { width: 40px; height: 40px; border-radius: 10px; }

/* ---------- v10 /install landing panel ---------- */

.wb-ip-panel {
  max-width: 460px;
  margin: 0 auto;
  padding: 28px 24px 24px;
  background: #fff;
  border: 1px solid var(--wb-ip-line);
  border-radius: var(--wb-ip-card-radius);
  box-shadow: 0 1px 3px rgba(16, 24, 40, .05);
}
.wb-ip-panel-head { display: flex; align-items: center; gap: 14px; }
.wb-ip-panel .wb-ip-appname { font-size: 18px; }
.wb-ip-panel .wb-ip-appmeta { font-size: 13px; }
.wb-ip-panel .wb-ip-title {
  margin: 18px 0 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -.01em;
}
.wb-ip-panel-actions { margin-top: 18px; }
.wb-ip-panel-note {
  margin: 14px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--wb-ip-dim);
  text-align: center;
}
.wb-ip-done {
  display: none;
  margin: 18px 0 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: #ECFDF3;
  color: #027A48;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}
.wb-ip-panel.is-done .wb-ip-done { display: block; }
.wb-ip-panel.is-done .wb-ip-panel-actions,
.wb-ip-panel.is-done .wb-ip-home,
.wb-ip-panel.is-done .wb-ip-steps { display: none; }

/* ---------- review-mode switcher (forced previews only) ---------- */

/* Deliberately unlike the product UI so it never reads as a real element. */
.wb-ip-switcher {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2147483600;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: calc(100vw - 24px);
  padding: 7px 9px 9px;
  border-radius: 18px;
  background: rgba(16, 24, 40, .92);
  color: #fff;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, .35);
}
.wb-ip-switcher--bottom { bottom: calc(14px + env(safe-area-inset-bottom)); }
.wb-ip-switcher--top { top: calc(14px + env(safe-area-inset-top)); }

.wb-ip-sw-tag {
  flex: 0 0 auto;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .16);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .09em;
}
.wb-ip-sw-step {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  font-family: inherit;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}
.wb-ip-sw-step:hover { background: rgba(255, 255, 255, .26); }
.wb-ip-sw-name {
  min-width: 0;
  padding: 0 4px;
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.wb-ip-sw-name b { font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.wb-ip-sw-name i { font-style: normal; font-size: 10.5px; opacity: .62; white-space: nowrap; }

/* ---------- motion ---------- */

@keyframes wb-ip-slide-down { from { transform: translateY(-100%); } to { transform: translateY(0); } }
@keyframes wb-ip-slide-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes wb-ip-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes wb-ip-pop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }

@media (prefers-reduced-motion: reduce) {
  .wb-ip-bar, .wb-ip-sheet, .wb-ip-toast, .wb-ip-modal, .wb-ip-backdrop, .wb-ip-fab { animation: none; }
}

/* ---------- narrow phones ---------- */

@media (max-width: 380px) {
  .wb-ip-bar { gap: 9px; padding-left: 12px; padding-right: 12px; }
  .wb-ip-bar .wb-ip-appmeta { display: none; }
  .wb-ip-get { padding: 9px 14px; }
  .wb-ip-home-row { gap: 12px; }
}

/* Installed (standalone) windows never need the prompt. */
@media (display-mode: standalone) {
  .wb-ip { display: none !important; }
}

/* ---------- native store badge ----------
   Apple's own artwork, at their minimum sizes. It carries the whole "this is
   an app" message on its own, so nothing is layered on top of it. */

.wb-ip-badge-link {
  flex: 0 0 auto;
  display: inline-block;
  line-height: 0;
  text-decoration: none;
}
.wb-ip-badge-link img { height: 40px; width: auto; display: block; }
.wb-ip-badge-link--block { display: flex; justify-content: center; margin: 0 auto; }
.wb-ip-badge-link--block img { height: 48px; }
.wb-ip-store-block { margin: 16px 0 0; text-align: center; }
.wb-ip-store-block .wb-ip-home-caption { margin-top: 10px; }

/* The App Store artwork is a white-background icon, so it needs a hairline
   rather than the tinted tile the PWA icon sits in. */
.wb-ip-tile--store { background: #fff; box-shadow: 0 2px 6px rgba(16, 24, 40, .18), inset 0 0 0 1px rgba(16, 24, 40, .08); }

@media (max-width: 380px) {
  .wb-ip-badge-link img { height: 36px; }
}

/* Device switch: the App Store view only exists on iOS, so a reviewer on a
   laptop needs to be able to ask for it explicitly. */
.wb-ip-sw-row { display: flex; align-items: center; gap: 4px; }
.wb-ip-sw-devs { display: flex; gap: 4px; padding: 0 2px; }
.wb-ip-sw-dev {
  flex: 1 1 0;
  padding: 5px 10px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, .12);
  color: rgba(255, 255, 255, .78);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.wb-ip-sw-dev:hover { background: rgba(255, 255, 255, .22); color: #fff; }
.wb-ip-sw-dev.is-on { background: #fff; color: #101828; }
