/**
 * Quiz Trivia - Trivia Crack Style Quiz Game
 * Responsive Mobile-First CSS
 */

/* ========================================
   OVERLAY & MODALS
   ======================================== */

.quiz-trivia-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
    animation: quiz-fade-in 0.3s ease;
}

@keyframes quiz-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ========================================
   CATEGORY SELECTOR
   ======================================== */

.quiz-trivia-modal {
    background: white;
    border-radius: 24px;
    padding: 32px;
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: quiz-slide-up 0.4s ease;
}

@keyframes quiz-slide-up {
    from { transform: translateY(50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.quiz-trivia-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.quiz-trivia-header h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: #1E293B;
    margin: 0;
}

.quiz-close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    color: #64748B;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.quiz-close-btn:hover {
    background: #F1F5F9;
    color: #1E293B;
}

.quiz-category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
}

.quiz-category-card {
    background: linear-gradient(135deg, var(--category-color) 0%, var(--category-color) 100%);
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 2px solid rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
}

.quiz-category-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at top right, rgba(255, 255, 255, 0.2), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.quiz-category-card:hover::before {
    opacity: 1;
}

.quiz-category-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
}

.quiz-category-icon {
    font-size: 48px;
    margin-bottom: 12px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.quiz-category-name {
    font-size: 1.125rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* ========================================
   QUESTION CONTAINER
   ======================================== */

.quiz-question-container {
    background: white;
    border-radius: 24px;
    padding: 32px;
    max-width: 700px;
    width: 100%;
    animation: quiz-slide-up 0.4s ease;
}

.quiz-question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.quiz-category-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--category-color);
    color: white;
    padding: 6px 12px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.75rem;
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.quiz-category-badge span:first-child {
    font-size: 1rem;
    flex-shrink: 0;
}

.quiz-category-badge span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
}

.quiz-question-number {
    color: #64748B;
    font-size: 0.875rem;
    font-weight: 600;
}

/* ========================================
   TIMER BAR
   ======================================== */

.quiz-timer-container {
    width: 100%;
    max-width: 100%;
    height: 6px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 20px;
}

.quiz-timer-bar {
    height: 100%;
    transition: width 1s linear;
    border-radius: 999px;
}

