/**
 * WP 邀请佣金榜 - 前台样式
 * 全部样式收在 .wpcms-card 内，避免影响主题和其他小工具
 */

/* 接管主题侧边栏小工具外壳，避免卡片套卡片 */
.widget_wpcms_commission,
.zib-widget.widget_wpcms_commission {
    padding: 0 !important;
    background: none !important;
    border: 0 !important;
    box-shadow: none !important;
}

.wpcms-card {
    --wpcms-row-h: 58px;
    --wpcms-line: rgba(16, 24, 40, 0.06);
    --wpcms-text: var(--key-color, #344054);
    --wpcms-muted: var(--muted-color, #98a2b3);
    --wpcms-soft: rgba(16, 24, 40, 0.03);
    position: relative;
    padding: 12px 0 4px;
    border: 1px solid var(--wpcms-line);
    border-radius: var(--main-radius, 14px);
    background: var(--main-bg-color, #fff);
    box-shadow: 0 8px 24px rgba(16, 24, 40, 0.06);
    overflow: hidden;
    box-sizing: border-box;
    contain: layout paint;
}

.wpcms-card *,
.wpcms-card *::before,
.wpcms-card *::after {
    box-sizing: border-box;
}

body.dark .wpcms-card,
.dark .wpcms-card {
    --wpcms-line: rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

/* 顶部柔光，增加层次但不抢内容 */
.wpcms-card::before {
    content: "";
    position: absolute;
    left: -30%;
    right: -30%;
    top: -96px;
    height: 190px;
    background: radial-gradient(60% 60% at 50% 50%, rgba(255, 138, 0, 0.16), rgba(255, 61, 110, 0.10) 45%, transparent 72%);
    pointer-events: none;
}

.wpcms-title {
    position: relative;
    z-index: 1;
    padding: 14px 14px 0;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--wpcms-text);
}

.wpcms-head {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 14px 10px;
}

.wpcms-live {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #12b76a;
    line-height: 1;
}

.wpcms-live i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #12b76a;
    box-shadow: 0 0 0 0 rgba(18, 183, 106, 0.45);
    animation: wpcms-pulse 1.8s ease-out infinite;
}

.wpcms-sub {
    font-size: 12px;
    color: var(--wpcms-muted);
    line-height: 1;
}

@keyframes wpcms-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(18, 183, 106, 0.45);
    }
    70% {
        box-shadow: 0 0 0 7px rgba(18, 183, 106, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(18, 183, 106, 0);
    }
}

/* 可视窗口：固定行数高度，上下渐隐 */
.wpcms-viewport {
    position: relative;
    height: calc(var(--wpcms-rows, 7) * var(--wpcms-row-h));
    overflow: hidden;
    -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 12px, #000 calc(100% - 12px), transparent 100%);
    mask-image: linear-gradient(180deg, transparent 0, #000 12px, #000 calc(100% - 12px), transparent 100%);
}

.wpcms-track {
    display: flex;
    flex-direction: column;
    animation: wpcms-scroll var(--wpcms-duration, 60s) linear infinite;
    will-change: transform;
}

.wpcms-viewport:hover .wpcms-track {
    animation-play-state: paused;
}

.wpcms-group {
    display: flex;
    flex-direction: column;
    flex: none;
}

@keyframes wpcms-scroll {
    from {
        transform: translateY(0);
    }
    to {
        transform: translateY(-50%);
    }
}

.wpcms-row {
    position: relative;
    display: grid;
    grid-template-columns: 22px 40px minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 10px;
    height: var(--wpcms-row-h);
    padding: 0 14px;
    border-top: 1px solid var(--wpcms-line);
}

.wpcms-group .wpcms-row:first-child {
    border-top: 0;
}

/* 两组衔接处保留一条分隔线，滚动循环时不突兀 */
.wpcms-group + .wpcms-group .wpcms-row:first-child {
    border-top: 1px solid var(--wpcms-line);
}

.wpcms-row:hover {
    background: var(--wpcms-soft);
}

/* 名次 */
.wpcms-rank {
    width: 22px;
    height: 22px;
    line-height: 22px;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    color: var(--wpcms-muted);
    font-variant-numeric: tabular-nums;
}

.wpcms-rank-1,
.wpcms-rank-2,
.wpcms-rank-3 {
    border-radius: 7px;
    font-size: 11px;
}

.wpcms-rank-1 {
    color: #7a4a00;
    background: linear-gradient(135deg, #ffe08a, #ffb300);
    box-shadow: 0 2px 6px rgba(255, 179, 0, 0.35);
}

.wpcms-rank-2 {
    color: #4a5364;
    background: linear-gradient(135deg, #eef1f6, #c3c9d6);
}

.wpcms-rank-3 {
    color: #7a3d16;
    background: linear-gradient(135deg, #ffd2b0, #f09b67);
}

/* 头像 */
.wpcms-avatar {
    display: block;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    background: rgba(16, 24, 40, 0.06);
    flex: none;
}

.wpcms-avatar img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.wpcms-avatar-text {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 14px;
    font-weight: 700;
    color: var(--wpcms-muted);
}

.wpcms-avatar-1 {
    box-shadow: 0 0 0 2px #ffd76a, 0 0 0 4px rgba(255, 215, 106, 0.22);
}

.wpcms-avatar-2 {
    box-shadow: 0 0 0 2px #cbd2df, 0 0 0 4px rgba(203, 210, 223, 0.22);
}

.wpcms-avatar-3 {
    box-shadow: 0 0 0 2px #f3ab7c, 0 0 0 4px rgba(243, 171, 124, 0.22);
}

/* 昵称 */
.wpcms-name {
    min-width: 0;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--wpcms-text);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 金额 */
.wpcms-amount {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    min-width: 70px;
    line-height: 1.12;
    text-align: right;
}

.wpcms-money {
    font-size: 15px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.2px;
    background: linear-gradient(90deg, #ff8a00, #ff3d6e);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
}

.wpcms-label {
    font-size: 10px;
    color: var(--wpcms-muted);
    letter-spacing: 0.4px;
}

/* 相对金额条：纯装饰，填充行内视觉空白 */
.wpcms-bar {
    position: absolute;
    left: 14px;
    right: auto;
    bottom: 0;
    width: calc(var(--wpcms-p, 0) * 1%);
    max-width: calc(100% - 28px);
    height: 2px;
    border-radius: 2px;
    background: linear-gradient(90deg, #ffb35c, #ff4d6d);
    opacity: 0.22;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.wpcms-row:hover .wpcms-bar {
    opacity: 0.55;
}

/* 移动端：略矮一些 */
@media (max-width: 768px) {
    .wpcms-card {
        --wpcms-row-h: 52px;
    }

    .wpcms-row {
        grid-template-columns: 20px 36px minmax(0, 1fr) auto;
        column-gap: 8px;
        padding: 0 12px;
    }

    .wpcms-avatar {
        width: 36px;
        height: 36px;
    }

    .wpcms-rank {
        width: 20px;
    }

    .wpcms-money {
        font-size: 14px;
    }

    .wpcms-bar {
        left: 12px;
        max-width: calc(100% - 24px);
    }
}

/* 减少动态效果：停止滚动，允许手动查看 */
@media (prefers-reduced-motion: reduce) {
    .wpcms-track {
        animation: none;
    }

    .wpcms-viewport {
        overflow-y: auto;
        -webkit-mask-image: none;
        mask-image: none;
    }

    .wpcms-live i {
        animation: none;
    }
}
