/* ============================================================
   Category Carousel — Animated UI
   ============================================================ */

/* ---- Wrapper entrance ---- */
@keyframes carousel-fadein {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.cat-carousel-wrapper {
    position: relative;
    background: #fff;
    border-bottom: 1px solid #ececec;
    margin-bottom: 40px;
    padding: 30px 64px 24px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
    animation: carousel-fadein 0.5s ease both;
}

/* Edge fade masks */
.cat-carousel-wrapper::before,
.cat-carousel-wrapper::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 60px;
    z-index: 5;
    pointer-events: none;
}
.cat-carousel-wrapper::before {
    left: 64px;
    background: linear-gradient(to right, #fff, transparent);
}
.cat-carousel-wrapper::after {
    right: 64px;
    background: linear-gradient(to left, #fff, transparent);
}

.cat-carousel-viewport { overflow: hidden; }

.cat-carousel-track {
    display: flex;
    will-change: transform;
}

.cat-carousel-item {
    flex: 0 0 calc(100% / 6);
    min-width: 0;
    padding: 0 6px;
    box-sizing: border-box;
}

@media (max-width: 1199px) { .cat-carousel-item { flex: 0 0 calc(100% / 5); } }
@media (max-width: 991px)  { .cat-carousel-item { flex: 0 0 calc(100% / 4); } }
@media (max-width: 767px)  { .cat-carousel-item { flex: 0 0 calc(100% / 3); } }
@media (max-width: 575px)  { .cat-carousel-item { flex: 0 0 calc(100% / 2); } }
@media (max-width: 399px)  { .cat-carousel-item { flex: 0 0 100%; } }

/* ---- Card stagger entrance ---- */
@keyframes card-popin {
    from { opacity: 0; transform: translateY(16px) scale(0.94); }
    to   { opacity: 1; transform: translateY(0)   scale(1); }
}

.cat-carousel-item:not(.cat-clone) .cat-card {
    animation: card-popin 0.4s ease both;
}

/* Stagger each card */
.cat-carousel-item:not(.cat-clone):nth-child(1)  .cat-card { animation-delay: 0.05s; }
.cat-carousel-item:not(.cat-clone):nth-child(2)  .cat-card { animation-delay: 0.10s; }
.cat-carousel-item:not(.cat-clone):nth-child(3)  .cat-card { animation-delay: 0.15s; }
.cat-carousel-item:not(.cat-clone):nth-child(4)  .cat-card { animation-delay: 0.20s; }
.cat-carousel-item:not(.cat-clone):nth-child(5)  .cat-card { animation-delay: 0.25s; }
.cat-carousel-item:not(.cat-clone):nth-child(6)  .cat-card { animation-delay: 0.30s; }
.cat-carousel-item:not(.cat-clone):nth-child(7)  .cat-card { animation-delay: 0.35s; }
.cat-carousel-item:not(.cat-clone):nth-child(8)  .cat-card { animation-delay: 0.40s; }

/* ---- Card ---- */
.cat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 10px 4px 10px;
    border: none;
    border-radius: 0;
    background: transparent;
    cursor: pointer;
    width: 100%;
    text-align: center;
    transition: transform 0.25s ease;
    position: relative;
    overflow: visible;
}

.cat-card::before,
.cat-card::after { display: none; }

.cat-card:hover {
    border-color: transparent;
    box-shadow: none;
    transform: translateY(-4px);
}

.cat-card:active {
    transform: translateY(-1px) scale(0.97);
    transition-duration: 0.1s;
}

.cat-card.active {
    border-color: transparent;
    background: transparent;
    box-shadow: none;
    transform: translateY(-4px);
}

/* ---- Image ring with spin on active ---- */
@keyframes ring-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.cat-card-img-wrap {
    position: relative;
    width: 160px;
    height: 160px;
    flex-shrink: 0;
}

.cat-card-img-wrap::before {
    content: '';
    position: absolute;
    inset: -5px;
    border-radius: 50%;
    border: 2px dashed transparent;
    transition: border-color 0.3s ease;
}

.cat-card.active .cat-card-img-wrap::before {
    border-color: #B2201D;
    animation: ring-spin 8s linear infinite;
}

.cat-card:hover:not(.active) .cat-card-img-wrap::before {
    border-color: rgba(178, 32, 29, 0.4);
}

.cat-card-img {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border: 3px solid #f0f0f0;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.25s ease, box-shadow 0.25s ease;
}

/* Letter placeholder when no image is set */
.cat-card-img--placeholder {
    background: linear-gradient(135deg, #B2201D 0%, #e05050 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    border-color: transparent;
}

.cat-card-img--placeholder span {
    color: #fff;
    font-size: 52px;
    font-weight: 800;
    line-height: 1;
    text-shadow: 0 1px 3px rgba(0,0,0,0.2);
    pointer-events: none;
}

.cat-card:hover .cat-card-img {
    transform: scale(1.06);
    border-color: rgba(178, 32, 29, 0.4);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

.cat-card.active .cat-card-img {
    transform: scale(1.06);
    border-color: #B2201D;
    box-shadow: 0 8px 28px rgba(178, 32, 29, 0.25);
}

/* ---- Label ---- */
.cat-card-label {
    font-size: 12px;
    font-weight: 600;
    color: #555;
    line-height: 1.3;
    transition: color 0.22s ease, letter-spacing 0.22s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    letter-spacing: 0.2px;
}

.cat-card:hover .cat-card-label {
    letter-spacing: 0.4px;
}

.cat-card.active .cat-card-label {
    color: #B2201D;
    font-weight: 700;
    letter-spacing: 0.4px;
}

/* ---- Nav buttons ---- */
@keyframes btn-pulse {
    0%, 100% { box-shadow: 0 4px 12px rgba(178,32,29,0.4); }
    50%       { box-shadow: 0 4px 20px rgba(178,32,29,0.65); }
}

.cat-carousel-prev,
.cat-carousel-next {
    position: absolute;
    top: 50%;
    transform: translateY(-60%);
    z-index: 10;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: #B2201D;
    color: #fff;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(178, 32, 29, 0.4);
    transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    animation: btn-pulse 2.5s ease-in-out infinite;
}

.cat-carousel-prev { left: 12px; }
.cat-carousel-next { right: 12px; }

.cat-carousel-prev:hover,
.cat-carousel-next:hover {
    background: #8b1714;
    transform: translateY(-60%) scale(1.15);
    box-shadow: 0 8px 22px rgba(178, 32, 29, 0.55);
    animation: none;
}

.cat-carousel-prev:active,
.cat-carousel-next:active {
    transform: translateY(-60%) scale(0.92);
    transition-duration: 0.08s;
}

/* Icon bounce on hover */
.cat-carousel-prev:hover .fa { animation: bounce-left  0.4s ease; }
.cat-carousel-next:hover .fa { animation: bounce-right 0.4s ease; }

@keyframes bounce-left  {
    0%,100% { transform: translateX(0); }
    40%     { transform: translateX(-4px); }
    70%     { transform: translateX(2px); }
}
@keyframes bounce-right {
    0%,100% { transform: translateX(0); }
    40%     { transform: translateX(4px); }
    70%     { transform: translateX(-2px); }
}

/* ---- Dots ---- */
.cat-carousel-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 12px;
    padding-bottom: 4px;
}

@keyframes dot-pop {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.5); }
    100% { transform: scale(1); }
}

