/* ==========================================================================
   PWA modal + install chip
   ========================================================================== */

/* ---------- Base helpers ---------- */

/* Make [hidden] reliably hide in all browsers */
[hidden]{ display:none !important; }

/* ---------- Overlay ---------- */
.pwa-overlay{
  position: fixed;
  inset: 0;
  display: none;
  z-index: 99999;
  background: rgba(0,0,0,.45);
}
.pwa-overlay.show{
  display: grid;
  place-items: center;
}

/* ---------- iOS instructional box (inside the modal) ---------- */
.pwa-ios{
  background:#f7f7f7;
  border:1px solid rgba(0,0,0,.08);
  border-radius:10px;
  padding:12px 14px;
  margin:10px 0 6px;
  color:#111;
}
.pwa-steps{ margin:0; padding-left:22px; }
.pwa-steps li{ margin:.4em 0; }

/* KBD / small pill used around inline icons/shortcuts */
.pwa-kbd{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:0 .45em;
  border:1px solid rgba(0,0,0,.25);
  border-bottom-width:2px;
  border-radius:.35em;
  background:#fff;
  font:600 12px/1.4 system-ui,-apple-system,Segoe UI,Roboto,sans-serif;
}

/* Small glyph image version (kept for optional use elsewhere) */
.pwa-icon-share-img{
  width:16px;
  height:16px;
  display:block;
}

/* Toolbar screenshot version — Step 1 image on its own line */
#pwaIosSteps img.toolbar-shot{
  display:block;               /* force a new line under “Safari:” */
  width:140px;                 /* adjust 120–160px to taste */
  max-width:80%;
  height:auto;
  margin:.35rem 0 .15rem;
  border-radius:8px;
}

/* Force “Add to Home Screen” onto its own line in Step 2 */
#pwaIosSteps .ios-force-line{ display:block; }

/* ---------- Modal card ---------- */
.pwa-card{
  width: min(540px, 92vw);
  background: rgba(255,255,255,.92);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: #111;
  border-radius: 12px;
  padding: 20px 24px;
  box-shadow: 0 18px 45px rgba(0,0,0,.35);
  font-family: system-ui,-apple-system,Segoe UI,Roboto,sans-serif;

  /* ensure content is scrollable on smaller screens */
  max-height: min(84vh, 560px);
  overflow:auto;
  -webkit-overflow-scrolling: touch;
}

.pwa-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 8px;
}
.pwa-logo{ border-radius: 8px; flex: 0 0 auto; }

.pwa-card h3{
  margin: 0 8px;
  font-weight: 700;
  font-size: 18px;
}
.pwa-card p{
  margin: 8px 0 14px;
  color: #333;
  line-height: 1.35;
}

/* ---------- Actions (buttons) ---------- */
.pwa-actions{
  display: flex;
  gap: 12px;
  justify-content: flex-end;   /* JS centers this on iOS when only “Close” shows */
}
.pwa-btn{
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid rgba(0,0,0,.12);
  font-size: 16px;             /* button typography */
  font-weight: 600;
  letter-spacing: .2px;
  -webkit-tap-highlight-color: transparent;
}
.pwa-btn.equal{ min-width: 120px; text-align: center; }
.pwa-btn.primary{ background: #000; color: #fff; }
.pwa-btn.secondary{ background: #eee; color: #111; }
.pwa-btn:hover{ opacity: .9; }
.pwa-btn:active{ transform: translateY(0.5px); }
.pwa-btn:focus-visible{
  outline: 2px solid #000;
  outline-offset: 2px;
}

/* Slightly larger on iOS to counter Safari text sizing */
@supports (-webkit-touch-callout: none){
  .pwa-btn{ font-size: 17px; }
}

/* Never show overlays or FAB inside the installed app */
@media (display-mode: standalone){
  .pwa-overlay{ display: none !important; }
  #installFab{ display: none !important; }
}

/* ==========================================================================
   Floating “Install app” chip — TOP-RIGHT
   ========================================================================== */

/* Tweak these if needed */
:root{
  --header-offset: 56px; /* approx header height */
  --fab-gap: -2px;       /* nudge up/down: negative = closer to header */
}

/* CHIP (now with inline × button space) */
.pwa-fab{
  position: fixed;
  top: calc(var(--header-offset) + var(--fab-gap));
  right: 16px;

  display: inline-flex;
  align-items: center;
  gap: 10px;

  padding: 10px 10px;          /* room for close button */
  border-radius: 999px;
  background: rgba(60,60,60,.44);          /* semi-translucent dark grey */
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: #fff;
  border: 1px solid rgba(255,255,255,.28);
  font: 500 14px/1.2 system-ui,-apple-system,Segoe UI,Roboto,sans-serif;
  box-shadow: 0 8px 20px rgba(0,0,0,.25);   /* slightly lighter shadow */
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  z-index: 2147483647; /* above scroll-to-top bubbles, etc. */
}
.pwa-fab:hover{ transform: translateY(-1px); }
#installFab:focus-visible{
  outline: 2px solid #fff;
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce){
  .pwa-fab:hover{ transform:none; }
}

/* Respect iOS safe areas (camera notch / right inset) */
@supports (top: env(safe-area-inset-top)){
  .pwa-fab{
    top: calc(env(safe-area-inset-top) + var(--header-offset) + var(--fab-gap));
    right: calc(env(safe-area-inset-right) + 16px);
  }
}

/* Slightly tighter on very small screens */
@media (max-width: 480px){
  .pwa-fab{ right: 12px; }
}

/* Inline “×” close button inside the chip */
.pwa-fab-close{
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid rgba(255,255,255,.28);
  background: rgba(255,255,255,.10);
  color: #fff;
  border-radius: 999px;
  width: 24px; height: 24px;
  display: grid;
  place-items: center;
  font-size: 16px; line-height: 1;
  padding: 0;
  cursor: pointer;
}
.pwa-fab-close:hover{
  background: rgba(255,255,255,.18);
}
.pwa-fab-close:focus-visible{
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* Hide chip while the modal is open (overlay precedes the chip in DOM) */
.pwa-overlay.show ~ #installFab{
  opacity: 0;
  pointer-events: none;
}
