/**
 * TRIVIA ENHANCED CSS
 * Part of RT398 Outstanding Trivia Initiative
 *
 * Styles for:
 * - Streak celebrations and milestones
 * - Achievement notifications
 * - Visual escalation system
 * - Leaderboard displays
 * - Rank badges
 *
 * Respects prefers-reduced-motion
 */

/* ==========================================================================
   STREAK CELEBRATIONS
   ========================================================================== */

.streak-celebration {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    pointer-events: none;
    animation: celebration-enter 0.3s ease-out;
    will-change: transform, opacity;
}

.celebration-content {
    text-align: center;
    padding: 2rem 3rem;
    border-radius: 1rem;
    background: linear-gradient(135deg, rgba(30, 30, 40, 0.95), rgba(20, 20, 30, 0.98));
    border: 2px solid var(--streak-color, #f59e0b);
    box-shadow: 0 0 60px var(--streak-glow, rgba(245, 158, 11, 0.5));
    animation: celebration-pulse 0.5s ease-in-out infinite alternate;
}

.celebration-icon {
    font-size: 4rem;
    margin-bottom: 0.5rem;
    animation: icon-bounce 0.5s ease-out;
}

.celebration-streak {
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--streak-color, #f59e0b);
    text-shadow: 0 0 20px var(--streak-glow, rgba(245, 158, 11, 0.8));
    letter-spacing: 0.1em;
}

.celebration-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    margin-top: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
}

.celebration-badge,
.celebration-hof {
    margin-top: 1rem;
    padding: 0.5rem 1rem;
    background: rgba(255, 215, 0, 0.2);
    border-radius: 0.5rem;
    color: #ffd700;
    font-weight: 600;
    animation: badge-glow 1s ease-in-out infinite alternate;
}

.celebration-fade {
    animation: celebration-exit 0.5s ease-out forwards;
}

