/* Carousel Categories - VELI style (settings-driven) */
.cctg-wrapper {
    /* default CSS variables — overridden inline by render_carousel() */
    --cctg-card-w: 170px;
    --cctg-card-h: 215px;
    --cctg-all-w: 170px;
    --cctg-img: 110px;
    --cctg-img-mb: 18px;
    --cctg-text: 14px;
    --cctg-text-align: left;
    --cctg-gap: 16px;
    --cctg-card-bg: #EAEAEA;
    --cctg-card-color: #111111;
    --cctg-card-radius: 12px;
    --cctg-all-bg: #000000;
    --cctg-all-color: #FFFFFF;
    --cctg-arrow-bg: #FFFFFF;
    --cctg-arrow-color: #000000;
    --cctg-arrow-size: 48px;
    --cctg-arrow-shadow: 0 8px 24px rgba(0, 0, 0, .22);
    --cctg-modal-cols: 4;

    width: 100%;
    box-sizing: border-box;
    font-family: inherit;
}
.cctg-wrapper *,
.cctg-wrapper *::before,
.cctg-wrapper *::after { box-sizing: border-box; }

.cctg-carousel {
    display: flex;
    align-items: stretch;
    width: 100%;
    position: relative;
    padding: 8px 0;
}

/* "All categories" button — first item inside the track */
.cctg-all-btn {
    flex: 0 0 var(--cctg-all-w);
    width: var(--cctg-all-w);
    height: var(--cctg-card-h);
    margin: 0;
    background: var(--cctg-all-bg);
    color: var(--cctg-all-color);
    border: 0;
    border-radius: var(--cctg-card-radius);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 18px 12px;
    text-align: center;
    font-weight: 700;
    font-size: calc(var(--cctg-text) + 1px);
    line-height: 1.25;
    transition: transform .15s ease;
}
.cctg-all-btn:hover { transform: translateY(-1px); }
.cctg-menu-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}
.cctg-all-label { display: block; }

/* Track wrap */
.cctg-track-wrap {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
}

.cctg-track {
    display: flex;
    gap: var(--cctg-gap);
    overflow-x: auto;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 0 8px 4px 8px;
}
.cctg-track::-webkit-scrollbar { display: none; }

/* Category card */
.cctg-card {
    flex: 0 0 var(--cctg-card-w);
    width: var(--cctg-card-w);
    height: var(--cctg-card-h);
    background: var(--cctg-card-bg);
    border-radius: var(--cctg-card-radius);
    text-decoration: none;
    color: var(--cctg-card-color);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 14px 14px 0 14px;
    overflow: hidden;
    position: relative;
    transition: transform .15s ease, box-shadow .15s ease;
}
.cctg-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, .08);
}
.cctg-card-title {
    font-size: var(--cctg-text);
    font-weight: 600;
    line-height: 1.3;
    color: var(--cctg-card-color);
    text-align: var(--cctg-text-align);
    overflow-wrap: break-word;
    /* No clamp by default — full text visible. Clamp injected via inline style if user sets text_lines > 0 */
}
.cctg-card-img {
    width: var(--cctg-img);
    height: var(--cctg-img);
    object-fit: contain;
    margin: 0 0 var(--cctg-img-mb) 0;
    align-self: flex-end;
}

/* Arrows */
.cctg-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: var(--cctg-arrow-size);
    height: var(--cctg-arrow-size);
    border-radius: 50%;
    background: var(--cctg-arrow-bg);
    color: var(--cctg-arrow-color);
    border: 1px solid rgba(0, 0, 0, .06);
    box-shadow: var(--cctg-arrow-shadow);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    padding: 0;
    transition: transform .15s ease, box-shadow .15s ease;
}
.cctg-arrow:hover {
    transform: translateY(-50%) scale(1.05);
}
.cctg-arrow-prev { left: -8px; }
.cctg-arrow-next { right: -8px; }
.cctg-arrow[disabled] { opacity: 0; pointer-events: none; }

