/* =====================================================
 *  行動版滿版分類選單（左側主分類 + 右側格狀子分類）
 *  由 Views/Shared/_行動版分類選單.cshtml 使用。
 *  桌機（>=992px）一律不顯示，桌機仍走 header 的 mega menu。
 * ===================================================== */

.mcat-panel {
    position: fixed;
    inset: 0;
    z-index: 1050; /* 高於 handheld-toolbar(1030) 與 navbar-sticky */
    display: none;
    flex-direction: column;
    background: #fff;
}

.mcat-panel.is-open {
    display: flex;
}

/* 開啟時鎖住背景捲動 */
body.mcat-panel-open {
    overflow: hidden;
}

/* ===== 頂部：標題 + 關閉 + 搜尋 ===== */
.mcat-panel__header {
    flex: 0 0 auto;
    padding: calc(8px + env(safe-area-inset-top)) 12px 10px;
    border-bottom: 1px solid var(--border-light, #e1e7ec);
}

.mcat-panel__bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.mcat-panel__title {
    flex: 1;
    min-width: 0;
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary, #373f50);
}

.mcat-panel__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin-right: -8px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-primary, #373f50);
    font-size: 1.25rem;
    line-height: 1;
}

.mcat-panel__close:active {
    background: var(--light-bg, #f6f9fc);
}

/* ===== 主體：左右兩欄 ===== */
.mcat-panel__body {
    flex: 1 1 auto;
    display: flex;
    min-height: 0;
}

/* 左欄：主分類 */
.mcat-panel__rail {
    flex: 0 0 108px;
    width: 108px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--light-bg, #f6f9fc);
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

.mcat-rail__item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 56px;
    padding: 10px 8px;
    border: 0;
    border-left: 3px solid transparent;
    background: transparent;
    color: var(--text-primary, #373f50);
    font-size: 0.875rem;
    line-height: 1.3;
    text-align: center;
}

.mcat-rail__item.is-active {
    border-left-color: var(--morandi-pink-deep, #c19a8b);
    background: #fff;
    color: var(--morandi-pink-deep, #c19a8b);
    font-weight: 600;
}

/* 右欄：子分類格狀清單 */
.mcat-panel__panes {
    flex: 1 1 auto;
    min-width: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 14px 12px calc(24px + env(safe-area-inset-bottom));
}

.mcat-pane {
    display: none;
}

.mcat-pane.is-active {
    display: block;
}

.mcat-pane__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
}

.mcat-pane__title {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary, #373f50);
}

.mcat-group__title {
    margin: 18px 0 8px;
    color: var(--text-secondary, #7d879c);
    font-size: 0.8125rem;
    font-weight: 500;
}

.mcat-group:first-child .mcat-group__title {
    margin-top: 0;
}

/* 主分類本身的入口，橫跨整列 */
.mcat-grid--lead {
    margin-bottom: 14px;
}

.mcat-grid__item--wide {
    grid-column: 1 / -1;
}

.mcat-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

@media (min-width: 480px) {
    .mcat-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.mcat-grid__item {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 56px;
    padding: 10px 8px;
    border: 1px solid transparent;
    border-radius: var(--radius-base, 12px);
    background: var(--light-bg, #f6f9fc);
    color: var(--text-primary, #373f50);
    font-size: 0.8125rem;
    line-height: 1.3;
    text-align: center;
    text-decoration: none;
    word-break: break-word;
}

/* a 本身是 flex 置中容器，文字包一層 block 才能讓 <br> 正常斷行 */
.mcat-grid__item-text {
    display: block;
}

.mcat-grid__item.is-active {
    border-color: var(--morandi-pink, #e8c9bc);
    background: #fff;
    color: var(--morandi-pink-deep, #c19a8b);
    font-weight: 600;
}

/* 桌機不使用此面板 */
@media (min-width: 992px) {
    .mcat-panel {
        display: none !important;
    }

    body.mcat-panel-open {
        overflow: auto;
    }
}
