/* ============================================================================
   Aurenqo — Mobile Shell V2 (<= 900px)

   One unified mobile shell: a compact utility bar, a single main topbar
   (logo on the home page, back + compact title on inner pages), no oversized
   page hero, a real bottom tabbar, and safe-area handling through one set of
   CSS variables.  Desktop (> 900px) is deliberately untouched: every rule
   below lives inside the 900px media query except the one that keeps the new
   topbar hidden on desktop.

   Loaded last on every customer page so it wins over the page-specific sheets
   (home-commerce / mobile-shop-flow / partner).
   ========================================================================== */

.mobile-topbar { display: none; }

@media (max-width: 900px) {
  :root {
    /* One place for every shell height; content clears the tabbar through
       these instead of ad-hoc 66px / 73px / 78px offsets. */
    --shell-utility-h: 40px;
    --shell-topbar-h: 52px;
    --shell-tabbar-h: 58px;
    --shell-safe-top: env(safe-area-inset-top, 0px);
    --shell-safe-bottom: env(safe-area-inset-bottom, 0px);
  }

  /* ---- sticky shell: utility bar + topbar stay pinned together ---- */
  [data-shell-header] { position: sticky; inset-block-start: 0; z-index: 1000; }
  .site-header { position: static; inset-block-start: auto; }

  /* ---- 1. utility bar: three compact selects, never overflowing ---- */
  .utility-bar { padding-top: var(--shell-safe-top); }
  .utility-bar .utility-inner {
    min-height: 0; height: auto; width: 100%; max-width: 100%;
    display: block; overflow: visible; padding: 5px 12px 6px;
  }
  .utility-bar .utility-message { display: none; }
  .utility-bar .utility-controls {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px; width: 100%; margin: 0;
  }
  .utility-bar .utility-controls label { min-width: 0; gap: 0; margin: 0; }
  .utility-bar .utility-controls label > span { display: none; }
  .utility-bar .utility-controls .language-globe { width: 14px; height: 14px; flex: 0 0 auto; margin-inline-end: 2px; }
  .utility-bar .utility-controls select {
    width: 100%; max-width: 100%; min-width: 0; height: 30px;
    padding: 0 20px 0 8px; font-size: .74rem; line-height: 1;
    border: 1px solid var(--line); border-radius: 8px; background: #fff;
    color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  html[dir="rtl"] .utility-bar .utility-controls select { padding: 0 8px 0 20px; }

  /* ---- 2. main topbar ---- */
  .site-header .header-main { display: none; }
  .site-header .nav-row { display: none; padding-block: 8px; }
  .site-header .nav-row.open { display: flex; }
  .mobile-topbar {
    display: flex; align-items: center; gap: 4px;
    min-height: var(--shell-topbar-h); padding: 4px 8px 4px 4px;
    background: rgba(255, 255, 255, .97);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
  }
  html[dir="rtl"] .mobile-topbar { padding: 4px 4px 4px 8px; }
  .mobile-topbar-back {
    display: none; place-items: center; flex: 0 0 auto;
    width: 44px; height: 44px; padding: 0; border: 0; border-radius: 12px;
    background: transparent; color: var(--ink); font-size: 1.35rem; line-height: 1; cursor: pointer;
  }
  /* The forward control is the same size and weight as Back: one shared rule
     keeps the pair visually identical, and both clear the 44px touch target
     without adding a single pixel of page height. */
  .mobile-topbar-forward {
    display: none; place-items: center; flex: 0 0 auto;
    width: 44px; height: 44px; padding: 0; border: 0; border-radius: 12px;
    background: transparent; color: var(--ink); font-size: 1.35rem; line-height: 1; cursor: pointer;
  }
  .mobile-topbar-back:hover, .mobile-topbar-forward:hover { background: var(--canvas); }
  body:not([data-page="home"]) .mobile-topbar-back,
  body:not([data-page="home"]) .mobile-topbar-forward { display: grid; }
  .mobile-topbar-brand {
    display: none; align-items: center; flex: 0 0 auto;
    min-height: 44px; padding-inline: 6px; text-decoration: none;
  }
  body[data-page="home"] .mobile-topbar-brand { display: inline-flex; }
  .mobile-topbar-brand .brand-logo { height: 30px; max-width: 132px; width: auto; display: block; }
  .mobile-topbar-title {
    display: none; flex: 1 1 auto; min-width: 0;
    font-size: 1rem; font-weight: 800; color: var(--ink);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  body:not([data-page="home"]) .mobile-topbar-title { display: block; }
  .mobile-topbar-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 0; }
  .mobile-topbar-actions a, .mobile-topbar-actions .nav-toggle {
    position: relative; display: grid; place-items: center;
    width: 44px; height: 44px; min-width: 44px; min-height: 44px;
    padding: 0; border: 0; border-radius: 12px; background: transparent;
    color: var(--ink); font-size: 1.35rem; line-height: 1; text-decoration: none; cursor: pointer;
  }
  .mobile-topbar-actions a:hover, .mobile-topbar-actions .nav-toggle:hover { background: var(--canvas); }
  .mobile-topbar-actions .cart-badge { inset-inline-end: 3px; inset-block-start: 3px; }

  /* Menu keeps the full primary navigation reachable on every page. */
  .mobile-topbar .nav-toggle { display: grid; }
  .mobile-topbar .nav-toggle span[aria-hidden] { font-size: 1.3rem; }

  /* ---- 3. no oversized page hero on mobile (title lives in the topbar) ---- */
  body:not([data-page="home"]):not([data-page="order-confirmation"]):not([data-page="partner-center"]) .page-hero { display: none; }

  /* Partner Centre: the mobile topbar already carries the page title, but the
     commission explanation is actual business content and must remain visible.
     Keep only that explanation, compactly, instead of hiding the whole hero. */
  body[data-page="partner-center"] .page-hero {
    display: block;
    padding-block: 12px 8px;
  }
  body[data-page="partner-center"] .page-hero .eyebrow,
  body[data-page="partner-center"] .page-hero h1 {
    display: none;
  }
  body[data-page="partner-center"] .page-hero .partner-hero-lead {
    margin: 0;
    max-width: none;
    font-size: .84rem;
    line-height: 1.55;
  }

  /* The order-confirmation hero carries the submitted-help line, so it is
     compacted instead of removed. */
  body[data-page="order-confirmation"] .page-hero { padding-block: 12px; }
  body[data-page="order-confirmation"] .page-hero .eyebrow { display: none; }
  body[data-page="order-confirmation"] .page-hero h1 { font-size: 1.2rem; margin-bottom: 4px; }

  /* ---- 4. bottom tabbar: real touch targets, active state, badge ---- */
  .mobile-bottom-nav {
    position: fixed; z-index: 1200; inset-inline: 0; inset-block-end: 0;
    height: calc(var(--shell-tabbar-h) + var(--shell-safe-bottom));
    padding-bottom: var(--shell-safe-bottom);
    display: grid; grid-template-columns: repeat(4, 1fr);
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, .97);
    backdrop-filter: blur(14px);
  }
  .mobile-bottom-nav a {
    position: relative; display: grid; place-items: center; align-content: center;
    gap: 1px; min-height: 44px; min-width: 44px;
    color: var(--ink-soft); font-size: 12px; font-weight: 800; text-decoration: none;
  }
  .mobile-bottom-nav a > span:first-child { color: var(--ink); font-size: 23px; line-height: 1; }
  .mobile-bottom-nav a.is-active,
  .mobile-bottom-nav a.is-active > span:first-child,
  .mobile-bottom-nav a[aria-current="page"],
  .mobile-bottom-nav a[aria-current="page"] > span:first-child { color: var(--brand); }
  .mobile-bottom-nav a.is-active::after {
    content: ""; position: absolute; inset-block-start: 0; inset-inline: 32%;
    height: 3px; border-radius: 0 0 3px 3px; background: var(--brand);
  }
  .mobile-bottom-nav b {
    position: absolute; inset-inline-end: calc(50% - 22px); inset-block-start: 4px;
    min-width: 18px; height: 18px; display: grid; place-items: center;
    border-radius: 99px; background: var(--accent); color: #fff; font-size: .62rem; font-weight: 800;
  }

  /* Content clears the fixed tabbar through the variable, on every page. */
  html body { padding-bottom: calc(var(--shell-tabbar-h) + var(--shell-safe-bottom)); }

  /* ---- 5. checkout shell: back to cart, no tabbar, nothing covered ---- */
  body[data-page="checkout"] .mobile-bottom-nav { display: none; }
  html body[data-page="checkout"] {
    padding-bottom: calc(var(--shell-safe-bottom) + 16px);
  }
  body[data-page="checkout"] .checkout-actions,
  body[data-page="checkout"] .place-order { margin-bottom: 0; }

  /* ---- 6. sticky product actions + toast sit above the tabbar ---- */
  .detail-actions { inset-block-end: calc(var(--shell-tabbar-h) + var(--shell-safe-bottom) + 8px); }
  /* Keep the chat FAB at the far right; place "back to top" immediately to
     its left so the two floating actions never overlap on mobile. */
  .back-to-top {
    inset-inline-end: 78px;
    inset-block-end: calc(var(--shell-tabbar-h) + var(--shell-safe-bottom) + 14px);
  }
  html body .toast-message { inset-block-end: calc(var(--shell-tabbar-h) + var(--shell-safe-bottom) + 16px); }

  /* ---- 7. the shop keeps its own mobile heading/controls ---- */
  body[data-page="shop"] .shop-mobile-heading { padding-block: 4px 8px; }
}

/* Small phones: only the tweaks that genuinely need the narrower width. */
@media (max-width: 375px) {
  .mobile-topbar-brand .brand-logo { height: 27px; max-width: 116px; }
  .mobile-topbar-title { font-size: .95rem; }
  .utility-bar .utility-controls select { font-size: .7rem; }
}
