/**
 * Mobile dock (sections/mobile-dock.liquid).
 *
 * Fixed bottom bar under 750px, display: none above. Height is one custom
 * property (--mobile-dock-height, safe-area inclusive) declared on :root
 * so THREE consumers stay in lockstep: the bar itself, the body padding
 * that stops it covering the page bottom, and the lift applied to the
 * sticky add-to-cart bar.
 *
 * Why body:has(.mobile-dock) rather than an injected <style>: :has scopes
 * the padding to the dock's actual presence in the DOM - remove the
 * section in the theme editor and the padding vanishes with the same
 * re-render, with no stale injected style and no JS measuring. This file
 * only loads on pages that render the section anyway, so :has is a second
 * guard, not the first. Trade-off: a browser too old for :has (pre-2023)
 * skips the padding and the dock can sit over the last ~60px of the
 * footer - degraded, not broken, and those browsers are a rounding error
 * for this store.
 *
 * z-index 45: above the sticky ATC card (40, section-sticky-atc.css) and
 * the sticky header (30), below the header's overlays (50/51). The cart
 * drawer is a modal <dialog> in the browser's top layer and beats every
 * z-index regardless. On product pages the sticky ATC would share the
 * same bottom edge, so the rule at the end lifts it by the dock's height -
 * scoped to the dock's presence with the same :has.
 */
:root {
  --mobile-dock-height: calc(58px + env(safe-area-inset-bottom, 0px));
}

.mobile-dock {
  display: none;
}

@media screen and (max-width: 749px) {
  .mobile-dock {
    display: block;
    position: fixed;
    inset-block-end: 0;
    inset-inline: 0;
    z-index: 45;
    height: var(--mobile-dock-height);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background-color: var(--color-bg);
    border-top: 1px solid var(--color-line);
  }

  body:has(.mobile-dock) {
    padding-bottom: var(--mobile-dock-height);
  }

  body:has(.mobile-dock) .sticky-atc {
    inset-block-end: var(--mobile-dock-height);
  }

  /* Shopify Inbox's chat bubble pins itself to the bottom-left corner,
     right over the dock's Search tab. Same lift; !important because the
     app sets its own bottom. The open chat panel still fits above the dock.
     --sticky-atc-offset (assets/sticky-atc.js) adds the product page's
     sticky add-to-cart card while it is showing. */
  body:has(.mobile-dock) shopify-chat {
    bottom: calc(var(--mobile-dock-height) + var(--sticky-atc-offset, 0px)) !important;
  }

  .mobile-dock__list {
    display: flex;
    align-items: stretch;
    height: 58px;
    margin: 0;
  }

  .mobile-dock__item {
    flex: 1 1 0;
    min-width: 0;
  }

  .mobile-dock__link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    height: 100%;
    color: var(--color-muted);
    text-decoration: none;
  }

  .mobile-dock__link.is-current {
    color: var(--color-brand);
  }

  .mobile-dock__icon {
    position: relative;
    display: inline-flex;
  }

  .mobile-dock__label {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.2;
  }

  .mobile-dock__cart-count {
    position: absolute;
    top: -5px;
    right: -9px;
    min-width: 16px;
    height: 16px;
    padding-inline: 4px;
    border-radius: var(--radius-pill);
    background-color: var(--color-brand);
    color: var(--color-bg);
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
  }

  .mobile-dock__cart-count:empty {
    display: none;
  }
}
