/* ── Variables pour le TOC Moderne ── */
:root {
    --toc-width: 280px;
    --toc-accent: var(--c-accent);
}

/* ── Layout Article avec Sidebar ── */
@media (min-width: 1024px) {
    .article-grid {
        display: grid;
        grid-template-columns: 1fr var(--toc-width);
        gap: 40px;
    }
}

.article-main-col {
    min-width: 0;
    /* Évite l'overflow du contenu long */
}

/* Cache le sommaire inline classique si on utilise la sidebar/mobile */
.article-toc.is-hidden {
    display: none !important;
}

/* ── Sidebar & Blocks ── */
.article-sidebar {
    display: none;
}

@media (min-width: 1024px) {
    .article-sidebar {
        display: block;
    }
}

.sidebar-sticky {
    position: sticky;
    top: 100px;
    /* Aligné avec le header scroll */
    transition: top 0.3s ease;
}

.sidebar-block {
    background: var(--c-surface);
    padding: 24px;
    border-radius: var(--r-lg);
    border: 1px solid var(--c-border);
    margin-bottom: 30px;
}

.sidebar-block h4 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--c-accent);
    display: inline-block;
}

/* ── Sommaire Sidebar (ScrollSpy) ── */
.toc-sidebar-block {
    padding: 20px;
}

.toc-sidebar-block ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc-sidebar-block li {
    margin-bottom: 8px;
}

.toc-sidebar-block a {
    color: var(--c-text-2);
    font-size: 0.95rem;
    line-height: 1.4;
    display: block;
    padding-left: 12px;
    border-left: 2px solid transparent;
    transition: all 0.2s ease;
}

.toc-sidebar-block a:hover {
    color: var(--c-accent);
    padding-left: 16px;
}

.toc-sidebar-block a.active {
    color: var(--c-accent);
    font-weight: 600;
    border-left-color: var(--c-accent);
    padding-left: 16px;
}

/* ── Articles Similaires Sidebar ── */
.similar-sidebar-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.similar-sidebar-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s;
    margin-bottom: 20px;
}

.similar-sidebar-item:last-child {
    margin-bottom: 0;
}

.similar-sidebar-item:hover {
    transform: translateY(-3px);
}

.similar-sidebar-item .sim-img {
    width: 100%;
    height: 140px;
    border-radius: var(--r-md);
    overflow: hidden;
    flex-shrink: 0;
}

.similar-sidebar-item .sim-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.similar-sidebar-item .sim-text {
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.3;
    padding: 0 5px;
}

/* ── Barre de Recherche Sidebar ── */
.search-sidebar-block {
    padding: 15px;
}

.home-search-box {
    display: flex;
    flex-grow: 1;
    max-width: 500px;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--r-md);
    padding: 4px;
    box-shadow: var(--shadow-sm);
}

.home-search-box input {
    flex-grow: 1;
    border: none;
    background: transparent;
    padding: 8px 15px;
    color: var(--c-text);
    font-size: 15px;
    outline: none;
    width: 60%;
    /* Évite l'écrasement sur petits conteneurs */
}

.home-search-box button {
    background: var(--c-accent);
    color: white;
    border: none;
    padding: 8px 18px;
    border-radius: calc(var(--r-md) - 2px);
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
    white-space: nowrap;
}

.home-search-box button:hover {
    background: var(--c-accent-hover, #dc4c00);
}

.search-sidebar-block .home-search-box {
    width: 100%;
    max-width: none;
    margin: 0;
}

.search-sidebar-block .home-search-box input {
    height: 45px;
}

/* ── TOC Mobile ── */
.toc-mobile-trigger {
    position: fixed;
    bottom: 25px;
    right: 25px;
    width: 55px;
    height: 55px;
    background: var(--g-header);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    z-index: 3000;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    opacity: 0.8;
}

.toc-mobile-trigger:hover {
    transform: scale(1.1);
    opacity: 1;
}

.toc-mobile-trigger.hidden {
    transform: translateY(100px);
    opacity: 0;
}

.toc-trigger-icon {
    font-size: 24px;
}

/* Drawer */
.toc-mobile-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 90%;
    max-width: 400px;
    height: 100%;
    background: var(--c-bg);
    z-index: 4000;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.1);
}

.toc-mobile-drawer.open {
    transform: translateX(0);
}

.drawer-header {
    padding: 20px;
    border-bottom: 1px solid var(--c-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
    font-size: 1.2rem;
}

.drawer-close {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--c-text-2);
}

.drawer-body {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
}

.drawer-body ul {
    list-style: none;
    padding: 0;
}

.drawer-body li {
    margin-bottom: 5px;
}

.drawer-body a {
    display: block;
    padding: 12px 15px;
    color: var(--c-text);
    border-radius: var(--r-md);
    transition: background 0.2s;
}

.drawer-body a:hover,
.drawer-body a.active {
    background: var(--c-surface2);
    color: var(--c-accent);
}

.toc-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 3500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(3px);
}

.toc-drawer-overlay.open {
    opacity: 1;
    pointer-events: auto;
}