/* ============================================================
   MedSchoolHub Quiz Engine — Glassmorphic UI
   Uses theme CSS variables for seamless light/dark mode
   ============================================================ */

/* ── Quiz Container ── */
.msh-quiz-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px 0;
    font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ── Loading State ── */
.msh-quiz-loading {
    text-align: center;
    padding: 60px 40px;
    color: var(--text-secondary);
    font-size: 1rem;
}
.msh-quiz-loading::before {
    content: '';
    display: block;
    width: 40px;
    height: 40px;
    margin: 0 auto 16px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: msh-spin 0.8s linear infinite;
}
@keyframes msh-spin {
    to { transform: rotate(360deg); }
}

/* ── Glass Card Base ── */
.msh-quiz-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-card, 20px);
    backdrop-filter: var(--blur, blur(20px));
    -webkit-backdrop-filter: var(--blur, blur(20px));
    box-shadow: var(--shadow-card);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    overflow: hidden;
}

/* ═══════════════════════════════════════
   START SCREEN
   ═══════════════════════════════════════ */
.msh-quiz-start {
    padding: 48px 40px;
    text-align: center;
}
.msh-quiz-start-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}
.msh-quiz-start h2 {
    font-size: clamp(1.4rem, 3vw, 1.8rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-primary);
    margin: 0 0 12px;
}
.msh-quiz-start-desc {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.7;
    max-width: 500px;
    margin: 0 auto 28px;
}
.msh-quiz-meta {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-bottom: 32px;
    flex-wrap: wrap;
}
.msh-quiz-meta-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.msh-quiz-meta-item span {
    font-weight: 700;
    color: var(--text-primary);
}
.msh-quiz-meta-icon {
    font-size: 1.1rem;
}

