/* ====================================================
   Tutorial Content Enhanced — design enrichi
   Injecté via tutorial.php
   ==================================================== */

/* ---------- Offset scroll pour header fixe ---------- */
/* S'applique aussi aux liens directs #anchor dans l'URL */
.tutorial-content h1,
.tutorial-content h2,
.tutorial-content h3,
.tutorial-content h4,
.tutorial-content h5,
.tutorial-content h6 {
    scroll-margin-top: 90px; /* hauteur header (~70px) + marge */
}

/* ---------- Barre de progression de lecture ---------- */
#reading-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0%;
    background: linear-gradient(90deg, #667eea 0%, #ff0050 60%, #764ba2 100%);
    z-index: 9999;
    transition: width 0.1s linear;
    box-shadow: 0 0 8px rgba(102, 126, 234, 0.6);
}

/* ---------- Table des matières flottante ---------- */
#toc-floating {
    position: sticky;
    top: 80px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #d1d5db transparent;
}

#toc-floating::-webkit-scrollbar { width: 4px; }
#toc-floating::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }
.dark #toc-floating::-webkit-scrollbar-thumb { background: #4b5563; }

#toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

#toc-list li {
    margin-bottom: 2px;
}

#toc-list a {
    display: block;
    padding: 6px 10px;
    font-size: 0.8125rem;
    color: #4b5563;
    border-left: 2px solid transparent;
    border-radius: 0 6px 6px 0;
    text-decoration: none;
    transition: all 0.2s ease;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dark #toc-list a { color: #9ca3af; }

#toc-list a:hover,
#toc-list a.toc-active {
    color: #667eea;
    border-left-color: #667eea;
    background: rgba(102, 126, 234, 0.08);
    padding-left: 14px;
}

.dark #toc-list a:hover,
.dark #toc-list a.toc-active {
    color: #a78bfa;
    border-left-color: #a78bfa;
    background: rgba(167, 139, 250, 0.1);
}

#toc-list li[data-level="2"] > a { padding-left: 20px; font-size: 0.75rem; }
#toc-list li[data-level="3"] > a { padding-left: 30px; font-size: 0.7rem; }

/* ---------- Callout boxes ---------- */
.callout {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px 18px;
    border-radius: 10px;
    margin: 1.75rem 0;
    border: 1px solid transparent;
    font-size: 0.9375rem;
    line-height: 1.6;
    position: relative;
    overflow: hidden;
}

.callout::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0.04;
    pointer-events: none;
}

.callout-icon {
    font-size: 1.15rem;
    flex-shrink: 0;
    margin-top: 1px;
}

.callout-body { flex: 1; min-width: 0; }
.callout-title { font-weight: 700; font-size: 0.875rem; margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.05em; }

