/**
 * FortPass
 * @author David Medel
 * @Copyright 2026 Medel Platforms (medel.es)
**/

/* ============================================================
   PWA — "Open in the app" top bar + install bottom sheet.
   Markup is rendered by assets/js/home/install-pwa.js; this file
   is linked from _home_head.php and _app_head.php only while the
   PWA is enabled in /admin/settings#pwa.
   ============================================================ */

html { --fp-appbar-h: 68px; }

/* ----- TOP BAR (phones/small tablets; JS toggles html.fp-appbar-on) ----- */
.fp-appbar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 96;               /* above .v-topbar / .home-nav (50), below sidenav (999) and modals */
  height: var(--fp-appbar-h);
  padding-block: 0;
  padding-inline: 4px 12px;
  align-items: center;
  gap: 10px;
  background: var(--surface-solid);
  color: var(--text-1);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.08);
  font-family: var(--font);
}
html.fp-appbar-on .fp-appbar { display: flex; }
/* !important: the public pages reset .home-body { padding: 0 !important }. */
html.fp-appbar-on body { padding-top: var(--fp-appbar-h) !important; }

/* Everything pinned to the top of the viewport moves down by the bar
   height (plus the demo banner when that one is mounted too). */
html.fp-appbar-on body .home-nav    { top: calc(12px + var(--fp-appbar-h) + var(--demo-banner-h, 0px)) !important; }
html.fp-appbar-on body .home-mobile { top: calc(78px + var(--fp-appbar-h) + var(--demo-banner-h, 0px)) !important; }
html.fp-appbar-on body .v-topbar    { top: var(--fp-appbar-h); }
html.fp-appbar-on body #demo-banner { top: var(--fp-appbar-h); }

.fp-appbar__x {
  flex: 0 0 auto;
  width: 32px; height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0; border: 0; background: none;
  color: var(--text-3);
  cursor: pointer;
}
.fp-appbar__x:focus { background: none; }
.fp-appbar__x .material-icons { font-size: 20px; }

.fp-appbar__icon {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  border-radius: 11px;
  object-fit: cover;
  background: var(--surface-soft);
  box-shadow: 0 0 0 1px var(--border);
}
.fp-appbar__icon--blank {
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-3));
  color: #fff;
}

.fp-appbar__text {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.fp-appbar__text strong,
.fp-appbar__text span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fp-appbar__text strong { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; color: var(--text-1); }
.fp-appbar__text span   { font-size: 13.5px; color: var(--text-3); margin-top: 2px; }

.fp-appbar__cta,
.fp-appbar__cta:focus {
  flex: 0 0 auto;
  padding: 9px 20px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--accent);
  color: #fff;
  font: 600 15px/1.2 var(--font);
  box-shadow: 0 4px 14px var(--accent-glow);
  cursor: pointer;
  transition: transform 0.12s ease;
}
.fp-appbar__cta:active { transform: scale(0.96); }

/* ----- BOTTOM SHEET ----- */
.fp-sheet {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  font-family: var(--font);
  /* Palette of the illustrated browser mock-ups (iOS-like). */
  --ill-screen: #f2f2f7;
  --ill-card:   #ffffff;
  --ill-text:   #111114;
  --ill-sub:    rgba(17, 17, 20, 0.38);
  --ill-frame:  #c7c7cc;
  --ill-line:   rgba(0, 0, 0, 0.08);
}
[data-theme="dark"] .fp-sheet {
  --ill-screen: #1c1c1e;
  --ill-card:   #2c2c2e;
  --ill-text:   #f5f5f7;
  --ill-sub:    rgba(245, 245, 247, 0.38);
  --ill-frame:  #48484a;
  --ill-line:   rgba(255, 255, 255, 0.08);
}
/* While the sheet is open (body.fp-sheet-open, set by install-pwa.js)
   the page's heavy decoration stops: the drifting blurred background,
   the hero orbs (blur 160px) and the floating mockup (backdrop-filter).
   Phones re-apply those blurs on every frame of the slide-in, which made
   the sheet crawl in. On phones the sheet covers them anyway, so they
   are hidden; on wider screens, where they stay visible around the
   sheet, they are only paused. */
body.fp-sheet-open::before,
body.fp-sheet-open .home-hero__orb,
body.fp-sheet-open .home-mockup,
body.fp-sheet-open .home-eyebrow__dot { animation-play-state: paused; }
@media (max-width: 768px) {
  body.fp-sheet-open::before,
  body.fp-sheet-open .home-hero__orbs,
  body.fp-sheet-open .home-mockup { visibility: hidden; }
}