.timer-safe {
    background: linear-gradient(90deg, #10B981, #34D399);
}

.timer-warning {
    background: linear-gradient(90deg, #FBBF24, #FCD34D);
}

.timer-danger {
    background: linear-gradient(90deg, #EF4444, #F87171);
    animation: timer-pulse 0.5s infinite;
}

@keyframes timer-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ========================================
   QUESTION CARD
   ======================================== */

.quiz-question-card {
    background: #F8FAFC;
    border-radius: 16px;
    padding: 24px;
}

.quiz-question-text {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1E293B;
    line-height: 1.6;
    margin-bottom: 24px;
    text-align: center;
}

.quiz-options-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.quiz-option-btn {
    background: white;
    border: 2px solid #E2E8F0;
    border-radius: 12px;
    padding: 16px 20px;
    text-align: left;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 12px;
}

.quiz-option-letter {
    background: var(--category-color);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}

.quiz-option-text {
    flex: 1;
    color: #1E293B;
}

.quiz-option-btn:hover:not(:disabled) {
    background: #F1F5F9;
    border-color: var(--category-color);
    transform: translateX(4px);
}

.quiz-option-btn.selected {
    background: var(--category-color);
    border-color: var(--category-color);
}

.quiz-option-btn.selected .quiz-option-letter {
    background: white;
    color: var(--category-color);
}

.quiz-option-btn.selected .quiz-option-text {
    color: white;
}

.quiz-option-btn.correct-answer {
    background: #10B981;
    border-color: #10B981;
}

.quiz-option-btn.correct-answer .quiz-option-letter {
    background: white;
    color: #10B981;
}

.quiz-option-btn.correct-answer .quiz-option-text {
    color: white;
}

.quiz-option-btn:disabled {
    cursor: not-allowed;
    opacity: 0.8;
}

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

.quiz-feedback-correct {
    animation: correct-flash 0.6s ease;
}

@keyframes correct-flash {
    0% { background: white; }
    50% { background: rgba(16, 185, 129, 0.1); }
    100% { background: white; }
}

.quiz-feedback-wrong {
    animation: wrong-shake 0.5s ease;
}

@keyframes wrong-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.quiz-feedback-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 32px;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    text-align: center;
    animation: quiz-pop-in 0.4s ease;
    z-index: 10;
}

@keyframes quiz-pop-in {
    0% { transform: translate(-50%, -50%) scale(0.8); opacity: 0; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.quiz-feedback-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.quiz-feedback-message.correct .quiz-feedback-icon {
    color: #10B981;
}

.quiz-feedback-message.wrong .quiz-feedback-icon {
    color: #EF4444;
}

.quiz-feedback-text {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.quiz-feedback-message.correct .quiz-feedback-text {
    color: #10B981;
}

.quiz-feedback-message.wrong .quiz-feedback-text {
    color: #EF4444;
}

.quiz-feedback-points {
    font-size: 1.25rem;
    font-weight: 600;
    color: #FBBF24;
}

.quiz-feedback-correct {
    font-size: 0.875rem;
    color: #64748B;
    margin-top: 8px;
}

/* ========================================
   RESULTS SCREEN
   ======================================== */

.quiz-results-container {
    background: white;
    border-radius: 24px;
    padding: 40px;
    max-width: 600px;
    width: 100%;
    animation: quiz-slide-up 0.4s ease;
}

.quiz-results-header {
    text-align: center;
    margin-bottom: 32px;
}

.quiz-results-header h2 {
    font-size: 2rem;
    font-weight: 700;
    color: #1E293B;
    margin: 0;
}

.quiz-results-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}

.quiz-stat-card {
    background: linear-gradient(135deg, var(--category-color), var(--category-color));
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    color: white;
}

.quiz-stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.quiz-stat-label {
    font-size: 0.875rem;
    opacity: 0.9;
}

.quiz-results-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.quiz-results-actions .btn {
    width: 100%;
}

/* ========================================
   RANKING TABLE
   ======================================== */

.quiz-ranking-container {
    background: white;
    border-radius: 24px;
    padding: 32px;
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: quiz-slide-up 0.4s ease;
}

.quiz-ranking-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.quiz-ranking-header h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: #1E293B;
    margin: 0;
}

.quiz-ranking-table-container {
    overflow-y: auto;
    flex: 1;
}

.quiz-ranking-table {
    width: 100%;
    border-collapse: collapse;
}

.quiz-ranking-table thead {
    background: linear-gradient(135deg, #1E40AF, #3B82F6);
    color: white;
    position: sticky;
    top: 0;
    z-index: 10;
}

.quiz-ranking-table th {
    padding: 16px;
    text-align: left;
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.quiz-ranking-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #E2E8F0;
    color: #1E293B;
}

.quiz-ranking-table tbody tr:hover {
    background: #F8FAFC;
}

.quiz-ranking-position {
    font-weight: 700;
    font-size: 1.125rem;
}

.quiz-ranking-position.top-1 {
    color: #FBBF24; /* Gold */
}

.quiz-ranking-position.top-2 {
    color: #94A3B8; /* Silver */
}

.quiz-ranking-position.top-3 {
    color: #CD7F32; /* Bronze */
}

.text-center {
    text-align: center;
}

/* ========================================
   RESPONSIVE (MOBILE)
   ======================================== */

@media (max-width: 640px) {
    .quiz-trivia-modal,
    .quiz-question-container,
    .quiz-results-container,
    .quiz-ranking-container {
        padding: 20px;
        border-radius: 16px;
    }
    
    .quiz-category-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .quiz-category-card {
        padding: 20px 16px;
    }
    
    .quiz-category-icon {
        font-size: 40px;
    }
    
    .quiz-category-name {
        font-size: 1rem;
    }
    
    .quiz-question-text {
        font-size: 1.125rem;
    }
    
    .quiz-option-btn {
        padding: 12px 16px;
        font-size: 0.9375rem;
    }
    
    .quiz-option-letter {
        width: 28px;
        height: 28px;
        font-size: 0.875rem;
    }
    
    .quiz-results-stats {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .quiz-stat-card {
        padding: 20px;
    }
    
    .quiz-stat-value {
        font-size: 2rem;
    }
    
    .quiz-ranking-table th,
    .quiz-ranking-table td {
        padding: 10px 12px;
        font-size: 0.875rem;
    }
    
    .quiz-feedback-message {
        padding: 24px;
        max-width: 90%;
    }
    
    .quiz-feedback-icon {
        font-size: 48px;
    }
    
    .quiz-feedback-text {
        font-size: 1.25rem;
    }
}

@media (max-width: 480px) {
    .quiz-trivia-overlay {
        padding: 12px;
    }
    
    .quiz-category-grid {
        grid-template-columns: 1fr;
    }
    
    .quiz-results-header h2 {
        font-size: 1.5rem;
    }
}

