/* 定义头像左右晃动动画 */
@keyframes shake-avatar {
    0% { transform: rotate(0deg); }
    25% { transform: rotate(-15deg); }
    50% { transform: rotate(15deg); }
    75% { transform: rotate(-15deg); }
    100% { transform: rotate(0deg); }
}

/* --- 基础通用样式 (移动端优先) --- */

/* 核心页面容器，减少底部外边距 */
.main {
    padding-bottom: 20px;
}

/* 顶部背景图样式 */
.top-bg-container {
    width: 100%;
    height: 280px; /* 移动端高度 */
    background-image: url('https://img.qninq.cn/ota/46vip/AHxLtEtJ.webp');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    margin-bottom: 10px;
}

/* 核心优化：为所有可点击项添加禁止长按和提示行为 */
.comment-rank-top3 .rank-item,
.comment-rank-list-others .rank-item {
    -webkit-tap-highlight-color: transparent;
    outline: none;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    transition: all 0.3s ease-in-out;
}

/* 核心优化：为所有可点击项添加点击交互效果 */
.comment-rank-top3 .rank-item:active img,
.comment-rank-list-others .rank-item:active img {
    animation: shake-avatar 0.5s ease-in-out;
}

/* --- Top 3 区域样式 (移动端) --- */
.comment-rank-top3 {
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    position: absolute;
    bottom: 10px;
    left: 0;
    width: 100%;
    padding: 0 15px;
}

.comment-rank-top3 .rank-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    text-decoration: none;
    width: 30%;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 10px 5px;
}

