/**
 * 排序题拖拽样式
 * 
 * 包含：
 * - 拖拽项基础样式
 * - 拖拽状态样式（ghost、chosen、drag）
 * - 排名数字颜色（前三名高亮）
 * - 动画效果
 * - 移动端优化
 */

/* 排序列表容器 */
.ranking-sortable-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
}

/* 可拖拽项基础样式 */
.sortable-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    cursor: move;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    touch-action: none; /* 防止移动端滚动冲突 */
}

/* 悬停效果 */
.sortable-item:hover {
    border-color: #818cf8;
    box-shadow: 0 2px 12px rgba(99, 102, 241, 0.15);
    transform: translateY(-1px);
}

/* 拖拽手柄 */
.drag-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    color: #9ca3af;
    font-size: 20px;
    cursor: grab;
    flex-shrink: 0;
    transition: color 0.2s;
}

.drag-handle:active {
    cursor: grabbing;
}

.sortable-item:hover .drag-handle {
    color: #6366f1;
}

/* 排名数字 */
.rank-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 排名颜色 - 第一名（金色） */
.rank-number.rank-1 {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(251, 191, 36, 0.4);
}

/* 排名颜色 - 第二名（银色） */
.rank-number.rank-2 {
    background: linear-gradient(135deg, #cbd5e1 0%, #94a3b8 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(148, 163, 184, 0.4);
}

/* 排名颜色 - 第三名（铜色） */
.rank-number.rank-3 {
    background: linear-gradient(135deg, #fb923c 0%, #f97316 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(249, 115, 22, 0.4);
}

/* 排名颜色 - 其他（蓝紫色） */
.rank-number.rank-other {
    background: linear-gradient(135deg, #818cf8 0%, #6366f1 100%);
    color: white;
    box-shadow: 0 2px 6px rgba(99, 102, 241, 0.3);
}

/* 选项文本 */
.option-text {
    flex: 1;
    font-size: 15px;
    color: #1f2937;
    line-height: 1.5;
}

/* 拖拽时的 Ghost 样式（占位符） */
.sortable-ghost {
    opacity: 0.4;
    background: #eef2ff !important;
    border-color: #818cf8 !important;
    border-style: dashed !important;
}

.sortable-ghost .rank-number {
    opacity: 0.5;
}

/* 被选中时的样式 */
.sortable-chosen {
    border-color: #6366f1 !important;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.25) !important;
    transform: scale(1.02);
}

/* 拖拽中的样式 */
.sortable-drag {
    opacity: 1 !important;
    cursor: grabbing !important;
    transform: rotate(2deg) scale(1.05);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2) !important;
}

/* Fallback 样式（不支持原生拖拽时） */
.sortable-fallback {
    opacity: 0.8;
    background: white;
    border-color: #6366f1;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.3);
}

/* 拖拽时的全局样式 */
body.is-dragging {
    cursor: grabbing !important;
}

body.is-dragging * {
    cursor: grabbing !important;
}

/* 提示文本 */
.ranking-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding: 10px 12px;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    font-size: 13px;
    color: #0369a1;
}

.ranking-hint-icon {
    font-size: 16px;
}

/* 动画效果 */
@keyframes pulse-border {
    0%, 100% {
        border-color: #818cf8;
    }
    50% {
        border-color: #6366f1;
    }
}

.sortable-item:active {
    animation: pulse-border 0.5s ease-in-out;
}

/* 移动端优化 */
@media (max-width: 768px) {
    .sortable-item {
        padding: 16px 14px;
        gap: 10px;
        min-height: 64px; /* 确保足够的触摸区域 */
    }
    
    .drag-handle {
        width: 28px;
        height: 28px;
        font-size: 22px;
    }
    
    .rank-number {
        width: 40px;
        height: 40px;
        min-width: 40px;
        font-size: 17px;
    }
    
    .option-text {
        font-size: 16px; /* 避免 iOS 自动缩放 */
    }
    
    /* 移动端拖拽时增加视觉反馈 */
    .sortable-drag {
        transform: rotate(3deg) scale(1.08);
    }
}

/* 平板优化 */
@media (min-width: 769px) and (max-width: 1024px) {
    .sortable-item {
        padding: 14px 16px;
    }
}

/* 暗色模式支持（可选） */
@media (prefers-color-scheme: dark) {
    .sortable-item {
        background: #1f2937;
        border-color: #374151;
    }
    
    .sortable-item:hover {
        border-color: #818cf8;
        background: #111827;
    }
    
    .option-text {
        color: #f9fafb;
    }
    
    .drag-handle {
        color: #6b7280;
    }
    
    .sortable-item:hover .drag-handle {
        color: #818cf8;
    }
    
    .sortable-ghost {
        background: #1e1b4b !important;
    }
}

/* 无障碍优化 */
@media (prefers-reduced-motion: reduce) {
    .sortable-item,
    .rank-number,
    .drag-handle {
        transition: none !important;
        animation: none !important;
    }
    
    .sortable-drag {
        transform: none !important;
    }
}

/* 打印样式 */
@media print {
    .drag-handle {
        display: none;
    }
    
    .sortable-item {
        cursor: default;
        border-color: #d1d5db;
    }
}
