/* =====================================================
   COURS REACT - STYLESHEET
   Créé par Geoffroy Streit - 2025
   ===================================================== */

:root {
    --primary: #61dafb;
    /* React Blue */
    --secondary: #20232a;
    /* Dark React BG */
    --accent: #ffffff;
    --bg: #282c34;
    /* Code BG */
    --bg2: #32363e;
    --card: #20232a;
    --text: #e8f0ff;
    --muted: #999ca0;
    /* React Light Gray */
    --dim: #6d6d6d;
    --border: #3e4249;
    --green: #98c379;
    --purple: #c678dd;
    --pink: #e06c75;
    --orange: #d19a66;
    --red: #e06c75;
    --blue: #61dafb;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px;
}

/* === HEADER === */
header {
    position: sticky;
    top: 0;
    background: rgba(32, 35, 42, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    z-index: 100;
    padding: 16px 0;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary);
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
    border-radius: 50%;
    /* Circle for React */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 700;
    animation: spin 20s linear infinite;
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

nav {
    display: flex;
    gap: 4px;
}

nav a {
    color: var(--muted);
    text-decoration: none;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    transition: all 0.2s;
}

nav a:hover,
nav a.active {
    background: var(--bg2);
    color: var(--primary);
}

/* Top Nav enrichi */
.top-nav {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-wrap: wrap;
}

/* Séparateur vertical entre groupes */
.nav-sep {
    width: 1px;
    height: 18px;
    background: var(--border);
    margin: 0 6px;
    display: inline-block;
}

/* Bouton Quiz mis en valeur */
.nav-quiz {
    border: 1px solid var(--primary) !important;
    color: var(--primary) !important;
    border-radius: 8px;
    padding: 6px 12px;
    font-weight: 600;
}

.nav-quiz:hover {
    background: rgba(97, 218, 251, 0.1) !important;
}

/* Burger Menu (Mobile) */
.burger-menu {
    display: none;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
    padding: 8px;
}

.burger-menu span {
    width: 22px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: all 0.3s;
}

.burger-menu.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.burger-menu.open span:nth-child(2) { opacity: 0; }
.burger-menu.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Responsive */
@media (max-width: 860px) {
    .burger-menu { display: flex; }
    .top-nav {
        display: none;
        position: fixed;
        top: 0; right: -100%;
        width: 260px;
        height: 100vh;
        flex-direction: column;
        flex-wrap: nowrap;
        background: rgba(30, 32, 40, 0.98);
        backdrop-filter: blur(12px);
        padding: 80px 20px 20px;
        gap: 4px;
        border-left: 1px solid var(--border);
        transition: right 0.3s ease;
    }
    .top-nav.open { display: flex; right: 0; }
    .nav-sep { display: none; }
    .top-nav a { font-size: 1rem; padding: 12px; border-bottom: 1px solid var(--border); border-radius: 0; }
}

/* === HERO === */
.hero {
    padding: 70px 0 50px;
    text-align: center;
    border-bottom: 1px solid var(--border);
    background: radial-gradient(circle at center, rgba(97, 218, 251, 0.1) 0%, transparent 60%);
}

.hero h1 {
    font-size: 2.8rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 16px;
    text-shadow: 0 0 20px rgba(97, 218, 251, 0.3);
}

.hero p {
    color: var(--muted);
    max-width: 600px;
    margin: 0 auto;
    font-size: 1.05rem;
}

/* === TOC === */
.toc {
    padding: 35px 0;
    border-bottom: 1px solid var(--border);
}

.toc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
}

.toc-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text);
    font-size: 0.88rem;
    transition: all 0.2s;
}

.toc-item:hover {
    border-color: var(--primary);
    transform: translateX(4px);
    background: rgba(97, 218, 251, 0.05);
}

.toc-num {
    width: 26px;
    height: 26px;
    background: rgba(97, 218, 251, 0.1);
    color: var(--primary);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    font-weight: 600;
    flex-shrink: 0;
    border: 1px solid rgba(97, 218, 251, 0.2);
}

/* === SECTIONS === */
section {
    padding: 55px 0;
    border-bottom: 1px solid var(--border);
}

.sec-header {
    display: flex;
    align-items: flex-start;
    gap: 18px;
    margin-bottom: 30px;
}

.sec-num {
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, var(--primary), #2d79c7);
    color: #fff;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.2rem;
    font-weight: 600;
    flex-shrink: 0;
    box-shadow: 0 4px 15px rgba(97, 218, 251, 0.2);
}

