@mixin sidenote($wide: false) {

    font-family: $font-text-secondary;
    font-size: $font-size-default * $font-size-smaller;
    line-height: $line-height-default;
    text-indent: 0;
    margin-top: 0;
    margin-bottom: $line-height-default;
    text-align: left; // sidenotes are too narrow for justification

    // Don't text-indent paragraphs that follow sidenotes that follow a heading.
    // We allow for up to three sidenotes between the heading and paragraph.
    h1 + & + p,
    h2 + & + p,
    h3 + & + p,
    h4 + & + p,
    h5 + & + p,
    h6 + & + p,
    h1 + & + & + p,
    h2 + & + & + p,
    h3 + & + & + p,
    h4 + & + & + p,
    h5 + & + & + p,
    h6 + & + & + p,
    h1 + & + & + & + p,
    h2 + & + & + & + p,
    h3 + & + & + & + p,
    h4 + & + & + & + p,
    h5 + & + & + & + p,
    h6 + & + & + & + p {
        text-indent: 0;
    }

    p {
        text-align: left;

        // Unless we're spacing paras, put back the indent
        // on paras that follow sidenotes that follow paras.
        & + p {
            text-indent: $paragraph-indent;

            &.first {
                text-indent: 0;
            }
        }
    }

    @if $spaced-paras {
        p + & + p {
            text-indent: 0;
        }
    }

    // If we have a sidebar, move elements to the sidebar using
    // Prince's @sidenote region, available from Prince 15.
    @if $pdf-sidebar {

        width: $sidebar-content-width;
        float: sidenote;

        // -prince-clear: end; // not sure this is necessary in all cases
        // -prince-sidenote-placement: top; // may not be necessary

        // Override other potentially inherited styles
        margin-left: 0;
        margin-right: 0;
        margin-inside: 0;
        margin-outside: 0;
        max-width: none;
        min-width: auto;

        @if $wide == true {
            float: wide;
        }

        &.pdf-align-top {
            float: sidenote align-top;
        }

        &.pdf-align-bottom {
            float: sidenote align-bottom;
        }

        &.float-top,
        &.pdf-float-top {
            -prince-float-placement: top;
        }

    } @else {

        // This version of the mixin assumes there is no sidebar,
        // and moves sidenotes to the outside of the body text.

        clear: both;
        float: outside;
        width: $sidebar-content-width;

        margin-left: 0;
        margin-right: 0;
        margin-inside: $paragraph-indent;
        margin-outside: 0;
        margin-top: $line-height-default;
        margin-bottom: $line-height-default;
        max-width: none;
        min-width: none;

        @if $wide == true {
            width: $sidebar-content-width * 2;
        }
    }
}
