/**
 * ======== sanxio 商城分类列表 · 移动端布局 start ===========
 * 配合 template/responsive/mall/list.htm
 */

/* 桌面：隐藏移动端头/筛选条/sheet */
.sx-mall-list-mhead,
.sx-mall-list-mbar,
.sx-mall-list-sheet {
  display: none;
}

/* ---------- 移动端 ---------- */
@media (max-width: 767px) {
  .sx-mall-list-page {
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }

  .sx-mall-list-page > .sx-mall-path,
  .sx-mall-list-page > .sanxio-path-bar {
    display: none !important;
  }

  .sx-mall-list-mhead {
    display: block;
    margin: 0;
    padding: 0;
  }

  .sx-mall-list-mhead__row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--sanxio-gap-md, 12px);
  }

  .sx-mall-list-mhead__title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--md3-color-on-surface, #1a1c1e);
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    min-width: 0;
  }

  .sx-mall-list-mhead__count {
    flex-shrink: 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--md3-color-on-surface-variant, #43474e);
  }

  .sx-mall-list-msubs {
    margin-top: var(--sanxio-gap-sm, 8px);
    margin-bottom: 0;
    overflow: visible;
  }

  .sx-mall-list-msubs__scroll {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 2px 2px 4px;
    /* 末项不被裁切：右侧留白 */
    scroll-padding-inline: 4px;
  }

  .sx-mall-list-msubs__scroll::-webkit-scrollbar {
    display: none;
  }

  .sx-mall-list-msubs__chip {
    box-sizing: border-box;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 32px;
    max-width: min(70vw, 220px);
    width: auto;
    height: auto;
    margin: 0;
    padding: 6px 14px;
    border-radius: var(--md3-shape-full, 9999px);
    border: 1px solid var(--md3-color-outline-variant, #c3c6cf);
    background: var(--md3-color-surface, #fff);
    color: var(--md3-color-on-surface, #1a1c1e);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.25;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    vertical-align: middle;
  }

  .sx-mall-list-msubs__chip-text {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: inherit;
  }

  .sx-mall-list-msubs__chip.is-on {
    background: var(--md3-color-primary, #005fb8);
    border-color: var(--md3-color-primary, #005fb8);
    color: var(--md3-color-on-primary, #fff);
  }

  .sx-mall-list-msubs__chip:focus-visible {
    outline: 2px solid var(--md3-color-primary, #005fb8);
    outline-offset: 2px;
  }

  /* 芯片 ↔ 筛选条 ↔ 商品：各只留 gap-sm，避免 padding+margin 叠高 */
  .sx-mall-list-mbar {
    display: flex;
    gap: var(--sanxio-gap-sm, 8px);
    position: sticky;
    top: 0;
    z-index: 20;
    margin: var(--sanxio-gap-sm, 8px) 0;
    padding: 0;
    background: var(--md3-color-surface-container-low, #f3f5f9);
  }

  .sx-mall-list-mbar__btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 40px;
    margin: 0;
    padding: 0 10px;
    border: 1px solid var(--md3-color-outline-variant, #c3c6cf);
    border-radius: var(--md3-shape-full, 9999px);
    background: var(--md3-color-surface, #fff);
    color: var(--md3-color-on-surface, #1a1c1e);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
  }

  .sx-mall-list-mbar__btn .material-symbols-outlined {
    font-size: 18px;
    color: var(--md3-color-primary, #005fb8);
  }

  .sx-mall-list-mbar__caret {
    font-size: 16px !important;
    color: var(--md3-color-on-surface-variant, #43474e) !important;
  }

  /* 侧栏筛选 / 推荐：移动端不占高 */
  .sx-mall-list-page .sx-mall-filters--desktop,
  .sx-mall-list-page .sx-mall-aside--desktop {
    display: none !important;
  }

  .sx-mall-list-page .sx-mall-layout {
    display: block;
    gap: 0;
    margin-top: 0;
  }

  .sx-mall-list-page .sx-mall-main,
  .sx-mall-list-page .sx-mall-main-card,
  .sx-mall-list-page .sx-mall-list-feed {
    margin-top: 0;
  }

  .sx-mall-list-page .sx-mall-main-card {
    border: none;
    box-shadow: none;
    background: transparent;
    padding: 0;
    border-radius: 0;
  }

  /* 对比工具条在移动端收起，避免占位 */
  .sx-mall-list-page .sx-mall-toolbar,
  .sx-mall-list-page .sx-mall-toolbar--foot,
  .sx-mall-list-page .sx-mall-tip,
  .sx-mall-list-page .sx-mall-result-card__check {
    display: none !important;
  }

  .sx-mall-list-page .sx-mall-product-grid.mdc-search-results__list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--sanxio-gap-md, 12px);
  }

  .sx-mall-list-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: var(--sanxio-gap-sm, 8px);
    padding: 48px var(--sanxio-card-px, 12px);
    background: var(--md3-color-surface, #fff);
    border: 1px dashed var(--md3-color-outline-variant, #c3c6cf);
    border-radius: var(--md3-shape-lg, 16px);
  }

  .sx-mall-list-empty__icon {
    font-size: 48px;
    color: var(--md3-color-outline, #747775);
  }

  .sx-mall-list-empty__title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--md3-color-on-surface, #1a1c1e);
  }

  .sx-mall-list-empty__hint {
    margin: 0 0 var(--sanxio-gap-md, 12px);
    font-size: 13px;
    color: var(--md3-color-on-surface-variant, #43474e);
  }

  /* Bottom sheet */
  .sx-mall-list-sheet {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 2400;
    pointer-events: none;
    visibility: hidden;
  }

  .sx-mall-list-sheet.is-open {
    pointer-events: auto;
    visibility: visible;
  }

  .sx-mall-list-sheet__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.32);
    opacity: 0;
    transition: opacity 0.2s ease;
  }

  .sx-mall-list-sheet.is-open .sx-mall-list-sheet__backdrop {
    opacity: 1;
  }

  .sx-mall-list-sheet__panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: min(72vh, 560px);
    display: flex;
    flex-direction: column;
    background: var(--md3-color-surface, #fff);
    border-radius: 28px 28px 0 0;
    box-shadow: var(--md3-elevation-3, 0 8px 24px rgba(0, 0, 0, 0.16));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    transform: translateY(100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .sx-mall-list-sheet.is-open .sx-mall-list-sheet__panel {
    transform: translateY(0);
  }

  .sx-mall-list-sheet__handle {
    width: 32px;
    height: 4px;
    margin: 10px auto 0;
    border-radius: 2px;
    background: var(--md3-color-outline-variant, #c3c6cf);
  }

  .sx-mall-list-sheet__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px var(--sanxio-card-px, 12px) 8px;
  }

  .sx-mall-list-sheet__title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--md3-color-on-surface, #1a1c1e);
  }

  .sx-mall-list-sheet__close {
    width: 40px;
    height: 40px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 20px;
    background: transparent;
    color: var(--md3-color-on-surface-variant, #43474e);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .sx-mall-list-sheet__body {
    padding: 4px var(--sanxio-card-px, 12px) var(--sanxio-card-py, 12px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .sx-mall-list-sheet__chips {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .sx-mall-list-sheet__chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-width: 44px;
    min-height: 36px;
    max-width: 100%;
    width: auto;
    padding: 8px 14px;
    border-radius: var(--md3-shape-full, 9999px);
    border: 1px solid var(--md3-color-outline-variant, #c3c6cf);
    background: var(--md3-color-surface-container-low, #f3f5f9);
    color: var(--md3-color-on-surface, #1a1c1e);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.25;
    text-decoration: none;
    word-break: break-word;
  }

  .sx-mall-list-sheet__chip em {
    margin-left: 4px;
    font-style: normal;
    font-weight: 500;
    color: var(--md3-color-on-surface-variant, #43474e);
  }

  .sx-mall-list-sheet__chip.is-on {
    background: var(--md3-color-primary, #005fb8);
    border-color: var(--md3-color-primary, #005fb8);
    color: var(--md3-color-on-primary, #fff);
  }

  .sx-mall-list-sheet__chip.is-on em {
    color: inherit;
    opacity: 0.85;
  }

  body.sx-mall-list-sheet-open {
    overflow: hidden;
  }
}

/* 桌面空态也可用 */
@media (min-width: 768px) {
  .sx-mall-list-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    padding: 56px 24px;
  }

  .sx-mall-list-empty__icon {
    font-size: 48px;
    color: var(--md3-color-outline, #747775);
  }

  .sx-mall-list-empty__title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
  }

  .sx-mall-list-empty__hint {
    margin: 0 0 12px;
    font-size: 13px;
    color: var(--md3-color-on-surface-variant, #43474e);
  }
}

/*======= sanxio 商城分类列表 · 移动端布局 end ===========*/

/*======= sanxio 分类列表无限滚动 start ===========*/
.sx-mall-list-feed-sentinel {
  height: 1px;
  width: 100%;
  margin: 0;
  padding: 0;
  pointer-events: none;
}

.sx-mall-list-feed-status {
  display: none;
  margin: var(--sanxio-content-gap, 12px) 0 0;
  padding: 8px 0 4px;
  text-align: center;
  font-size: 13px;
  color: var(--md3-color-on-surface-variant, #43474e);
}

.sx-mall-list-feed-status.is-loading::before {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 6px;
  vertical-align: -2px;
  border: 2px solid var(--md3-color-outline-variant, #c3c6cf);
  border-top-color: var(--md3-color-primary, #005fb8);
  border-radius: 50%;
  animation: sx-mall-list-spin 0.7s linear infinite;
}

.sx-mall-list-feed-status.is-end {
  color: var(--md3-color-outline, #747775);
}

.sx-mall-list-feed-status.is-error {
  color: var(--md3-color-error, #ba1a1a);
}

@keyframes sx-mall-list-spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 767px) {
  .sx-mall-list-page .sx-mall-list-pages-desktop,
  .sx-mall-list-page .pages.mdc-search-pagination {
    display: none !important;
  }

  .sx-mall-list-page .sx-mall-list-feed-status {
    display: block;
  }
}

@media (min-width: 768px) {
  .sx-mall-list-page .sx-mall-list-feed-sentinel,
  .sx-mall-list-page .sx-mall-list-feed-status {
    display: none !important;
  }
}
/*======= sanxio 分类列表无限滚动 end ===========*/