section:nth-child(odd) .sec-num {
    background: linear-gradient(135deg, var(--purple), #7c3aed);
}

section:nth-child(3n) .sec-num {
    background: linear-gradient(135deg, var(--green), #059669);
}

section:nth-child(4n) .sec-num {
    background: linear-gradient(135deg, var(--pink), #db2777);
}

.sec-title {
    font-size: 1.7rem;
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--primary);
}

.sec-sub {
    color: var(--muted);
    font-size: 0.95rem;
}

h3 {
    font-size: 1.15rem;
    margin: 28px 0 14px;
    color: var(--primary);
}

p,
li {
    color: var(--muted);
    margin-bottom: 8px;
}

ul {
    list-style: none;
    padding-left: 0;
}

li {
    padding-left: 22px;
    position: relative;
}

li::before {
    content: '▸';
    position: absolute;
    left: 0;
    color: var(--primary);
}

/* === CODE BLOCKS === */
.code {
    background: #1e1e1e;
    /* VS Code dark */
    border: 1px solid var(--border);
    border-radius: 10px;
    margin: 14px 0;
    overflow: hidden;
}

.code-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: #252526;
    border-bottom: 1px solid var(--border);
    font-size: 0.78rem;
    color: var(--muted);
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.dot.r {
    background: #ff5f56;
}

.dot.y {
    background: #ffbd2e;
}

.dot.g {
    background: #27ca40;
}

pre {
    padding: 16px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    line-height: 1.55;
    overflow-x: auto;
    color: #abb2bf;
}

/* JSX Syntax Highlighting Colors */
.kw {
    color: #c678dd;
}

/* Purple: const, return, import */
.fn {
    color: #61dafb;
}

/* React Blue: functions, components */
.tag {
    color: #e06c75;
}

/* Red: HTML tags */
.attr {
    color: #d19a66;
}

/* Orange: attributes */
.str {
    color: #98c379;
}

/* Green: strings */
.num {
    color: #d19a66;
}

/* Orange: numbers */
.c {
    color: #5c6370;
    font-style: italic;
}

/* Grey: comments */
.var {
    color: #e5c07b;
}

/* Yellow: vars */
.prop {
    color: #e06c75;
}

/* Red: props */
.text {
    color: #abb2bf;
}

/* Standard text */
.hook {
    color: #c678dd;
}

/* Purple: hooks */

/* === DEMOS === */
.demo {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 22px;
    margin: 14px 0;
}

.demo-title {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--dim);
    margin-bottom: 14px;
}

.demo-output {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    min-height: 50px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.demo-btn {
    padding: 10px 20px;
    background: var(--primary);
    color: var(--secondary);
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin: 4px;
}

.demo-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(97, 218, 251, 0.3);
}

.demo-input {
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.9rem;
    margin: 4px;
    color: var(--primary);
}

.demo-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* === GRIDS === */
.grid2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.grid3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
}

/* === ALERTS === */
.tip {
    background: rgba(152, 195, 121, 0.1);
    border-left: 3px solid var(--green);
    padding: 14px 18px;
    border-radius: 0 10px 10px 0;
    margin: 14px 0;
}

.tip strong {
    color: var(--green);
}

.info {
    background: rgba(97, 218, 251, 0.1);
    border-left: 3px solid var(--primary);
    padding: 14px 18px;
    border-radius: 0 10px 10px 0;
    margin: 14px 0;
}

.info strong {
    color: var(--primary);
}

.warning {
    background: rgba(224, 108, 117, 0.1);
    border-left: 3px solid var(--red);
    padding: 14px 18px;
    border-radius: 0 10px 10px 0;
    margin: 14px 0;
}

.warning strong {
    color: var(--red);
}

/* === DETAILS / SUMMARY === */
details {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin: 14px 0;
    overflow: hidden;
}

summary {
    padding: 12px 16px;
    cursor: pointer;
    font-weight: 600;
    color: var(--primary);
    list-style: none;
    /* Hide default arrow */
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.2s;
}

summary::-webkit-details-marker {
    display: none;
}

summary:hover {
    background: rgba(97, 218, 251, 0.05);
}

summary::after {
    content: '+';
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--muted);
    transition: transform 0.2s;
}

details[open] summary::after {
    transform: rotate(45deg);
}

details[open] summary {
    border-bottom: 1px solid var(--border);
    background: rgba(97, 218, 251, 0.05);
}

.details-content {
    padding: 16px;
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1.6;
}

.details-content p {
    margin-bottom: 10px;
}

.details-content strong {
    color: var(--text);
}

/* === TABLES === */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 14px 0;
    font-size: 0.88rem;
}

