/* ===== Hello AI — Design System v2 ===== */
/* Inspired by TeachingEval: Swiss precision + Academic authority + Glassmorphism */

/* --- CSS Variables --- */
:root {
    --sjtu-blue: #2563eb;
    --sjtu-purple: #7c3aed;
    --sjtu-gradient: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
    --ink-900: #0f172a;
    --ink-800: #1e293b;
    --ink-600: #475569;
    --ink-500: #64748b;
    --ink-400: #94a3b8;
    --ink-300: #cbd5e1;
    --ink-200: #e2e8f0;
    --ink-100: #f1f5f9;
    --ink-50: #f8fafc;
    --radius: 12px;
    --radius-lg: 16px;
    --transition: 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* --- Glass Navigation --- */
.nav-glass {
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border-bottom: 1px solid rgba(226, 232, 240, 0.6);
    box-shadow: 0 1px 2px rgba(0,0,0,0.03), 0 4px 16px rgba(0,0,0,0.01);
}

/* --- Navigation Pills (Capsule Style) --- */
.nav-pill {
    padding: 7px 16px;
    font-size: 13px;
    font-weight: 500;
    color: #64748b;
    border-radius: 50px;
    transition: all 0.2s ease;
    letter-spacing: -0.005em;
}
.nav-pill:hover { color: #1e293b; background: rgba(0,0,0,0.04); }
.nav-pill.active {
    color: #fff;
    background: #1e293b;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(30,41,59,0.2);
}

/* --- Glass Cards --- */
.glass-card {
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(226, 232, 240, 0.7);
    border-radius: var(--radius);
    padding: 1.5rem;
    transition: all var(--transition);
    box-shadow: 0 1px 3px 0 rgba(0,0,0,0.02);
}
.glass-card:hover {
    border-color: rgba(37, 99, 235, 0.15);
    box-shadow: 0 10px 30px -5px rgba(0,0,0,0.06);
    transform: translateY(-2px);
}

/* --- Swiss Label --- */
.swiss-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #94a3b8;
}

/* --- Prose / Article Content --- */
.prose { font-size: 15px; line-height: 1.85; color: #334155; }
.prose h2 {
    font-family: 'Noto Serif SC', 'Playfair Display', serif;
    font-size: 1.5rem; font-weight: 700; margin-top: 2.8rem; margin-bottom: 1rem;
    color: #0f172a; letter-spacing: -0.02em;
    padding-bottom: 0.7rem; border-bottom: 1px solid #e2e8f0;
}
.prose h3 {
    font-family: 'Noto Serif SC', 'Playfair Display', serif;
    font-size: 1.2rem; font-weight: 600; margin-top: 2.2rem; margin-bottom: 0.75rem;
    color: #1e293b; letter-spacing: -0.01em;
}
.prose h4 { font-size: 1rem; font-weight: 600; margin-top: 1.5rem; margin-bottom: 0.5rem; color: #334155; }
.prose p { margin-bottom: 1.2rem; }
.prose ul, .prose ol { margin-bottom: 1.2rem; padding-left: 1.25rem; }
.prose li { margin-bottom: 0.45rem; line-height: 1.75; }
.prose ul li { list-style-type: disc; }
.prose ol li { list-style-type: decimal; }
.prose li::marker { color: #94a3b8; }
.prose strong { font-weight: 600; color: #1e293b; }
.prose a { color: #2563eb; text-decoration: underline; text-underline-offset: 2px; text-decoration-color: rgba(37,99,235,0.3); }
.prose a:hover { text-decoration-color: #2563eb; }

/* Code */
.prose code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85em; background: #f1f5f9; padding: 0.15em 0.45em;
    border-radius: 5px; color: #1e40af; border: 1px solid #e2e8f0;
}
.prose pre {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85em; background: #0f172a; color: #e2e8f0;
    padding: 1.25rem 1.5rem; border-radius: var(--radius); overflow-x: auto;
    margin: 1.5rem 0; border: 1px solid #1e293b; line-height: 1.65;
}
.prose pre code { background: none; color: inherit; padding: 0; border: none; font-size: 1em; }

/* Blockquote */
.prose blockquote {
    border-left: 3px solid #2563eb; padding: 1rem 1.25rem; margin: 1.5rem 0;
    background: #eff6ff; border-radius: 0 var(--radius) var(--radius) 0; color: #334155;
    font-style: normal;
}
.prose blockquote p:last-child { margin-bottom: 0; }

/* Tables */
.prose table { width: 100%; border-collapse: collapse; margin: 1.5rem 0; font-size: 0.92em; }
.prose thead th {
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
    background: #f8fafc; font-weight: 600; color: #64748b;
    padding: 0.75rem 1rem; text-align: left; border-bottom: 2px solid #e2e8f0;
}
.prose tbody td { padding: 0.7rem 1rem; border-bottom: 1px solid #f1f5f9; }
.prose tbody tr:last-child td { border-bottom: none; }
.prose tbody tr:hover { background: #f8fafc; }

/* Images */
.prose img { display: block; width: 100%; max-width: 100%; border-radius: var(--radius); margin: 1.25rem 0 1.5rem; border: 1px solid #e2e8f0; box-shadow: 0 2px 12px rgba(0,0,0,0.06); }

/* Admonitions */
.prose .admonition {
    padding: 1rem 1.25rem; border-radius: 10px; margin: 1.75rem 0;
    border-left: 3px solid; font-size: 0.93em;
}
.prose .admonition-title { font-weight: 600; margin-bottom: 0.4rem; font-size: 0.95em; }
.prose .admonition p:last-child { margin-bottom: 0; }
.prose .admonition.note { background: #eff6ff; border-color: #2563eb; }
.prose .admonition.note .admonition-title { color: #1e40af; }
.prose .admonition.tip { background: #ecfdf5; border-color: #10b981; }
.prose .admonition.tip .admonition-title { color: #059669; }
.prose .admonition.warning { background: #fffbeb; border-color: #f59e0b; }
.prose .admonition.warning .admonition-title { color: #d97706; }
.prose .admonition.important { background: #fef2f2; border-color: #ef4444; }
.prose .admonition.important .admonition-title { color: #dc2626; }

/* --- Notion-style Sidebar Navigation --- */
.sidebar-nav { scrollbar-width: thin; scrollbar-color: #e2e8f0 transparent; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: #cbd5e1; }

/* Collapsible chapter group */
.sidebar-chapter { margin-bottom: 2px; }
.sidebar-chapter-toggle {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 8px; font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.05em;
    color: #94a3b8; cursor: pointer; user-select: none;
    border-radius: 6px; transition: all 0.15s;
}
.sidebar-chapter-toggle:hover { color: #64748b; background: rgba(0,0,0,0.02); }
.sidebar-chapter-toggle .chevron {
    width: 16px; height: 16px; transition: transform 0.2s ease;
    flex-shrink: 0;
}
.sidebar-chapter-toggle.collapsed .chevron { transform: rotate(-90deg); }
.sidebar-chapter-sections { overflow: hidden; transition: max-height 0.25s ease; }
.sidebar-chapter-sections.collapsed { max-height: 0 !important; }

.sidebar-link {
    display: flex; align-items: flex-start; gap: 8px;
    padding: 5px 8px 5px 28px; border-radius: 6px; font-size: 13px;
    color: #64748b; transition: all 0.15s; line-height: 1.5;
    text-decoration: none;
}
.sidebar-link:hover { color: #1e293b; background: rgba(0,0,0,0.03); }
.sidebar-link.active {
    color: #2563eb; background: #eff6ff; font-weight: 600;
}
.sidebar-link .dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: #cbd5e1; flex-shrink: 0; margin-top: 7px;
    transition: all 0.15s;
}
.sidebar-link.active .dot { background: #2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,0.2); }
.sidebar-link:hover .dot { background: #94a3b8; }

/* --- Resize Handle --- */
.resize-handle {
    width: 5px; cursor: col-resize; position: relative;
    flex-shrink: 0; z-index: 10; transition: background 0.15s;
}
.resize-handle::after {
    content: ''; position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 3px; height: 32px; border-radius: 3px;
    background: #e2e8f0; transition: all 0.2s;
}
.resize-handle:hover::after, .resize-handle:active::after {
    background: #2563eb; height: 48px; width: 3px;
}
.resize-handle:active { background: #eff6ff; }

/* --- AI Chat Panel --- */
.chat-panel {
    display: flex; flex-direction: column; height: 100%;
    background: #ffffff;
}
.chat-messages {
    flex: 1; overflow-y: auto; padding: 16px;
    scrollbar-width: thin; scrollbar-color: #e2e8f0 transparent;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 4px; }
.chat-bubble {
    max-width: 88%; padding: 10px 14px; border-radius: 14px;
    font-size: 13.5px; line-height: 1.6; margin-bottom: 10px;
    animation: slideUp 0.3s ease-out;
}
.chat-bubble.user {
    margin-left: auto; background: var(--sjtu-gradient); color: white;
    border-bottom-right-radius: 4px;
}
.chat-bubble.assistant {
    margin-right: auto; background: #f1f5f9; color: #334155;
    border-bottom-left-radius: 4px;
}
.chat-input-area {
    padding: 12px 16px; border-top: 1px solid #e2e8f0; background: #f8fafc;
}

/* --- Progress Bar --- */
.progress-track { height: 4px; background: #e2e8f0; border-radius: 4px; overflow: hidden; }
.progress-fill {
    height: 100%; background: var(--sjtu-gradient);
    border-radius: 4px; transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Badges --- */
.badge {
    display: inline-flex; align-items: center; padding: 3px 10px;
    font-size: 11px; font-weight: 600; border-radius: 6px;
    letter-spacing: 0.02em; border: 1px solid transparent;
}
.badge-beginner { background: #ecfdf5; color: #059669; border-color: #d1fae5; }
.badge-intermediate { background: #eff6ff; color: #2563eb; border-color: #dbeafe; }
.badge-advanced { background: #fef3c7; color: #d97706; border-color: #fde68a; }

/* --- Buttons --- */
.btn-primary {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 24px; background: var(--sjtu-gradient); color: white;
    border-radius: 10px; font-size: 14px; font-weight: 600;
    transition: all 0.25s; border: none; cursor: pointer;
    box-shadow: 0 2px 8px rgba(37,99,235,0.2);
}
.btn-primary:hover {
    box-shadow: 0 8px 20px rgba(37,99,235,0.3);
    transform: translateY(-1px);
}

.btn-secondary {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 24px; background: white; color: #334155;
    border-radius: 10px; font-size: 14px; font-weight: 600;
    transition: all 0.25s; border: 1px solid #e2e8f0; cursor: pointer;
}
.btn-secondary:hover { border-color: rgba(37,99,235,0.3); color: #2563eb; background: #f8fafc; }

/* --- Quiz Styles --- */
.quiz-choice {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 14px; border-radius: 10px; border: 1px solid #e2e8f0;
    background: white; cursor: pointer; transition: all 0.15s;
    font-size: 14px;
}
.quiz-choice:hover { border-color: rgba(37,99,235,0.3); background: #f8fafc; }
.quiz-choice.correct { border-color: #10b981; background: #ecfdf5; }
.quiz-choice.incorrect { border-color: #ef4444; background: #fef2f2; }
.quiz-choice input[type="radio"],
.quiz-choice input[type="checkbox"] { margin-top: 3px; accent-color: #2563eb; }

/* --- Content Scroll --- */
.content-scroll {
    overflow-y: auto; scrollbar-width: thin;
    scrollbar-color: #e2e8f0 transparent;
}
.content-scroll::-webkit-scrollbar { width: 6px; }
.content-scroll::-webkit-scrollbar-track { background: transparent; }
.content-scroll::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 6px; }
.content-scroll::-webkit-scrollbar-thumb:hover { background: #cbd5e1; }

/* --- Icon Box (TeachingEval pattern) --- */
.icon-box {
    width: 44px; height: 44px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.icon-box:hover { transform: rotate(5deg) scale(1.1); }

/* --- Selection & Focus --- */
::selection { background: rgba(37,99,235,0.15); color: #0f172a; }
:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; border-radius: 4px; }

/* --- Difficulty Filter Tabs --- */
.diff-tab {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 7px 16px; font-size: 13px; font-weight: 500;
    color: #64748b; border-radius: 50px; cursor: pointer;
    transition: all 0.2s ease; border: none; background: none;
    letter-spacing: -0.005em;
}
.diff-tab:hover { color: #1e293b; background: rgba(0,0,0,0.04); }
.diff-tab.active {
    color: #fff; background: #1e293b; font-weight: 600;
    box-shadow: 0 2px 8px rgba(30,41,59,0.2);
}
.diff-tab.active span { background: #fff !important; }

/* --- Mobile: prevent horizontal scroll on reading pages --- */
@media (max-width: 1023px) {
    #reading-layout { overflow-x: hidden; }
    #content-panel { overflow-x: hidden; }
    .prose pre { max-width: calc(100vw - 3rem); overflow-x: auto; }
    .prose table { display: block; overflow-x: auto; max-width: calc(100vw - 3rem); }
    .prose img { max-width: 100%; height: auto; }
    .prose blockquote { max-width: calc(100vw - 3rem); }
    .prose code { word-wrap: break-word; max-width: 100%; }
    .glass-card { max-width: 100%; }
    .chat-bubble { max-width: 85%; word-wrap: break-word; }
    .admonition { max-width: calc(100vw - 3rem); }
    .content-scroll { overflow-x: hidden; }
    .sidebar-nav { overflow-x: hidden; }
}

html, body { overflow-x: hidden; }

/* --- Stat Number (Tabular) --- */
.stat-num {
    font-family: 'JetBrains Mono', monospace;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    letter-spacing: -0.02em;
}

/* --- Grid Dot Background --- */
.grid-dots {
    background-image:
        radial-gradient(circle, #cbd5e1 0.8px, transparent 0.8px);
    background-size: 24px 24px;
}

/* --- Homepage Gradient Shimmer on "AI" --- */
@keyframes gradientShimmer {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
.gradient-shimmer {
    background: linear-gradient(270deg, #2563eb, #7c3aed, #6366f1, #2563eb);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: gradientShimmer 6s ease infinite;
}

/* --- Floating Orb Animation --- */
@keyframes floatOrb {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25%      { transform: translate(30px, -20px) scale(1.05); }
    50%      { transform: translate(-15px, 15px) scale(0.95); }
    75%      { transform: translate(20px, 10px) scale(1.02); }
}
.float-orb { animation: floatOrb 20s ease-in-out infinite; }
.float-orb-slow { animation: floatOrb 28s ease-in-out infinite reverse; }

/* --- Staggered Card Entrance --- */
@keyframes cardEnter {
    0%   { opacity: 0; transform: translateY(24px) scale(0.97); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}
.card-stagger { animation: cardEnter 0.5s cubic-bezier(0.25, 0.8, 0.25, 1) both; }

/* --- Card Accent Colors --- */
.card-accent-blue { border-top: 3px solid #2563eb; }
.card-accent-purple { border-top: 3px solid #7c3aed; }
.card-accent-emerald { border-top: 3px solid #10b981; }
.card-accent-blue:hover { border-color: #2563eb; box-shadow: 0 10px 30px -5px rgba(37,99,235,0.1); }
.card-accent-purple:hover { border-color: #7c3aed; box-shadow: 0 10px 30px -5px rgba(124,58,237,0.1); }
.card-accent-emerald:hover { border-color: #10b981; box-shadow: 0 10px 30px -5px rgba(16,185,129,0.1); }

/* --- Homepage Path Row — Gradient Border on Hover --- */
.path-row {
    position: relative;
    background: white;
    border-radius: 14px;
    transition: all 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.path-row::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 14px;
    padding: 1.5px;
    background: linear-gradient(135deg, transparent, transparent);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: all 0.35s ease;
}
.path-row:hover::before { opacity: 1; }
.path-row.path-blue:hover::before {
    background: linear-gradient(135deg, #93c5fd, #2563eb, #3b82f6, #93c5fd);
    background-size: 300% 300%;
    animation: gradientShimmer 3s ease infinite;
}
.path-row.path-purple:hover::before {
    background: linear-gradient(135deg, #c4b5fd, #7c3aed, #8b5cf6, #c4b5fd);
    background-size: 300% 300%;
    animation: gradientShimmer 3s ease infinite;
}
.path-row.path-emerald:hover::before {
    background: linear-gradient(135deg, #6ee7b7, #10b981, #34d399, #6ee7b7);
    background-size: 300% 300%;
    animation: gradientShimmer 3s ease infinite;
}
.path-row:hover {
    box-shadow: 0 4px 24px -6px rgba(0,0,0,0.08);
    transform: translateY(-1px);
}