/* ===== Modal ===== */
.cctg-modal[hidden] { display: none; }
.cctg-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.cctg-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .35);
}
.cctg-modal-dialog {
    position: relative;
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 1200px;
    padding: 28px 36px 36px 36px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .18);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 80px);
}
.cctg-modal-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1 1 auto;
    min-height: 0;
    padding-right: 4px;
    margin-right: -4px;
}
.cctg-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px;
}
.cctg-modal-title {
    font-size: 20px;
    font-weight: 700;
    margin: 0;
    color: #111;
}
.cctg-modal-close {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #F1F1F1;
    border: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cctg-modal-close:hover { background: #e6e6e6; }

.cctg-modal-grid {
    display: grid;
    grid-template-columns: repeat(var(--cctg-modal-cols), 1fr);
    gap: 16px;
}
.cctg-modal-card {
    background: var(--cctg-card-bg);
    border-radius: var(--cctg-card-radius);
    padding: 18px 20px;
    min-height: 110px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-decoration: none;
    color: var(--cctg-card-color);
    gap: 12px;
    transition: transform .15s ease, box-shadow .15s ease;
}
.cctg-modal-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, .08);
}
.cctg-modal-card-title {
    font-size: var(--cctg-text);
    font-weight: 600;
    line-height: 1.3;
    flex: 1 1 auto;
    overflow-wrap: break-word;
    min-width: 0;
}
.cctg-modal-card-img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    flex: 0 0 80px;
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .cctg-wrapper { --cctg-modal-cols: 3; }
}

/* Tablet */
@media (max-width: 880px) {
    .cctg-wrapper {
        --cctg-card-w: 150px;
        --cctg-card-h: 195px;
        --cctg-all-w: 130px;
        --cctg-img: 96px;
        --cctg-modal-cols: 2;
    }
}

/* Mobile — hide arrows entirely (touch swipe is enough), trim sizes,
   make sure the carousel never tries to constrain children. */
@media (max-width: 720px) {
    .cctg-wrapper {
        --cctg-card-w: 140px;
        --cctg-card-h: 188px;
        --cctg-all-w: 126px;
        --cctg-img: 88px;
        --cctg-img-mb: 14px;
        --cctg-gap: 12px;
    }
    .cctg-track {
        padding: 0 4px 4px 4px;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
    }
    .cctg-card,
    .cctg-all-btn { scroll-snap-align: start; }
    .cctg-arrow { display: none !important; }
    .cctg-all-btn { padding: 14px 10px; font-size: 13px; }
    .cctg-menu-icon { margin-bottom: 10px; }
    .cctg-menu-icon svg { width: 36px; height: 36px; }
    .cctg-card { padding: 12px 12px 0 12px; }
    .cctg-modal {
        padding: 0;
        align-items: stretch;
    }
    .cctg-modal-dialog {
        padding: 18px 14px 20px 14px;
        border-radius: 16px 16px 0 0;
        max-width: 100%;
        max-height: 92vh;
        margin-top: auto;
        box-shadow: 0 -10px 40px rgba(0,0,0,.2);
    }
    .cctg-modal-header { margin-bottom: 14px; }
    .cctg-modal-title  { font-size: 17px; }
    .cctg-modal-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    .cctg-modal-card {
        flex-direction: column;
        align-items: center;
        justify-content: space-between;
        padding: 14px 10px 12px 10px;
        min-height: 150px;
        text-align: center;
        gap: 8px;
    }
    .cctg-modal-card-title {
        flex: 0 0 auto;
        text-align: center;
        font-size: 13px;
        order: 1;
        width: 100%;
    }
    .cctg-modal-card-img {
        width: 70px;
        height: 70px;
        flex: 0 0 70px;
        order: 2;
    }
}

@media (max-width: 420px) {
    .cctg-wrapper {
        --cctg-card-w: 130px;
        --cctg-card-h: 176px;
        --cctg-all-w: 116px;
        --cctg-img: 80px;
        --cctg-img-mb: 12px;
        --cctg-gap: 10px;
    }
    .cctg-all-btn { font-size: 12px; padding: 12px 8px; }
    .cctg-menu-icon { margin-bottom: 8px; }
    .cctg-menu-icon svg { width: 32px; height: 32px; }
    .cctg-card-title { font-size: calc(var(--cctg-text) - 1px); }
}