.fp-sheet__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.26s ease;
  will-change: opacity;
  touch-action: none;
}
.fp-sheet.is-open .fp-sheet__backdrop { opacity: 1; }

.fp-sheet__panel {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface-solid);
  color: var(--text-1);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.28);
  transform: translate3d(0, 100%, 0);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  will-change: transform;
  padding-bottom: env(safe-area-inset-bottom);
}
.fp-sheet.is-open .fp-sheet__panel { transform: translate3d(0, 0, 0); }
.fp-sheet__panel.is-dragging { transition: none; }

.fp-sheet__grab {
  display: flex;
  justify-content: center;
  padding: 8px 0 2px;
  touch-action: none;
  cursor: grab;
}
.fp-sheet__grab span {
  width: 38px; height: 5px;
  border-radius: 3px;
  background: var(--border-strong);
}

.fp-sheet__head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 56px 14px;
  border-bottom: 1px solid var(--border);
  touch-action: none;
}
.fp-sheet__head h3 { margin: 0; font-size: 17px; font-weight: 700; text-align: center; }

.fp-sheet__x,
.fp-sheet__x:focus {
  position: absolute;
  left: 10px; top: 50%;
  width: 40px; height: 40px;
  margin-top: -23px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0; border: 0; border-radius: 50%;
  background: none;
  color: var(--accent);
  cursor: pointer;
}
[dir="rtl"] .fp-sheet__x { left: auto; right: 10px; }
.fp-sheet__x .material-icons { font-size: 24px; }

.fp-sheet__body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 18px 20px 26px;
  background: var(--surface-soft);
}
.fp-sheet__q {
  margin: 4px 0 16px;
  font-size: 17px;
  font-weight: 700;
  text-align: center;
  color: var(--text-1);
}
.fp-sheet__step {
  margin: 12px 4px 22px;
  font-size: 15px;
  line-height: 1.45;
  text-align: center;
  color: var(--text-2);
}
.fp-sheet__step b { color: var(--text-1); }
.fp-sheet__nobr  { white-space: nowrap; }
.fp-sheet__share { display: inline-flex; vertical-align: -4px; color: var(--accent); }
.fp-sheet__share .material-icons { font-size: 19px; }
.fp-sheet__note {
  margin: 4px 0 0;
  font-size: 12.5px;
  text-align: center;
  color: var(--text-3);
}

/* "Install app" — shown once Chromium hands over the native prompt */
.fp-sheet__cta,
.fp-sheet__cta:focus {
  width: 100%;
  margin: 0 0 16px;
  padding: 13px 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--accent);
  color: #fff;
  font: 600 15px/1.2 var(--font);
  box-shadow: 0 6px 18px var(--accent-glow);
  cursor: pointer;
}
.fp-sheet__cta[hidden] { display: none; }
.fp-sheet__cta .material-icons { font-size: 20px; }

/* "Already installed" state */
.fp-sheet__done { display: flex; justify-content: center; margin: 6px 0 4px; color: var(--success, #30d158); }
.fp-sheet__done .material-icons { font-size: 52px; }

/* Per-browser step list (Android, desktop, others) */
.fp-sheet .pwa-guide { margin-bottom: 14px; text-align: start; }
.pwa-guide__device {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
  font-size: 13px;
  color: var(--text-2);
}
.pwa-guide__device .material-icons { font-size: 20px; color: var(--accent); }
.pwa-guide__steps { list-style: none; margin: 0; padding: 0; }
.pwa-guide__steps li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-1);
}
.pwa-guide__steps li + li { border-top: 1px dashed var(--border); }
.pwa-guide__num {
  flex-shrink: 0;
  width: 24px; height: 24px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}
.pwa-guide__text { flex: 1; }
.pwa-guide__text b { color: var(--text-1); }
.pwa-inline-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px;
  margin: 0 2px;
  vertical-align: -7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-soft);
}
.pwa-inline-icon .material-icons { font-size: 16px; color: var(--accent); }
.pwa-guide__hint {
  margin: 14px 0 0;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  font-size: 12.5px;
  color: var(--text-2);
}
.pwa-guide__hint b { color: var(--accent); }

/* ----- ILLUSTRATIONS (pure CSS browser mock-ups) ----- */
.fp-ill {
  position: relative;
  width: min(100%, 320px);
  height: 170px;
  margin: 0 auto;
  overflow: hidden;
  background: var(--ill-screen);
  color: var(--ill-text);
  border: 6px solid var(--ill-frame);
  border-top: 0;
  border-radius: 0 0 40px 40px;
  font-size: 13px;
}
/* Fade the cut edge of the mock-up into its screen colour. A static
   overlay instead of mask-image: masks are costly to composite on
   phones. */