/* Milestone-specific colors */
.streak-5 { --streak-color: #f97316; --streak-glow: rgba(249, 115, 22, 0.5); }
.streak-10 { --streak-color: #ef4444; --streak-glow: rgba(239, 68, 68, 0.6); }
.streak-15 { --streak-color: #eab308; --streak-glow: rgba(234, 179, 8, 0.6); }
.streak-20 { --streak-color: #a855f7; --streak-glow: rgba(168, 85, 247, 0.6); }
.streak-25 { --streak-color: #06b6d4; --streak-glow: rgba(6, 182, 212, 0.6); }
.streak-50 { --streak-color: #10b981; --streak-glow: rgba(16, 185, 129, 0.6); }
.streak-100 { --streak-color: #ffd700; --streak-glow: rgba(255, 215, 0, 0.8); }

/* Celebration size variations */
.celebration-small .celebration-content { transform: scale(0.9); }
.celebration-medium .celebration-content { transform: scale(1); }
.celebration-large .celebration-content { transform: scale(1.1); }
.celebration-epic .celebration-content { transform: scale(1.2); }
.celebration-legendary .celebration-content { transform: scale(1.3); }
.celebration-mythic .celebration-content {
    transform: scale(1.4);
    background: linear-gradient(135deg,
        rgba(255, 215, 0, 0.2),
        rgba(168, 85, 247, 0.2),
        rgba(6, 182, 212, 0.2),
        rgba(255, 215, 0, 0.2)
    );
    background-size: 400% 400%;
    animation: rainbow-bg 3s ease infinite, celebration-pulse 0.5s ease-in-out infinite alternate;
}

/* ==========================================================================
   STREAK VISUAL CLASSES (for game area)
   ========================================================================== */

.streak-visual-warm {
    --game-bg-tint: rgba(249, 115, 22, 0.05);
}

.streak-visual-hot {
    --game-bg-tint: rgba(239, 68, 68, 0.08);
}

.streak-visual-gold {
    --game-bg-tint: rgba(234, 179, 8, 0.1);
}

.streak-visual-fire {
    --game-bg-tint: rgba(239, 68, 68, 0.15);
}

.streak-visual-rainbow {
    background: linear-gradient(135deg,
        rgba(239, 68, 68, 0.1),
        rgba(234, 179, 8, 0.1),
        rgba(16, 185, 129, 0.1),
        rgba(6, 182, 212, 0.1),
        rgba(168, 85, 247, 0.1)
    );
    background-size: 400% 400%;
    animation: rainbow-bg 5s ease infinite;
}

/* Apply tint to game container */
.trivia-game[class*="streak-visual-"] {
    background-color: var(--game-bg-tint, transparent);
    transition: background-color 0.5s ease;
}

/* ==========================================================================
   SCREEN SHAKE
   ========================================================================== */

.screen-shake {
    animation: shake 0.3s ease-in-out;
}

/* ==========================================================================
   ACHIEVEMENT NOTIFICATIONS
   ========================================================================== */

.achievement-notification {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 10001;
    animation: achievement-slide-in 0.5s ease-out;
    will-change: transform, opacity;
}

.achievement-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, rgba(30, 30, 40, 0.98), rgba(20, 20, 30, 0.98));
    border: 2px solid #ffd700;
    border-radius: 1rem;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.3);
}

.achievement-icon {
    font-size: 2.5rem;
    animation: icon-bounce 0.5s ease-out;
}

.achievement-text {
    text-align: left;
}

.achievement-label {
    font-size: 0.75rem;
    color: #ffd700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
}

.achievement-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
}

.achievement-desc {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.7);
}

.achievement-fade {
    animation: achievement-slide-out 0.5s ease-out forwards;
}

/* ==========================================================================
   RANK BADGES
   ========================================================================== */

.trivia-rank-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    font-weight: 600;
    font-size: 0.875rem;
}

.rank-tier-1 { background: linear-gradient(135deg, #6b7280, #4b5563); color: white; }
.rank-tier-2 { background: linear-gradient(135deg, #3b82f6, #2563eb); color: white; }
.rank-tier-3 { background: linear-gradient(135deg, #10b981, #059669); color: white; }
.rank-tier-4 { background: linear-gradient(135deg, #8b5cf6, #7c3aed); color: white; }
.rank-tier-5 { background: linear-gradient(135deg, #f59e0b, #d97706); color: black; }
.rank-tier-6 { background: linear-gradient(135deg, #ec4899, #db2777); color: white; }
.rank-tier-7 { background: linear-gradient(135deg, #06b6d4, #0891b2); color: black; }
.rank-tier-8 { background: linear-gradient(135deg, #f43f5e, #e11d48); color: white; }
.rank-tier-9 {
    background: linear-gradient(135deg, #ffd700, #ffb800, #ffd700);
    color: black;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
}

.rank-icon {
    font-size: 1.25rem;
}

.rank-name {
    font-weight: 700;
}

/* ==========================================================================
   LEADERBOARD DISPLAY
   ========================================================================== */

.trivia-leaderboard {
    background: rgba(30, 30, 40, 0.8);
    border-radius: 1rem;
    padding: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.leaderboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.leaderboard-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
}

.leaderboard-tabs {
    display: flex;
    gap: 0.5rem;
}

.leaderboard-tab {
    padding: 0.25rem 0.75rem;
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.leaderboard-tab:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.leaderboard-tab.active {
    background: var(--accent-color, #3b82f6);
    color: white;
}

.leaderboard-entry {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    transition: background 0.2s ease;
}

.leaderboard-entry:hover {
    background: rgba(255, 255, 255, 0.05);
}

.leaderboard-entry.self {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.entry-rank {
    width: 2rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.5);
}

.entry-rank.top-1 { color: #ffd700; }
.entry-rank.top-2 { color: #c0c0c0; }
.entry-rank.top-3 { color: #cd7f32; }

.entry-name {
    flex: 1;
    font-weight: 600;
    color: white;
}

.entry-score {
    font-weight: 700;
    color: var(--accent-color, #3b82f6);
}

.entry-badge {
    margin-left: 0.5rem;
    font-size: 1.25rem;
}

/* ==========================================================================
   PROGRESS BAR
   ========================================================================== */

.xp-progress {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    height: 0.75rem;
    overflow: hidden;
    position: relative;
}

.xp-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-color, #3b82f6), #8b5cf6);
    border-radius: 0.5rem;
    transition: width 0.5s ease-out;
    position: relative;
}

.xp-progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.3) 50%,
        transparent 100%
    );
    animation: progress-shine 2s linear infinite;
}

/* ==========================================================================
   PERSONAL STATS CARD
   ========================================================================== */

.personal-stats-card {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    padding: 1rem;
    background: rgba(30, 30, 40, 0.6);
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-item {
    text-align: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 0.75rem;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: white;
    line-height: 1;
}

.stat-label {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.5rem;
}

/* ==========================================================================
   ANIMATIONS
   ========================================================================== */

@keyframes celebration-enter {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes celebration-exit {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.8);
    }
}

@keyframes celebration-pulse {
    from {
        box-shadow: 0 0 60px var(--streak-glow, rgba(245, 158, 11, 0.5));
    }
    to {
        box-shadow: 0 0 100px var(--streak-glow, rgba(245, 158, 11, 0.7));
    }
}

@keyframes icon-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes badge-glow {
    from { box-shadow: 0 0 10px rgba(255, 215, 0, 0.3); }
    to { box-shadow: 0 0 25px rgba(255, 215, 0, 0.6); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

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

@keyframes achievement-slide-in {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes achievement-slide-out {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

@keyframes progress-shine {
    from { transform: translateX(-100%); }
    to { transform: translateX(200%); }
}

/* ==========================================================================
   REDUCED MOTION
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .streak-celebration,
    .streak-celebration *,
    .achievement-notification,
    .achievement-notification *,
    .screen-shake,
    .xp-progress-bar::after {
        animation: none !important;
        transition: none !important;
    }

    .celebration-content {
        box-shadow: 0 0 30px var(--streak-glow, rgba(245, 158, 11, 0.3));
    }
}

/* Note: Reduced motion is handled by @media (prefers-reduced-motion: reduce) above.
   The reduced-motion class is added programmatically for HalojinixSettings override. */
.reduced-motion .celebration-content,
.reduced-motion .celebration-icon {
    animation: none !important;
    transition: none !important;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 640px) {
    .celebration-content {
        padding: 1.5rem 2rem;
        margin: 1rem;
    }

    .celebration-icon {
        font-size: 3rem;
    }

    .celebration-streak {
        font-size: 2rem;
    }

    .celebration-name {
        font-size: 1.25rem;
    }

    .achievement-notification {
        top: auto;
        bottom: 1rem;
        left: 1rem;
        right: 1rem;
    }

    .achievement-content {
        width: 100%;
    }

    .personal-stats-card {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ==========================================================================
   STREAK COUNTER DISPLAY (in-game)
   ========================================================================== */

.streak-counter {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(30, 30, 40, 0.8);
    border-radius: 2rem;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.streak-counter.active {
    border-color: var(--streak-color, #f59e0b);
    box-shadow: 0 0 15px var(--streak-glow, rgba(245, 158, 11, 0.3));
}

.streak-counter .streak-icon {
    font-size: 1.25rem;
    transition: transform 0.3s ease;
}

.streak-counter.active .streak-icon {
    animation: flame-pulse 0.5s ease-in-out infinite alternate;
}

.streak-counter .streak-value {
    font-size: 1.25rem;
    font-weight: 800;
    color: white;
}

.streak-counter .streak-label {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
}

@keyframes flame-pulse {
    from { transform: scale(1) rotate(-5deg); }
    to { transform: scale(1.2) rotate(5deg); }
}

/* Dynamic streak colors for counter */
.streak-counter[data-streak="5"] { --streak-color: #f97316; --streak-glow: rgba(249, 115, 22, 0.4); }
.streak-counter[data-streak="10"] { --streak-color: #ef4444; --streak-glow: rgba(239, 68, 68, 0.4); }
.streak-counter[data-streak="15"] { --streak-color: #eab308; --streak-glow: rgba(234, 179, 8, 0.4); }
.streak-counter[data-streak="20"] { --streak-color: #a855f7; --streak-glow: rgba(168, 85, 247, 0.4); }
.streak-counter[data-streak="25"] { --streak-color: #06b6d4; --streak-glow: rgba(6, 182, 212, 0.4); }
