/**
 * Gamification Styles
 * Styles for points display, progress map, challenges, and celebrations
 */

/* =========================================
   GAMIFICATION SIDEBAR (Profile + Hasanat + Leaderboard)
   ========================================= */

.gamification-sidebar {
    position: fixed;
    top: 16px;
    left: 12px;
    z-index: 998;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Sidebar buttons base style */
.sidebar-btn {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: var(--ui-font, 'Readex Pro', sans-serif);
    position: relative;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.sidebar-btn:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.sidebar-btn:active {
    transform: scale(0.95);
}

/* Profile button - rectangular like hasanat button */
.profile-btn {
    background: linear-gradient(135deg,
            rgba(120, 144, 156, 0.9),
            rgba(96, 125, 139, 0.9));
    color: white;
}

.profile-btn i {
    font-size: 1.2rem;
}

/* Profile initial letter */
.profile-initial {
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1;
    text-transform: uppercase;
}

.profile-btn:hover {
    background: linear-gradient(135deg,
            rgba(96, 125, 139, 1),
            rgba(69, 90, 100, 1));
}

/* Hasanat (Points) button - Leaf/Nature theme */
.hasanat-btn {
    background: linear-gradient(135deg,
            rgba(76, 175, 80, 0.95),
            rgba(56, 142, 60, 0.95));
    color: white;
    gap: 2px;
}

.hasanat-btn:hover {
    background: linear-gradient(135deg,
            rgba(67, 160, 71, 1),
            rgba(46, 125, 50, 1));
}

.hasanat-icon {
    font-size: 1.1rem;
    line-height: 1;
    animation: leaf-sway 3s ease-in-out infinite;
}

@keyframes leaf-sway {

    0%,
    100% {
        transform: rotate(-5deg);
    }

    50% {
        transform: rotate(5deg);
    }
}

.hasanat-value {
    font-size: 0.7rem;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    min-width: 30px;
    text-align: center;
}

/* Leaderboard button */
.gamification-sidebar .leaderboard-btn {
    background: linear-gradient(135deg,
            rgba(255, 193, 7, 0.95),
            rgba(255, 160, 0, 0.95));
    color: white;
}

.gamification-sidebar .leaderboard-btn:hover {
    background: linear-gradient(135deg,
            rgba(255, 179, 0, 1),
            rgba(255, 143, 0, 1));
}

.gamification-sidebar .leaderboard-btn i {
    font-size: 1.2rem;
}

/* Multiplier badge (positioned below sidebar) */
.gamification-sidebar .multiplier-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 10px;
    background: linear-gradient(135deg, #ff6b35, #ff9f1c);
    border-radius: 12px;
    font-size: 0.65rem;
    font-weight: 600;
    color: white;
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.4);
}

.gamification-sidebar .multiplier-badge.active {
    animation: pulse-glow 2s ease-in-out infinite;
}

/* Points earned animation */
.points-earned-popup {
    position: fixed;
    z-index: 10001;
    pointer-events: none;
    font-family: var(--ui-font, 'Readex Pro', sans-serif);
    font-size: 1.25rem;
    font-weight: 700;
    color: #4caf50;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3),
        0 0 20px rgba(76, 175, 80, 0.5);
    animation: points-float 1.5s ease-out forwards;
}

@keyframes points-float {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }

    50% {
        opacity: 1;
        transform: translateY(-30px) scale(1.1);
    }

    100% {
        opacity: 0;
        transform: translateY(-60px) scale(0.9);
    }
}

@keyframes pulse-glow {

    0%,
    100% {
        box-shadow: 0 0 5px rgba(255, 107, 53, 0.5);
    }

    50% {
        box-shadow: 0 0 15px rgba(255, 107, 53, 0.8);
    }
}

/* =========================================
   STREAK MULTIPLIER DISPLAY
   ========================================= */

