/* --- Swiss Design / Brutalist Reset --- */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    overflow: hidden; /* Empêche le scroll global, géré dans 'main' */
    background-color: #F9F9F6;
    color: #1C1C1C;
}

html.dark body {
    background-color: #111111;
    color: #F0F0F0;
}

/* Typography Overrides */
h1, h2, h3, .font-serif {
    font-family: 'Playfair Display', serif;
}

/* --- Course Content Typography Overrides (Editorial Design) --- */
#main-content section {
    font-size: 1.125rem;
    line-height: 1.8;
}
#main-content h1 { font-size: 3.5rem !important; line-height: 1.1 !important; margin-bottom: 1.5rem; letter-spacing: -0.02em; }
#main-content h2 { font-size: 2.5rem !important; line-height: 1.3 !important; margin-top: 2.5rem; margin-bottom: 1.5rem; letter-spacing: -0.01em; }
#main-content h3 { font-size: 1.75rem !important; line-height: 1.4 !important; margin-top: 1.5rem; margin-bottom: 1rem; }
#main-content p { margin-bottom: 1.5rem; color: #666666; }
html.dark #main-content p { color: #A1A1AA; }

/* --- Sidebar Section Titles Line Height --- */
#sidebar .text-\[10px\] {
    line-height: 1.5;
}

/* --- Layout Principal --- */
.layout-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* --- Scrollbars --- */
#sidebar, .sidebar-scroll, .main-scroll, #ai-chat-messages {
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #C05C42 transparent;
}
#sidebar::-webkit-scrollbar, .sidebar-scroll::-webkit-scrollbar, .main-scroll::-webkit-scrollbar, #ai-chat-messages::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-thumb, .sidebar-scroll::-webkit-scrollbar-thumb, .main-scroll::-webkit-scrollbar-thumb, #ai-chat-messages::-webkit-scrollbar-thumb { background-color: #C05C42; border-radius: 4px; }

.main-scroll {
    flex: 1;
    overflow-y: auto;
    scroll-behavior: smooth;
}

/* --- Menu Latéral (Boutons) --- */
.nav-btn { 
    transition: all 0.2s ease; 
    border-left: 2px solid transparent;
}
.nav-btn.active {
    color: #C05C42;
    font-weight: 700;
    border-left: 2px solid #C05C42;
}
.nav-btn:hover:not(.active) {
    background-color: #F0F0F0;
    color: #1C1C1C;
}
html.dark .nav-btn:hover:not(.active) {
    background-color: #1A1A1A;
    color: #F0F0F0;
}

/* --- Bento Grid Cards --- */
.bento-card {
    background: transparent;
    border: 1px solid #E5E7EB; /* gray-200 */
    border-radius: 0.5rem; /* rounded-md */
    transition: all 0.2s ease;
    position: relative;
    padding-bottom: 3.5rem !important; /* Espace pour la flèche en bas */
}
html.dark .bento-card {
    border: 1px solid #27272A; /* gray-800 */
}
.bento-card:hover {
    border-color: #C05C42;
}
html.dark .bento-card:hover {
    border-color: #C05C42;
}
/* Flèche hover */
.bento-arrow {
    transition: transform 0.2s ease;
    position: absolute;
    bottom: 1.25rem;
    right: 1.5rem;
}
.bento-card:hover .bento-arrow {
    transform: translateX(4px);
    color: #C05C42;
}

/* --- Animations de contenu --- */
.hidden-section { 
    display: none; 
}
.fade-in { 
    animation: fadeIn 0.4s ease-in-out; 
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Overlay Mobile --- */
#mobile-menu-overlay {
    background-color: rgba(0,0,0,0.5);
    transition: opacity 0.3s ease;
}

/* --- Chatbot Markdown Styles --- */
.markdown-body {
    font-size: 0.875rem;
    line-height: 1.5;
}
.markdown-body p { margin-bottom: 0.5rem; }
.markdown-body p:last-child { margin-bottom: 0; }
.markdown-body strong { font-weight: 700; color: #1C1C1C; }
html.dark .markdown-body strong { color: #F0F0F0; }
.markdown-body ul { list-style-type: disc; margin-left: 1rem; margin-bottom: 0.5rem; }
.markdown-body ol { list-style-type: decimal; margin-left: 1rem; margin-bottom: 0.5rem; }
.markdown-body li { margin-bottom: 0.25rem; }
.markdown-body h1, .markdown-body h2, .markdown-body h3 { font-weight: 700; color: #1C1C1C; margin-top: 0.5rem; margin-bottom: 0.25rem; }
html.dark .markdown-body h1, html.dark .markdown-body h2, html.dark .markdown-body h3 { color: #F0F0F0; }

/* ========================================================
   MODE SOMBRE (Surcharges Globales)
   ======================================================== */
html.dark .bg-white { background-color: #111111 !important; border-color: #27272A !important; }
html.dark .bg-gray-100, html.dark .bg-gray-50 { background-color: #1A1A1A !important; border-color: #27272A !important; }
html.dark .text-gray-900, html.dark .text-gray-800 { color: #F0F0F0 !important; }
html.dark .text-gray-700, html.dark .text-gray-600 { color: #A1A1AA !important; }
html.dark .border-gray-200, html.dark .border-gray-100 { border-color: #27272A !important; }

/* Surcharges Menu, Header, Liens */
html.dark aside, html.dark header { background-color: #111111 !important; border-color: #27272A !important; }

/* Surcharges du Chatbot IA */
html.dark #ai-chat-window { background-color: #111111 !important; border-color: #27272A !important; }
html.dark #ai-chat-messages { background-color: #1A1A1A !important; }
html.dark .self-start.bg-white { background-color: #27272A !important; color: #F0F0F0 !important; border-color: #3F3F46 !important; }
html.dark #ai-chat-input { background-color: #1A1A1A !important; color: white !important; border-color: #3F3F46 !important; }

/* ========================================================
   VIEW TRANSITIONS (Material Expressive 3 - Native)
   ======================================================== */
@view-transition {
    navigation: auto;
}

#main-content {
    view-transition-name: main-content;
}

/* Désactiver l'animation globale pour ne pas faire clignoter la sidebar */
::view-transition-old(root),
::view-transition-new(root) {
    animation: none;
    mix-blend-mode: normal;
}

/* Animation Material 3 sur le contenu principal uniquement */
::view-transition-old(main-content) {
    animation: fade-out 0.2s cubic-bezier(0.4, 0, 0.2, 1) forwards, scale-down 0.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

::view-transition-new(main-content) {
    animation: fade-in 0.4s cubic-bezier(0.2, 0, 0, 1) forwards, slide-up 0.4s cubic-bezier(0.2, 0, 0, 1) forwards;
}

@keyframes fade-out {
    to { opacity: 0; }
}
@keyframes scale-down {
    to { transform: scale(0.98); }
}
@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes slide-up {
    from { transform: translateY(15px); }
    to { transform: translateY(0); }
}

/* Empêcher le sous-menu de se ré-animer et corriger la superposition du texte */
::view-transition-old(cours-submenu) {
    display: none;
}
::view-transition-new(cours-submenu) {
    animation: none;
    opacity: 1;
}

/* --- Adaptive Title for Cards --- */
.card-inner {
    container-type: inline-size;
}

.adaptive-title {
    font-size: min(1.875rem, 12cqi);
    line-height: 1.2;
    hyphens: none;
    word-break: keep-all;
    overflow-wrap: normal;
}