/* Doku-Layout für den Entwicklerbereich (#2021): pages/partials/docs_layout/docs_base.html, JS: custom/pages/docs_layout.js */

html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}

.docs-layout {
    padding-top: 2rem;
    padding-bottom: 3rem;
}

/* Inhalt: kein horizontales Scrollen (lange Codes umbrechen, Codeblöcke scrollen in sich) */
.docs-content {
    min-width: 0;
}

.docs-content p code,
.docs-content li code {
    overflow-wrap: anywhere;
}

.docs-content pre {
    max-width: 100%;
    overflow-x: auto;
}

.docs-section {
    padding-bottom: 1.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--bs-gray-200);
    scroll-margin-top: 1rem;
}

.docs-section:last-child {
    border-bottom: 0;
}

.docs-section-highlight {
    background-color: #e0f2fe;
    border-radius: .5rem;
    padding: 1.5rem;
    border-bottom: 0;
}

.docs-content h3[id] {
    scroll-margin-top: 1rem;
}

/* Verlinkbare Anker an Überschriften: sichtbar beim Überfahren und bei Tastaturfokus */
.docs-anchor {
    margin-left: .4rem;
    font-size: .8em;
    color: var(--bs-gray-500);
    text-decoration: none;
    opacity: 0;
    transition: opacity .15s;
}

h2:hover > .docs-anchor,
h3:hover > .docs-anchor,
.docs-anchor:focus,
.docs-anchor:focus-visible {
    opacity: 1;
}

.docs-anchor:hover {
    color: var(--bs-primary-dark);
}

@media (hover: none) {
    .docs-anchor {
        opacity: .6;
    }
}

/* Navigation (Seitennavigation, „Auf dieser Seite“, mobiles Menü) */
.docs-nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.docs-nav-link,
.docs-toc-section {
    display: block;
    padding: .3rem .75rem;
    border-left: 2px solid transparent;
    color: var(--bs-gray-700);
    text-decoration: none;
    font-size: .925rem;
    line-height: 1.35;
    /* Navigationstitel sind kurz (docs_nav); nur im Notfall mitten im Wort umbrechen */
    overflow-wrap: break-word;
}

.docs-nav-link:hover,
.docs-toc-section:hover {
    color: var(--bs-primary-dark);
    text-decoration: underline;
}

.docs-nav-link[aria-current],
.docs-toc-section[aria-current] {
    border-left-color: var(--bs-primary);
    color: var(--bs-primary-dark);
    font-weight: 600;
    background-color: var(--bs-gray-100);
}

.docs-sidebar,
.docs-toc {
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
}

.docs-toc-title {
    font-size: .8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--bs-gray-600);
    margin: 0 0 .5rem .75rem;
}

.docs-toc-section {
    font-weight: 600;
}

.docs-toc-group + .docs-toc-group {
    margin-top: .75rem;
}

.docs-toc-group .docs-nav-link {
    padding-left: 1.25rem;
    font-size: .875rem;
}

/* Mobil: Menü „Inhalt“ oben, bleibt beim Scrollen erreichbar */
.docs-mobile-nav {
    position: sticky;
    top: 0;
    z-index: 1010;
    margin-bottom: 1.5rem;
    background-color: #fff;
    border: 1px solid var(--bs-gray-300);
    border-radius: .5rem;
}

.docs-mobile-nav > summary {
    min-height: 44px;
    padding: .6rem 1rem;
    font-weight: 600;
    cursor: pointer;
}

/* Touch: Einträge des mobilen Menüs mindestens 44 px hoch (wie mobile.css) */
@media (pointer: coarse) {
    .docs-mobile-nav .docs-nav-link {
        min-height: 44px;
        padding-top: .7rem;
        padding-bottom: .7rem;
    }
}

.docs-mobile-nav > nav {
    max-height: 60vh;
    overflow-y: auto;
    padding: 0 .5rem .75rem;
    border-top: 1px solid var(--bs-gray-200);
}

.docs-nav-sub .docs-nav-link {
    padding-left: 1.5rem;
    font-size: .875rem;
}

/* Seiten des Entwicklerbereichs (#2022): Seite fett, aktuelle Seite markiert, Abschnitte eingerückt darunter */
.docs-nav-page {
    display: block;
    padding: .4rem .75rem;
    color: var(--bs-gray-800);
    font-weight: 600;
    text-decoration: none;
    font-size: .95rem;
    line-height: 1.35;
    overflow-wrap: break-word;
}

.docs-nav-page:hover {
    color: var(--bs-primary-dark);
    text-decoration: underline;
}

.docs-nav-page {
    border-left: 2px solid transparent;
}

.docs-nav-page[aria-current] {
    color: var(--bs-primary-dark);
    border-left-color: var(--bs-primary);
    background-color: var(--bs-gray-100);
}

.docs-nav-sub .docs-nav-sub .docs-nav-link {
    padding-left: 2.25rem;
}

.docs-nav-separate {
    margin-top: .5rem;
    padding-top: .5rem;
    border-top: 1px solid var(--bs-gray-200);
}

@media (pointer: coarse) {
    .docs-mobile-nav .docs-nav-page {
        min-height: 44px;
        padding-top: .7rem;
        padding-bottom: .7rem;
    }
}

/* „Zurück/Weiter“ am Seitenende (#2022) */
.docs-pager {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 2rem;
}

.docs-pager-link {
    flex: 1 1 14rem;
    display: flex;
    flex-direction: column;
    min-height: 44px;
    padding: .75rem 1rem;
    border: 1px solid var(--bs-gray-300);
    border-radius: .5rem;
    color: var(--bs-gray-800);
    text-decoration: none;
}

.docs-pager-link:hover,
.docs-pager-link:focus-visible {
    border-color: var(--bs-primary);
    color: var(--bs-primary-dark);
}

.docs-pager-next {
    text-align: right;
    margin-left: auto;
}

.docs-pager-label {
    font-size: .85rem;
    color: var(--bs-gray-600);
}

.docs-pager-title {
    font-weight: 600;
}

/* Wegweiser-Kacheln der Übersicht (#2022) */
.docs-topic-card {
    display: block;
    height: 100%;
    padding: 1rem 1.25rem;
    border: 1px solid var(--bs-gray-300);
    border-radius: .5rem;
    color: inherit;
    text-decoration: none;
}

.docs-topic-card:hover,
.docs-topic-card:focus-visible {
    border-color: var(--bs-primary);
}

.docs-topic-card .docs-topic-title {
    color: var(--bs-primary-dark);
    font-weight: 600;
}

@media (max-width: 991.98px) {
    .docs-section,
    .docs-content h3[id] {
        scroll-margin-top: 4rem;
    }
}

/* Lesefortschritt (nur mit JS sichtbar, rein dekorativ) */
.docs-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 1040;
    pointer-events: none;
}

.docs-progress-bar {
    height: 100%;
    background-color: var(--bs-primary);
    transform-origin: left center;
    transform: scaleX(0);
}
