/* Quiz Results Modal System Styles for Sertifikatet Platform */

/* Glass morphism base style */
.glass {
    background: rgba(139, 92, 246, 0.1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Modal backdrop */
#quiz-results-backdrop {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* Primary modal container */
#quiz-results-modal {
    background: linear-gradient(135deg, 
        rgba(139, 92, 246, 0.2) 0%, 
        rgba(236, 72, 153, 0.15) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 
        0 25px 50px -12px rgba(0, 0, 0, 0.25),
        0 8px 16px -4px rgba(139, 92, 246, 0.1);
}

/* Purple scrollbar for main modal */
#quiz-results-modal::-webkit-scrollbar {
    width: 8px;
}

#quiz-results-modal::-webkit-scrollbar-track {
    background: #1f2937;
    border-radius: 4px;
}

#quiz-results-modal::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    border-radius: 4px;
    border: 1px solid #4c1d95;
}

#quiz-results-modal::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
}

/* Review modal container */
#quiz-review-modal {
    background: linear-gradient(135deg, 
        rgba(139, 92, 246, 0.15) 0%, 
        rgba(236, 72, 153, 0.1) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 
        0 25px 50px -12px rgba(0, 0, 0, 0.25),
        0 8px 16px -4px rgba(139, 92, 246, 0.1);
}

/* Purple scrollbar for review modal */
#quiz-review-modal::-webkit-scrollbar,
#review-content::-webkit-scrollbar {
    width: 8px;
}

#quiz-review-modal::-webkit-scrollbar-track,
#review-content::-webkit-scrollbar-track {
    background: #1f2937;
    border-radius: 4px;
}

#quiz-review-modal::-webkit-scrollbar-thumb,
#review-content::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    border-radius: 4px;
    border: 1px solid #4c1d95;
}

#quiz-review-modal::-webkit-scrollbar-thumb:hover,
#review-content::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
}

/* Circular progress ring animations */
#progress-circle {
    transition: stroke-dashoffset 2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Score counter animation */
#score-counter {
    transition: all 0.3s ease;
}

/* XP counter styling */
#xp-counter {
    text-shadow: 0 0 20px rgba(255, 193, 7, 0.5);
    animation: xp-glow 2s ease-in-out infinite alternate;
}

@keyframes xp-glow {
    from { text-shadow: 0 0 20px rgba(255, 193, 7, 0.5); }
    to { text-shadow: 0 0 30px rgba(255, 193, 7, 0.8), 0 0 40px rgba(255, 193, 7, 0.3); }
}

/* Achievement unlock animations */
.achievement-unlock {
    transform: translateY(20px);
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    animation: achievement-bounce 0.6s ease-out forwards;
}

@keyframes achievement-bounce {
    0% {
        transform: translateY(20px) scale(0.8);
        opacity: 0;
    }
    60% {
        transform: translateY(-5px) scale(1.05);
        opacity: 1;
    }
    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* Button hover animations */
.quiz-results-modal button,
.quiz-review-modal button {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.quiz-results-modal button:hover,
.quiz-review-modal button:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2);
}

/* Button ripple effect */
.quiz-results-modal button::before,
.quiz-review-modal button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transition: width 0.6s, height 0.6s, top 0.6s, left 0.6s;
    transform: translate(-50%, -50%);
    z-index: 0;
}

.quiz-results-modal button:active::before,
.quiz-review-modal button:active::before {
    width: 300px;
    height: 300px;
}

.quiz-results-modal button > *,
.quiz-review-modal button > * {
    position: relative;
    z-index: 1;
}

/* Question navigation dots */
.question-dot {
    cursor: pointer;
    transition: all 0.2s ease;
}

.question-dot:hover {
    transform: scale(1.2);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

/* Review content animations */
#review-content {
    transition: opacity 0.3s ease;
}

