/**
 * Dokumentation – App-Layout: feste Navigation oben, darunter zwei getrennte Scrollbereiche
 * (Themen links, Inhalt rechts). Die Seite selbst scrollt nie.
 * Überschreibt bewusst ältere Layout-Regeln (Inline-Styles, styles.css), daher teils !important.
 * --docs-top wird von docs-shell.js aus der tatsächlichen Höhe der Navigation gesetzt.
 */

/* Spezifität bewusst hoch: styles.css macht Dashboard-Seiten sonst dokument-scrollbar
   (body.kynx-dashboard-nav:not(:has(main#app .hero)) …) */
html:has(body.kx-docs.kynx-dashboard-nav main#main-content.content),
html body.kx-docs.kynx-dashboard-nav:has(main#main-content) {
    height: 100% !important;
    max-height: none !important;
    overflow: hidden !important;
    overscroll-behavior: none;
}

html body.kx-docs {
    --docs-top: 74px;
    --docs-sidebar-w: 288px;
    --docs-line: rgba(255, 255, 255, 0.07);
    --docs-muted: rgba(235, 237, 245, 0.62);
    --docs-accent: #8b98ff;
}

/* ---------- Gerüst ---------- */
html body.kx-docs .docs-container {
    position: fixed !important;
    top: var(--docs-top) !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 1;
    display: grid !important;
    grid-template-columns: var(--docs-sidebar-w) minmax(0, 1fr) !important;
    width: auto !important;
    max-width: none !important;
    height: auto !important;
    max-height: none !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
}

/* ---------- Themenleiste links ---------- */
html body.kx-docs .sidebar {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 0.75rem 2.5rem !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    background: rgba(10, 11, 20, 0.72) !important;
    border-right: 1px solid var(--docs-line) !important;
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
}

html body.kx-docs .sidebar .search-container {
    position: sticky;
    top: 0;
    z-index: 2;
    margin: 0 -0.75rem 0.4rem;
    padding: 0.9rem 0.75rem;
    background: #0b0c16;
    border-bottom: 1px solid var(--docs-line);
}

html body.kx-docs .sidebar .search-icon {
    left: 1.6rem;
    font-size: 0.85rem;
    pointer-events: none;
}

html body.kx-docs .sidebar .search-input {
    height: 40px;
    padding: 0 2.4rem 0 2.3rem;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    font-size: 0.88rem;
}

html body.kx-docs .sidebar .search-input::-webkit-search-cancel-button { filter: invert(0.8); }

html body.kx-docs .sidebar .search-input:focus {
    border-color: rgba(139, 152, 255, 0.7);
    background: rgba(88, 101, 242, 0.08);
    box-shadow: 0 0 0 3px rgba(88, 101, 242, 0.18);
}

.docs-kbd {
    position: absolute;
    top: 50%;
    right: 1.5rem;
    transform: translateY(-50%);
    min-width: 20px;
    padding: 0.05rem 0.35rem;
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.05);
    color: rgba(235, 237, 245, 0.55);
    font: 600 0.72rem/1.4 ui-monospace, Consolas, monospace;
    text-align: center;
    pointer-events: none;
}

.search-container:focus-within .docs-kbd { opacity: 0; }

html body.kx-docs .sidebar-section { margin: 0 0 0.35rem; }

html body.kx-docs .sidebar-title {
    margin: 1.1rem 0 0.35rem;
    padding: 0 0.75rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    color: rgba(235, 237, 245, 0.42);
}

html body.kx-docs .sidebar-links a {
    gap: 0.65rem;
    min-height: 36px;
    padding: 0.4rem 0.75rem;
    border-left: 0;
    border-radius: 8px;
    color: rgba(235, 237, 245, 0.72);
    font-size: 0.875rem;
    line-height: 1.35;
}

html body.kx-docs .sidebar-links a i {
    width: 18px;
    font-size: 0.9rem;
    color: rgba(165, 172, 255, 0.7);
}

html body.kx-docs .sidebar-links a:focus-visible {
    outline: 2px solid var(--docs-accent);
    outline-offset: -2px;
}

/* ---------- Inhalt ---------- */
html body.kx-docs.kynx-dashboard-nav main#main-content.content {
    position: relative !important;
    flex: none !important;
    max-height: none !important;
    width: auto !important;
    height: auto !important;
    min-width: 0 !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
}

.docs-main {
    display: grid;
    grid-template-columns: minmax(0, 840px) 220px;
    justify-content: center;
    gap: 3.5rem;
    padding: 2.6rem 3rem 5rem;
}

.docs-article { min-width: 0; }

/* Abschnitte: nur der aktive ist sichtbar – Trennlinien nur in der Suche (mehrere Treffer) */
html body.kx-docs .content .section + .section {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}
html body.kx-docs .content .section.active ~ .section.active {
    margin-top: 3rem;
    padding-top: 2.6rem;
    border-top: 1px solid var(--docs-line);
}

html body.kx-docs .content .section > h1,
html body.kx-docs .content .section > h2 { margin-top: 0; }

html body.kx-docs .content .section h3 {
    margin: 2.2rem 0 0.7rem;
    font-size: 1.12rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.01em;
    scroll-margin-top: 1.5rem;
}