.streak-multiplier {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: linear-gradient(135deg, #ff6b35, #ff9f1c);
    border-radius: 20px;
    color: white;
    font-size: 0.85rem;
    font-weight: 600;
}

.streak-multiplier .fire {
    animation: fire-flicker 0.5s ease-in-out infinite alternate;
}

@keyframes fire-flicker {
    from {
        transform: scale(1) rotate(-2deg);
    }

    to {
        transform: scale(1.05) rotate(2deg);
    }
}

/* =========================================
   PROGRESS MAP
   ========================================= */

.progress-map-container {
    padding: 20px;
    overflow-x: auto;
}

.progress-map {
    display: flex;
    align-items: center;
    gap: 0;
    min-width: max-content;
    padding: 20px 0;
}

.milestone-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.milestone-connector {
    width: 40px;
    height: 4px;
    background: var(--border-color, #e0e5e8);
    position: relative;
}

.milestone-connector.completed {
    background: linear-gradient(90deg,
            var(--primary-color, #3a9d74),
            var(--accent-color, #5dc299));
}

.milestone-connector.current {
    background: linear-gradient(90deg,
            var(--primary-color, #3a9d74) 50%,
            var(--border-color, #e0e5e8) 50%);
}

.milestone-badge {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: var(--card-bg, white);
    border: 3px solid var(--border-color, #e0e5e8);
    transition: all 0.3s ease;
    position: relative;
    z-index: 1;
}

.milestone-badge.unlocked {
    border-color: var(--primary-color, #3a9d74);
    background: linear-gradient(135deg,
            var(--primary-color, #3a9d74),
            var(--accent-color, #5dc299));
    box-shadow: 0 4px 15px rgba(58, 157, 116, 0.4);
}

.milestone-badge.current {
    border-color: var(--secondary-color, #d4a853);
    animation: current-pulse 2s ease-in-out infinite;
}

@keyframes current-pulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(212, 168, 83, 0.4);
        transform: scale(1);
    }

    50% {
        box-shadow: 0 0 0 10px rgba(212, 168, 83, 0);
        transform: scale(1.05);
    }
}

.milestone-badge.locked {
    opacity: 0.5;
    filter: grayscale(0.5);
}

.milestone-info {
    text-align: center;
    margin-top: 10px;
    max-width: 80px;
}

.milestone-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-color, #333);
    white-space: nowrap;
}

.milestone-ayahs {
    font-size: 0.65rem;
    color: var(--muted-text, #666);
}

/* Progress bar under current milestone */
.milestone-progress-bar {
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background: var(--border-color, #e0e5e8);
    border-radius: 2px;
    overflow: hidden;
}

.milestone-progress-bar .fill {
    height: 100%;
    background: linear-gradient(90deg,
            var(--secondary-color, #d4a853),
            var(--primary-color, #3a9d74));
    transition: width 0.5s ease;
}

/* =========================================
   CHALLENGE CARDS
   ========================================= */

.challenges-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    padding: 16px;
}

.challenge-card {
    background: var(--card-bg, white);
    border-radius: 16px;
    padding: 20px;
    border: 1px solid var(--border-color, #e0e5e8);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.challenge-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.challenge-card.completed {
    background: linear-gradient(135deg,
            rgba(58, 157, 116, 0.1),
            rgba(93, 194, 153, 0.1));
    border-color: var(--primary-color, #3a9d74);
}

.challenge-card.completed::after {
    content: '✓';
    position: absolute;
    top: 10px;
    right: 10px;
    width: 24px;
    height: 24px;
    background: var(--primary-color, #3a9d74);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: bold;
}

.challenge-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.challenge-icon {
    font-size: 2rem;
    line-height: 1;
}

.challenge-title {
    flex: 1;
}

.challenge-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color, #333);
    margin: 0 0 4px 0;
}

.challenge-difficulty {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.challenge-difficulty.easy {
    background: #e8f5e9;
    color: #2e7d32;
}

.challenge-difficulty.medium {
    background: #fff3e0;
    color: #ef6c00;
}

.challenge-difficulty.hard {
    background: #ffebee;
    color: #c62828;
}

.challenge-description {
    font-size: 0.85rem;
    color: var(--muted-text, #666);
    margin-bottom: 16px;
    line-height: 1.4;
}

.challenge-progress {
    margin-bottom: 12px;
}

.challenge-progress-bar {
    height: 8px;
    background: var(--border-color, #e0e5e8);
    border-radius: 4px;
    overflow: hidden;
}

.challenge-progress-bar .fill {
    height: 100%;
    background: linear-gradient(90deg,
            var(--primary-color, #3a9d74),
            var(--accent-color, #5dc299));
    transition: width 0.5s ease;
    border-radius: 4px;
}

.challenge-progress-text {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--muted-text, #666);
    margin-top: 4px;
}

.challenge-reward {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--secondary-color, #d4a853);
}

.challenge-reward .bonus {
    font-size: 0.7rem;
    padding: 2px 6px;
    background: linear-gradient(135deg, #ff6b35, #ff9f1c);
    color: white;
    border-radius: 8px;
    margin-left: 6px;
}

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

.challenge-celebration {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    z-index: 10000;
    background: linear-gradient(135deg,
            var(--primary-color, #3a9d74),
            var(--secondary-color, #d4a853));
    padding: 30px 40px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    text-align: center;
    color: white;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.challenge-celebration.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.challenge-celebration-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.challenge-celebration .challenge-icon {
    font-size: 3rem;
    animation: celebration-bounce 0.6s ease infinite alternate;
}

@keyframes celebration-bounce {
    from {
        transform: translateY(0) rotate(-5deg);
    }

    to {
        transform: translateY(-10px) rotate(5deg);
    }
}

.challenge-celebration .challenge-title {
    font-size: 1.3rem;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.challenge-celebration .challenge-name {
    font-size: 1rem;
    opacity: 0.9;
}

.challenge-celebration .challenge-reward {
    font-size: 1.5rem;
    margin-top: 10px;
}

.challenge-celebration .reward-points {
    font-size: 2rem;
    font-weight: 800;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.challenge-celebration .reward-label {
    font-size: 0.9rem;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Milestone unlock celebration */
.milestone-celebration {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.milestone-celebration.show {
    opacity: 1;
}

.milestone-celebration-content {
    background: linear-gradient(135deg,
            var(--primary-color, #3a9d74),
            var(--secondary-color, #d4a853));
    padding: 50px 60px;
    border-radius: 30px;
    text-align: center;
    color: white;
    transform: scale(0.5);
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-width: 90%;
}

.milestone-celebration.show .milestone-celebration-content {
    transform: scale(1);
}

.milestone-celebration .milestone-badge {
    font-size: 5rem;
    margin-bottom: 20px;
    animation: badge-reveal 1s ease-out forwards;
}

@keyframes badge-reveal {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }

    60% {
        transform: scale(1.2) rotate(10deg);
    }

    100% {
        transform: scale(1) rotate(0);
        opacity: 1;
    }
}

.milestone-celebration .milestone-title {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 10px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.milestone-celebration .milestone-description {
    font-size: 1rem;
    opacity: 0.9;
    margin-bottom: 20px;
}

.milestone-celebration .milestone-rewards {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

.milestone-celebration .reward-tag {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    font-size: 0.9rem;
    backdrop-filter: blur(5px);
}

.milestone-celebration .close-btn {
    margin-top: 30px;
    padding: 12px 30px;
    background: white;
    color: var(--primary-color, #3a9d74);
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.milestone-celebration .close-btn:hover {
    transform: scale(1.05);
}

/* Confetti animation */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    overflow: hidden;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    animation: confetti-fall 4s ease-out forwards;
}

@keyframes confetti-fall {
    0% {
        transform: translateY(-10px) rotate(0deg);
        opacity: 1;
    }

    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* =========================================
   OBJECTIVES MODAL
   ========================================= */

.objectives-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.objectives-modal.show {
    opacity: 1;
    visibility: visible;
}

.objectives-modal-content {
    background: var(--card-bg, white);
    border-radius: 24px;
    max-width: 600px;
    width: 95%;
    max-height: 85vh;
    overflow: hidden;
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.objectives-modal.show .objectives-modal-content {
    transform: translateY(0);
}

.objectives-modal-header {
    padding: 24px;
    background: linear-gradient(135deg,
            var(--primary-color, #3a9d74),
            var(--accent-color, #5dc299));
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.objectives-modal-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0;
}

.objectives-modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    transition: background 0.2s ease;
}

.objectives-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.objectives-modal-body {
    padding: 24px;
    overflow-y: auto;
    max-height: 60vh;
}

.objectives-section {
    margin-bottom: 24px;
}

.objectives-section-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-color, #333);
    margin: 0 0 16px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

@media (max-width: 767px) {
    .gamification-sidebar {
        top: 16px;
        left: auto;
        right: 60px;
        flex-direction: row;
        gap: 6px;
    }

    .sidebar-btn {
        width: 44px;
        height: 44px;
        border-radius: 12px;
    }

    .hasanat-icon {
        font-size: 0.95rem;
    }

    .hasanat-value {
        font-size: 0.6rem;
    }

    .profile-btn i,
    .gamification-sidebar .leaderboard-btn i {
        font-size: 1rem;
    }

    .challenges-container {
        grid-template-columns: 1fr;
        padding: 12px;
    }

    .challenge-card {
        padding: 16px;
    }

    .milestone-badge {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }

    .milestone-connector {
        width: 25px;
    }

    .milestone-celebration-content {
        padding: 30px 25px;
    }

    .milestone-celebration .milestone-badge {
        font-size: 3.5rem;
    }
}

/* =========================================
   DARK MODE
   ========================================= */

body.dark-mode .gamification-sidebar .sidebar-btn {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

body.dark-mode .challenge-card {
    background: var(--card-bg-dark, #252a28);
    border-color: var(--border-color-dark, #353d3a);
}

body.dark-mode .challenge-card.completed {
    background: linear-gradient(135deg,
            rgba(58, 157, 116, 0.15),
            rgba(93, 194, 153, 0.15));
}

body.dark-mode .challenge-difficulty.easy {
    background: rgba(46, 125, 50, 0.2);
}

body.dark-mode .challenge-difficulty.medium {
    background: rgba(239, 108, 0, 0.2);
}

body.dark-mode .challenge-difficulty.hard {
    background: rgba(198, 40, 40, 0.2);
}

body.dark-mode .milestone-badge {
    background: var(--card-bg-dark, #252a28);
    border-color: var(--border-color-dark, #353d3a);
}

body.dark-mode .milestone-badge.unlocked {
    border-color: var(--primary-color, #3a9d74);
}

body.dark-mode .objectives-modal-content {
    background: var(--card-bg-dark, #252a28);
}