#review-content.changing {
    opacity: 0.5;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    #quiz-results-modal {
        inset: 1rem;
        transform: none;
        position: fixed;
        top: auto;
        left: auto;
        bottom: 0;
        border-radius: 1rem 1rem 0 0;
        max-height: 90vh;
    }
    
    #quiz-review-modal {
        inset: 0.5rem;
        border-radius: 1rem;
        max-height: 95vh;
    }
    
    /* Larger touch targets on mobile */
    .question-dot {
        width: 1rem;
        height: 1rem;
        margin: 0 0.25rem;
    }
    
    /* Better button spacing on mobile */
    #quiz-results-modal .space-y-3 > * + * {
        margin-top: 1rem;
    }
    
    /* Larger close buttons */
    #close-modal-btn,
    #close-review-btn {
        width: 2.5rem;
        height: 2.5rem;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.1);
    }
}

/* Progressive enhancement for better devices */
@media (min-width: 1024px) {
    #quiz-results-modal {
        max-width: 32rem;
    }
    
    #quiz-review-modal {
        max-width: 64rem;
        max-height: 85vh;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    #quiz-results-modal,
    #quiz-review-modal,
    #quiz-results-backdrop {
        transition: opacity 0.2s ease;
    }
    
    #progress-circle {
        transition: stroke-dashoffset 0.5s ease;
    }
    
    .achievement-unlock {
        animation: none;
        transform: translateY(0);
        opacity: 1;
    }
    
    @keyframes achievement-bounce {
        from, to {
            transform: translateY(0) scale(1);
            opacity: 1;
        }
    }
    
    @keyframes xp-glow {
        from, to {
            text-shadow: 0 0 20px rgba(255, 193, 7, 0.5);
        }
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .glass {
        background: rgba(0, 0, 0, 0.8);
        border: 2px solid white;
    }
    
    #quiz-results-modal,
    #quiz-review-modal {
        background: rgba(0, 0, 0, 0.9);
        border: 2px solid white;
    }
    
    .bg-white.bg-opacity-10,
    .bg-white.bg-opacity-20 {
        background: rgba(255, 255, 255, 0.2) !important;
        border: 1px solid rgba(255, 255, 255, 0.3);
    }
}

/* Focus management for accessibility */
.quiz-results-modal button:focus,
.quiz-review-modal button:focus {
    outline: 2px solid #8b5cf6;
    outline-offset: 2px;
}

/* Loading states */
.quiz-results-loading {
    pointer-events: none;
    opacity: 0.7;
}

.quiz-results-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2rem;
    height: 2rem;
    margin: -1rem 0 0 -1rem;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Swipe indicators for mobile review */
@media (max-width: 768px) {
    #quiz-review-modal::before {
        content: 'Sveip eller bruk pilene for å navigere';
        position: absolute;
        bottom: 1rem;
        left: 50%;
        transform: translateX(-50%);
        background: rgba(0, 0, 0, 0.8);
        color: white;
        padding: 0.5rem 1rem;
        border-radius: 0.5rem;
        font-size: 0.75rem;
        opacity: 0.8;
        z-index: 10;
        animation: fade-hint 4s ease-out;
    }
}

@keyframes fade-hint {
    0%, 20% { opacity: 0.8; }
    80%, 100% { opacity: 0; }
}

/* Dark theme adjustments */
@media (prefers-color-scheme: dark) {
    #quiz-results-backdrop {
        background: rgba(0, 0, 0, 0.7);
    }
}

/* Print styles (for potential result printing) */
@media print {
    #quiz-results-backdrop,
    #quiz-results-modal,
    #quiz-review-modal {
        position: static !important;
        background: white !important;
        color: black !important;
        box-shadow: none !important;
        backdrop-filter: none !important;
    }
    
    .text-white {
        color: black !important;
    }
    
    .text-purple-200,
    .text-purple-100 {
        color: #4B5563 !important;
    }
    
    button {
        display: none !important;
    }
}