th,
td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: var(--bg2);
    color: var(--primary);
    font-weight: 600;
}

td {
    color: var(--muted);
}

td code {
    color: var(--primary);
    background: rgba(97, 218, 251, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.78rem;
}

/* === FOOTER === */
footer {
    padding: 40px 0;
    text-align: center;
    color: var(--dim);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .hero h1 {
        font-size: 2rem;
    }

    nav {
        display: none;
    }

    .sec-header {
        flex-direction: column;
    }
}

/* === SCROLLBAR === */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* === LAYOUT UPDATES === */
.main-layout {
    display: flex;
    min-height: calc(100vh - 73px);
    /* 100vh - header height */
}

/* Sidebar (Desktop) */
aside#sidebar-container {
    width: 280px;
    background: var(--bg2);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    flex-shrink: 0;
    position: sticky;
    top: 73px;
    /* Header height */
    height: calc(100vh - 73px);
    transition: transform 0.3s ease;
}

main {
    flex-grow: 1;
    min-width: 0;
    width: 100%;
}

.module-content {
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Sidebar Content */
.sidebar-inner {
    padding: 24px 16px;
}

.sidebar-header {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--muted);
    font-weight: 700;
    margin-bottom: 16px;
    padding-left: 12px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: var(--text);
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--primary);
}

.sidebar-link.active {
    background: rgba(97, 218, 251, 0.1);
    color: var(--primary);
    font-weight: 500;
    border-color: rgba(97, 218, 251, 0.2);
}

.sidebar-link .num {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    opacity: 0.5;
    min-width: 20px;
}

.sidebar-link .icon {
    font-size: 1rem;
    opacity: 0.8;
}

.sidebar-footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 0.8rem;
}

.sidebar-footer a {
    color: var(--dim);
}

/* Nav Buttons (Next/Prev) */
.nav-buttons {
    display: flex;
    justify-content: space-between;
    margin-top: 60px;
    padding-top: 30px;
    border-top: 1px solid var(--border);
    gap: 20px;
}

.btn-prev,
.btn-next {
    display: inline-flex;
    align-items: center;
    padding: 12px 20px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
}

.btn-next {
    background: var(--primary);
    color: var(--secondary);
    border-color: var(--primary);
    margin-left: auto;
}

.btn-prev:hover {
    border-color: var(--text);
}

.btn-next:hover {
    box-shadow: 0 4px 12px rgba(97, 218, 251, 0.3);
    transform: translateY(-2px);
}

/* BURGER */
.burger-menu {
    display: none;
    cursor: pointer;
    width: 24px;
    height: 18px;
    position: relative;
    z-index: 1000;
}

.burger-menu span {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--text);
    position: absolute;
    transition: all 0.3s;
    border-radius: 2px;
}

.burger-menu span:nth-child(1) {
    top: 0;
}

.burger-menu span:nth-child(2) {
    top: 8px;
}

.burger-menu span:nth-child(3) {
    top: 16px;
}

.burger-menu.open span:nth-child(1) {
    transform: rotate(45deg);
    top: 8px;
}

.burger-menu.open span:nth-child(2) {
    opacity: 0;
}

.burger-menu.open span:nth-child(3) {
    transform: rotate(-45deg);
    top: 8px;
}

/* RESPONSIVE */
@media (max-width: 900px) {
    .main-layout {
        display: block;
        /* Stack */
    }

    aside#sidebar-container {
        position: fixed;
        left: 0;
        top: 73px;
        bottom: 0;
        height: auto;
        width: 100%;
        background: var(--bg);
        /* Full bg */
        transform: translateX(-100%);
        z-index: 99;
        border-right: none;
    }

    aside#sidebar-container.open {
        transform: translateX(0);
    }

    .burger-menu {
        display: block;
    }

    .top-nav {
        display: none;
        /* Hide top links on mobile, rely on sidebar */
    }

    .sec-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .nav-buttons {
        flex-direction: column;
    }

    .btn-next {
        margin-left: 0;
        width: 100%;
        justify-content: center;
    }

    .btn-prev {
        width: 100%;
        justify-content: center;
        order: 2;
    }
}

/* === SCROLL PROGRESS BAR === */
#scrollProgress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), #4dc0e8);
    z-index: 1001;
    transition: width 0.1s;
}

/* === BACK TO TOP BUTTON === */
#backToTop {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--primary);
    color: var(--secondary);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(97, 218, 251, 0.35);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 9999;
    border: none;
}

#backToTop.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

#backToTop:hover {
    background: #4dc0e8;
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(97, 218, 251, 0.5);
}