.cat-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    border: none;
    background: #ddd;
    cursor: pointer;
    padding: 0;
    transition: background 0.25s ease, width 0.25s ease, border-radius 0.25s ease;
}

.cat-dot.active {
    background: #B2201D;
    width: 20px;
    border-radius: 3px;
    animation: dot-pop 0.3s ease;
}

/* ---- Mobile ---- */
@media (max-width: 576px) {
    .cat-carousel-wrapper {
        padding: 18px 46px 14px;
    }
    .cat-carousel-wrapper::before { left: 46px; }
    .cat-carousel-wrapper::after  { right: 46px; }
    .cat-carousel-prev { left: 6px; }
    .cat-carousel-next { right: 6px; }
    .cat-carousel-prev,
    .cat-carousel-next { width: 32px; height: 32px; font-size: 11px; }
    .cat-card-img-wrap,
    .cat-card-img { width: 110px; height: 110px; }
    .cat-card-label { font-size: 11px; }
}

/* ---- Accessibility ---- */
.cat-carousel-prev:focus-visible,
.cat-carousel-next:focus-visible,
.cat-dot:focus-visible {
    outline: 2px solid #F6BA1A;
    outline-offset: 2px;
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
    .cat-carousel-wrapper,
    .cat-card,
    .cat-card::after,
    .cat-card-img,
    .cat-carousel-prev,
    .cat-carousel-next,
    .cat-dot {
        animation: none !important;
        transition: none !important;
    }
}
