/*
 * Styles propres au site de documentation : mise en page à trois colonnes (sommaire / contenu /
 * "sur cette page"), recherche cliente, blocs de code. Décline uniquement les tokens de niang.css,
 * chargé juste avant ce fichier — jamais de couleur en dur ici.
 */

.icon--sm { width: 1.05em; height: 1.05em; }
.icon--xs { width: 13px; height: 13px; stroke-width: 2.25; }

/* Un site de doc a besoin de plus de largeur qu'une page marketing (sommaire + contenu + TOC) :
   élargit --container pour ce projet seulement, sans toucher niang.css (partagé par tous les
   thèmes de démonstration, qui doivent garder leur largeur de colonne éditoriale plus étroite). */
body.docs { --container: 96rem; }

/* ---------- Mise en page à trois colonnes ---------- */

.docs-shell {
    display: grid;
    grid-template-columns: 15rem minmax(0, 1fr);
    gap: var(--space-6);
    padding-block: var(--space-6);
    align-items: start;
}

@media (min-width: 75em) {
    .docs-shell { grid-template-columns: 15rem minmax(0, 1fr) 13rem; }
}

.docs-sidebar-toggle {
    display: none;
    align-items: center;
    gap: var(--space-2);
    width: 100%;
    margin-bottom: var(--space-4);
    padding: 0.7em var(--space-4);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.docs-sidebar-toggle:hover { border-color: var(--accent-text); box-shadow: var(--shadow-sm); }
@media (max-width: 63.99em) { html.js .docs-sidebar-toggle { display: inline-flex; } }

/* ---------- Sidebar : refonte "carte" moderne ---------- */

.docs-sidebar {
    position: sticky;
    top: calc(var(--header-height) + var(--space-4));
    max-height: calc(100dvh - var(--header-height) - var(--space-6));
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: var(--space-4);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.docs-sidebar::-webkit-scrollbar { width: 6px; }
.docs-sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
.docs-sidebar::-webkit-scrollbar-track { background: transparent; }

.docs-sidebar__section {
    padding-block: var(--space-3);
    border-top: 1px solid var(--border);
}
.docs-sidebar__section:first-child { padding-top: 0; border-top: 0; }

.docs-sidebar__section h2 {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin: 0 0 0.4rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    color: var(--muted);
    transition: color 0.15s;
}
.docs-sidebar__section-icon {
    display: grid;
    place-items: center;
    flex: none;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--muted);
    transition: background-color 0.2s, color 0.2s;
}
.docs-sidebar__section.is-active h2 { color: var(--text); }
.docs-sidebar__section.is-active .docs-sidebar__section-icon { background: var(--accent-soft); color: var(--accent-text); }

.docs-sidebar__section ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }

.docs-sidebar__section a {
    position: relative;
    display: block;
    padding: 0.5em 0.75em 0.5em 1.85rem;
    border-radius: 9px;
    color: var(--muted);
    text-decoration: none;
    font-size: var(--step--1);
    line-height: 1.4;
    transition: color 0.15s, background-color 0.15s, transform 0.15s;
}
.docs-sidebar__section a::before {
    content: "";
    position: absolute;
    left: 0.75rem;
    top: 50%;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--border);
    transform: translateY(-50%) scale(1);
    transition: background-color 0.15s, transform 0.15s;
}
.docs-sidebar__section a:hover { color: var(--text); background: var(--surface-2); transform: translateX(2px); }
.docs-sidebar__section a:hover::before { background: var(--muted); }
.docs-sidebar__section a[aria-current="page"] {
    color: var(--accent-text);
    background: var(--accent-soft);
    font-weight: 700;
}
.docs-sidebar__section a[aria-current="page"]::before {
    background: var(--accent-text);
    transform: translateY(-50%) scale(1.6);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.docs-sidebar__soon {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    padding: 0.5em 0.75em 0.5em 1.85rem;
    color: var(--muted);
    font-size: var(--step--1);
    opacity: 0.65;
}
.docs-sidebar__soon .badge { font-size: 0.65rem; padding: 0.1em 0.5em; }

@media (max-width: 63.99em) {
    .docs-shell { grid-template-columns: minmax(0, 1fr); }
    .docs-sidebar {
        position: static;
        max-height: none;
        margin-bottom: var(--space-4);
    }
    html.js .docs-sidebar { display: none; }
    html.js .docs-sidebar.is-open { display: block; }
}

.docs-content { min-width: 0; }
.docs-content .eyebrow { margin-bottom: var(--space-2); }
.docs-content .lead { font-size: var(--step-0); line-height: 1.6; max-width: 46rem; }

.docs-toc {
    position: sticky;
    top: calc(var(--header-height) + var(--space-4));
    max-height: calc(100dvh - var(--header-height) - var(--space-6));
    overflow-y: auto;
    display: none;
    font-size: var(--step--1);
}
@media (min-width: 75em) { .docs-toc { display: block; } }
.docs-toc__title { margin: 0 0 var(--space-3); font-weight: 700; color: var(--muted); font-size: 0.72rem; letter-spacing: 0.03em; }
.docs-toc ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.docs-toc li a {
    position: relative;
    display: block;
    padding: 0.35em 0.6em 0.35em 1.1rem;
    border-radius: 8px;
    color: var(--muted);
    text-decoration: none;
    transition: color 0.15s, background-color 0.15s;
}
.docs-toc li a::before {
    content: "";
    position: absolute;
    left: 0.15rem;
    top: 50%;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--border);
    transform: translateY(-50%);
    transition: background-color 0.15s, transform 0.15s;
}
.docs-toc__level-3 a { padding-left: 1.75rem; }
.docs-toc__level-3 a::before { left: 0.8rem; }
.docs-toc li a:hover { color: var(--text); background: var(--surface-2); }
.docs-toc li a.is-active { color: var(--accent-text); font-weight: 600; background: var(--accent-soft); }
.docs-toc li a.is-active::before { background: var(--accent-text); transform: translateY(-50%) scale(1.4); }

