/* MLTutor 全局样式 - 明亮丝滑教育风格 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Noto+Sans+SC:wght@400;500;600;700&display=swap');

:root {
    /* 主色调 - 清新蓝 */
    --primary: #3b82f6;
    --primary-light: #60a5fa;
    --primary-dark: #2563eb;

    /* 辅助色 */
    --secondary: #8b5cf6;
    --accent: #f59e0b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;

    /* 背景色 - 温暖明亮 */
    --bg-base: #f0f4f8;
    --bg-card: #ffffff;
    --bg-elevated: #ffffff;
    --bg-muted: #f8fafc;

    /* 文字 - 高对比度 */
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --text-light: #94a3b8;

    /* 边框 */
    --border: #e2e8f0;
    --border-light: #f1f5f9;

    /* 阴影 - 柔和 */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.10);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.12);

    /* Level 颜色 */
    --level-1: #10b981;
    --level-2: #3b82f6;
    --level-3: #f59e0b;
    --level-4: #ef4444;
    --level-5: #8b5cf6;

    /* 动画 - 丝滑 */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
    --duration-fast: 0.15s;
    --duration-normal: 0.25s;
    --duration-slow: 0.4s;
}

/* 重置 */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

/* 选中文字高亮 */
::selection {
    background: rgba(59, 130, 246, 0.2);
    color: var(--text-primary);
}

/* 滚动条 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-muted);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* 主体 */
body {
    font-family: 'Inter', 'Noto Sans SC', -apple-system, sans-serif;
    background: linear-gradient(135deg, #e0e7ff 0%, #faf5ff 50%, #fff1f2 100%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* 入场动画 */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.container {
    max-width: 100%;
    width: 100%;
    margin: 0 auto;
    padding: 20px 24px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    animation: fadeInUp 0.6s var(--ease-out);
    box-sizing: border-box;
}

/* Header */
header {
    text-align: center;
    padding: 24px 20px 32px;
    color: var(--text-primary);
}

header h1 {
    font-size: 2.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

header .subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-weight: 500;
}

header .subtitle-desc {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-top: 6px;
}

/* 主内容 */
.main-content {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 24px;
    flex: 1;
    min-height: 0;
    width: 100%;
    box-sizing: border-box;
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

/* 卡片基础样式 */
.card-base {
    background: var(--bg-card);
    border-radius: 20px;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(255, 255, 255, 0.8);
    transition: box-shadow var(--duration-normal) var(--ease-out),
                transform var(--duration-normal) var(--ease-out);
}

.card-base:hover {
    box-shadow: var(--shadow-lg);
}

/* 知识图谱容器 */
#knowledge-graph-container {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 24px;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(255, 255, 255, 0.8);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: fadeInUp 0.6s var(--ease-out) 0.1s both;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border-light);
}

#knowledge-graph {
    flex: 1;
    min-height: 420px;
    background: linear-gradient(180deg, #fafbfc 0%, #f1f5f9 100%);
    border-radius: 16px;
    border: 1px solid var(--border-light);
}

.hint {
    text-align: center;
    color: var(--text-light);
    font-size: 0.8rem;
    margin-top: 12px;
}

/* 快速入口 */
.quick-access {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 24px;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(255, 255, 255, 0.8);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: fadeInUp 0.6s var(--ease-out) 0.2s both;
}

.card-grid-wrapper {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 6px;
    min-height: 0;
}

.card-grid-wrapper::-webkit-scrollbar {
    width: 5px;
}

.card-grid-wrapper::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--primary-light), var(--secondary));
    border-radius: 3px;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

/* 算法卡片 */
.card {
    background: linear-gradient(135deg, #fafbfc 0%, #f1f5f9 100%);
    border-radius: 14px;
    padding: 16px 14px;
    text-decoration: none;
    color: var(--text-primary);
    border: 1px solid var(--border);
    transition: all var(--duration-normal) var(--ease-out);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    opacity: 0;
    transition: opacity var(--duration-normal) var(--ease-out);
    z-index: 0;
}

/* 类别色背景 - hover 时显示 */
.card[data-category="回归"]::before {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.08), rgba(139, 92, 246, 0.04));
}

.card[data-category="分类"]::before {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(59, 130, 246, 0.04));
}

.card[data-category="神经网络"]::before {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.08), rgba(239, 68, 68, 0.04));
}

.card[data-category="聚类"]::before {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.08), rgba(16, 185, 129, 0.04));
}

.card[data-category="降维"]::before {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), rgba(245, 158, 11, 0.04));
}

.card[data-category="强化学习"]::before {
    background: linear-gradient(135deg, rgba(236, 72, 153, 0.08), rgba(236, 72, 153, 0.04));
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.card:hover::before {
    opacity: 1;
}

.card h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    position: relative;
    z-index: 1;
}

.card .level-badge {
    position: relative;
    z-index: 1;
}

.card p {
    display: none;
}

@media (max-width: 1024px) {
    .card-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .card-grid {
        grid-template-columns: 1fr;
    }
}

/* Level 徽章 */
.level-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    color: white;
    letter-spacing: 0.02em;
    background: var(--text-muted);
}

/* 卡片类别色 - 使用 data-category 属性 */
.card[data-category="回归"] {
    border-left: 4px solid #8b5cf6;
}

.card[data-category="分类"] {
    border-left: 4px solid #3b82f6;
}

.card[data-category="神经网络"] {
    border-left: 4px solid #ef4444;
}

.card[data-category="聚类"] {
    border-left: 4px solid #10b981;
}

.card[data-category="降维"] {
    border-left: 4px solid #f59e0b;
}

.card[data-category="强化学习"] {
    border-left: 4px solid #ec4899;
}

/* Footer */
footer {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
}

footer p {
    margin-bottom: 4px;
    font-size: 0.85rem;
}

footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--duration-fast);
}

footer a:hover {
    color: var(--secondary);
}

/* 模式切换按钮 */
.graph-mode-switch {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
}

.mode-btn {
    padding: 10px 22px;
    border: 2px solid var(--border);
    background: var(--bg-muted);
    color: var(--text-secondary);
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    font-family: inherit;
    transition: all var(--duration-normal) var(--ease-out);
}

.mode-btn:hover {
    border-color: var(--primary-light);
    color: var(--primary);
    background: rgba(59, 130, 246, 0.05);
}

.mode-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* 图谱视图 */
.graph-view {
    display: none;
    flex: 1;
    min-height: 420px;
    background: linear-gradient(180deg, #fafbfc 0%, #f1f5f9 100%);
    border-radius: 16px;
    border: 1px solid var(--border-light);
}

.graph-view.active {
    display: block;
    animation: fadeInUp 0.3s var(--ease-out);
}

/* Tooltip */
.tooltip {
    position: absolute;
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 14px 18px;
    border-radius: 12px;
    font-size: 13px;
    max-width: 280px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    pointer-events: none;
    z-index: 1000;
    line-height: 1.5;
}

.tooltip .tooltip-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 6px;
    color: var(--primary);
}

.tooltip .tooltip-year {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.tooltip .tooltip-desc {
    color: var(--text-secondary);
}

/* 进化史边 */
.evolution-edge {
    stroke: #cbd5e1;
    stroke-width: 2;
    fill: none;
}

.evolution-edge-label {
    font-size: 10px;
    fill: var(--text-muted);
}

/* 响应式 */
@media (max-width: 768px) {
    .container {
        padding: 16px;
    }

    header h1 {
        font-size: 1.7rem;
    }

    .graph-mode-switch {
        flex-direction: column;
    }

    .mode-btn {
        width: 100%;
        text-align: center;
    }
}
