/**
 * Matching Question Styles - F-030 Phase 4C-3
 *
 * Styles for matching questions with dropdown pairing UI
 *
 * Features:
 * - Left column with static items
 * - Dropdown selectors for right column items
 * - Visual feedback (green/red) for correct/incorrect pairs
 * - Mobile responsive with touch-friendly dropdowns
 * - Keyboard navigation support
 */

/* ==================== CONTAINER ==================== */
/* Note: Container frame comes from parent .question-display */

.quiz-matching {
    width: 100%;
    animation: matchingContentFadeIn 300ms ease-out;
}

@keyframes matchingContentFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.matching-container {
    margin-top: var(--space-lg);
    margin-bottom: var(--space-lg);
}

/* ==================== MATCHING PAIR ROW ==================== */

.matching-pair-row {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    margin-bottom: var(--space-sm);
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.matching-pair-row:hover {
    border-color: var(--border-light);
    background: var(--bg-hover);
}

/* ==================== LEFT COLUMN (STATIC ITEMS) ==================== */

.matching-left-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex: 1;
    min-width: 0; /* Allow text truncation */
}

.matching-left-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--accent);
    color: white;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: var(--font-sm);
    flex-shrink: 0;
}

.matching-left-text {
    flex: 1;
    color: var(--text-primary);
    font-size: var(--font-base);
    line-height: var(--line-height);
    word-break: break-word;
}

/* ==================== RIGHT COLUMN (DROPDOWN) ==================== */

.matching-dropdown-container {
    flex: 1;
    min-width: 0;
}

.matching-dropdown {
    width: 100%;
    padding: 8px 12px;
    font-size: 16px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.matching-dropdown:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: var(--bg-secondary);
}

/* Default "Select..." option styling */
.matching-dropdown option[value=""] {
    color: var(--text-muted);
    font-style: italic;
}

/* ==================== VISUAL FEEDBACK (AFTER VALIDATION) ==================== */

/* Pending state (default) */
.matching-pair-pending {
    border-color: var(--border);
}

/* Correct pair */
.matching-pair-correct {
    border-color: var(--success);
    background: rgba(34, 197, 94, 0.1);
}

.matching-pair-correct .matching-left-number {
    background: var(--success);
}

.matching-pair-correct .matching-dropdown {
    border-color: var(--success);
    background: rgba(34, 197, 94, 0.05);
    color: var(--success-dark);
    font-weight: 500;
}

.matching-pair-correct:hover {
    background: rgba(34, 197, 94, 0.1);
}

/* Incorrect pair */
.matching-pair-incorrect {
    border-color: var(--error);
    background: rgba(239, 68, 68, 0.1);
}

.matching-pair-incorrect .matching-left-number {
    background: var(--error);
}

.matching-pair-incorrect .matching-dropdown {
    border-color: var(--error);
    background: rgba(239, 68, 68, 0.05);
    color: var(--error-dark);
}

.matching-pair-incorrect:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* ==================== SCORE DISPLAY ==================== */

.matching-score-container {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-top: var(--space-md);
    padding: var(--space-md);
    background: rgba(59, 130, 246, 0.1);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm);
}

.matching-score-label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: var(--font-sm);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.matching-score-value {
    font-weight: 700;
    color: var(--accent);
    font-size: var(--font-base);
}

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

/* Success feedback animation */
@keyframes matchingSuccessPulse {
    0%, 100% {
        border-color: var(--success);
    }
    50% {
        border-color: #22c55e;
        box-shadow: 0 0 12px rgba(34, 197, 94, 0.4);
    }
}

.matching-pair-correct {
    animation: matchingSuccessPulse 0.6s ease-in-out;
}

/* Error feedback animation */
@keyframes matchingErrorShake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-4px);
    }
    75% {
        transform: translateX(4px);
    }
}

.matching-pair-incorrect {
    animation: matchingErrorShake 0.4s ease-in-out;
}

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

@media (max-width: 640px) {
    .matching-pair-row {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-sm);
        padding: var(--space-sm);
    }

    .matching-left-item {
        width: 100%;
    }

    .matching-left-number {
        width: 24px;
        height: 24px;
        font-size: var(--font-xs);
    }

    .matching-left-text {
        font-size: var(--font-sm);
    }

    .matching-dropdown-container {
        width: 100%;
    }

    .matching-dropdown {
        width: 100%;
        font-size: var(--font-sm);
        padding: var(--space-sm);
        padding-right: var(--space-lg);
        min-height: 44px; /* Touch-friendly height */
    }

    .matching-score-container {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-xs);
    }
}

/* ==================== ACCESSIBILITY ==================== */

/* Focus visible for keyboard navigation */
.matching-dropdown:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .matching-pair-row {
        border-width: 3px;
    }

    .matching-pair-correct {
        border-width: 4px;
    }

    .matching-pair-incorrect {
        border-width: 4px;
    }

    .matching-dropdown {
        border-width: 3px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .matching-pair-row,
    .matching-dropdown,
    .matching-pair-correct,
    .matching-pair-incorrect {
        transition: none;
        animation: none;
    }
}

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

@media (prefers-color-scheme: dark) {
    .matching-pair-row {
        background: rgba(255, 255, 255, 0.05);
        border-color: rgba(255, 255, 255, 0.1);
    }

    .matching-pair-row:hover {
        background: rgba(255, 255, 255, 0.08);
        border-color: rgba(255, 255, 255, 0.2);
    }

    .matching-dropdown {
        background: rgba(255, 255, 255, 0.05);
        border-color: rgba(255, 255, 255, 0.1);
        color: rgba(255, 255, 255, 0.9);
    }

    .matching-dropdown:hover:not(:disabled) {
        background: rgba(255, 255, 255, 0.08);
    }

    .matching-dropdown:disabled {
        background: rgba(255, 255, 255, 0.03);
    }

    .matching-pair-correct {
        background: rgba(34, 197, 94, 0.15);
    }

    .matching-pair-incorrect {
        background: rgba(239, 68, 68, 0.15);
    }

    .matching-pair-correct .matching-dropdown {
        background: rgba(34, 197, 94, 0.1);
        color: var(--success-light);
    }

    .matching-pair-incorrect .matching-dropdown {
        background: rgba(239, 68, 68, 0.1);
        color: var(--error-light);
    }
}

/* ==================== PRINT STYLES ==================== */

@media print {
    .matching-dropdown {
        border: 1px solid #000;
        background: #fff;
    }

    .matching-score-container {
        display: none;
    }

    .matching-pair-correct,
    .matching-pair-incorrect {
        animation: none;
    }
}
