/* 首页随机展示图：只作用于本插件，不修改 RiPro 全局容器。 */
.yws-home-random-images-widget > .container > .yws-home-random-images,
.yws-home-random-images-widget .yws-home-random-images {
    position: relative;
    width: 100vw;
    max-width: 100vw;
    left: 50%;
    margin-left: -50vw;
    box-sizing: border-box;
    padding-left: var(--yws-random-margin-x, 0px);
    padding-right: var(--yws-random-margin-x, 0px);
    margin-top: var(--yws-random-margin-top, 24px);
    margin-bottom: var(--yws-random-margin-bottom, 40px);
    overflow-x: clip;
    /* 100vw 会包含浏览器滚动条宽度，页面级横向溢出由 body 级保护处理。 */
}

/* 对不支持 overflow: clip 的浏览器回退，避免产生页面横向滚动条。 */
@supports not (overflow: clip) {
    .yws-home-random-images-widget > .container > .yws-home-random-images,
    .yws-home-random-images-widget .yws-home-random-images {
        overflow-x: hidden;
    }
}

.yws-home-random-images__heading {
    padding: 0 0 16px;
}

.yws-home-random-images__title {
    margin: 0;
    font-size: var(--yws-random-title-size, 22px);
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: normal;
}

.yws-home-random-images__desc {
    margin-top: 4px;
    color: #888;
    font-size: var(--yws-random-desc-size, 14px);
    white-space: pre-wrap;
    word-break: normal;
}

.yws-home-random-images__grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: var(--yws-random-gap, 4px);
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.yws-home-random-images__item {
    display: block;
    min-width: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
    border: 0;
    background: transparent;
    text-decoration: none !important;
}

.yws-home-random-images__media {
    display: block;
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: var(--yws-random-radius, 0px);
    background: #f3f3f3;
}

.yws-home-random-images--mode-cover .yws-home-random-images__media {
    aspect-ratio: var(--yws-random-ratio, 4 / 3);
    height: var(--yws-random-height, auto);
}

.yws-home-random-images--mode-original .yws-home-random-images__media {
    height: auto;
    aspect-ratio: auto;
}

.yws-home-random-images__media img {
    display: block;
    width: 100%;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: inherit;
    transition: transform .35s ease;
}

.yws-home-random-images--mode-cover .yws-home-random-images__media img {
    height: 100%;
    object-fit: cover;
}

.yws-home-random-images--mode-original .yws-home-random-images__media img {
    height: auto;
    object-fit: contain;
}

.yws-home-random-images__item:hover .yws-home-random-images__media img {
    transform: scale(1.025);
}

.yws-home-random-images__sentinel {
    width: 100%;
    height: 1px;
    margin: 1px 0 0;
    pointer-events: none;
}

.yws-home-random-images__loading,
.yws-home-random-images__complete {
    padding: 14px 0 0;
    text-align: center;
    font-size: 12px;
    line-height: 1.5;
    color: #999;
}

.yws-home-random-images__pool {
    display: none !important;
}

@media (max-width: 991.98px) {
    .yws-home-random-images__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (prefers-reduced-motion: reduce) {
    .yws-home-random-images__media img {
        transition: none;
    }
}

/* 仅当本插件存在时，阻止全宽突破模块造成页面横向滚动条。 */
html:has(.yws-home-random-images),
body:has(.yws-home-random-images),
body.yws-home-random-images-no-x-overflow {
    overflow-x: clip !important;
}
@supports not (overflow: clip) {
    html:has(.yws-home-random-images),
    body:has(.yws-home-random-images),
    body.yws-home-random-images-no-x-overflow {
        overflow-x: hidden !important;
    }
}
