.topolivro > figure {
    position: absolute;
    top: 5rem;
    left: 0;
    height: 18rem;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    width: 100%;
    align-items: center;
    flex-shrink: 0;
    flex-grow: 0;
}

.topolivro > figure > img {
    display: block;
    object-fit: cover;
    width: 100%;
    height: 100%;
    opacity: 1;
}

.topolivro h1 {
    font-size: calc(1.7rem + 1vw);
    padding-top: 18rem;
}

.corpo {
    display: grid;
    grid-template-columns: 1fr 3fr;
    gap: 1rem;
}

#toc {
    position: sticky;
    top: 6rem;
    height: fit-content;
    background: var(--corsecundaria);
    overflow-y: auto;
    max-height: 80vh;
    overflow-x: hidden;
}

/*#toc *{}*/

#toc ul {
    list-style: none;
    padding-left: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
}
#toc li {
    width: 100%;
}
#toc a {
    text-decoration: none;
    color: #fff;
    padding: 0.5rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
#toc a.active {
    font-weight: bold;
    background-color: var(--corprincipal);
}

/* Sublistas (H3–H6) colapsadas por padrão */
#toc .sublist {
    display: none !important;
}

#toc .sublist a {
    padding-left: 2rem;
}

#toc .sublist.open {
    display: block !important;
}

#toc .sublist-indicator {
    transition: transform 0.2s ease;
}

#toc a.active .sublist-indicator,
#toc a.open-sublist .sublist-indicator {
    transform: rotate(90deg);
}

.titulomenu {
    font-size: 1.1rem;
    border-bottom: 1px solid #ccc;
    font-weight: bold;
}

/* Compensar header fixo de 6rem quando rolar pra um heading */
#content h1,
#content h2,
#content h3,
#content h4,
#content h5,
#content h6 {
    scroll-margin-top: 6rem;
}
.corpo article {
    text-align: justify;

    h2,
    h3,
    h4,
    h5,
    h6 {
        font-variant: small-caps;
    }

    h3 {
        border-bottom: 1px solid var(--corprincipal);
        margin-bottom: 1rem;
    }

    p {
        margin-bottom: 0.5rem;
        text-indent: 1rem;
    }

    .primeiro {
        text-indent: 0;

        &::first-line {
            font-variant: small-caps;
            font-weight: 500;
        }

        &::first-letter {
            font-weight: bold;
            float: left;
            font-size: 5rem;
            line-height: 4.5rem;
            padding: 0 0.5rem 0 0;
        }
    }

    .descritivo {
        background-color: #faf7ea;
        padding: 1rem 1.5rem;
        position: relative;
        width: auto;
        display: flex;
        flex-direction: column;
        overflow: visible;
        border-radius: 0;
        border-left: 1px solid;
        border-right: 1px solid;
        border-color: var(--corprincipal);
        border-top: 0;
        border-bottom: 0;
        color: #222;
        line-height: 1.6;
        font-size: 0.9rem;
        text-indent: 0;
        margin: 1.5rem 0;

        &::before,
        &::after {
            content: "";
            border-radius: 50%;
            background-position: 0;
            background-size: contain;
            background-repeat: no-repeat;
            height: 8px;
            width: 8px;
            left: -4px;
            position: absolute;
            background-color: var(--corprincipal);
        }

        &::before {
            top: -4px;
        }

        &::after {
            bottom: -4px;
        }

        p:first-of-type:before,
        p:last-of-type:after {
            content: "";
            border-radius: 50%;
            background-position: 100%;
            background-size: contain;
            background-repeat: no-repeat;
            height: 8px;
            width: 8px;
            right: -4px;
            position: absolute;
            background-color: var(--corprincipal);
        }

        p:first-of-type:before {
            top: -4px;
        }

        p:first-of-type {
            text-indent: 0;
        }

        p:last-of-type:after {
            bottom: -4px;
        }
    }

    .notas {
        display: flex;
        background-color: #e0e5c1;
        position: relative;
        width: auto;
        flex-direction: column;
        overflow: visible;
        margin: 1.5rem 0;
        line-height: 1.6;
        padding: 1rem 1.5rem;
        border-radius: 0;
        border-color: var(--corprincipal) var(--corsecundaria);
        border-style: solid;
        border-width: 3px 0;
        color: #222;
        font-size: 0.9rem;

        &::before,
        &::after {
            content: "";
            background-image: url('data:image/svg+xml,<%3Fxml version="1.0" encoding="UTF-8"%3F><svg id="a" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16.69 11.78"><path fill="%23c13a5a" d="M0,10.85C5.56,7.24,11.13,3.62,16.69,0V11.78H0"/></svg>'),
                url('data:image/svg+xml,<%3Fxml version="1.0" encoding="UTF-8"%3F><svg id="a" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16.69 11.78"><path fill="%23c13a5a" d="M16.69,10.85C11.13,7.24,5.56,3.62,0,0V11.78H16.69"/></svg>');
            background-position: 0, 100%;
            background-size: contain;
            background-repeat: no-repeat;
            height: 11px;
            position: absolute;
            left: 0.1px;
            z-index: -1;
        }

        &::before {
            top: -13px;
            right: 0.1px;
        }

        &::after {
            bottom: -13px;
            right: -0.1px;
            transform: scaleY(-1);
        }
    }

    img {
        margin: 1rem auto;
    }
}

