/* Neukalen Markdown – Inhaltsverzeichnis ([tok]) */

.tok-toc {
    background: #f8f9fa;
    border-left: 4px solid #0073aa;
    border-radius: 4px;
    padding: 1rem 1.25rem;
    margin: 1.5rem 0;
    display: inline-block;
    min-width: 220px;
    max-width: 100%;
}

.tok-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin: 0 0 0.5rem 0;
    color: #333;
}

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

.tok-toc li {
    margin: 0.2rem 0;
    line-height: 1.4;
}

/* Einrückung nach Ebene */
.tok-toc li.tok-level-2 { padding-left: 0; }
.tok-toc li.tok-level-3 { padding-left: 1rem; }
.tok-toc li.tok-level-4 { padding-left: 2rem; }

.tok-toc a {
    color: #0073aa;
    text-decoration: none;
    font-size: 0.9rem;
}

.tok-toc a:hover {
    text-decoration: underline;
    color: #005177;
}

/* Rechts-positioniertes Inhaltsverzeichnis (wie GitHub-Wiki) */

/*
 * Grid-Layout: Content bleibt dauerhaft in der linken Spalte,
 * TOC bleibt sticky in der rechten Spalte – auf der gesamten Seitenlänge.
 */
.entry-content:has(.tok-toc--right),
.post-content:has(.tok-toc--right),
.page-content:has(.tok-toc--right) {
    display: grid;
    grid-template-columns: 1fr 260px;
    column-gap: 2rem;
    align-items: start;
}

/* Alle direkten Kinder → linke Spalte */
.entry-content:has(.tok-toc--right) > *,
.post-content:has(.tok-toc--right) > *,
.page-content:has(.tok-toc--right) > * {
    grid-column: 1;
    min-width: 0;
}

/* TOC → rechte Spalte, überspannt alle Zeilen, scrollt mit dem Inhalt */
.entry-content:has(.tok-toc--right) .tok-toc--right,
.post-content:has(.tok-toc--right) .tok-toc--right,
.page-content:has(.tok-toc--right) .tok-toc--right {
    grid-column: 2;
    grid-row: 1 / 9999;
    align-self: start;
    float: none;
    margin: 0;
    max-width: none;
    min-width: 0;
    font-size: 0.85rem;
}

.tok-toc--right .tok-title {
    font-size: 0.85rem;
}

.tok-toc--right a {
    font-size: 0.82rem;
}

/* Tabellen: alle Theme-Rahmen zurücksetzen */
.entry-content .wp-block-table table,
.entry-content .wp-block-table thead,
.entry-content .wp-block-table tbody,
.entry-content .wp-block-table tfoot,
.entry-content .wp-block-table tr,
.entry-content .wp-block-table td,
.entry-content .wp-block-table th,
.post-content .wp-block-table table,
.post-content .wp-block-table thead,
.post-content .wp-block-table tbody,
.post-content .wp-block-table tfoot,
.post-content .wp-block-table tr,
.post-content .wp-block-table td,
.post-content .wp-block-table th,
.page-content .wp-block-table table,
.page-content .wp-block-table thead,
.page-content .wp-block-table tbody,
.page-content .wp-block-table tfoot,
.page-content .wp-block-table tr,
.page-content .wp-block-table td,
.page-content .wp-block-table th {
    border: none !important;
    border-top: none !important;
    border-bottom: none !important;
}

/* GitHub-artiger Tabellen-Stil */
.entry-content .wp-block-table table,
.post-content .wp-block-table table,
.page-content .wp-block-table table {
    border-collapse: collapse !important;
    width: 100%;
}

.entry-content .wp-block-table th,
.entry-content .wp-block-table thead td,
.post-content .wp-block-table th,
.post-content .wp-block-table thead td,
.page-content .wp-block-table th,
.page-content .wp-block-table thead td {
    background: #f6f8fa;
    /* Farbe der Kopfzeilen-Linie: in Einstellungen → Neukalen MD Stile änderbar */
    border-bottom: 2px solid var(--neukalen-table-border-color, #adb5bd) !important;
    padding: 0.4em 0.8em;
    text-align: left;
    font-weight: 600;
}

.entry-content .wp-block-table td,
.post-content .wp-block-table td,
.page-content .wp-block-table td {
    border-bottom: 1px solid var(--neukalen-table-row-color, #dee2e6) !important;
    padding: 0.4em 0.8em;
}

.entry-content .wp-block-table tr:last-child td,
.post-content .wp-block-table tr:last-child td,
.page-content .wp-block-table tr:last-child td {
    border-bottom: none !important;
}

.entry-content .wp-block-table tr:nth-child(even) td,
.post-content .wp-block-table tr:nth-child(even) td,
.page-content .wp-block-table tr:nth-child(even) td {
    background: #f6f8fa;
}

@media (max-width: 768px) {
    .entry-content:has(.tok-toc--right),
    .post-content:has(.tok-toc--right),
    .page-content:has(.tok-toc--right) {
        display: block;
    }

    .entry-content:has(.tok-toc--right) .tok-toc--right,
    .post-content:has(.tok-toc--right) .tok-toc--right,
    .page-content:has(.tok-toc--right) .tok-toc--right {
        position: static;
        max-width: 100%;
        margin: 0 0 1.5rem 0;
    }
}