/* ---------- Pagination précédent / suivant ---------- */

.docs-pager {
    display: flex;
    justify-content: space-between;
    gap: var(--space-4);
    margin-top: var(--space-8);
    padding-top: var(--space-5);
    border-top: 1px solid var(--border);
}
.docs-pager__link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    max-width: 48%;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    text-decoration: none;
    font-size: var(--step--1);
    line-height: 1.35;
}
.docs-pager__link:hover { border-color: var(--accent-text); background: var(--accent-soft); }
.docs-pager__link--next { margin-left: auto; text-align: right; }

/* ---------- Recherche ---------- */

.docs-search-trigger {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 0.5em 0.75em;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--muted);
    font: inherit;
    font-size: var(--step--1);
    cursor: pointer;
}
.docs-search-trigger:hover { border-color: var(--accent-text); color: var(--text); }
.docs-search-trigger kbd {
    padding: 0.1em 0.5em;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--surface-2);
    font-family: var(--font-mono);
    font-size: 0.75rem;
}
@media (max-width: 40em) { .docs-search-trigger span { display: none; } }

.docs-search { position: fixed; inset: 0; z-index: 200; }
.docs-search[hidden] { display: none; }
.docs-search__backdrop { position: absolute; inset: 0; background: rgb(6 33 30 / 0.55); backdrop-filter: blur(2px); }
.docs-search__dialog {
    position: relative;
    z-index: 1;
    width: min(36rem, calc(100vw - 2rem));
    margin: 10vh auto 0;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.docs-search__field { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-4); border-bottom: 1px solid var(--border); color: var(--muted); }
.docs-search__field input {
    flex: 1;
    border: 0;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: var(--step-0);
    outline: none;
}
.docs-search__field button { border: 0; background: transparent; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.docs-search__results { list-style: none; margin: 0; padding: var(--space-2); overflow-y: auto; }
.docs-search__results li a {
    display: block;
    padding: var(--space-3) var(--space-3);
    border-radius: var(--radius-sm);
    color: var(--text);
    text-decoration: none;
}
.docs-search__results li a:hover,
.docs-search__results li a.is-active { background: var(--accent-soft); }
.docs-search__results .docs-search__result-page { font-size: var(--step--1); color: var(--accent-text); font-weight: 700; margin-bottom: 0.1em; }
.docs-search__results .docs-search__result-snippet { font-size: var(--step--1); color: var(--muted); }
.docs-search__empty { padding: var(--space-5); text-align: center; color: var(--muted); }

/* ---------- Blocs de code ---------- */

.code-block {
    margin: var(--space-5) 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface-2);
}
.code-block__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: 0.5em var(--space-4);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--muted);
}
.code-block__copy {
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    padding: 0.3em 0.6em;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 0.75rem;
    cursor: pointer;
}
.code-block__copy:hover { color: var(--text); border-color: var(--accent-text); }
.code-block__copy.is-copied { color: var(--accent-text); border-color: var(--accent-text); }
.code-block__pre {
    margin: 0;
    padding: var(--space-4);
    overflow-x: auto;
}
.code-block__code {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.6;
    background: none;
    padding: 0;
    color: var(--text);
    white-space: pre;
}

.tok-kw { color: var(--accent-text); font-weight: 600; }
.tok-var { color: var(--gold-text); }
.tok-str { color: #a3826f; }
.tok-num { color: var(--gold-text); }
.tok-com { color: var(--muted); font-style: italic; }
.tok-name { color: var(--text); }
.tok-punct { color: var(--muted); }

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .tok-str { color: #f0b990; }
}
:root[data-theme="dark"] .tok-str { color: #f0b990; }

/* ---------- Prose : contenu de doc en dehors des blocs de code ---------- */

.prose { max-width: none; }
.prose h2 { scroll-margin-top: calc(var(--header-height) + var(--space-4)); }
.prose h3 { scroll-margin-top: calc(var(--header-height) + var(--space-4)); }
.prose table { width: 100%; border-collapse: collapse; margin: var(--space-5) 0; font-size: var(--step--1); }
.prose table th, .prose table td { padding: var(--space-2) var(--space-3); text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.prose table th { background: var(--surface-2); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.prose .callout {
    padding: var(--space-4) var(--space-5);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent-text);
    border-radius: var(--radius-sm);
    background: var(--accent-soft);
    margin: var(--space-5) 0;
}
.prose .callout p:last-child { margin-bottom: 0; }
.prose .callout--warning { border-left-color: var(--gold-text); background: var(--gold-soft); }

/* Emblème NP du logo (public/logo-mark.png, découpé depuis public/logo.png) */
.brand__logo {
    display: block;
    width: 2.5rem;
    height: 2.5rem;
    object-fit: contain;
    transition: transform 0.25s;
}
.brand:hover .brand__logo { transform: rotate(-8deg) scale(1.06); }

/* Sélecteur de langue FR / EN dans l'en-tête */
.lang-switch {
    display: inline-flex;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    font-size: var(--step--1);
    font-weight: 700;
}
.lang-switch a {
    padding: 0.3em 0.65em;
    border-radius: 999px;
    color: var(--muted);
    text-decoration: none;
    line-height: 1.2;
}
.lang-switch a:hover { color: var(--text); }
.lang-switch a[aria-current] { background: var(--accent-soft); color: var(--accent-text); }
