/* =========================================================
   MAIN CATEGORIES GRID
   ========================================================= */

.main-categories-grid {
    width: 100%;
    position: relative;

    /* Horizontal slider */
    overflow-x: auto;
    overflow-y: hidden;

    /* Existing spacing */
    padding: 8px 4px 16px;

    /* Allow touch scrolling horizontally */
    -webkit-overflow-scrolling: touch;

    /* Mouse dragging */
    cursor: grab;

    /*
     * IMPORTANT:
     * Do not use smooth scrolling here.
     * JavaScript controls the movement.
     */
    scroll-behavior: auto;

    /*
     * Allows normal vertical page scrolling on mobile
     * while still allowing horizontal dragging.
     */
    touch-action: pan-y;

    /*
     * Prevent the scrollbar from taking too much space.
     */
    scrollbar-width: thin;

    scrollbar-color: rgba(0, 0, 0, 0.18) transparent;
}


/* =========================================================
   HIDE SCROLLBAR
   ========================================================= */

/*
 * Firefox
 */
.main-categories-grid {
    scrollbar-width: none;
}

/*
 * Chrome / Edge / Safari
 */
.main-categories-grid::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}
/* =========================================================
   DRAGGING STATE
   ========================================================= */

.main-categories-grid.is-dragging {
    cursor: grabbing;
    scroll-behavior: auto;
}


/* =========================================================
   CATEGORY TRACK
   ========================================================= */

.main-categories-grid__track {
    display: flex;

    flex-direction: row;
    flex-wrap: nowrap;

    align-items: stretch;

    /*
     * Critical:
     * The track must be wider than the viewport.
     */
    width: max-content;
    min-width: max-content;

    gap: 18px;

    /*
     * Prevent flex items from shrinking.
     */
    flex-shrink: 0;
}


/* =========================================================
   CATEGORY CARD
   ========================================================= */

.main-categories-grid__card {
    flex: 0 0 280px;

    width: 280px;
    min-width: 280px;

    box-sizing: border-box;

    padding: 12px 12px 11px;

    background: #ffffff;

    border: 3px solid #eeeeF2;

    border-radius: 25px;

    text-align: center;

    /*
     * Remove all default link styling.
     */
    text-decoration: none !important;

    /*
     * Prevent theme link styles from affecting the card.
     */
    color: inherit !important;

    overflow: hidden;

    scroll-snap-align: none;
}


/* Remove underline/color changes in every card state */

.main-categories-grid__card,
.main-categories-grid__card:visited,
.main-categories-grid__card:hover,
.main-categories-grid__card:focus,
.main-categories-grid__card:active {
    text-decoration: none !important;
}


/* Keep the category text clean */

.main-categories-grid__name,
.main-categories-grid__count {
    text-decoration: none !important;
}

/* =========================================================
   CATEGORY IMAGE
   ========================================================= */

.main-categories-grid__image {
    width: 100%;

    /*
     * Slightly wider than tall, matching your design.
     */
    aspect-ratio: 1.38 / 1;

    overflow: hidden;

    border-radius: 20px;

    display: flex;

    align-items: center;
    justify-content: center;
}


/* Actual category image */

.main-categories-grid__image img {
    width: 100%;
    height: 100%;

    display: block;

    /*
     * Fill the image area without stretching it.
     */
    object-fit: cover;

    object-position: center;
}




/* =========================================================
   CATEGORY IMAGE PLACEHOLDER
   ========================================================= */

.main-categories-grid__placeholder {
    width: 100%;
    height: 100%;

    display: flex;

    align-items: center;
    justify-content: center;

    text-align: center;
}


/* =========================================================
   CATEGORY NAME
   ========================================================= */

.main-categories-grid__name {
    margin-top: 10px;

    font-size: 20px;

    font-weight: 600;

    line-height: 1.2;

    /*
     * Keep long category names on one line.
     */
    white-space: nowrap;

    overflow: hidden;

    text-overflow: ellipsis;
}


/* =========================================================
   CATEGORY COUNT
   ========================================================= */

.main-categories-grid__count {
    margin-top: 3px;

    font-size: 11px;

    font-weight: 600;

    line-height: 1.2;
}


/* =========================================================
   TABLET
   ========================================================= */

@media (max-width: 900px) {

    .main-categories-grid {
        padding: 8px 4px 16px;
    }


    .main-categories-grid__track {
        gap: 18px;
    }


    .main-categories-grid__card {
        flex: 0 0 245px;

        width: 245px;
        min-width: 245px;

        padding: 10px;

        border-radius: 21px;
    }


    .main-categories-grid__image {
        border-radius: 17px;
    }


    .main-categories-grid__name {
        font-size: 21px;
    }


    .main-categories-grid__count {
        font-size: 14px;
    }

}


/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 600px) {

    .main-categories-grid {
        padding: 8px 4px 14px;
    }


    .main-categories-grid__track {
        gap: 18px;
    }


    .main-categories-grid__card {
        flex: 0 0 205px;

        width: 205px;
        min-width: 205px;

        padding: 8px;

        border-radius: 18px;
    }


    .main-categories-grid__image {
        border-radius: 14px;
    }


    .main-categories-grid__name {
        font-size: 18px;
    }


    .main-categories-grid__count {
        font-size: 13px;
    }

}


/* =========================================================
   SMALL MOBILE
   ========================================================= */

@media (max-width: 380px) {

    .main-categories-grid {
        padding: 8px 4px 14px;
    }


    .main-categories-grid__track {
        gap: 18px;
    }


    .main-categories-grid__card {
        flex: 0 0 185px;

        width: 185px;
        min-width: 185px;

        padding: 7px;

        border-radius: 16px;
    }


    .main-categories-grid__image {
        border-radius: 12px;
    }


    .main-categories-grid__name {
        font-size: 17px;
    }


    .main-categories-grid__count {
        font-size: 12px;
    }

}