/**
 * 特殊稱號顯示系統 - "賢賢的摯愛"
 * 超級華麗版本 💖✨
 */

/* ========== 稱號容器 ========== */
.player-with-title {
    position: relative;
}

.title-badge-container {
    position: absolute;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    pointer-events: auto;
    animation: float-up-down 3s ease-in-out infinite;
}

/* 浮動動畫 */
@keyframes float-up-down {
    0%, 100% {
        transform: translateX(-50%) translateY(0);
    }
    50% {
        transform: translateX(-50%) translateY(-10px);
    }
}

/* ========== 粉紅色光暈背景 ========== */
.title-glow-bg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(255, 107, 157, 0.4) 0%, rgba(255, 107, 157, 0.2) 50%, transparent 70%);
    border-radius: 50%;
    animation: glow-pulse 2s ease-in-out infinite;
    pointer-events: none;
}

@keyframes glow-pulse {
    0%, 100% {
        opacity: 0.6;
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.1);
    }
}

/* ========== 絲帶稱號本體 ========== */
.title-ribbon {
    position: relative;
    display: inline-block;
    padding: 8px 25px 8px 25px;
    background: linear-gradient(135deg,
        #ffc3dc 0%,   /* 淺粉 */
        #ff9ec8 25%,  /* 中粉 */
        #ff6b9d 50%,  /* 深粉 */
        #ff9ec8 75%,  /* 中粉 */
        #ffc3dc 100%  /* 淺粉 */
    );
    background-size: 200% 200%;
    animation: ribbon-gradient 3s ease infinite;
    color: #fff;
    font-size: 14px;
    font-weight: bold;
    text-shadow:
        0 0 5px rgba(255, 215, 0, 0.8),
        0 0 10px rgba(255, 107, 157, 0.6),
        2px 2px 4px rgba(0, 0, 0, 0.3);
    border-radius: 20px;
    box-shadow:
        0 4px 15px rgba(255, 107, 157, 0.6),
        0 0 30px rgba(255, 107, 157, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.5);
    white-space: nowrap;
    animation: ribbon-gradient 3s ease infinite,
               ribbon-shine 2s ease-in-out infinite,
               gem-sparkle 1.5s ease-in-out infinite;
}

/* 絲帶漸變動畫 */
@keyframes ribbon-gradient {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

/* 絲帶閃光動畫（寶石效果） */
@keyframes ribbon-shine {
    0%, 100% {
        box-shadow:
            0 4px 15px rgba(255, 107, 157, 0.6),
            0 0 30px rgba(255, 107, 157, 0.4),
            inset 0 1px 0 rgba(255, 255, 255, 0.5);
    }
    50% {
        box-shadow:
            0 4px 20px rgba(255, 215, 0, 0.8),
            0 0 40px rgba(255, 215, 0, 0.6),
            inset 0 1px 0 rgba(255, 255, 255, 0.8);
    }
}

/* 寶石閃爍效果 */
@keyframes gem-sparkle {
    0%, 100% {
        filter: brightness(1);
    }
    50% {
        filter: brightness(1.2);
    }
}

/* ========== 絲帶兩側的三角形 ========== */
.title-ribbon::before,
.title-ribbon::after {
    content: '';
    position: absolute;
    top: 0;
    width: 0;
    height: 0;
    border-style: solid;
}

.title-ribbon::before {
    left: -15px;
    border-width: 15px 15px 15px 0;
    border-color: transparent #ff6b9d transparent transparent;
    filter: drop-shadow(-2px 2px 4px rgba(0, 0, 0, 0.3));
}

.title-ribbon::after {
    right: -15px;
    border-width: 15px 0 15px 15px;
    border-color: transparent transparent transparent #ff6b9d;
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.3));
}

