/**
 * Ordering Question Styles - F-030 Phase 4C-2
 *
 * Styles for drag-and-drop ordering questions with button fallback
 *
 * Features:
 * - Draggable list items with visual feedback
 * - Button controls (↑↓) for accessibility
 * - Position indicators (1, 2, 3...)
 * - Correct/incorrect visual feedback (green/red)
 * - Mobile responsive with touch-friendly targets
 * - Keyboard navigation support
 */

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

.quiz-ordering {
    width: 100%;
    animation: orderingContentFadeIn 300ms ease-out;
}

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

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

/* ==================== ORDERING LIST ==================== */

.ordering-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    padding: 0;
    margin: 0;
    list-style: none;
}

/* ==================== ORDERING ITEM ==================== */

.ordering-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    cursor: move;
    cursor: grab;
    transition: all var(--transition-fast);
    user-select: none;
    min-height: 60px;
}

.ordering-item:hover {
    border-color: var(--border-light);
    background: var(--bg-hover);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.ordering-item:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Dragging state */
.ordering-item-dragging {
    opacity: 0.5;
    cursor: grabbing;
    transform: scale(0.95);
}

/* Drag over state */
.ordering-item-drag-over {
    border-color: var(--accent);
    border-style: dashed;
    background: rgba(59, 130, 246, 0.1);
}

/* ==================== POSITION NUMBER ==================== */

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

/* ==================== ITEM TEXT ==================== */

.ordering-item-text {
    flex: 1;
    color: var(--text-primary);
    font-size: var(--font-base);
    line-height: var(--line-height);
}

/* ==================== CONTROLS (BUTTONS) ==================== */

.ordering-controls {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    flex-shrink: 0;
}

.ordering-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 28px;
    padding: 0;
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: var(--font-lg);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.ordering-btn:hover:not(:disabled) {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    transform: translateY(-1px);
}

.ordering-btn:active:not(:disabled) {
    transform: translateY(0);
}

.ordering-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.ordering-btn:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Button icons */
.ordering-btn span {
    display: block;
    line-height: 1;
}

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

/* Correct position */
.ordering-item-correct {
    border-color: var(--success);
    background: rgba(34, 197, 94, 0.1);
    cursor: default;
}

.ordering-item-correct .ordering-item-number {
    background: var(--success);
}

.ordering-item-correct:hover {
    transform: none;
    box-shadow: none;
}

/* Incorrect position */
.ordering-item-incorrect {
    border-color: var(--error);
    background: rgba(239, 68, 68, 0.1);
    cursor: default;
}

.ordering-item-incorrect .ordering-item-number {
    background: var(--error);
}

.ordering-item-incorrect:hover {
    transform: none;
    box-shadow: none;
}

/* Disable dragging after validation */
.ordering-item[draggable="false"] {
    cursor: default;
}

.ordering-item[draggable="false"]:hover {
    transform: none;
}

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

.ordering-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);
}

.ordering-score-label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: var(--font-sm);
}

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

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

@media (max-width: 640px) {
    .ordering-item {
        padding: var(--space-sm);
        gap: var(--space-sm);
        min-height: 70px; /* Larger touch targets */
    }

    .ordering-item-number {
        width: 28px;
        height: 28px;
        font-size: var(--font-xs);
    }

    .ordering-item-text {
        font-size: var(--font-sm);
    }

    .ordering-controls {
        gap: var(--space-xs);
    }

    .ordering-btn {
        width: 36px;
        height: 32px;
        font-size: var(--font-xl);
    }

    /* Increase touch targets */
    .ordering-btn::before {
        content: '';
        position: absolute;
        top: -8px;
        right: -8px;
        bottom: -8px;
        left: -8px;
    }
}

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

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

.ordering-btn:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
}

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

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

/* Item reorder animation */
@keyframes itemReorder {
    0% {
        transform: translateY(-4px);
        opacity: 0.8;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

.ordering-item {
    animation: itemReorder 0.2s ease-out;
}

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

.ordering-item-correct {
    animation: successPulse 0.6s ease-in-out;
}

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

.ordering-item-incorrect {
    animation: errorShake 0.4s ease-in-out;
}

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

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

    .ordering-item:hover {
        background: rgba(255, 255, 255, 0.08);
        border-color: rgba(255, 255, 255, 0.2);
    }

    .ordering-item-drag-over {
        background: rgba(59, 130, 246, 0.15);
    }

    .ordering-btn {
        background: rgba(255, 255, 255, 0.05);
        border-color: rgba(255, 255, 255, 0.1);
        color: rgba(255, 255, 255, 0.7);
    }

    .ordering-btn:hover:not(:disabled) {
        background: var(--accent);
        color: white;
    }
}

/* ==================== HIGH CONTRAST MODE ==================== */

@media (prefers-contrast: high) {
    .ordering-item {
        border-width: 3px;
    }

    .ordering-item-correct {
        border-width: 4px;
    }

    .ordering-item-incorrect {
        border-width: 4px;
    }

    .ordering-btn {
        border-width: 2px;
    }
}
