/* ==========================================================================
   Food Store - 响应式样式（改进版）
   需在主样式文件之后加载。
   断点只保留真正有用的几个：
     ≥ 768px        桌面 / 平板
     ≤ 767.98px     手机（用 .98 避免 767~768 之间的小数缝隙）
     ≤ 480px        小屏手机
   另有两处针对 1025–1199px 和平板横屏的宽度微调。
   如需让底部购物车栏的安全区生效，页面 viewport 需包含 viewport-fit=cover：
   <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
   ========================================================================== */

/* --------------------------------------------------------------------------
   笔记本 / 小桌面
   -------------------------------------------------------------------------- */
@media (min-width: 1025px) and (max-width: 1199px) {
  .wfs-cart-overview-description {
    width: 20%;
  }
}

/* --------------------------------------------------------------------------
   平板横屏
   -------------------------------------------------------------------------- */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
  .wfs-cart-overview-description {
    width: 24%;
  }
}

/* --------------------------------------------------------------------------
   平板及以上（≥ 768px）
   -------------------------------------------------------------------------- */
@media (min-width: 768px) {
  /* 桌面端用右侧的加购按钮，隐藏摘要区里那一份 */
  .wfs-food-item-summery .button-add-to-cart,
  .wfs-food-item-summery .wfs-text-out-of-stock {
    display: none;
  }

  .wfs-cart-purchase-actions-mobile {
    display: none;
  }

  /* 侧边栏列表过长时在自身内部滚动，并避开固定头部 */
  #wfs-sticky-sidebar .wfs-sidebar-menu ul {
    max-height: calc(100vh - var(--wfs-sticky-top, 0px) - 40px);
    max-height: calc(100dvh - var(--wfs-sticky-top, 0px) - 40px);
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scrollbar-gutter: stable;
  }
}

/* --------------------------------------------------------------------------
   手机（≤ 767.98px）
   -------------------------------------------------------------------------- */
@media (max-width: 767.98px) {
  /* 手机端用摘要区里的加购按钮，隐藏右侧那一份 */
  .wfs-food-item-cart-action .button-add-to-cart,
  .wfs-food-item-cart-action .wfs-text-out-of-stock {
    display: none;
  }

  /* 底部购物车栏精简 */
  .wfs-cart-purchase-actions,
  .wfs-cart-overview-description,
  .wfs-cart-service-settings {
    display: none;
  }

  .wfs-cart-overview {
    padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px)); /* iPhone 底部横条 */
    box-shadow: none;
  }

  .wfs-cart-overview-row {
    padding: 0;
  }

  .wfs-cart-overview > div.fs-container {
    padding-right: 5px;
    padding-left: 10px;
  }

  /* 给页面底部留出空间，避免最后几个菜品被固定的购物车栏盖住 */
  #foodstore {
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }

  /* 单列布局 */
  #foodstore > .fs-row,
  .wfsmodal .modal-content-wrapper,
  .wfs-cart-content-area {
    display: block;
  }

  /* ---- 分类栏：顶部横向滚动的胶囊 ---- */
  #wfs-sticky-sidebar {
    position: sticky;
    top: var(--wfs-sticky-top, 0px);
    z-index: var(--wfs-z-sidebar, 3); /* 低于遮罩层，购物车展开时会被一起变暗 */
    width: 100%;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
    background: #fff;
  }

  /* 覆盖 theiaStickySidebar 插件写在行内的样式 */
  #wfs-sticky-sidebar .theiaStickySidebar {
    position: static !important;
    width: auto !important;
    transform: none !important;
  }

  #wfs-sticky-sidebar .wfs-sidebar-menu ul {
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
    margin: 0;
    padding: 0 32px 0 12px; /* 右侧留白，配合渐变提示“还可以滑动” */
    overflow-x: auto;
    white-space: nowrap;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
  }

  #wfs-sticky-sidebar .wfs-sidebar-menu ul::-webkit-scrollbar {
    display: none;
  }

  #wfs-sticky-sidebar .wfs-sidebar-menu ul li {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    padding: 0;
    list-style: none;
    scroll-snap-align: center;
  }

  #wfs-sticky-sidebar .wfs-sidebar-menu ul li a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-sizing: border-box;
    min-height: 44px; /* 触控目标 */
    padding: 10px 16px;
    border: 1px solid #dcdcdc;
    border-radius: 999px;
    background: #fff;
    color: #666;
    line-height: 1.2;
    white-space: nowrap;
  }

  #wfs-sticky-sidebar .wfs-sidebar-menu ul li a.active {
    border-color: var(--wfs-primary, var(--wfs-primary-color, #337ab7));
    background: var(--wfs-primary, var(--wfs-primary-color, #337ab7));
    color: #fff;
    font-weight: 600;
  }

  #wfs-sticky-sidebar .wfs-sidebar-menu ul li a span.wfs-items-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    float: none;
    min-width: 22px;
    height: 22px;
    margin: 0;
    padding: 0 6px;
    border-radius: 999px;
    font-size: 12px;
    line-height: 1;
  }

  /* 激活的胶囊里，数量徽标用半透明白，避免和主色融在一起 */
  #wfs-sticky-sidebar .wfs-sidebar-menu ul li a.active span.wfs-items-count {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
  }

  #wfs-food-items {
    margin-top: 20px;
  }

  /* ---- 购物车面板 ---- */
  .cart-content-left {
    width: 97%;
  }

  .cart-content-right {
    width: 100%;
  }

  .wfs-cart-totals-container {
    padding-left: 0;
  }

  .wfs-cart-expanded .fs-container {
    padding-left: 20px;
  }

  /* ---- Mini cart 展开后，恢复被上面隐藏的服务设置和结算按钮 ---- */
  .wfs-cart-wrapper.mini-cart .wfs-cart-overview {
    padding-bottom: 6px; /* 抽屉里的概览栏不在屏幕底部，不需要安全区 */
  }

  .wfs-cart-wrapper.mini-cart .wfs-cart-overview-row {
    padding: 20px 0;
  }

  .wfs-cart-wrapper.mini-cart.active .wfs-cart-service-settings,
  .wfs-cart-wrapper.mini-cart.active .wfs-cart-purchase-actions {
    display: block;
  }
}

/* --------------------------------------------------------------------------
   小屏手机（≤ 480px）
   mini-cart 的宽度与位置已在主样式里用 min() + transform 处理，
   这里不再需要写死 right / width。
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
  .wfs-modal-count {
    margin-right: 10px;
  }
}