.fp-ill::after {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 26px;
  background: linear-gradient(to bottom, var(--ill-screen), transparent);
  pointer-events: none;
  z-index: 2;
}
.fp-ill--top {
  border-top: 6px solid var(--ill-frame);
  border-bottom: 0;
  border-radius: 40px 40px 0 0;
}
.fp-ill--top::after {
  top: auto; bottom: 0;
  background: linear-gradient(to top, var(--ill-screen), transparent);
}
.fp-ill .material-icons { font-size: 18px; }

.fp-ill__page {
  position: absolute;
  left: 18px; right: 18px; top: 30px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.fp-ill--top .fp-ill__page { top: 76px; }
.fp-ill__page span { display: block; height: 8px; border-radius: 4px; background: var(--ill-line); }
.fp-ill__page span:nth-child(2) { width: 72%; }
.fp-ill__page span:nth-child(3) { width: 46%; }

/* Safari 26 compact bar: back · address pill · more */
.fp-ill__bar {
  position: absolute;
  left: 10px; right: 10px; bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.fp-ill__circle {
  flex: 0 0 auto;
  width: 36px; height: 36px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--ill-card);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
.fp-ill__pill {
  flex: 1 1 auto;
  min-width: 0;
  height: 36px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border-radius: 18px;
  background: var(--ill-card);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
.fp-ill__host {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-align: center;
  font-size: 12.5px;
}

/* Popover menu */
.fp-ill__menu {
  background: var(--ill-card);
  border-radius: 14px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
  overflow: hidden;
}
.fp-ill__menu--float { position: absolute; right: 12px; bottom: 58px; width: 64%; }
[dir="rtl"] .fp-ill__menu--float { right: auto; left: 12px; }
.fp-ill__row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  white-space: nowrap;
  overflow: hidden;
}
.fp-ill__row + .fp-ill__row { border-top: 1px solid var(--ill-line); }
.fp-ill__row span { overflow: hidden; text-overflow: ellipsis; }
.fp-ill__row--dim { color: var(--ill-sub); }
.fp-ill__row--on { font-weight: 600; }
.fp-ill__row--on .material-icons { color: var(--accent); }

/* Ring on the control the user has to tap. The pulse is a pseudo
   element animated with transform/opacity only, so the GPU moves it
   without repainting the mock-up on every frame. */
.fp-ill__hot {
  position: relative;
  color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent), 0 0 10px var(--accent-glow);
}
.fp-ill__hot::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: inherit;
  box-shadow: 0 0 0 3px var(--accent), 0 0 14px var(--accent-glow);
  opacity: 0;
  /* A few pulses to catch the eye, then it rests (no endless repaint). */
  animation: fpIllPulse 1.6s ease-out 0.35s 3;
  pointer-events: none;
}
@keyframes fpIllPulse {
  0%   { transform: scale(1);    opacity: 0.9; }
  100% { transform: scale(1.35); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .fp-ill__hot::after { animation: none; opacity: 0; } }

/* Safari 18 and older: address pill above the toolbar */
.fp-ill__pill--wide { position: absolute; left: 14px; right: 14px; bottom: 54px; }
.fp-ill__toolbar {
  position: absolute;
  left: 16px; right: 16px; bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--accent);
}
.fp-ill__btn {
  width: 34px; height: 34px;
  border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
}

/* Chrome on iOS: omnibox at the top with Share on its right edge */
.fp-ill__omni {
  position: absolute;
  left: 12px; right: 12px; top: 18px;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px 0 12px;
  border-radius: 20px;
  background: var(--ill-card);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
.fp-ill__omni .fp-ill__btn { border-radius: 50%; }
.fp-ill__omni .fp-ill__host { text-align: start; }

/* "Add to Home Screen" list */
.fp-ill--list { height: auto; padding: 30px 26px 24px; }
.fp-ill--list .fp-ill__menu { border-radius: 14px 14px 0 0; box-shadow: none; }
.fp-ill__row--pop {
  position: relative;
  margin: 0 -14px;
  padding: 13px 18px;
  border-radius: 14px;
  background: var(--ill-card);
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18), 0 0 0 2px var(--accent);
}
.fp-ill__row--pop .material-icons { font-size: 22px; color: var(--accent); }