.docs-eyebrow {
    display: block;
    margin: 0 0 0.6rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #a5acff;
}

/* Einführung hat eigene Brotkrumen – die Kategorie-Zeile reicht */
html body.kx-docs #introduction .breadcrumbs { display: none; }

/* ---------- Zurück / Weiter ---------- */
.docs-pager {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin-top: 3.5rem;
    padding-top: 2rem;
    border-top: 1px solid var(--docs-line);
}
.docs-pager[hidden] { display: none; }
.docs-pager__link {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.95rem 1.1rem;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.09);
    background: rgba(22, 24, 38, 0.55);
    color: #fff;
    text-decoration: none;
    transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
}
.docs-pager__link:hover,
.docs-pager__link:focus-visible {
    border-color: rgba(139, 152, 255, 0.55);
    background: rgba(88, 101, 242, 0.12);
    transform: translateY(-1px);
    outline: none;
}
.docs-pager__link--next { grid-column: 2; text-align: right; }
.docs-pager__hint { font-size: 0.75rem; color: var(--docs-muted); }
.docs-pager__title { font-weight: 700; font-size: 0.98rem; }

/* ---------- Auf dieser Seite (rechts) ---------- */
.docs-toc {
    position: sticky;
    top: 2.6rem;
    align-self: start;
    max-height: calc(100vh - var(--docs-top) - 5rem);
    overflow-y: auto;
    padding-left: 1rem;
    border-left: 1px solid var(--docs-line);
    scrollbar-width: none;
}
.docs-toc[hidden] { display: none; }
.docs-toc__title {
    margin: 0 0 0.7rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(235, 237, 245, 0.45);
}
.docs-toc__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.15rem; }
.docs-toc__list a {
    display: block;
    padding: 0.3rem 0;
    color: var(--docs-muted);
    font-size: 0.83rem;
    line-height: 1.4;
    text-decoration: none;
    transition: color 0.15s ease;
}
.docs-toc__list a:hover,
.docs-toc__list a:focus-visible { color: #fff; outline: none; }
.docs-toc__list a.is-active { color: #c9d1ff; font-weight: 600; }

/* ---------- Handy/Tablet-Leiste ---------- */
.docs-mobilebar { display: none; }
.docs-backdrop { display: none; }

@media (max-width: 1279px) {
    .docs-main { grid-template-columns: minmax(0, 860px); }
    .docs-toc { display: none !important; }
}

@media (max-width: 1024px) {
    html body.kx-docs .docs-container { grid-template-columns: minmax(0, 1fr) !important; }

    html body.kx-docs .sidebar {
        position: fixed !important;
        top: var(--docs-top) !important;
        bottom: 0 !important;
        left: 0 !important;
        z-index: 1002;
        width: min(320px, 86vw) !important;
        background: rgba(10, 11, 20, 0.97) !important;
        transform: translateX(-104%);
        transition: transform 0.25s ease;
        box-shadow: 18px 0 40px rgba(0, 0, 0, 0.45);
    }
    html body.kx-docs .sidebar.active { transform: none; }

    .docs-backdrop {
        display: block;
        position: fixed;
        inset: var(--docs-top) 0 0 0;
        z-index: 1001;
        background: rgba(3, 4, 10, 0.55);
    }
    .docs-backdrop[hidden] { display: none; }

    .docs-mobilebar {
        position: sticky;
        top: 0;
        z-index: 5;
        display: flex;
        align-items: center;
        gap: 0.75rem;
        min-height: 54px;
        padding: 0.55rem 1rem;
        border-bottom: 1px solid var(--docs-line);
        background: rgba(10, 11, 20, 0.9);
        -webkit-backdrop-filter: blur(14px);
        backdrop-filter: blur(14px);
    }
    .docs-mobilebar__btn {
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
        flex-shrink: 0;
        min-height: 38px;
        padding: 0 0.85rem;
        border-radius: 10px;
        border: 1px solid rgba(139, 152, 255, 0.35);
        background: rgba(88, 101, 242, 0.14);
        color: #fff;
        font: inherit;
        font-size: 0.88rem;
        font-weight: 600;
        cursor: pointer;
    }
    .docs-mobilebar__btn:focus-visible { outline: 2px solid var(--docs-accent); outline-offset: 2px; }
    .docs-mobilebar__title {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        color: var(--docs-muted);
        font-size: 0.88rem;
    }

    .docs-main { padding: 1.6rem 1.5rem 4rem; }
}

@media (max-width: 600px) {
    .docs-main { padding: 1.25rem 1rem 6rem; }
    .docs-pager { grid-template-columns: minmax(0, 1fr); }
    .docs-pager__link--next { grid-column: 1; }
}

@media (prefers-reduced-motion: reduce) {
    html body.kx-docs .sidebar,
    .docs-pager__link { transition: none; }
}

.docs-no-results {
    margin: 0 0 1.5rem;
    padding: 1rem 1.2rem;
    border-radius: 12px;
    border: 1px dashed rgba(255, 255, 255, 0.16);
    color: var(--docs-muted);
}