/* 💡 Tip */
.callout-tip {
    background: #f0fdf4;
    border-color: #86efac;
    color: #166534;
}
.dark .callout-tip { background: rgba(134, 239, 172, 0.08); border-color: rgba(134,239,172,0.3); color: #86efac; }
.callout-tip .callout-icon { color: #22c55e; }

/* ⚠️ Warning */
.callout-warning {
    background: #fffbeb;
    border-color: #fcd34d;
    color: #92400e;
}
.dark .callout-warning { background: rgba(252, 211, 77, 0.08); border-color: rgba(252,211,77,0.3); color: #fcd34d; }
.callout-warning .callout-icon { color: #f59e0b; }

/* ℹ️ Info */
.callout-info {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #1e40af;
}
.dark .callout-info { background: rgba(147,197,253,0.08); border-color: rgba(147,197,253,0.3); color: #93c5fd; }
.callout-info .callout-icon { color: #3b82f6; }

/* 🚫 Danger */
.callout-danger {
    background: #fff1f2;
    border-color: #fca5a5;
    color: #991b1b;
}
.dark .callout-danger { background: rgba(252,165,165,0.08); border-color: rgba(252,165,165,0.3); color: #fca5a5; }
.callout-danger .callout-icon { color: #ef4444; }

/* ---------- Étapes numérotées améliorées ---------- */
.tutorial-steps {
    counter-reset: step-counter;
    list-style: none;
    padding: 0;
    margin: 1.5rem 0;
}

.tutorial-steps li {
    counter-increment: step-counter;
    display: flex;
    gap: 16px;
    align-items: flex-start;
    padding: 18px 20px;
    margin-bottom: 12px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    position: relative;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.dark .tutorial-steps li {
    background: #1f2937;
    border-color: #374151;
}

.tutorial-steps li:hover {
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.12);
    transform: translateX(3px);
}

.tutorial-steps li::before {
    content: counter(step-counter);
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 0.875rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    margin-top: 1px;
}

/* ---------- Blocs de code améliorés ---------- */
.tutorial-content pre {
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    overflow-x: auto;
    margin: 1.75rem 0;
    position: relative;
    font-size: 0.875rem;
    line-height: 1.7;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.tutorial-content pre::before {
    content: attr(data-lang);
    position: absolute;
    top: 10px;
    right: 14px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-family: sans-serif;
}

.tutorial-content pre .copy-code-btn {
    position: absolute;
    top: 8px;
    right: 60px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    color: #94a3b8;
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: sans-serif;
}

.tutorial-content pre .copy-code-btn:hover {
    background: rgba(255,255,255,0.2);
    color: #f1f5f9;
}

.tutorial-content code {
    font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
}

.tutorial-content :not(pre) > code {
    background: rgba(102, 126, 234, 0.1);
    color: #4f46e5;
    padding: 2px 7px;
    border-radius: 5px;
    font-size: 0.875em;
    border: 1px solid rgba(102,126,234,0.2);
}

.dark .tutorial-content :not(pre) > code {
    background: rgba(167, 139, 250, 0.12);
    color: #a78bfa;
    border-color: rgba(167,139,250,0.25);
}

/* ---------- Résumé estimé de lecture ---------- */
#read-meta-bar {
    display: flex;
    gap: 20px;
    align-items: center;
    padding: 10px 16px;
    background: linear-gradient(135deg, #f0f4ff 0%, #faf5ff 100%);
    border: 1px solid #e0e7ff;
    border-radius: 10px;
    margin-bottom: 1.5rem;
    font-size: 0.8125rem;
    color: #4b5563;
    flex-wrap: wrap;
}

.dark #read-meta-bar {
    background: linear-gradient(135deg, rgba(102,126,234,0.08) 0%, rgba(118,75,162,0.08) 100%);
    border-color: rgba(102,126,234,0.2);
    color: #9ca3af;
}

#read-meta-bar span { display: flex; align-items: center; gap: 6px; }
#read-meta-bar i { color: #667eea; font-size: 0.875rem; }
.dark #read-meta-bar i { color: #a78bfa; }

/* ---------- Animations de reveal au scroll ---------- */
.reveal-on-scroll {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.reveal-on-scroll.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* ---------- Mobile TOC toggle ---------- */
#toc-mobile-toggle {
    display: none;
}

@media (max-width: 1023px) {
    #toc-mobile-toggle {
        display: flex;
        align-items: center;
        gap: 8px;
        width: 100%;
        padding: 10px 14px;
        background: #f3f4f6;
        border: 1px solid #e5e7eb;
        border-radius: 10px;
        font-size: 0.875rem;
        font-weight: 600;
        color: #374151;
        cursor: pointer;
        margin-bottom: 12px;
        transition: background 0.2s;
    }

    .dark #toc-mobile-toggle {
        background: #1f2937;
        border-color: #374151;
        color: #d1d5db;
    }

    #toc-mobile-toggle:hover { background: #e5e7eb; }
    .dark #toc-mobile-toggle:hover { background: #374151; }

    #toc-mobile-content {
        display: none;
    }
    #toc-mobile-content.open {
        display: block;
        animation: slideDown 0.25s ease;
    }

    @keyframes slideDown {
        from { opacity: 0; transform: translateY(-8px); }
        to { opacity: 1; transform: translateY(0); }
    }

    #toc-floating { position: static; max-height: none; }
}
