/*
 * Whapido - Mobile fixed header + fixed breadcrumb (all pages) + fixed title (single product)
 * v0.1.16
 *
 * Goals (mobile):
 * - Header ALWAYS fixed (no collapse/hide on scroll)
 * - Breadcrumb ALWAYS fixed right under header (all pages)
 * - Single product title block fixed under breadcrumb (only if present)
 * - Avoid 1px white gap between header and breadcrumb
 */

/*
 * Primary targeting: Elessi adds `nasa-in-mobile` on mobile layouts.
 * We apply rules via that class so it works even when viewport width is
 * slightly above 768px (some devices / zoom / landscape).
 */
body.nasa-in-mobile #header-content {
  position: fixed !important;
  top: var(--whp-adminbar-h, 0px) !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  transform: none !important;
  -webkit-transform: none !important;
  opacity: 1 !important;
  visibility: visible !important;
  /* Above page content, but BELOW off-canvas overlays (menu/minicart) */
  z-index: 350 !important;
  transition: none !important;
  -webkit-transition: none !important;
  will-change: auto !important;
}

body.nasa-in-mobile #nasa-breadcrumb-site {
  position: fixed !important;
  top: calc(var(--whp-adminbar-h, 0px) + var(--whp-mobile-header-h, 0px) - 1px) !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  margin: 0 !important;
  transform: none !important;
  -webkit-transform: none !important;
  z-index: 349 !important;
}

body.nasa-in-mobile #nasa-breadcrumb-site .breadcrumb-row {
  margin-top: 0 !important;
}

body.single-product.nasa-in-mobile .whp-mobile-product-title {
  position: fixed !important;
  top: calc(
    var(--whp-adminbar-h, 0px) +
    var(--whp-mobile-header-h, 0px) +
    var(--whp-mobile-breadcrumb-h, 0px) - 1px
  ) !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  z-index: 348 !important;
  background: #fff;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
}

body.nasa-in-mobile #main-content {
  padding-top: calc(
    var(--whp-mobile-header-h, 0px) +
    var(--whp-mobile-breadcrumb-h, 0px) +
    var(--whp-mobile-title-h, 0px)
  ) !important;
}

/* Fallback targeting by viewport width (if body class isn't present) */
@media (max-width: 768px) {
  /*
   * 1) Header: truly fixed + always visible
   * Target the real header element (#header-content) so we override
   * Elessi JS that sets inline `top: -Xpx` on scroll down.
   */
  body.nasa-in-mobile #header-content,
  body #header-content {
    position: fixed !important;
    top: var(--whp-adminbar-h, 0px) !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    transform: none !important;
    -webkit-transform: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    /* Above page content, but BELOW off-canvas overlays (menu/minicart) */
    z-index: 350 !important;
    transition: none !important;
    -webkit-transition: none !important;
    will-change: auto !important;
  }

  /* Some layouts also move the wrapper/icons; keep them visible too */
  body.nasa-in-mobile .header-wrapper,
  body .header-wrapper,
  body.nasa-in-mobile .nasa-mobile-fixed,
  body .nasa-mobile-fixed,
  body.nasa-in-mobile .nasa-header-icons-wrap,
  body .nasa-header-icons-wrap {
    transform: none !important;
    -webkit-transform: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    transition: none !important;
    -webkit-transition: none !important;
  }

  /*
   * 2) Breadcrumb: fixed on ALL pages.
   * -1px pulls it up to avoid the visible gap.
   */
  body.nasa-in-mobile #nasa-breadcrumb-site,
  body #nasa-breadcrumb-site {
    position: fixed !important;
    top: calc(var(--whp-adminbar-h, 0px) + var(--whp-mobile-header-h, 0px) - 1px) !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    margin: 0 !important;
    transform: none !important;
    -webkit-transform: none !important;
    z-index: 349 !important;
  }

  /* Ensure the breadcrumb doesn't leave extra internal spacing that looks like a line */
  body.nasa-in-mobile #nasa-breadcrumb-site .breadcrumb-row,
  body #nasa-breadcrumb-site .breadcrumb-row {
    margin-top: 0 !important;
  }

  /*
   * 3) Product title block (single product only)
   * We use the Whapido-injected title above the gallery.
   */
  body.single-product.nasa-in-mobile .whp-mobile-product-title,
  body.single-product .whp-mobile-product-title {
    position: fixed !important;
    top: calc(
      var(--whp-adminbar-h, 0px) +
      var(--whp-mobile-header-h, 0px) +
      var(--whp-mobile-breadcrumb-h, 0px) - 1px
    ) !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    z-index: 348 !important;
    background: #fff;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
  }

  /*
   * 4) Push the page content down so it doesn't hide behind fixed bars.
   * JS updates these CSS vars dynamically.
   */
  body.nasa-in-mobile #main-content,
  body #main-content {
    padding-top: calc(
      var(--whp-mobile-header-h, 0px) +
      var(--whp-mobile-breadcrumb-h, 0px) +
      var(--whp-mobile-title-h, 0px)
    ) !important;
  }
}

/* ------------------------------------------------------------------
 * Z-INDEX SAFETY (mini-cart + off-canvas menu must be above header/bc)
 * ------------------------------------------------------------------ */
body.nasa-in-mobile #cart-sidebar,
body.nasa-in-mobile #nasa-menu-sidebar-content,
body #cart-sidebar,
body #nasa-menu-sidebar-content {
  z-index: 999999 !important;
}

body.nasa-in-mobile .black-window,
body .black-window {
  z-index: 999998 !important;
}

/* ------------------------------------------------------------------
 * Whapido link at the bottom of the MOBILE off-canvas menu
 * ------------------------------------------------------------------ */
body.nasa-in-mobile #nasa-menu-sidebar-content .whp-mobile-menu-footer {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 2;
  background: #fff;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  padding: 14px 18px;
  text-align: center;
  direction: ltr;
}

body.nasa-in-mobile #nasa-menu-sidebar-content .whp-mobile-menu-footer a {
  display: block;
  font-size: 13px;
  line-height: 1.3;
  color: inherit;
  text-decoration: none;
}

body.nasa-in-mobile #nasa-menu-sidebar-content .whp-mobile-menu-footer strong {
  font-weight: 700;
}

body.nasa-in-mobile #nasa-menu-sidebar-content .whp-mobile-menu-footer .whp-mobile-menu-footer__url {
  opacity: 0.85;
  text-decoration: underline;
}

/* Ensure menu items aren't hidden behind the sticky footer */
body.nasa-in-mobile #nasa-menu-sidebar-content .nasa-mobile-nav-wrap {
  padding-bottom: 70px;
}