.rank-avatar-top3 {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    margin-bottom: 8px;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.comment-rank-top3 .rank-item:nth-child(2) .rank-avatar-top3 {
    border-color: #007bff;
}
.comment-rank-top3 .rank-item:nth-child(1) .rank-avatar-top3 {
    border-color: #ffeb3b;
}
.comment-rank-top3 .rank-item:nth-child(3) .rank-avatar-top3 {
    border-color: #66D47E;
}

.comment-rank-top3 .rank-item:nth-child(1) {
    bottom: 10px;
}
.comment-rank-top3 .rank-item:nth-child(2) {
    bottom: 25px;
}
.comment-rank-top3 .rank-item:nth-child(3) {
    bottom: 0px;
}

.comment-rank-top3 .rank-name {
    font-weight: bold;
    font-size: 1em;
    color: #333;
    background-color: rgba(255, 255, 255, 0.8);
    padding: 2px 6px;
    border-radius: 4px;
    margin-bottom: 3px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.comment-rank-top3 .rank-name::before {
    content: none;
}

.comment-rank-top3 .rank-badge {
    padding: 3px 6px;
    background-color: rgba(255, 255, 255, 0.7);
    border-radius: 12px;
    font-size: 0.8em;
    color: #333;
}

/* 提示语样式 */
.rank-tip-container {
    text-align: center;
    font-size: 0.85em;
    color: #999;
    padding: 10px 15px 0;
    margin-bottom: 0;
}
.rank-tip-container::after {
    content: none;
}

/* --- 4-15名 列表区域样式 (移动端) --- */
.comment-rank-list-others {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
    margin-top: 0;
}

.comment-rank-list-others .rank-item {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    text-decoration: none;
    position: relative;
    background-color: transparent;
    border-radius: 8px;
    margin-bottom: 5px;
}
.comment-rank-list-others .rank-item:not(:last-child) {
    border-bottom: none;
}
.rank-info-and-count {
    display: flex;
    flex-grow: 1;
    align-items: center;
    justify-content: space-between;
}
.rank-user-info {
    display: flex;
    align-items: center;
    overflow: hidden;
}
.rank-number-others {
    font-size: 1.2em;
    font-weight: bold;
    color: #dcdcdc;
    margin-right: 12px;
    flex-shrink: 0;
    width: 1.5em;
    text-align: center;
}
.rank-avatar {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    margin-right: 15px;
    flex-shrink: 0;
    border: 1px solid #e8e8e8;
}
.rank-name-others {
    font-weight: 500;
    font-size: 1em;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.rank-badge-others {
    padding: 4px 8px;
    background-color: #f0f0f0;
    border-radius: 12px;
    font-size: 0.8em;
    color: #666;
    white-space: nowrap;
    margin-left: 15px;
}

/* --- PC端样式适配，使用媒体查询（Media Query） --- */
@media (min-width: 768px) {
    /* PC端交互：鼠标悬停效果 */
    .comment-rank-top3 .rank-item:hover,
    .comment-rank-list-others .rank-item:hover {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        transform: translateY(-5px); /* 新增悬停位移效果 */
    }
    .comment-rank-top3 .rank-item:hover img,
    .comment-rank-list-others .rank-item:hover img {
        transform: scale(1.05);
        transition: transform 0.3s ease-in-out;
    }

    /* 优化顶部背景图容器 */
    .top-bg-container {
        height: 350px; /* PC端高度 */
        margin-bottom: 20px;
        /* 关键：为PC端启用Flex布局，让内容居中 */
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
    }

    /* 重新设计PC端 Top 3 区域布局 */
    .comment-rank-top3 {
        /* 移除绝对定位，使其在Flex布局中正常流动 */
        position: static;
        width: auto; /* 宽度自适应 */
        padding: 20px 50px;
        justify-content: center; /* 居中对齐 */
        gap: 30px; /* 增加卡片间距 */
    }

    /* 移除PC端卡片特殊的bottom定位 */
    .comment-rank-top3 .rank-item:nth-child(1),
    .comment-rank-top3 .rank-item:nth-child(2),
    .comment-rank-top3 .rank-item:nth-child(3) {
        bottom: auto; /* 重置定位 */
    }
    
    /* 重新通过transform实现品字形布局 */
    .comment-rank-top3 {
        flex-direction: row;
        align-items: flex-end;
    }
    .comment-rank-top3 .rank-item:nth-child(2) {
        transform: translateY(-15px);
    }
    .comment-rank-top3 .rank-item:nth-child(1),
    .comment-rank-top3 .rank-item:nth-child(3) {
        transform: translateY(0); /* 确保其他卡片没有位移 */
    }

    .comment-rank-top3 .rank-item {
        width: 250px;
        height: 180px;
        background: rgba(255, 255, 255, 0.2);
        padding: 15px 10px;
    }

    .rank-avatar-top3 {
        width: 80px; /* PC端头像尺寸 */
        height: 80px;
        border-radius: 12px;
        margin-bottom: 12px;
    }

    .comment-rank-top3 .rank-name {
        font-size: 1.2em; /* PC端字体放大 */
        padding: 4px 10px;
        background-color: rgba(255, 255, 255, 0.9);
    }

    .comment-rank-top3 .rank-badge {
        font-size: 0.9em;
        padding: 5px 12px;
        background-color: rgba(255, 255, 255, 0.8);
    }

    /* 提示语调整 */
    .rank-tip-container {
        font-size: 0.95em;
        padding: 20px 30px 10px;
    }

    /* PC端 4-15名 列表样式 */
    .comment-rank-list-others {
        padding: 0 30px;
        gap: 8px; /* 列表项间距 */
    }
    .comment-rank-list-others .rank-item {
        padding: 12px 20px;
        background-color: #f7f7f7;
        border-radius: 10px;
    }

    .rank-number-others {
        font-size: 1.4em;
        margin-right: 20px;
    }

    .rank-avatar {
        width: 50px;
        height: 50px;
        margin-right: 20px;
    }

    .rank-name-others {
        font-size: 1.1em;
        margin-left: 0;
    }

    .rank-badge-others {
        padding: 5px 10px;
        font-size: 0.9em;
    }
}