/* AJF PWA Manager — clean front-end stylesheet (v1.0.28)
 * Owns only PWA UI: install prompt, app bottom navigation and app-only
 * compatibility safeguards. Header layout/auth controls remain owned by HFM.
 */

/* Install button */
.ajf-pwa-install-button[hidden] { display: none !important; }

/* The app navigation is injected by AJF PWA and is never shown on desktop. */
nav.ajf-mobile-nav { display: none !important; }

/* Show AJF app navigation only when launched as an installed PWA. */
@media (display-mode: standalone) {
  html.ajf-pwa-standalone nav.ajf-mobile-nav { display: grid !important; }
}

@media screen and (max-width: 900px) {
  html.ajf-pwa-standalone body { padding-bottom: calc(92px + env(safe-area-inset-bottom, 0px)) !important; }

  body > html.ajf-pwa-standalone nav.ajf-mobile-nav,
  html.ajf-pwa-standalone nav.ajf-mobile-nav {
    position: fixed !important;
    z-index: 999990 !important;
    left: 12px !important;
    right: 12px !important;
    bottom: calc(9px + env(safe-area-inset-bottom, 0px)) !important;
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    grid-auto-flow: column !important;
    align-items: stretch !important;
    justify-items: stretch !important;
    gap: 5px !important;
    width: auto !important;
    max-width: none !important;
    min-width: 0 !important;
    height: 68px !important;
    min-height: 68px !important;
    max-height: 68px !important;
    margin: 0 !important;
    padding: 7px !important;
    box-sizing: border-box !important;
    overflow: visible !important;
    border: 1px solid rgba(18, 59, 103, .14) !important;
    border-radius: 20px !important;
    background: rgba(255,255,255,.97) !important;
    box-shadow: 0 9px 28px rgba(17,42,70,.18) !important;
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    transform: none !important;
  }

  html.ajf-pwa-standalone nav.ajf-mobile-nav > a.ajf-mobile-nav__item {
    position: relative !important;
    display: flex !important;
    flex: none !important;
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: center !important;
    justify-self: stretch !important;
    align-self: stretch !important;
    gap: 4px !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    height: 100% !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 4px 2px !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    border: 0 !important;
    border-radius: 14px !important;
    background: transparent !important;
    color: #6c7a89 !important;
    font: 600 11px/1.15 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !important;
    text-align: center !important;
    text-decoration: none !important;
    white-space: nowrap !important;
    -webkit-tap-highlight-color: transparent;
  }

  html.ajf-pwa-standalone nav.ajf-mobile-nav > a.ajf-mobile-nav__item > svg {
    display: block !important;
    flex: 0 0 22px !important;
    width: 22px !important;
    height: 22px !important;
    min-width: 22px !important;
    min-height: 22px !important;
    max-width: 22px !important;
    max-height: 22px !important;
    fill: currentColor !important;
    stroke: none !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  html.ajf-pwa-standalone nav.ajf-mobile-nav > a.ajf-mobile-nav__item > span {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    color: inherit !important;
    font: inherit !important;
    line-height: inherit !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  html.ajf-pwa-standalone nav.ajf-mobile-nav > a.ajf-mobile-nav__item.is-active {
    color: #fff !important;
    background: linear-gradient(135deg, #164d80, #087bc0) !important;
    box-shadow: 0 4px 12px rgba(15,83,139,.24) !important;
  }

  html.ajf-pwa-standalone nav.ajf-mobile-nav > a.ajf-mobile-nav__item:focus-visible {
    outline: 2px solid #087bc0 !important;
    outline-offset: -2px !important;
  }

  html.ajf-pwa-standalone nav.ajf-mobile-nav > a.ajf-mobile-nav__item:active {
    transform: scale(.97) !important;
  }
}

@media screen and (max-width: 360px) {
  html.ajf-pwa-standalone nav.ajf-mobile-nav > a.ajf-mobile-nav__item { font-size: 10px !important; }
}

/* Mobile app uses its own bottom navigation instead of the theme footer. */
@media screen and (max-width: 767px) {
  html.ajf-pwa-standalone body footer,
  html.ajf-pwa-standalone body [role="contentinfo"],
  html.ajf-pwa-standalone body #colophon,
  html.ajf-pwa-standalone body .site-footer,
  html.ajf-pwa-standalone body .ast-footer,
  html.ajf-pwa-standalone body .ast-footer-overlay,
  html.ajf-pwa-standalone body .ast-footer-wrap,
  html.ajf-pwa-standalone body .ast-primary-footer,
  html.ajf-pwa-standalone body .ast-primary-footer-bar,
  html.ajf-pwa-standalone body .ast-small-footer,
  html.ajf-pwa-standalone body .ast-small-footer-wrap,
  html.ajf-pwa-standalone body .ast-builder-footer-grid-columns,
  html.ajf-pwa-standalone body .site-primary-footer-wrap,
  html.ajf-pwa-standalone body .site-below-footer-wrap,
  html.ajf-pwa-standalone body .ast-footer-copyright,
  html.ajf-pwa-standalone body .elementor-location-footer,
  html.ajf-pwa-standalone body .elementor-footer,
  html.ajf-pwa-standalone body .elementor[data-elementor-type="footer"],
  html.ajf-pwa-standalone body .wp-site-blocks > footer {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
  }
}

/* Install-help dialog */
#ajf-pwa-install-help {
  position: fixed !important;
  inset: 0 !important;
  z-index: 1000001 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 20px !important;
  box-sizing: border-box !important;
  background: rgba(10,25,43,.62) !important;
}
#ajf-pwa-install-help .ajf-pwa-install-help__card {
  position: relative !important;
  width: min(100%, 390px) !important;
  padding: 28px 22px 24px !important;
  box-sizing: border-box !important;
  border-radius: 18px !important;
  background: #fff !important;
  color: #18324d !important;
  box-shadow: 0 18px 55px rgba(0,0,0,.22) !important;
  text-align: center !important;
}
#ajf-pwa-install-help .ajf-pwa-install-help__logo {
  display: grid !important;
  place-items: center !important;
  width: 58px !important;
  height: 58px !important;
  margin: 0 auto 12px !important;
  border-radius: 16px !important;
  background: #123b67 !important;
  color: #fff !important;
  font-size: 20px !important;
  font-weight: 800 !important;
}
#ajf-pwa-install-help h3 {
  margin: 0 24px 12px !important;
  color: #123b67 !important;
  font-size: 21px !important;
}
#ajf-pwa-install-help p { margin: 0 0 12px !important; line-height: 1.55 !important; }
#ajf-pwa-install-help .ajf-pwa-install-help__note { color: #687789 !important; font-size: 12px !important; }
#ajf-pwa-install-help .ajf-pwa-install-help__close {
  position: absolute !important;
  top: 8px !important;
  right: 12px !important;
  border: 0 !important;
  background: transparent !important;
  color: #526273 !important;
  font-size: 28px !important;
  line-height: 1 !important;
  cursor: pointer !important;
}