/* ========== 蝴蝶結裝飾（左側） ========== */
.title-bow-left {
    position: absolute;
    left: -35px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    animation: bow-bounce 2s ease-in-out infinite;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

@keyframes bow-bounce {
    0%, 100% {
        transform: translateY(-50%) scale(1);
    }
    50% {
        transform: translateY(-50%) scale(1.1);
    }
}

/* ========== 蝴蝶結裝飾（右側） ========== */
.title-bow-right {
    position: absolute;
    right: -35px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    animation: bow-bounce 2s ease-in-out infinite 0.5s;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* ========== 愛心裝飾（左側） ========== */
.title-heart-left {
    position: absolute;
    left: -55px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    animation: heart-beat 1.5s ease-in-out infinite;
    filter: drop-shadow(0 0 5px rgba(255, 107, 157, 0.8));
}

@keyframes heart-beat {
    0%, 100% {
        transform: translateY(-50%) scale(1);
    }
    30% {
        transform: translateY(-50%) scale(1.2);
    }
    60% {
        transform: translateY(-50%) scale(1);
    }
}

/* ========== 愛心裝飾（右側） ========== */
.title-heart-right {
    position: absolute;
    right: -55px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    animation: heart-beat 1.5s ease-in-out infinite 0.3s;
    filter: drop-shadow(0 0 5px rgba(255, 107, 157, 0.8));
}

/* ========== 環繞星星 ========== */
.title-star {
    position: absolute;
    font-size: 12px;
    animation: star-rotate 4s linear infinite;
    pointer-events: none;
    filter: drop-shadow(0 0 3px rgba(255, 215, 0, 0.8));
}

.title-star:nth-child(1) { animation-delay: 0s; }
.title-star:nth-child(2) { animation-delay: -1s; }
.title-star:nth-child(3) { animation-delay: -2s; }
.title-star:nth-child(4) { animation-delay: -3s; }

@keyframes star-rotate {
    0% {
        transform: rotate(0deg) translateX(50px) rotate(0deg);
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
    100% {
        transform: rotate(360deg) translateX(50px) rotate(-360deg);
        opacity: 1;
    }
}

/* ========== 飄浮愛心粒子 ========== */
.title-heart-particle {
    position: absolute;
    font-size: 10px;
    opacity: 0;
    animation: heart-float 3s ease-in-out infinite;
    pointer-events: none;
}

.title-heart-particle:nth-child(1) {
    left: -20px;
    animation-delay: 0s;
}
.title-heart-particle:nth-child(2) {
    left: 0px;
    animation-delay: 0.5s;
}
.title-heart-particle:nth-child(3) {
    right: 0px;
    animation-delay: 1s;
}
.title-heart-particle:nth-child(4) {
    right: -20px;
    animation-delay: 1.5s;
}

@keyframes heart-float {
    0% {
        transform: translateY(0) scale(0);
        opacity: 0;
    }
    20% {
        opacity: 1;
    }
    80% {
        opacity: 1;
    }
    100% {
        transform: translateY(-50px) scale(1.2);
        opacity: 0;
    }
}

/* ========== 發光金框頭貼容器 ========== */
.player-avatar-with-title {
    position: relative;
    display: inline-block;
}

.avatar-golden-frame {
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    border: 3px solid;
    border-image: linear-gradient(
        45deg,
        #ffd700,
        #ffed4e,
        #ffd700,
        #ffb347,
        #ffd700
    ) 1;
    border-radius: 50%;
    box-shadow:
        0 0 10px rgba(255, 215, 0, 0.6),
        0 0 20px rgba(255, 215, 0, 0.4),
        inset 0 0 10px rgba(255, 215, 0, 0.3);
    animation: frame-glow 2s ease-in-out infinite;
    pointer-events: none;
}

@keyframes frame-glow {
    0%, 100% {
        box-shadow:
            0 0 10px rgba(255, 215, 0, 0.6),
            0 0 20px rgba(255, 215, 0, 0.4),
            inset 0 0 10px rgba(255, 215, 0, 0.3);
    }
    50% {
        box-shadow:
            0 0 20px rgba(255, 215, 0, 0.8),
            0 0 30px rgba(255, 215, 0, 0.6),
            inset 0 0 15px rgba(255, 215, 0, 0.5);
    }
}

/* ========== 互動效果 ========== */
.title-badge-container:hover .title-ribbon {
    transform: scale(1.15);
    transition: transform 0.3s ease;
}

.title-badge-container:hover .title-glow-bg {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.2);
}

/* ========== Tooltip ========== */
.title-tooltip {
    position: absolute;
    bottom: -35px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1000;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.title-tooltip::before {
    content: '';
    position: absolute;
    top: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 5px 5px 5px;
    border-color: transparent transparent rgba(0, 0, 0, 0.9) transparent;
}

.title-badge-container:hover .title-tooltip {
    opacity: 1;
}

/* ========== 點擊愛心噴發效果 ========== */
.love-burst-heart {
    position: fixed;
    font-size: 24px;
    pointer-events: none;
    animation: burst-out 1s ease-out forwards;
    z-index: 10000;
}

@keyframes burst-out {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(var(--tx), var(--ty)) scale(0.5);
        opacity: 0;
    }
}

/* ========== 彩虹漸變（特殊場合） ========== */
.title-ribbon.rainbow {
    background: linear-gradient(
        90deg,
        #ff6b9d,
        #feca57,
        #48dbfb,
        #0abde3,
        #ff9ff3,
        #ff6b9d
    );
    background-size: 300% 300%;
    animation: rainbow-flow 4s ease infinite, ribbon-shine 2s ease-in-out infinite;
}

@keyframes rainbow-flow {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

/* ========== 排行榜中的稱號顯示 ========== */
.side-leaderboard-item.has-title .player-name {
    position: relative;
    padding-top: 25px;
}

.side-leaderboard-item.has-title .player-name::before {
    content: '👑 賢賢的摯愛 👑';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    background: linear-gradient(135deg, #ff6b9d 0%, #ffd700 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: bold;
    white-space: nowrap;
    animation: title-glow-text 2s ease-in-out infinite;
}

@keyframes title-glow-text {
    0%, 100% {
        filter: drop-shadow(0 0 2px rgba(255, 215, 0, 0.6));
    }
    50% {
        filter: drop-shadow(0 0 5px rgba(255, 215, 0, 0.9));
    }
}

/* ========== 響應式設計 ========== */
@media (max-width: 768px) {
    .title-badge-container {
        top: -50px;
    }

    .title-ribbon {
        font-size: 11px;
        padding: 6px 20px;
    }

    .title-bow-left,
    .title-bow-right {
        font-size: 14px;
    }

    .title-heart-left,
    .title-heart-right {
        font-size: 12px;
    }

    .title-glow-bg {
        width: 150px;
        height: 150px;
    }
}
