/* ========================================================================
 * AG FLOLIST V49 | Mobile/tablet sticky header and accessible account links
 * All rules are under 1180px; PC layout stays as it is.
 * ======================================================================== */
@media screen and (max-width: 1179px) {
  :root { --agfl-sticky-height: 75px; }
  html { scroll-padding-top: calc(var(--agfl-sticky-height) + 16px); }

  body .site-header {
    position: sticky !important;
    inset: auto !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    z-index: 1100 !important;
    background: #fffbf8 !important;
    border-bottom: 1px solid #e8dcd3 !important;
    box-shadow: 0 4px 16px rgba(55, 40, 31, .055);
  }
  body .site-header__inner {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 10px !important;
    height: var(--agfl-sticky-height) !important;
    min-width: 0;
  }
  body .site-header__inner > .site-header__logo {
    order: 1;
    margin-right: auto !important;
    flex: 0 0 auto !important;
  }
  body .site-header__inner > .menu-toggle {
    order: 3;
    flex: 0 0 46px !important;
    width: 46px !important;
    height: 46px !important;
    margin: 0 !important;
    z-index: 2;
  }

  /* JS inserts the existing Welcart account/cart markup before the toggle.
     Preserve href, existing click handlers, and any quantity badge. */
  body .site-header__inner > article.my_account {
    order: 2;
    position: static !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    z-index: auto !important;
    flex: 0 0 auto !important;
    width: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    transform: none !important;
  }
  body .site-header__inner > article.my_account ul.my_list {
    display: flex !important;
    gap: 6px !important;
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
  }
  body .site-header__inner > article.my_account ul.my_list > li {
    position: relative !important;
    width: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
  }
  body .site-header__inner > article.my_account ul.my_list > li > a {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 42px !important;
    height: 42px !important;
    padding: 9px !important;
    border: 1px solid #e8ddd4 !important;
    border-radius: 9px !important;
    background: #faf7f4 !important;
    box-shadow: none !important;
  }
  body .site-header__inner > article.my_account ul.my_list > li > a img {
    display: block !important;
    width: 21px !important;
    height: 21px !important;
    max-height: 21px !important;
    object-fit: contain !important;
    filter: brightness(0) saturate(100%);
  }
  body .site-header__inner > article.my_account ul.my_list > li > span.total-quant {
    top: -5px !important;
    right: -5px !important;
    z-index: 1;
    font-size: 10px !important;
  }
  body.menu-open .site-header__inner > article.my_account {
    visibility: hidden !important;
    pointer-events: none !important;
  }

  /* In case a browser blocks the move script, keep the original icons
     away from the logo instead of leaving them at top:0/left:0. */
  body article.my_account:not(.agfl-mobile-account-inline) {
    position: fixed !important;
    top: 16px !important;
    right: 79px !important;
    left: auto !important;
    width: 90px !important;
    margin: 0 !important;
    z-index: 1101 !important;
  }

  /* The overlay starts BELOW the sticky header.  No duplicate menu logo. */
  body .sp-menu {
    top: var(--agfl-sticky-height) !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: auto !important;
    z-index: 1090 !important;
  }
  body .sp-menu__head { display: none !important; }
  body .sp-menu__list { margin-top: 14px !important; }

  /* Existing category title has top padding for an absolute header.
     Sticky header now occupies its own 75px in the document flow. */
  body #main.ag-product-category.ag-product-category--premium {
    padding-top: 42px !important;
  }
  body .ag-list-section, body .ag-list-anchor-alias {
    scroll-margin-top: calc(var(--agfl-sticky-height) + 16px);
  }
}

@media screen and (max-width: 599px) {
  :root { --agfl-sticky-height: 70px; }
  body .site-header__inner { gap: 8px !important; }
  body .site-header__inner > article.my_account ul.my_list > li > a {
    width: 40px !important;
    height: 40px !important;
    padding: 8px !important;
  }
  body #main.ag-product-category.ag-product-category--premium {
    padding-top: 24px !important;
  }
}
@media screen and (max-width: 360px) {
  body .site-header__inner > .site-header__logo {
    width: min(125px, 38vw) !important;
  }
  body .site-header__inner > article.my_account ul.my_list { gap: 4px !important; }
  body .site-header__inner { gap: 5px !important; }
}
/* WordPress admin bar (visible only to logged-in WP operators). */
@media screen and (min-width: 783px) and (max-width: 1179px) {
  body.admin-bar .site-header { top: 32px !important; }
  body.admin-bar .sp-menu { top: calc(var(--agfl-sticky-height) + 32px) !important; }
}
@media screen and (max-width: 782px) {
  body.admin-bar .site-header { top: 46px !important; }
  body.admin-bar .sp-menu { top: calc(var(--agfl-sticky-height) + 46px) !important; }
}

/* When the mobile drawer locks body scrolling, Chromium no longer keeps the
   sticky header pinned. Switch it to fixed for the open drawer state. */
@media screen and (max-width: 1179px) {
  body.menu-open .site-header {
    position: fixed !important;
    top: 0 !important;
  }
}
@media screen and (max-width: 782px) {
  body.admin-bar.menu-open .site-header { top: 46px !important; }
}
@media screen and (min-width: 783px) and (max-width: 1179px) {
  body.admin-bar.menu-open .site-header { top: 32px !important; }
}

/* The bottom cart dock has a much higher stacking order than the menu.
   Suppress it while the navigation drawer is open, then restore it. */
@media screen and (max-width: 1179px) {
  body.menu-open .agfl-cart-dock {
    visibility: hidden !important;
    pointer-events: none !important;
  }
}