/* Installed app only: suppress Astra's duplicate header, never the AJF HFM header. */
@media (display-mode: standalone) {
  html.ajf-pwa-standalone body.ajf-hfm-ready #masthead,
  html.ajf-pwa-standalone body.ajf-hfm-ready header.ast-header-break-point,
  html.ajf-pwa-standalone body.ajf-hfm-ready .ast-primary-header-bar,
  html.ajf-pwa-standalone body.ajf-hfm-ready .ast-mobile-header-wrap,
  html.ajf-pwa-standalone body.ajf-hfm-ready .ast-desktop-header,
  html.ajf-pwa-standalone body.ajf-hfm-ready .ast-mobile-header,
  html.ajf-pwa-standalone body.ajf-hfm-ready .ast-builder-menu-mobile,
  html.ajf-pwa-standalone body.ajf-hfm-ready .ast-mobile-popup-drawer {
    display: none !important;
    visibility: hidden !important;
    width: 0 !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    pointer-events: none !important;
  }

  html.ajf-pwa-standalone body.ajf-hfm-ready header.ajf-hfm-header {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }
}

/* HFM owns these controls. PWA only protects their real icon graphics from
   accidental inherited visibility/size rules; it does not create text labels,
   hide Login/Register links, or change click behavior. */
@media screen and (max-width: 767px) {
  html.ajf-pwa-standalone body.ajf-hfm-ready .ajf-hfm-header .ajf-hfm-mobile-search-toggle,
  html.ajf-pwa-standalone body.ajf-hfm-ready .ajf-hfm-header .ajf-hfm-toggle {
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }
  html.ajf-pwa-standalone body.ajf-hfm-ready .ajf-hfm-header .ajf-hfm-mobile-search-toggle svg {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: 20px !important;
    height: 20px !important;
    max-width: 20px !important;
    max-height: 20px !important;
    overflow: visible !important;
  }
  html.ajf-pwa-standalone body.ajf-hfm-ready .ajf-hfm-header .ajf-hfm-toggle > span {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: 21px !important;
    height: 2px !important;
    min-height: 2px !important;
    margin: 3px auto !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 2px !important;
    background: currentColor !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  nav.ajf-mobile-nav,
  nav.ajf-mobile-nav *,
  #ajf-pwa-install-help * { animation: none !important; transition: none !important; }
}


/* v1.0.28 — draw mobile header icons independently of inherited theme styles.
 * Do not suppress pseudo-elements: the search glyph is rendered with CSS,
 * while hamburger bars are rendered by the three HFM spans.
 */
@media screen and (max-width: 767px) {
  html.ajf-pwa-standalone body.ajf-hfm-ready .ajf-hfm-header button.ajf-hfm-mobile-search-toggle {
    position: relative !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 38px !important;
    min-width: 38px !important;
    height: 38px !important;
    padding: 0 !important;
    font-size: 0 !important;
    line-height: 0 !important;
    color: #173b68 !important;
    overflow: visible !important;
  }
  html.ajf-pwa-standalone body.ajf-hfm-ready .ajf-hfm-header button.ajf-hfm-mobile-search-toggle svg {
    display: none !important;
  }
  html.ajf-pwa-standalone body.ajf-hfm-ready .ajf-hfm-header button.ajf-hfm-mobile-search-toggle::before {
    content: "" !important;
    display: block !important;
    position: absolute !important;
    width: 11px !important;
    height: 11px !important;
    left: 11px !important;
    top: 10px !important;
    border: 2px solid currentColor !important;
    border-radius: 50% !important;
    box-sizing: border-box !important;
  }
  html.ajf-pwa-standalone body.ajf-hfm-ready .ajf-hfm-header button.ajf-hfm-mobile-search-toggle::after {
    content: "" !important;
    display: block !important;
    position: absolute !important;
    width: 7px !important;
    height: 2px !important;
    left: 21px !important;
    top: 22px !important;
    background: currentColor !important;
    border-radius: 2px !important;
    transform: rotate(45deg) !important;
    transform-origin: left center !important;
  }
  html.ajf-pwa-standalone body.ajf-hfm-ready .ajf-hfm-header button.ajf-hfm-toggle {
    display: block !important;
    position: relative !important;
    width: 38px !important;
    min-width: 38px !important;
    height: 38px !important;
    padding: 0 !important;
    font-size: 0 !important;
    line-height: 0 !important;
    color: #173b68 !important;
    background-color: #fff !important;
    background-image: linear-gradient(#173b68,#173b68), linear-gradient(#173b68,#173b68), linear-gradient(#173b68,#173b68) !important;
    background-repeat: no-repeat !important;
    background-size: 21px 2px, 21px 2px, 21px 2px !important;
    background-position: center 10px, center 18px, center 26px !important;
    overflow: visible !important;
  }
  /* The three original spans remain in the markup for accessibility/compatibility,
     but CSS gradients draw the bars independently of theme span styling. */
  html.ajf-pwa-standalone body.ajf-hfm-ready .ajf-hfm-header button.ajf-hfm-toggle > span {
    display: none !important;
  }
}

/* Keep each bottom-nav item in its own grid cell even if theme rules set
 * grid placement or flex sizing on generic navigation links. */
@media screen and (max-width: 900px) {
  nav.ajf-mobile-nav {
    grid-template-rows: minmax(0, 1fr) !important;
    grid-auto-columns: minmax(0, 1fr) !important;
    grid-auto-flow: column !important;
  }
  nav.ajf-mobile-nav > a.ajf-mobile-nav__item {
    grid-row: 1 !important;
    min-height: 0 !important;
    align-self: stretch !important;
  }
  nav.ajf-mobile-nav > a.ajf-mobile-nav__item:nth-child(1) { grid-column: 1 !important; }
  nav.ajf-mobile-nav > a.ajf-mobile-nav__item:nth-child(2) { grid-column: 2 !important; }
  nav.ajf-mobile-nav > a.ajf-mobile-nav__item:nth-child(3) { grid-column: 3 !important; }
}


/* v1.0.30 — hide the standalone mobile auth row below the logo and
   place its account links inside the hamburger navigation instead. */
@media screen and (max-width: 767px) {
  html.ajf-pwa-standalone body.ajf-hfm-ready .ajf-hfm-header .ajf-hfm-auth-actions {
    display: none !important;
  }
  html.ajf-pwa-standalone body.ajf-hfm-ready .ajf-hfm-header .ajf-hfm-nav .ajf-pwa-account-menu-item {
    display: block !important;
    width: 100% !important;
  }
  html.ajf-pwa-standalone body.ajf-hfm-ready .ajf-hfm-header .ajf-hfm-nav .ajf-pwa-account-menu-item > a {
    display: block !important;
    padding: 12px 5px !important;
    font-size: 14px !important;
    color: inherit !important;
  }
}


/* v1.0.32 — prevent the HFM account row from flashing before DOM-ready.
 * HFM intentionally forces this row to display:flex!important on mobile.
 * Do not wait for body.ajf-hfm-ready: standalone is marked synchronously in wp_head.
 * This selector is app-only, so normal mobile/desktop website headers are untouched.
 */
@media screen and (max-width: 767px) {
  html.ajf-pwa-standalone .ajf-hfm-header .ajf-hfm-head-inner > .ajf-hfm-auth-actions,
  html.ajf-pwa-standalone .ajf-hfm-header .ajf-hfm-auth-actions {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    overflow: hidden !important;
    pointer-events: none !important;
  }
}


/* v1.0.33: Hide the HFM account-action row from the first CSS paint in the
   installed mobile PWA. JS still copies the links into the hamburger menu. */
@media screen and (max-width: 767px) {
  html.ajf-pwa-standalone .ajf-hfm-header .ajf-hfm-auth-actions {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    height: 0 !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    pointer-events: none !important;
  }
}


/* v1.0.34: standalone auth row suppression without viewport/media-query dependency.
   The html class is set synchronously in wp_head only in installed app mode. */
html.ajf-pwa-standalone .ajf-hfm-header .ajf-hfm-auth-actions {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  height: 0 !important;
  min-height: 0 !important;
  max-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  overflow: hidden !important;
  pointer-events: none !important;
}


/* v1.0.35: Android installed-PWA fallback. Use the browser's native
   standalone display-mode signal directly instead of depending on a JS-added
   html class. This only affects the installed app, not normal mobile web. */
@media (display-mode: standalone) and (max-width: 767px) {
  header.ajf-hfm-header .ajf-hfm-head-inner > .ajf-hfm-auth-actions,
  header.ajf-hfm-header .ajf-hfm-auth-actions {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    overflow: hidden !important;
    pointer-events: none !important;
  }
}

/* v1.0.41 — visually separate Login/Dashboard/Logout account actions
   from ordinary navigation links inside the installed app hamburger menu. */
@media screen and (max-width: 767px) {
  html.ajf-pwa-standalone .ajf-hfm-header .ajf-hfm-nav .ajf-pwa-account-menu-item {
    margin: 12px 10px 8px !important;
    padding: 10px !important;
    width: auto !important;
    list-style: none !important;
    background: #f1f6fc !important;
    border: 1px solid #cbdcf0 !important;
    border-radius: 12px !important;
    box-shadow: 0 2px 7px rgba(20, 55, 90, .08) !important;
  }
  html.ajf-pwa-standalone .ajf-hfm-header .ajf-hfm-nav .ajf-pwa-account-menu-item > a {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 42px !important;
    padding: 10px 14px !important;
    border-radius: 8px !important;
    background: #174f85 !important;
    color: #fff !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    line-height: 1.3 !important;
    text-align: center !important;
    text-decoration: none !important;
  }
  html.ajf-pwa-standalone .ajf-hfm-header .ajf-hfm-nav .ajf-pwa-account-menu-item > a[href*="logout"] {
    background: #fff0f0 !important;
    color: #b42318 !important;
    border: 1px solid #f0b9b5 !important;
  }
}