/* ═══════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════ */
.msh-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 32px;
    border: none;
    border-radius: 50px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s ease;
    text-decoration: none;
}
.msh-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.msh-btn-primary {
    background: var(--accent-gradient, linear-gradient(135deg, #0984E3, #00CEC9));
    color: #FFFFFF;
    box-shadow: 0 4px 16px rgba(9, 132, 227, 0.35);
}
.msh-btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(9, 132, 227, 0.45);
}
.msh-btn-secondary {
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.msh-btn-secondary:hover:not(:disabled) {
    background: var(--bg-surface-hover);
    border-color: var(--border-color-hover);
}
.msh-btn-sm {
    padding: 10px 20px;
    font-size: 0.85rem;
}

/* ═══════════════════════════════════════
   PROGRESS BAR
   ═══════════════════════════════════════ */
.msh-quiz-progress {
    padding: 20px 32px 0;
}
.msh-quiz-progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.msh-quiz-progress-info strong {
    color: var(--text-primary);
    font-weight: 700;
}
.msh-quiz-progress-bar {
    width: 100%;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
}
.msh-quiz-progress-fill {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 3px;
    transition: width 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* ── Timer ── */
.msh-quiz-timer {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
}
.msh-quiz-timer.warning {
    color: var(--accent-orange, #FF9F43);
}
.msh-quiz-timer.danger {
    color: var(--accent-red, #FF7675);
    animation: msh-pulse 1s ease infinite;
}
@keyframes msh-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ═══════════════════════════════════════
   QUESTION VIEW
   ═══════════════════════════════════════ */
.msh-quiz-question {
    padding: 32px;
}
.msh-quiz-question-text {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.7;
    margin-bottom: 28px;
}
.msh-quiz-question-text p {
    margin: 0 0 8px;
}
.msh-quiz-question-text img {
    max-width: 100%;
    border-radius: 12px;
    margin: 12px 0;
}
.msh-quiz-question-hint {
    font-size: 0.85rem;
    color: var(--accent-blue);
    background: var(--bg-tag, rgba(9, 132, 227, 0.1));
    padding: 10px 16px;
    border-radius: 10px;
    margin-bottom: 24px;
    display: none;
}
.msh-quiz-question-hint.visible {
    display: block;
}

/* ── Answer Options ── */
.msh-quiz-answers {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.msh-quiz-answer {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    border-radius: 14px;
    border: 1.5px solid var(--border-color);
    background: var(--bg-surface);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}
.msh-quiz-answer:hover {
    border-color: var(--border-color-hover);
    background: var(--bg-surface-hover);
    transform: translateX(4px);
}
.msh-quiz-answer.selected {
    border-color: var(--accent-blue);
    background: rgba(9, 132, 227, 0.08);
}
.msh-quiz-answer.correct {
    border-color: #27ae60;
    background: rgba(39, 174, 96, 0.08);
}
.msh-quiz-answer.incorrect {
    border-color: var(--accent-red, #FF7675);
    background: rgba(255, 118, 117, 0.08);
}
.msh-quiz-answer.disabled {
    pointer-events: none;
    opacity: 0.7;
}

.msh-quiz-answer-marker {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--text-muted);
    transition: all 0.2s ease;
}
.msh-quiz-answer.selected .msh-quiz-answer-marker {
    border-color: var(--accent-blue);
    background: var(--accent-blue);
    color: #FFFFFF;
}
.msh-quiz-answer.correct .msh-quiz-answer-marker {
    border-color: #27ae60;
    background: #27ae60;
    color: #FFFFFF;
}
.msh-quiz-answer.incorrect .msh-quiz-answer-marker {
    border-color: var(--accent-red);
    background: var(--accent-red);
    color: #FFFFFF;
}

.msh-quiz-answer-text {
    font-size: 0.95rem;
    color: var(--text-primary);
    line-height: 1.5;
    flex-grow: 1;
}
.msh-quiz-answer-text img {
    max-width: 200px;
    border-radius: 8px;
    margin-top: 8px;
}

/* ── Question Navigation ── */
.msh-quiz-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 32px 28px;
    gap: 12px;
}
.msh-quiz-nav-hint {
    font-size: 0.8rem;
    color: var(--accent-blue);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* ── Explanation (shown after answering) ── */
.msh-quiz-explanation {
    margin: 0 32px 20px;
    padding: 20px;
    border-radius: 14px;
    background: rgba(9, 132, 227, 0.06);
    border: 1px solid rgba(9, 132, 227, 0.15);
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.7;
    display: none;
}
.msh-quiz-explanation.visible {
    display: block;
}
.msh-quiz-explanation strong {
    color: var(--text-primary);
    display: block;
    margin-bottom: 6px;
}
.msh-quiz-explanation p {
    margin: 0 0 8px;
}

/* ═══════════════════════════════════════
   RESULTS SCREEN
   ═══════════════════════════════════════ */
.msh-quiz-results {
    padding: 48px 40px;
    text-align: center;
}
.msh-quiz-score-ring {
    width: 140px;
    height: 140px;
    margin: 0 auto 24px;
    position: relative;
}
.msh-quiz-score-ring svg {
    transform: rotate(-90deg);
    width: 140px;
    height: 140px;
}
.msh-quiz-score-ring circle {
    fill: none;
    stroke-width: 8;
    stroke-linecap: round;
}
.msh-quiz-score-ring .ring-bg {
    stroke: var(--border-color);
}
.msh-quiz-score-ring .ring-fill {
    stroke: var(--accent-blue);
    transition: stroke-dashoffset 1.5s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.msh-quiz-score-ring .ring-fill.pass {
    stroke: #27ae60;
}
.msh-quiz-score-ring .ring-fill.fail {
    stroke: var(--accent-red, #FF7675);
}
.msh-quiz-score-value {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.msh-quiz-score-percent {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.03em;
}
.msh-quiz-score-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.msh-quiz-results h2 {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0 0 8px;
}
.msh-quiz-results-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 24px;
}

.msh-quiz-results-stats {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin-bottom: 32px;
    flex-wrap: wrap;
}
.msh-quiz-stat {
    text-align: center;
}
.msh-quiz-stat-value {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text-primary);
}
.msh-quiz-stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.msh-quiz-results-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* ═══════════════════════════════════════
   REVIEW MODE
   ═══════════════════════════════════════ */
.msh-quiz-review-list {
    padding: 24px 32px;
}
.msh-quiz-review-item {
    padding: 24px 0;
    border-bottom: 1px solid var(--border-color);
}
.msh-quiz-review-item:last-child {
    border-bottom: none;
}
.msh-quiz-review-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    margin-bottom: 12px;
}
.msh-quiz-review-status.correct {
    background: rgba(39, 174, 96, 0.1);
    color: #27ae60;
}
.msh-quiz-review-status.incorrect {
    background: rgba(255, 118, 117, 0.1);
    color: var(--accent-red, #FF7675);
}

/* ═══════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════ */
@media (max-width: 600px) {
    .msh-quiz-start { padding: 32px 24px; }
    .msh-quiz-question { padding: 24px 20px; }
    .msh-quiz-nav { padding: 16px 20px 24px; }
    .msh-quiz-results { padding: 32px 24px; }
    .msh-quiz-progress { padding: 16px 20px 0; }
    .msh-quiz-explanation { margin: 0 20px 16px; }
    .msh-quiz-answer { padding: 14px 16px; gap: 12px; }
    .msh-quiz-meta { gap: 16px; }
    .msh-quiz-results-stats { gap: 20px; }
    .msh-quiz-review-list { padding: 20px; }
    
    /* Reduce padding of entry-content div on mobile to make text column wider */
    .entry-content {
        padding: 16px 12px !important;
    }
}

/* ═══════════════════════════════════════
   TRUE/FALSE 3-STATE TOGGLE
   ═══════════════════════════════════════ */

/* T/F answer row — position relative for badge */
.msh-quiz-answer.msh-tf-answer {
    position: relative;
    padding-right: 56px;
}

/* Badge in the right corner */
.msh-tf-badge {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1.5px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    background: var(--bg-surface);
    transition: all 0.2s ease;
    user-select: none;
    flex-shrink: 0;
}

/* State: True — light blue */
.msh-quiz-answer.msh-tf-true {
    border-color: rgba(9, 132, 227, 0.4);
    background: rgba(9, 132, 227, 0.06);
}
.msh-quiz-answer.msh-tf-true .msh-tf-badge {
    border-color: rgba(9, 132, 227, 0.5);
    color: var(--text-secondary);
    background: rgba(9, 132, 227, 0.12);
}

/* State: False — light pink */
.msh-quiz-answer.msh-tf-false {
    border-color: rgba(255, 118, 117, 0.4);
    background: rgba(255, 118, 117, 0.06);
}
.msh-quiz-answer.msh-tf-false .msh-tf-badge {
    border-color: rgba(255, 118, 117, 0.5);
    color: var(--text-secondary);
    background: rgba(255, 118, 117, 0.12);
}

/* Result states — reuse existing correct/incorrect borders */
.msh-quiz-answer.msh-tf-answer.correct .msh-tf-badge {
    border-color: #27ae60;
    color: #27ae60;
    background: rgba(39, 174, 96, 0.1);
}
.msh-quiz-answer.msh-tf-answer.incorrect .msh-tf-badge {
    border-color: var(--accent-red, #FF7675);
    color: var(--accent-red, #FF7675);
    background: rgba(255, 118, 117, 0.1);
}

/* Strikethrough for incorrect user mark */
.msh-tf-strikethrough {
    text-decoration: line-through;
    opacity: 0.5;
    margin-right: 2px;
}

/* Red correct-answer reveal */
.msh-tf-correct-reveal {
    color: var(--accent-red, #FF7675);
    font-weight: 800;
}
