/* Home catalog design: category chips + animated grid cards */

/* Make sure the home product section doesn't inherit the carousel-style flex height from products.css */
#products .product-section {
    display: grid;
    /* 单列内容 */
    grid-template-columns: 1fr;
    align-items: start;
    padding: 20px 4%;
    margin-top: 24px;
    /* 与上一块内容拉开距离，避免重叠视觉 */
    height: auto;
}

/* 右侧“导航+进度条”组合容器（单列下就是主容器） */
.catalog-header {
    grid-column: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 8px;
}

#products .products_list {
    max-width: 1120px;
    margin: 10px auto 0;
    /* 顶部增加间距，避免与上方导航产生视觉重叠 */
    width: 100%;
    position: relative;
    /* 作为绝对定位子元素的定位上下文 */
    min-height: 360px;
    /* 初始高度，避免内容覆盖下方模块 */
    transition: height 300ms ease;
    /* 切换分类时平滑过渡容器高度 */
}

.catalog-nav {
    /* 不使用 sticky，避免点击时页面定位变化 */
    position: relative;
    z-index: 3;
    /* 提升层级，避免被下方图片或阴影视觉压住 */
    display: flex;
    gap: 6px 8px;
    flex-wrap: wrap;
    /* 允许多行，减小整体占宽 */
    padding: 6px 10px;
    margin: 8px auto 6px;
    /* 列内居中 */
    justify-content: center;
    /* 居中 chips */
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.75));
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    /* Safari 9+ 前缀 */
    border-radius: 10px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .08);
    /* 与背景分层，避免看起来“贴住/重叠” */
    width: fit-content;
    /* 收缩到内容宽度 */
    max-width: 100%;
    /* 不超过容器 */
}

.catalog-nav .chip {
    white-space: nowrap;
    padding: 6px 12px;
    /* 更小的 chip */
    border-radius: 999px;
    border: 1px solid #e7e7e7;
    background: #fff;
    color: #333;
    font-size: 14px;
    text-decoration: none;
    transition: all .2s ease;
}

.catalog-nav .chip:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, .08);
    transform: translateY(-1px);
}

.catalog-nav .chip.active {
    background: #22c55e;
    color: #fff;
    border-color: #22c55e;
}

.cat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 12px 0 6px;
}

.cat-title {
    font-size: 20px;
    padding-left: 12px;
    border-left: 4px solid #22c55e;
}

.cat-actions a {
    font-size: 14px;
    color: #22c55e;
    text-decoration: none;
}

.cat-actions a:hover {
    text-decoration: underline;
}

/* Tabbed sections: horizontal slide */
.cat-section {
    position: absolute;
    inset: 0;
    opacity: 0;
    transform: translateX(12%);
    pointer-events: none;
    transition: transform .4s ease, opacity .4s ease;
    /* 统一为 0.4s */
}

/* 起始状态：仅在未激活时生效 */
.cat-section.from-left:not(.active) {
    transform: translateX(-12%);
    opacity: 0;
}

.cat-section.from-right:not(.active) {
    transform: translateX(12%);
    opacity: 0;
}

/* 离场状态 */
.cat-section.slide-to-left {
    transform: translateX(-12%);
    opacity: 0;
    z-index: 1;
}

.cat-section.slide-to-right {
    transform: translateX(12%);
    opacity: 0;
    z-index: 1;
}

/* 目标状态（放在最后提升顺序） */
.cat-section.active {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
    z-index: 2;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.card {
    position: relative;
    background: #fff;
    border: 1px solid #efefef;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
    transform: translateY(6px);
    opacity: 0;
    transition: transform .35s ease, opacity .35s ease, box-shadow .2s ease;
}

.card.reveal {
    transform: translateY(0);
    opacity: 1;
}

.card:hover {
    box-shadow: 0 10px 24px rgba(0, 0, 0, .08), 0 1px 3px rgba(0, 0, 0, .06);
    transform: translateY(-2px);
}

.card img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    background: #fafafa;
    display: block;
}

.card .name {
    margin: 10px 12px 12px;
    font-size: 14px;
    color: #222;
}

@media (min-width: 1200px) {
    .card img {
        height: 160px;
    }
}

/* Mobile: stack layout */
@media (max-width: 768px) {
    #products .product-section {
        grid-template-columns: 1fr;
        padding: 15px 16px;
        /* 外层等距 */
    }

    #products .catalog-header {
        grid-column: 1;
    }

    .catalog-nav {
        gap: 6px 8px;
        padding: 6px 8px;
        flex-wrap: wrap;
        overflow: visible;
        row-gap: 6px;
    }

    .catalog-nav .chip {
        padding: 5px 10px;
        font-size: 13px;
    }

    /* 居中显示，去掉额外内边距，保持左右对称 */
    #products .products_list {
        padding-left: 0;
        padding-right: 0;
        margin-left: auto;
        margin-right: auto;
    }

    #products .catalog-nav,
    #products .products_list,
    #products .catalog-progress,
    #products .view-more {
        grid-column: 1;
    }

    #products .products_list {
        min-height: 300px;
    }

    #products .view-more {
        margin-top: 12px;
    }

    /* 手机端产品网格：两列更紧凑 */
    .grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }

    .card img {
        height: 120px;
    }

    /* 进度条在小屏全宽，避免换行带来的宽度计算误差 */
    .catalog-progress {
        width: 100%;
    }
}

/* Nice scrollbar for chips */
.catalog-nav::-webkit-scrollbar {
    height: 6px;
}

.catalog-nav::-webkit-scrollbar-thumb {
    background: #d7d7d7;
    border-radius: 99px;
}

/* Progress bar under grid (简洁细条，居中且略长) */
.catalog-progress {
    height: 4px;
    background: #eaeaea;
    border-radius: 999px;
    overflow: hidden;
    width: 60%;
    /* 缩短：默认 60%，再由 JS 根据导航宽度微调 */
    margin: 0 auto 6px;
    /* 居中，与导航对齐 */
    max-width: 1120px;
    /* 与列表统一宽度限制 */
}

.catalog-progress .bar {
    height: 100%;
    width: 0%;
    background: #22c55e;
}

/* 已移除首页“查看更多”按钮的样式（保留空位以便将来复用） */