/*
 * 保留子比小工具外壳负责的内容宽度与栅格定位，仅隐藏其视觉表面。
 * 不能给整个外壳设置 opacity: 0，否则内部卡片也会一并不可见。
 */
.xiaoyao-category-cards-widget,
.xiaoyao-category-cards-widget.zib-widget {
    background: rgba(255, 255, 255, 0) !important;
    border-color: rgba(255, 255, 255, 0) !important;
    box-shadow: none !important;
}

.dark-theme .xiaoyao-category-cards-widget,
.dark-theme .xiaoyao-category-cards-widget.zib-widget {
    background: rgba(0, 0, 0, 0) !important;
    border-color: rgba(0, 0, 0, 0) !important;
}

.xyccw-widget {
    --xyccw-gap: 16px;
    background: transparent;
    border: 0;
    box-shadow: none;
    margin: 0;
    min-width: 0;
    padding: 0;
    width: 100%;
}

.xyccw-widget__viewport {
    min-width: 0;
    overflow: hidden;
}

.xyccw-widget__rail {
    display: grid;
    gap: var(--xyccw-gap);
    grid-auto-columns: minmax(0, calc(16.666667% - 13.333333px));
    grid-auto-flow: column;
    min-width: 0;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    padding: 4px 2px 10px;
    scroll-padding-inline: 2px;
    scroll-snap-type: x proximity;
    scrollbar-color: rgba(119, 119, 119, .3) transparent;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}

.xyccw-widget__rail::-webkit-scrollbar {
    height: 4px;
}

.xyccw-widget__rail::-webkit-scrollbar-track {
    background: transparent;
}

.xyccw-widget__rail::-webkit-scrollbar-thumb {
    background: rgba(119, 119, 119, .3);
    border-radius: 999px;
}

.xyccw-card {
    aspect-ratio: 2 / 3;
    background: var(--muted-bg-color, #eee);
    border: 0;
    border-radius: max(10px, var(--main-radius, 8px));
    box-shadow: 0 5px 8px rgba(21, 28, 36, .12);
    color: #fff !important;
    display: block;
    isolation: isolate;
    min-width: 0;
    overflow: hidden;
    position: relative;
    scroll-snap-align: start;
    text-decoration: none !important;
    transform: translateZ(0);
    transition:
        box-shadow 220ms cubic-bezier(.22, 1, .36, 1),
        transform 220ms cubic-bezier(.22, 1, .36, 1);
}

.dark-theme .xyccw-card {
    box-shadow: 0 5px 8px rgba(0, 0, 0, .28);
}

.xyccw-card:hover,
.xyccw-card:focus-visible {
    box-shadow: 0 7px 8px rgba(21, 28, 36, .22);
    color: #fff !important;
    transform: translateY(-3px) scale(1.01);
}

.dark-theme .xyccw-card:hover,
.dark-theme .xyccw-card:focus-visible {
    box-shadow: 0 7px 8px rgba(0, 0, 0, .4);
}

.xyccw-card__image {
    height: 100% !important;
    inset: 0;
    margin: 0;
    max-height: none !important;
    max-width: none !important;
    object-fit: cover;
    position: absolute;
    transition: transform 280ms cubic-bezier(.22, 1, .36, 1);
    width: 100% !important;
    z-index: 0;
}

.xyccw-card:hover .xyccw-card__image,
.xyccw-card:focus-visible .xyccw-card__image {
    transform: scale(1.025);
}

.xyccw-card__shade {
    background: linear-gradient(
        180deg,
        rgba(4, 8, 14, 0) 42%,
        rgba(4, 8, 14, .2) 62%,
        rgba(4, 8, 14, .9) 100%
    );
    inset: 0;
    pointer-events: none;
    position: absolute;
    z-index: 1;
}

.xyccw-card__content {
    bottom: 0;
    display: flex;
    flex-direction: column;
    left: 0;
    padding: clamp(12px, 1.35vw, 18px);
    position: absolute;
    right: 0;
    text-shadow: 0 1px 5px rgba(0, 0, 0, .5);
    z-index: 2;
}

.xyccw-card__name {
    color: #fff;
    display: -webkit-box;
    font-size: clamp(14px, 1.2vw, 18px);
    font-weight: 650;
    line-height: 1.35;
    overflow: hidden;
    text-overflow: ellipsis;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.xyccw-card__count {
    color: rgba(255, 255, 255, .78);
    font-size: clamp(11px, .9vw, 13px);
    line-height: 1.3;
    margin-top: 5px;
}

@media (max-width: 991px) {
    .xyccw-widget__rail {
        grid-auto-columns: calc(23.809524% - 12.142857px);
    }
}

@media (max-width: 767px) {
    .xyccw-widget {
        --xyccw-gap: 12px;
    }

    .xyccw-widget__rail {
        grid-auto-columns: 39.5%;
        padding-bottom: 6px;
        scroll-snap-type: x mandatory;
        scrollbar-width: none;
    }

    .xyccw-widget__rail::-webkit-scrollbar {
        display: none;
    }

    .xyccw-card__content {
        padding: 12px;
    }

    .xyccw-card__name {
        font-size: 14px;
    }

    .xyccw-card__count {
        font-size: 11px;
        margin-top: 4px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .xyccw-card,
    .xyccw-card__image {
        transition: none;
    }

    .xyccw-card:hover,
    .xyccw-card:focus-visible,
    .xyccw-card:hover .xyccw-card__image,
    .xyccw-card:focus-visible .xyccw-card__image {
        transform: none;
    }
}