.flud {
    float: right;
    margin: 0 0 1rem 1rem !important;
    max-width: 50%;
}

.flue {
    float: left;
    margin: 0 1rem 1rem 0 !important;
    max-width: 50%;
}

.creditos {
    display: flex;
    gap: 1.5rem;
    justify-content: space-between;

    div {
        break-inside: avoid;
        flex: 1;
    }

    hr {
        margin-bottom: 0.5rem;
    }

    .creditostitulo {
        font-size: calc(1rem + 0.3svw);
    }
}

#toc-toggle {
    display: none;
}

.corpo2 {
    grid-template-columns: 3fr 1fr;
}

.outros {
    padding-left: 2.5rem;
}

.outrosposts > a {
    font-weight: 700;
    margin-top: 1rem;
    display: block;
}

.outrosposts > a:hover {
    text-decoration: underline;
}

.outrosposts > a > figure {
    width: 100%;
    aspect-ratio: 2/1;
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
}

@media (max-width: 41.5rem) {
    .lateralcaps > h6,
    .lateralcaps > nav {
        display: none;
    }

    #share_aside {
        display: block;
    }

    .lateralcaps {
        padding-left: 0;
    }

    .flud,
    .flue {
        float: none;
        width: 100%;
        max-width: initial;
        margin: 0 1rem;
    }
    
    .creditos {
        display: block;
        div {
            margin-bottom: 1rem;
        }
    }
}

@media (max-width: 59.9rem) {
    .corpo,
    .corpo2 {
        display: block;
    }

    .outros {
        padding: 0;
    }

    .lateralcaps {
        padding-left: 1rem;
    }

    .outros h6 {
        font-size: calc(1rem + 1vw);
    }

    .outrosposts {
        display: flex;
        flex-wrap: wrap;
        gap: 1rem;
    }

    .outrosposts > a {
        width: 100%;
    }

    #toc {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        padding-top: 1rem;
        max-height: initial;
        z-index: 98;
    }

    #toc.mobile-aberto {
        transform: translateX(0); /* aparece */
    }

    #toc-toggle {
        display: block;
        position: fixed;
        bottom: 1rem;
        right: 1rem;
        z-index: 99;
        background: var(--corprincipal);
        color: #fff;
        border: none;
        padding: 0.5rem 1rem;
        font-size: 1.5rem;
        cursor: pointer;
        transition: transform 0.3s ease;
    }

    body.no-scroll {
        overflow: hidden;
        height: 100vh;
    }
}

#livro h1,
#livro h2,
#livro h3,
#livro h4,
#livro h5,
#livro h6 {
    scroll-margin-top: 6rem; /* altura do cabeçalho fixo */
}
