/* Category filter (#catalogfirst.cat-slider): native horizontal scroll + edge fades + arrows.
   JS: public/frontend/js/main.js -> initCategoryScrollers() */
.cat-slider {
    position: relative;
}

.cat-scroll {
    position: relative; /* offsetParent for chips */
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1 1 auto;
    width: 100%;
    min-width: 0; /* allow shrinking inside the flex parent so it scrolls instead of overflowing */
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain; /* no browser back/forward on trackpad swipe */
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.cat-scroll::-webkit-scrollbar {
    display: none;
}

.cat-chip {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px 12px 18px;
    border-radius: 18px;
    color: #1d1f26;
    font-size: 16px;
    line-height: 24px;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    -webkit-user-drag: none;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.cat-chip img {
    width: 24px;
    height: 24px;
    object-fit: contain;
    -webkit-user-drag: none;
    pointer-events: none;
}

.cat-chip:hover {
    background-color: #f6f6f6;
}

.cat-chip.active-tag {
    background-color: #eeeeee;
    font-weight: 700;
}

.cat-chip:focus-visible {
    outline: 2px solid #ed1b32;
    outline-offset: -2px;
}

/* While dragging with the mouse: no hover flicker, grabbing cursor */
.cat-slider.is-dragging .cat-scroll,
.cat-slider.is-dragging .cat-chip {
    cursor: grabbing;
}

.cat-slider.is-dragging .cat-chip:hover {
    background-color: transparent;
}

.cat-slider.is-dragging .cat-chip.active-tag {
    background-color: #eeeeee;
}

/* Edge fades — only on the side that still has hidden items */
.cat-slider::before,
.cat-slider::after {
    content: "";
    position: absolute;
    top: 8px;
    bottom: 8px;
    width: 72px;
    z-index: 2;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.cat-slider::before {
    left: 8px;
    background: linear-gradient(to right, #fdfdfd 35%, rgba(253, 253, 253, 0));
    border-radius: 18px 0 0 18px;
}

.cat-slider::after {
    right: 8px;
    background: linear-gradient(to left, #fdfdfd 35%, rgba(253, 253, 253, 0));
    border-radius: 0 18px 18px 0;
}

.cat-slider.has-prev::before,
.cat-slider.has-next::after {
    opacity: 1;
}

/* Arrows — visible whenever there is more content in that direction */
.cat-nav {
    position: absolute;
    top: 50%;
    z-index: 3;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fdfdfd;
    color: #1d1f26;
    box-shadow: 0 1px 3px 0 rgba(16, 24, 40, 0.12), 0 1px 2px 0 rgba(16, 24, 40, 0.08);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-50%) scale(0.85);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s,
        background-color 0.2s ease, color 0.2s ease;
}

.cat-nav svg {
    width: 18px;
    height: 18px;
}

.cat-nav-prev {
    left: 12px;
}

.cat-nav-next {
    right: 12px;
}

.cat-slider.has-prev .cat-nav-prev,
.cat-slider.has-next .cat-nav-next {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%) scale(1);
}

.cat-nav:hover {
    background: #ed1b32;
    color: #fff;
}

.cat-nav:active {
    transform: translateY(-50%) scale(0.92);
}

/* Touch devices: swipe is the natural gesture, fades still hint at more content */
@media (hover: none) {
    .cat-nav {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cat-slider::before,
    .cat-slider::after,
    .cat-nav,
    .cat-chip {
        transition: none;
    }
}

/* ===== Category sections (home / menu page) ===== */
.cat-sections[hidden],
.cat-search-results[hidden] {
    display: none !important;
}

.cat-sections {
    display: flex;
    flex-direction: column;
    gap: 40px;
    padding-top: 24px;
}

.cat-section {
    scroll-margin-top: 16px;
}

.cat-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.cat-section-title {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    padding-left: 16px;
    color: #1d1f26;
    font-size: 22px;
    line-height: 30px;
    font-weight: 700;
}

.cat-section-title::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    width: 5px;
    height: 70%;
    border-radius: 9999px;
    background: #ed1b32;
    transform: translateY(-50%);
}

.cat-section-title img {
    width: 26px;
    height: 26px;
    object-fit: contain;
    flex-shrink: 0;
}

.cat-section-count {
    flex-shrink: 0;
    color: rgba(29, 31, 38, 0.5);
    font-size: 14px;
    line-height: 20px;
    white-space: nowrap;
}

.cat-more-wrap {
    display: flex;
    justify-content: center;
    margin-top: 24px;
}

.cat-more {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    height: 48px;
    padding: 0 20px 0 24px;
    border: 0;
    border-radius: 14px;
    background: #fdfdfd;
    color: #1d1f26;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 1px 3px 0 rgba(16, 24, 40, 0.1), 0 1px 2px 0 rgba(16, 24, 40, 0.06);
    transition: background-color 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
}

.cat-more svg {
    width: 18px;
    height: 18px;
    transition: transform 0.25s ease;
}

.cat-more-count {
    min-width: 28px;
    height: 24px;
    padding: 0 8px;
    border-radius: 9999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #fef3f2;
    color: #ed1b32;
    font-size: 13px;
    line-height: 1;
    transition: background-color 0.25s ease, color 0.25s ease;
}

.cat-more:hover {
    background: #ed1b32;
    color: #fff;
    box-shadow: 0 4px 12px rgba(237, 27, 50, 0.25);
}

.cat-more:hover svg {
    transform: translateY(2px);
}

.cat-more:hover .cat-more-count {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.cat-more:focus-visible {
    outline: 2px solid #ed1b32;
    outline-offset: 3px;
}

.cat-more.is-loading {
    pointer-events: none;
    opacity: 0.75;
}

.cat-more-spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 9999px;
    animation: cat-spin 0.7s linear infinite;
}

.cat-more.is-loading .cat-more-count,
.cat-more.is-loading .cat-more-icon {
    display: none;
}

.cat-more.is-loading .cat-more-spinner {
    display: inline-block;
}

@keyframes cat-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Newly loaded cards fade in */
.cat-card-enter {
    animation: cat-card-in 0.35s ease both;
}

@keyframes cat-card-in {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@media (min-width: 768px) {
    .cat-sections {
        gap: 56px;
        padding-top: 40px;
    }

    /* Leave room for the sticky category bar when jumping to a section */
    .cat-section {
        scroll-margin-top: 112px;
    }

    .cat-section-head {
        margin-bottom: 24px;
    }

    .cat-section-title {
        font-size: 32px;
        line-height: 40px;
    }

    .cat-section-title img {
        width: 34px;
        height: 34px;
    }

    .cat-section-count {
        font-size: 16px;
    }

    .cat-more-wrap {
        margin-top: 32px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cat-card-enter {
        animation: none;
    }

    .cat-more,
    .cat-more svg,
    .cat-more-count {
        transition: none;
    }
}
